<commit_before>// Generated by Creer at 03:39AM on October 10, 2015 UTC, git hash: '98604e3773d1933864742cb78acbf6ea0b4ecd7b'

var Class = require(__basedir + "/utilities/class");
var serializer = require(__basedir + "/gameplay/serializer");
var log = require(__basedir + "/gameplay/log");
var TurnBasedGame = require(__basedir + "/gameplay/shared/turnBasedGame");

//<<-- Creer-Merge: requires -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

// any additional requires you want can be required here safely between cree runs
//<<-- /Creer-Merge: requires -->>

// @class Game: Two player grid based game where each player tries to burn down the other player's buildings. Let it burn!
var Game = Class(TurnBasedGame, {
    /**
     * Initializes Games.
     *
     * @param {Object} a simple mapping passsed in to the constructor with whatever you sent with it.
     */
    init: function(data) {
        TurnBasedGame.init.apply(this, arguments);

        /**
         * How many bribes players get at the beginning of their turn, not counting their burned down Buildings.
         *
         * @type {number}
         */
        this._addProperty("baseBribesPerTurn", serializer.defaultInteger(data.baseBribesPerTurn));

        /**
         * All the buildings in the game.
         *
         * @type {list.<Building>}
         */
        this._addProperty("buildings", serializer.defaultArray(data.buildings));

        /**
         * The current Forecast, which will be applied at the end of the turn.
         *
         * @type {Forecast}
         */
        this._addProperty("currentForecast", serializer.defaultGameObject(data.currentForecast));

        /**
         * All the forecasts in the game, indexed by turn number.
         *
         * @type {list.<Forecast>}
         */
        this._addProperty("forecasts", serializer.defaultArray(data.forecasts));

        /**
         * The width of the entire map along the vertical (y) axis.
         *
         * @type {number}
         */
        this._addProperty("mapHeight", serializer.defaultInteger(data.mapHeight));

        /**
         * The width of the entire map along the horizontal (x) axis.
         *
         * @type {number}
         */
        this._addProperty("mapWidth", serializer.defaultInteger(data.mapWidth));

        /**
         * The maximum amount of fire value for any Building.
         *
         * @type {number}
         */
        this._addProperty("maxFire", serializer.defaultInteger(data.maxFire));

        /**
         * The next Forecast, which will be applied at the end of your opponent's turn. This is also the Forecast WeatherStations can control this turn.
         *
         * @type {Forecast}
         */
        this._addProperty("nextForecast", serializer.defaultGameObject(data.nextForecast));


        //<<-- Creer-Merge: init -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

        this.mapWidth = 40;
        this.mapHeight = 20;

        //<<-- /Creer-Merge: init -->>
    },

    name: "Anarchy",
    numberOfPlayers: 2,
    maxInvalidsPerPlayer: 10,

    /**
     * This is called when the game begins, once players are connected and ready to play, and game objects have been initialized. Anything in init() may not have the appropriate game objects created yet..
     */
    begin: function() {
        TurnBasedGame.begin.apply(this, arguments);

        //<<-- Creer-Merge: begin -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

        // this is all placeholder logic to randomly spawn random buildings for random players. Mostly to demonstrate adding game logic to Anarchy
        var buildings = [ "Warehouse", "FireDepartment", "PoliceDepartment", "WeatherStation" ];
        for(var x = 0; x < this.mapWidth; x++) {
            for(var y = 0; y < this.mapHeight; y++) {
                if(Math.random() > 0.5) {
                    var newBuilding = this.create(buildings.randomElement(), {
                        x: x,
                        y: y,
                        owner: this.players.randomElement(),
                        fire: Math.floor(Math.random() * 20),
                    });
                    this.buildings.push(newBuilding);

                    
                }
            }
        }

        //<<-- /Creer-Merge: begin -->>
    },


    //<<-- Creer-Merge: added-functions -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

    // You can add additional functions here. These functions will not be directly callable by client AIs

    //<<-- /Creer-Merge: added-functions -->>

});

module.exports = Game;<commit_msg>added first and second win conditions<commit_after>// Generated by Creer at 03:39AM on October 10, 2015 UTC, git hash: '98604e3773d1933864742cb78acbf6ea0b4ecd7b'

var Class = require(__basedir + "/utilities/class");
var serializer = require(__basedir + "/gameplay/serializer");
var log = require(__basedir + "/gameplay/log");
var TurnBasedGame = require(__basedir + "/gameplay/shared/turnBasedGame");

//<<-- Creer-Merge: requires -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

// any additional requires you want can be required here safely between cree runs
//<<-- /Creer-Merge: requires -->>

