<commit_before>/**
 * Represents the game board.
 * 0,0 is at the bottom left.
 * Properties:
 *  - h: height of the board
 *  - w: width of the board
 *  - actors: list of actors on that position
 *  - tile: the tile on that position
 */

(function() {
  var Board = (function() {
    var Board = function(h, w) {
      this.h = h;
      this.w = w;
      this.actors = [];
      this.tiles = [];
      for (var i = 0; i < h; i++) {
        this.actors[i] = [];
        this.tiles[i] = [];
        for (var j = 0; j < w; j++) {
          this.actors[i][j] = [];
        }
      }
    };

    Board.prototype.fillTiles = function fillTiles(jsonMap) {

    };

    Board.prototype.fillActors = function fillActors(jsonMap) {

    };

    return Board;
  })();

  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')<commit_msg>add board holding actors and tiles<commit_after>/**
 * Represents the game board.
 * 0,0 is at the bottom left.
 * Properties:
 *  - h: height of the board
 *  - w: width of the board
 *  - actors: list of actors on that position
 *  - tile: the tile on that position
 */

if (typeof(module) !== 'undefined') {
  var Actor = require('./actor.js').Actor;
}

(function() {
  var Board = (function() {
    var Board = function(h, w) {
      this.h = h;
      this.w = w;
      this.actors = [];
      this.tiles = [];
      for (var i = 0; i < w; i++) {
        this.actors[i] = [];
        this.tiles[i] = [];
        for (var j = 0; j < h; j++) {
          this.actors[i][j] = [];
        }
      }
      this.game = undefined;
    };

    Board.prototype.fillTiles = function(symbol2D) {
      for (var x = 0; x < this.w; x++) {
        for (var y = 0; y < this.h; y++) {
          var symbol = symbol2D[this.h - 1 - y][x];
          this.tiles[x][y] = Actor.symbolMap[symbol].clone();
          this.tiles[x][y].x = x;
          this.tiles[x][y].y = y;
        }
      }
    };

    Board.prototype.fillActors = function(symbol3D) {
      for (var x = 0; x < this.h; x++) {
        for (var y = 0; y < this.w; y++) {
          var symbols = symbol3D[this.h - 1 - y][x];
          for (var symbol in symbols) {
            this.moveActor(Actor.symbolMap[symbol].clone(), x, y);
          }
        }
      }
    };

    Board.prototype.moveActor = function(actor, x, y) {
      if (actor.x != -1 && actor.y != -1) {
        var i = this.actors[actor.x][actor.y].indexOf(actor);
        if (i > -1) {
          this.actors[actor.x][actor.y] = this.actors[actor.x][actor.y].splice(i, 1);
        }
      }

      this.actors[x][y].push(actor);
      actor.x = x;
      actor.y = y;
    };

    Board.prototype.setActive = function(requirement) {
      for (var x = 0; x < this.h; x++) {
        for (var y = 0; y < this.w; y++) {
          for (var actor in this.actors[x][y]) {
            actor.active = actor.passRequirement(requirement);
          }
        }
      }
    };

    return Board;
  })();

  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
{'fraction_non_alphanumeric': 0.17518970636753547, 'fraction_numerical': 0.00791817881887166, 'mean_word_length': 1.8309990662931839, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 4, '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': '4449310', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1040, 'n_words': 270}