<commit_before>const Type = require('./type').Type;
const util = require('util');

const noop = function() {}
const toRoom = (location, firstParty, secondParty, players) => config => {

  util.log('broadcast ->>>>', config);
  const firstPartyMsger = Type.isPlayer(firstParty) ?
    firstParty.say : noop;
  const secondPartyMsger = Type.isPlayer(secondParty) ?
    secondParty.say : noop;
  const thirdPartyMsger = msg => players.eachIf(
    player => {
      const isSpecificParty = party =>
        Type.isPlayer(party) && party.getAccountName() === player.getAccountName();
      const isFirstParty = isSpecificParty(firstParty);
      const isSecondParty = isSpecificParty(secondParty);
      if (!isFirstParty && !isSecondParty) {
        player.say(msg);
      }
    });



  if (config.firstPartyMessage) {
    firstPartyMsger(config.firstPartyMessage);
  }
  if (config.secondPartyMessage) {
    secondPartyMsger(config.secondPartyMessage);
  }
  if (config.thirdPartyMessage) {
    thirdPartyMsger(config.thirdPartyMessage);
  }

};

exports.Broadcast = { toRoom };<commit_msg>Fix up use of players.eachIF to account for location.<commit_after>const Type = require('./type').Type;
const util = require('util');

const noop = function() {}
const toRoom = (room, firstParty, secondParty, players) => config => {

  const firstPartyMsger = Type.isPlayer(firstParty) ?
    firstParty.say : noop;
  const secondPartyMsger = Type.isPlayer(secondParty) ?
    secondParty.say : noop;


  const isThirdPartyInRoom = player => {
    const isSpecificParty = party =>
      Type.isPlayer(party) && party.getAccountName() === player.getAccountName();
    const isFirstParty  = isSpecificParty(firstParty);
    const isSecondParty = isSpecificParty(secondParty);
    const inSameRoom    = room.getLocation() === player.getLocation();
    return !isFirstParty && !isSecondParty && inSameRoom;
  };

  const thirdPartyMsger = msg => players.eachIf(
    isThirdPartyInRoom,
    player => player.say(msg));

  if (config.firstPartyMessage) {
    firstPartyMsger(config.firstPartyMessage);
  }
  if (config.secondPartyMessage) {
    secondPartyMsger(config.secondPartyMessage);
  }
  if (config.thirdPartyMessage) {
    thirdPartyMsger(config.thirdPartyMessage);
  }

};

exports.Broadcast = { toRoom };
{'fraction_non_alphanumeric': 0.12816041848299914, 'fraction_numerical': 0.0, 'mean_word_length': 4.134228187919463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2435984', 'n_tokens_mistral': 757, 'n_tokens_neox': 683, 'n_words': 135}