'use strict';
const CommandUtil = require('../src/command_util').CommandUtil;
const Random = require('../src/random').Random;
const move = require('../src/commands').Commands.move;
const l10nFile = __dirname + '/../l10n/commands/flee.yml';
const util = require('util');
const l10n = require('../src/l10n')(l10nFile);

exports.command = (rooms, items, players, npcs, Commands) => {
  return (args, player) => {

    if (!player.hasEnergy(2, items)) { return player.noEnergy(); }

    if (!player.isInCombat()) {
      player.sayL10n(l10n, "NO_FIGHT");
      return;
    }

    util.log(player.getName() + ' is trying to flee from:');

    const opponents = player.getInCombat();

    opponents.forEach( opp => util.log(opp.getShortDesc('en')) );

    const fleed     = Random.coinFlip();
    const room      = rooms.getAt(player.getLocation());
    const exit      = Random.fromArray(room.getExits());

    if (fleed && move(exit, player)) {
      opponents.forEach(opp => opp.removeFromCombat(player));
      player.fleeFromCombat();

      player.sayL10n(l10n, 'FLEE_SUCCEED');
      util.log(player.getName() + " fled successfully.");
      return;
    }

    player.sayL10n(l10n, "FLEE_FAIL");
    return;
  };
};

@@ -514,54 +514,69 @@
     
-player.sayL10n(l10n, %22NO_FIGHT%22);%0A      return
+return player.warn('You have nothing to flee from... right?')
 ;%0A  
@@ -691,75 +691,8 @@
 );%0A%0A
-    opponents.forEach( opp =%3E util.log(opp.getShortDesc('en')) );%0A%0A
     
@@ -703,20 +703,16 @@
 t fleed 
-    
 = Random
@@ -740,20 +740,16 @@
 t room  
-    
 = rooms.
@@ -793,20 +793,16 @@
 t exit  
-    
 = Random
@@ -1018,81 +1018,245 @@
     
-util.log(player.getName() + %22 fled successfully.%22);%0A      return;%0A    %7D%0A%0A
+const duration = player.getAttribute('level') * 1000;%0A      util.log(player.getName() + %22 fled successfully.%22);%0A      player.addEffect('cowardice', %7B%0A        type: 'debuff',%0A        penalty: 1,%0A        duration:%0A      %7D);%0A    %7D else %7B%0A  
     
@@ -1298,15 +1298,9 @@
     
-return;
+%7D
 %0A  %7D

Clean up flee command.