<commit_before>const blessed = require('blessed');

const SculptureStore = require('@anyware/game-logic/lib/sculpture-store');
const MoleGameLogic = require('@anyware/game-logic/lib/logic/mole-game-logic');
const DiskGameLogic = require('@anyware/game-logic/lib/logic/disk-game-logic');
const SimonGameLogic = require('@anyware/game-logic/lib/logic/simon-game-logic');

const VIEW_TITLE = "{center}{bold}Sculpture{/bold}{/center}";

export default class SculptureView extends blessed.Box {
  constructor(store, config, windowOptions) {
    super(Object.assign({
      tags: true,
      border: {
        type: 'line'
      },
      style: {
        fg: 'white',
        bg: 'gray'
      }
    }, windowOptions));

    this.store = store;
    this.config = config;
    this.renderSculptureProperties();

    this.store.on(SculptureStore.EVENT_CHANGE, this.renderSculptureProperties.bind(this));
  }

  renderSculptureProperties() {
    let content = VIEW_TITLE + '\n';
    content += `{yellow-fg}status:{/yellow-fg} ${this.store.data.get('status')}\n`;

    content += this.renderHandshakes();
    content += this.renderCurrentGameProperties();

    this.setContent(content);
  }

  renderHandshakes() {
    const handshakes = this.store.data.get("handshakes");

    var rendered = [];
    for (let username of handshakes) {
      const value = handshakes.get(username);
      if (!value) {
        continue;
      }

      let renderContent = `{yellow-fg}${username}:{/yellow-fg} `;
      renderContent += `{bold}{green-fg}${value}{/green-fg}{/bold}`;

      rendered.push(renderContent);
    }

    let content = "{yellow-fg}handshakes:{/yellow-fg}\n";
    if (rendered.length) {
      content += rendered.join(", ");
    }
    else {
      content += "nothing yet."
    }

    return content + '\n';
  }

  renderCurrentGameProperties() {
    if (this.store.isPlayingHandshakeGame) {
      return this.renderHandshakeGameProperties();
    }
    else if (this.store.isPlayingMoleGame) {
      return this.renderMoleGameProperties();
    }
    else if (this.store.isPlayingDiskGame) {
      return this.renderDiskGameProperties();
    }
    else if (this.store.isPlayingSimonGame) {
      return this.renderSimonGameProperties();
    }
    else {
      return 'No game currently being played';
    }
  }

  renderHandshakeGameProperties() {
    let content = '{yellow-fg}handshake:{/yellow-fg} (nothing for the handshake game)';
    return content;
  }

  renderMoleGameProperties() {
    let content = '{yellow-fg}mole:{/yellow-fg} ';

    const moleGame = this.store.data.get('mole');
    for (let propName of Object.keys(MoleGameLogic.trackedProperties)) {
      content += `{yellow-fg}${propName}:{/yellow-fg} ${moleGame.get(propName)}  `;
    }

    return content;
  }

  renderDiskGameProperties() {
    let content = '{yellow-fg}disk:{/yellow-fg} ';<commit_msg>Removed a confusing message about the handshake game properties<commit_after>const blessed = require('blessed');

const SculptureStore = require('@anyware/game-logic/lib/sculpture-store');
const MoleGameLogic = require('@anyware/game-logic/lib/logic/mole-game-logic');
const DiskGameLogic = require('@anyware/game-logic/lib/logic/disk-game-logic');
const SimonGameLogic = require('@anyware/game-logic/lib/logic/simon-game-logic');

const VIEW_TITLE = "{center}{bold}Sculpture{/bold}{/center}";

export default class SculptureView extends blessed.Box {
  constructor(store, config, windowOptions) {
    super(Object.assign({
      tags: true,
      border: {
        type: 'line'
      },
      style: {
        fg: 'white',
        bg: 'gray'
      }
    }, windowOptions));

    this.store = store;
    this.config = config;
    this.renderSculptureProperties();

    this.store.on(SculptureStore.EVENT_CHANGE, this.renderSculptureProperties.bind(this));
  }

  renderSculptureProperties() {
    let content = VIEW_TITLE + '\n';
    content += `{yellow-fg}status:{/yellow-fg} ${this.store.data.get('status')}\n`;

    content += this.renderHandshakes();
    content += this.renderCurrentGameProperties();

    this.setContent(content);
  }

  renderHandshakes() {
    const handshakes = this.store.data.get("handshakes");

    var rendered = [];
    for (let username of handshakes) {
      const value = handshakes.get(username);
      if (!value) {
        continue;
      }

      let renderContent = `{yellow-fg}${username}:{/yellow-fg} `;
      renderContent += `{bold}{green-fg}${value}{/green-fg}{/bold}`;

      rendered.push(renderContent);
    }

    let content = "{yellow-fg}handshakes:{/yellow-fg}\n";
    if (rendered.length) {
      content += rendered.join(", ");
    }
    else {
      content += "nothing yet."
    }

    return content + '\n';
  }

  renderCurrentGameProperties() {
    if (this.store.isPlayingHandshakeGame) {
      return this.renderHandshakeGameProperties();
    }
    else if (this.store.isPlayingMoleGame) {
      return this.renderMoleGameProperties();
    }
    else if (this.store.isPlayingDiskGame) {
      return this.renderDiskGameProperties();
    }
    else if (this.store.isPlayingSimonGame) {
      return this.renderSimonGameProperties();
    }
    else {
      return 'No game currently being played';
    }
  }

  renderHandshakeGameProperties() {
    let content = '{yellow-fg}handshake:{/yellow-fg} (N/A)';
    return content;
  }

  renderMoleGameProperties() {
    let content = '{yellow-fg}mole:{/yellow-fg} ';

    const moleGame = this.store.data.get('mole');
    for (let propName of Object.keys(MoleGameLogic.trackedProperties)) {
      content += `{yellow-fg}${propName}:{/yellow-fg} ${moleGame.get(propName)}  `;
    }

    return content;
  }

  renderDiskGameProperties() {
    let content = '{yellow-fg}disk:{/yellow-fg} ';
{'fraction_non_alphanumeric': 0.15049470578024648, 'fraction_numerical': 0.0, 'mean_word_length': 3.2555391432791727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3708400', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1840, 'n_words': 314}