<commit_before>const Store = require("./store").Store;
const cards = require("./cards");
const Player = require("./player").Player;
// eslint-disable-next-line no-unused-vars
const Connection = require("./connection").Connection; // Useful for VS Code type info

class Game {
  constructor() {
    this.store = new Store();
    /**
     * @type {Object.<string, Player>}
     */
    this.players = {};
    this.trash = [];
    this.started = false;
  }

  /**
   * @param {Player[]} ps
   */
  initClients(ps) {
    const included = this.store.included.map(c => c.name);
    ps.forEach(p => p.send({included}));

    const colors = this.store.getAllCards().reduce((o, c) => {
      o[c.name] = c.color;
      o["Buy: " + c.name] = c.color;
      return o;
    }, {});
    ps.forEach(p => p.send({colors}));
  }

  start(debugMode) {
    this.started = true;
    const ps = this.allPlayers();
    
    this.initClients(ps);

    ps.forEach(p => p.redrawHand());

    if (debugMode) {
      Array.prototype.push.apply(ps[0].hand, this.store.getAvailable(99));
      ps[0].sendHand();
      this.allLog("!!!!!!\n" + ps[0].name + " IS CHEATING\n!!!!!!");
    }

    let turn = Math.floor(Math.random() * ps.length);
    const nextTurn = () => {
      if (this.store.gameOver()) {
        let result = "GAME OVER!!!\r\n";
        result += ps
          .sort((a, b) => b.getPoints() - a.getPoints()) // descending
          .map(p => p.name + ": " + p.getPoints() + "\n    " +
            p.allCards()
              .filter(c => c.ofKind("property")||c.ofKind("curse"))
              .map(c => c.name)
              .sort()
              .toString())
          .join("\r\n");
        this.allLog(result);
        return;
      }

      ++turn;
      ps[turn % ps.length].takeTurn(nextTurn);
    };

    ps[turn].takeTurn(nextTurn);
  }

  /**
   * @param {Connection} connection
   */
  addPlayer(connection) {
    const name = connection.name;
<commit_msg>remove newline from allLog messages<commit_after>const Store = require("./store").Store;
const cards = require("./cards");
const Player = require("./player").Player;
// eslint-disable-next-line no-unused-vars
const Connection = require("./connection").Connection; // Useful for VS Code type info

class Game {
  constructor() {
    this.store = new Store();
    /**
     * @type {Object.<string, Player>}
     */
    this.players = {};
    this.trash = [];
    this.started = false;
  }

  /**
   * @param {Player[]} ps
   */
  initClients(ps) {
    const included = this.store.included.map(c => c.name);
    ps.forEach(p => p.send({included}));

    const colors = this.store.getAllCards().reduce((o, c) => {
      o[c.name] = c.color;
      o["Buy: " + c.name] = c.color;
      return o;
    }, {});
    ps.forEach(p => p.send({colors}));
  }

  start(debugMode) {
    this.started = true;
    const ps = this.allPlayers();
    
    this.initClients(ps);

    ps.forEach(p => p.redrawHand());

    if (debugMode) {
      Array.prototype.push.apply(ps[0].hand, this.store.getAvailable(99));
      ps[0].sendHand();
      this.allLog("!!!!!! " + ps[0].name + " IS CHEATING!!!!!!");
    }

    let turn = Math.floor(Math.random() * ps.length);
    const nextTurn = () => {
      if (this.store.gameOver()) {
        this.allLog("GAME OVER!!!");
        ps.sort((a, b) => b.getPoints() - a.getPoints()) // descending
          .map(p => `${p.name}: ${p.getPoints()}     ` +
            p.allCards()
              .filter(c => c.ofKind("property") || c.ofKind("curse"))
              .map(c => c.name)
              .sort()
              .toString())
          .forEach(line => this.allLog(line));
        return;
      }

      ++turn;
      ps[turn % ps.length].takeTurn(nextTurn);
    };

    ps[turn].takeTurn(nextTurn);
  }

  /**
   * @param {Connection} connection
   */
  addPlayer(connection) {
    const name = connection.name;

{'fraction_non_alphanumeric': 0.19989709287368151, 'fraction_numerical': 0.002572678157962439, 'mean_word_length': 2.1973684210526314, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 26, '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': '1014670', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1305, 'n_words': 236}