// @class Game: Two player grid based game where each player tries to burn down the other player's buildings. Let it burn!
var Game = Class(TurnBasedGame, {
    /**
     * Initializes Games.
     *
     * @param {Object} a simple mapping passsed in to the constructor with whatever you sent with it.
     */
    init: function(data) {
        TurnBasedGame.init.apply(this, arguments);

        /**
         * How many bribes players get at the beginning of their turn, not counting their burned down Buildings.
         *
         * @type {number}
         */
        this._addProperty("baseBribesPerTurn", serializer.defaultInteger(data.baseBribesPerTurn));

        /**
         * All the buildings in the game.
         *
         * @type {list.<Building>}
         */
        this._addProperty("buildings", serializer.defaultArray(data.buildings));

        /**
         * The current Forecast, which will be applied at the end of the turn.
         *
         * @type {Forecast}
         */
        this._addProperty("currentForecast", serializer.defaultGameObject(data.currentForecast));

        /**
         * All the forecasts in the game, indexed by turn number.
         *
         * @type {list.<Forecast>}
         */
        this._addProperty("forecasts", serializer.defaultArray(data.forecasts));

        /**
         * The width of the entire map along the vertical (y) axis.
         *
         * @type {number}
         */
        this._addProperty("mapHeight", serializer.defaultInteger(data.mapHeight));

        /**
         * The width of the entire map along the horizontal (x) axis.
         *
         * @type {number}
         */
        this._addProperty("mapWidth", serializer.defaultInteger(data.mapWidth));

        /**
         * The maximum amount of fire value for any Building.
         *
         * @type {number}
         */
        this._addProperty("maxFire", serializer.defaultInteger(data.maxFire));

        /**
         * The next Forecast, which will be applied at the end of your opponent's turn. This is also the Forecast WeatherStations can control this turn.
         *
         * @type {Forecast}
         */
        this._addProperty("nextForecast", serializer.defaultGameObject(data.nextForecast));


        //<<-- Creer-Merge: init -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

        this.mapWidth = 40;
        this.mapHeight = 20;

        //<<-- /Creer-Merge: init -->>
    },

    name: "Anarchy",
    numberOfPlayers: 2,
    maxInvalidsPerPlayer: 10,

    /**
     * This is called when the game begins, once players are connected and ready to play, and game objects have been initialized. Anything in init() may not have the appropriate game objects created yet..
     */
    begin: function() {
        TurnBasedGame.begin.apply(this, arguments);

        //<<-- Creer-Merge: begin -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.

        // this is all placeholder logic to randomly spawn random buildings for random players. Mostly to demonstrate adding game logic to Anarchy
        var buildings = [ "Warehouse", "FireDepartment", "PoliceDepartment", "WeatherStation" ];
        for(var x = 0; x < this.mapWidth; x++) {
            for(var y = 0; y < this.mapHeight; y++) {
                if(Math.random() > 0.5) {
                    var newBuilding = this.create(buildings.randomElement(), {
                        x: x,
                        y: y,
                        owner: this.players.randomElement(),
                        fire: Math.floor(Math.random() * 20),
                    });
                    this.buildings.push(newBuilding);


                }
            }
        }

        //<<-- /Creer-Merge: begin -->>
    },

    //<<-- Creer-Merge: added-functions -->> - Code you add between this comment and the end comment will be preserved between Creer re-runs.
    //This function will deal with the next turn logic and win conditons
    nextTurn: function() {
      for(var i = 0; i < this.players.length; i++){
        var player = this.players[i];

        if(player.headquarters.health <= 0){
          game.declairLoser(player, "YOUR HEADQUARTERS IS BURNED DOWN!");
          game.declairWinner(this.getOtherPlayers(player)[0], "You burned down the other players Headquarters");
        }
      }
       return TurnBasedGame.nextTurn.apply(this, arguments);
   },

   _maxTurnsReached: function(){TurnBasedGame._maxTurnsReached.apply(this, arguments);
     TurnBasedGame._maxTurnsReached.apply(this, arguments);

     for(var i = 0; i < this.players.length; i++){
       var  player = this.players[i];

       if(player.headquarters.health < this.getOtherPlayers(player)[0]){
         game.declairLoser(player, "Your HQ has less health than the opponents!");
         game.declairWinner(this.getOtherPlayers(player)[0], "You did more damage to the other player's HQ!");
       }
     }
   },
    // You can add additional functions here. These functions will not be directly callable by client AIs

    //<<-- /Creer-Merge: added-functions -->>

});

module.exports = Game;
{'fraction_non_alphanumeric': 0.1120511374318481, 'fraction_numerical': 0.009588268471517203, 'mean_word_length': 2.1777180406212664, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 41, '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': '4472877', 'n_tokens_mistral': 3009, 'n_tokens_neox': 2823, 'n_words': 923}