<commit_before>Meteor.methods({
  endGame: function() {
    Game.remove({});
    Occupation.remove({});
    Player.remove({});
    Territory.remove({});
    Message.remove({});

    Tracker.flush();
  },

  setUpBoard: function(){
    Meteor.call("newMessage", "You have started a new game!");

    Meteor.call("endGame");

    for( var n = 1; n <= 3; n++ ) {
      Player.insert(
        {
          name: "Player "+n,
          username: "player"+n
        }
      );
    }
    var players = Player.find().fetch(); // three players, 35 armies each
    var maxArmiesPerPlayer = 35;

    // Create game
    var gameId = Game.insert({
      name: "Game",
      players: players,
      currentPlayer: players[0]
    });

    Game.update(gameId,
      {
        $set: { currentPlayer: players[0] }
      }
    );

    var world = JSON.parse(Assets.getText("json/map_topojson.json"));
    countries = world.objects.map.geometries;

    var territory_id = 1;
    for (var country in countries) {
      Territory.insert({
        _id: String(territory_id),
        game: gameId,
        name: countries[country].id,
        continent: "North America",
      });

      territory_id ++;
    }

    var territories = Territory.find().fetch();
    var maxTerritoriesPerPlayer = territories.length / players.length

    // Create occupations for each territory/player
    var territoryIndex = 0;
    for (var n = 0; n < players.length; n++) {
      var player = players[n];
      var armiesPerTerritory = Math.floor(maxArmiesPerPlayer / maxTerritoriesPerPlayer)

      for (var x = 0; x < maxTerritoriesPerPlayer; x++) {
        Occupation.insert({
          game: gameId,
          player: player._id,
          territory: territories[territoryIndex]._id,
          armies: armiesPerTerritory,
        });
        territoryIndex++;
      }
    }
  }
});<commit_msg>bugfix for loading territories<commit_after>Meteor.methods({
  endGame: function() {
    Game.remove({});
    Occupation.remove({});
    Player.remove({});
    Territory.remove({});
    Message.remove({});

    Tracker.flush();
  },

  setUpBoard: function(){
    Meteor.call("newMessage", "You have started a new game!");

    Meteor.call("endGame");

    for( var n = 1; n <= 3; n++ ) {
      Player.insert(
        {
          name: "Player "+n,
          username: "player"+n
        }
      );
    }
    var players = Player.find().fetch(); // three players, 35 armies each
    var maxArmiesPerPlayer = 35;

    // Create game
    var gameId = Game.insert({
      name: "Game",
      players: players,
      currentPlayer: players[0]
    });

    Game.update(gameId,
      {
        $set: { currentPlayer: players[0] }
      }
    );

    var world = JSON.parse(Assets.getText("json/map_topojson.json"));
    countries = world.objects.map.geometries;

    var territory_id = 1;
    for (var country in countries) {
      Territory.insert({
        _id: String(territory_id),
        game: gameId,
        name: countries[country].id,
        continent: "North America",
      });

      territory_id ++;
    }

    var territories = Territory.find().fetch();
    var maxTerritoriesPerPlayer = territories.length / players.length

    // Create occupations for each territory/player
    var territoryIndex = 0;
    for (var n = 0; n < players.length; n++) {
      var player = players[n];
      var armiesPerTerritory = Math.floor(maxArmiesPerPlayer / maxTerritoriesPerPlayer)

      for (var x = 0; x < maxTerritoriesPerPlayer; x++) {
        if (territories[territoryIndex]) {
          Occupation.insert({
            game: gameId,
            player: player._id,
            territory: territories[territoryIndex]._id,
            armies: armiesPerTerritory,
          });
        }
        territoryIndex++;
      }
    }
  }
});
{'fraction_non_alphanumeric': 0.13653136531365315, 'fraction_numerical': 0.0063257775434897206, 'mean_word_length': 2.2215619694397284, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6931000', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1131, 'n_words': 261}