<commit_before>'use strict';
const CommandUtil = require('../src/command_util')
  .CommandUtil;
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.isInCombat()) {
      player.say('You are too busy for that right now.');
      return;
    }

    args = args.toLowerCase().split(' ');

    const room = rooms.getAt(player.getLocation());
    const exits = room
      .getExits()
      .filter(exit => exit.direction.indexOf(args[0]) > -1);

    if (exit.length !== 1) {
      player.say('Which door do you want to open?');
      return;
    }

    const exit = exits[0];

    if (!exit.door) {
      player.say('There is no door.');
      return;
    }


    if (exit.door.open === true) {
      player.say('That door is already opened.');
      return;
    }

    player.say('You open the door.');
    exit.door.open = true;

    const dest = rooms.getAt(exit.location);
    const otherSideDoor = dest
      .getExits()
      .filter(exit => exit.location === player.getLocation())
      .forEach(exit => exit.door.open = true);

    players.eachIf(
      p => CommandUtil.inSameRoom(p, player),
      p => {
        const destTitle = dest.getTitle('en');
        p.say(player.getName() + ' opens the door to ' + dest + '.');
      });

    players.eachIf(
      p => p.getLocation() === exit.location,
      p => {
        const src = rooms.getAt(player.getLocation()).getTitle('en');
        p.say('The door to ' + src + ' swings open.');
      });
  };
};<commit_msg>Clean up the function calls and assignments a bit.<commit_after>'use strict';
const CommandUtil = require('../src/command_util')
  .CommandUtil;
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.isInCombat()) {
      player.say('You are too busy for that right now.');
      return;
    }

    args = args.toLowerCase().split(' ');

    const room = rooms.getAt(player.getLocation());
    const exits = room.getExits()
      .filter(exit => exit.direction.indexOf(args[0]) > -1);

    if (exit.length !== 1) {
      player.say('Which door do you want to open?');
      return;
    }

    const exit = exits[0];

    if (!exit.door) {
      player.say('There is no door.');
      return;
    }


    if (exit.door.open === true) {
      player.say('That door is already opened.');
      return;
    }

    player.say('You open the door.');
    exit.door.open = true;

    const dest = rooms.getAt(exit.location);
    const src = rooms.getAt(player.getLocation());
    dest
      .getExits()
      .filter(exit => exit.location === player.getLocation())
      .forEach(exit => exit.door.open = true);


    players.eachIf(
      p => CommandUtil.inSameRoom(p, player),
      p => {
        const destTitle = dest.getTitle('en');
        p.say(player.getName() + ' opens the door to ' + dest + '.');
      });

    players.eachIf(
      p => p.getLocation() === exit.location,
      p => {
        const srcTitle = src.getTitle('en');
        p.say('The door to ' + src + ' swings open.');
      });
  };
};
{'fraction_non_alphanumeric': 0.1736544751709783, 'fraction_numerical': 0.008325899494498959, 'mean_word_length': 2.45025641025641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1497253', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1086, 'n_words': 258}