<commit_before>"use strict";

var uuid = require('node-uuid');

var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.use(express.static('../client'));

function requestMap() {
  return [
    {x: 0, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 1, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 2, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 4, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 5, z: 0, seH: 0, swH: 0, neH: .25, nwH: .25},
    {x: 5, z: 1, seH: 0, swH: 0, neH: .25, nwH: .25},
    {x: 5, z: 2, seH: 0, swH: 0, neH: .25, nwH: .25},
    {x: 5, z: 3, seH: 0, swH: 0, neH: .25, nwH: .25},
    {x: 5, z: 4, seH: 0, swH: 0, neH: .25, nwH: .25},
    {x: 6, z: 0, seH: .25, swH: .25, neH: .5, nwH: .5},
    {x: 6, z: 1, seH: .25, swH: .25, neH: .5, nwH: .5},
    {x: 6, z: 2, seH: .25, swH: .25, neH: .5, nwH: .5},
    {x: 6, z: 3, seH: .25, swH: .25, neH: .5, nwH: .5},
    {x: 6, z: 4, seH: .25, swH: .25, neH: .5, nwH: .5},
    {x: 7, z: 0, seH: .5, swH: .5, neH: .75, nwH: .75},
    {x: 7, z: 1, seH: .5, swH: .5, neH: .75, nwH: .75},
    {x: 7, z: 2, seH: .5, swH: .5, neH: .75, nwH: .75},
    {x: 7, z: 3, seH: .5, swH: .5, neH: .75, nwH: .75},
    {x: 7, z: 4, seH: .5, swH: .5, neH: .75, nwH: .75},
    {x: 8, z: 0, seH: .75, swH: .75, neH: 1, nwH: 1},
    {x: 8, z: 1, seH: .75, swH: .75, neH: 1, nwH: 1},
    {x: 8, z: 2, seH: .75, swH: .75, neH: 1, nwH: 1},
    {x: 8, z: 3, seH: .75, swH: .75, neH: 1, nwH: 1},
    {x: 8, z: 4, seH: .75, swH: .75, neH: 1, nwH: 1},
    {x: 9, z: 0, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
    {x: 9, z: 1, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
    {x: 9, z: 2, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
    {x: 9, z: 3, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
    {x: 9, z: 4, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
    {x: 10, z: 0, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 10, z: 1, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 10, z: 2, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 10, z: 3, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 10, z: 4, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 11, z: 0, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 11, z: 1, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 11, z: 2, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 11, z: 3, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
    {x: 11, z: 4, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25}
  ];
}

var games = {};

function loadRuntimeMap(game) {
  var mapTemplate = game.map.template;
  for (let tileDef of mapTemplate) {
    loadTile(game.map.runtime, tileDef);
  }
}

function loadTile(runtime, tileDef) {
  if (!(tileDef.x in runtime)) {
    runtime[tileDef.x] = {}
  }
  runtime[tileDef.x][tileDef.z] = {
    type: tileDef.hasOwnProperty('type') ? tileDef.type : "default",
    unit: null
  };
}

function createGame(game) {
  if (!games.hasOwnProperty(game)) {
    var newGame = games[game] = {
      id: game,
      winner: null,
      map: {
        runtime: {},
        slots: [
          {
            x: 0,
            z: 0,
            player: null
          },
          {
            x: 11,
            z: 4,
            player: null
          }
        ],
        template: requestMap()
      },
      players: [],
      units: {},
      unitDefinitions: {}
    }

    // Define some units
    newGame.unitDefinitions["Red Robot"] = {
      name: "Red Robot",
      cost: 12,
      health: 20,
      hitPower: 4,
      blockingPower: 0,
      attacks: 3,
      movement: 2
    };
    newGame.unitDefinitions["Blue Robot"] = {<commit_msg>Reduced the map size, for the demo<commit_after>"use strict";

var uuid = require('node-uuid');

var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.use(express.static('../client'));

function requestMap() {
  return [
    {x: 0, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 0, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 1, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 1, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 2, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 2, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 3, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0, type: "spawner"},
    {x: 4, z: 0, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 1, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 2, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 3, seH: 0, swH: 0, neH: 0, nwH: 0},
    {x: 4, z: 4, seH: 0, swH: 0, neH: 0, nwH: 0}
  ];
}

/*
{x: 5, z: 0, seH: 0, swH: 0, neH: .25, nwH: .25},
{x: 5, z: 1, seH: 0, swH: 0, neH: .25, nwH: .25},
{x: 5, z: 2, seH: 0, swH: 0, neH: .25, nwH: .25},
{x: 5, z: 3, seH: 0, swH: 0, neH: .25, nwH: .25},
{x: 5, z: 4, seH: 0, swH: 0, neH: .25, nwH: .25},
{x: 6, z: 0, seH: .25, swH: .25, neH: .5, nwH: .5},
{x: 6, z: 1, seH: .25, swH: .25, neH: .5, nwH: .5},
{x: 6, z: 2, seH: .25, swH: .25, neH: .5, nwH: .5},
{x: 6, z: 3, seH: .25, swH: .25, neH: .5, nwH: .5},
{x: 6, z: 4, seH: .25, swH: .25, neH: .5, nwH: .5},
{x: 7, z: 0, seH: .5, swH: .5, neH: .75, nwH: .75},
{x: 7, z: 1, seH: .5, swH: .5, neH: .75, nwH: .75},
{x: 7, z: 2, seH: .5, swH: .5, neH: .75, nwH: .75},
{x: 7, z: 3, seH: .5, swH: .5, neH: .75, nwH: .75},
{x: 7, z: 4, seH: .5, swH: .5, neH: .75, nwH: .75},
{x: 8, z: 0, seH: .75, swH: .75, neH: 1, nwH: 1},
{x: 8, z: 1, seH: .75, swH: .75, neH: 1, nwH: 1},
{x: 8, z: 2, seH: .75, swH: .75, neH: 1, nwH: 1},
{x: 8, z: 3, seH: .75, swH: .75, neH: 1, nwH: 1},
{x: 8, z: 4, seH: .75, swH: .75, neH: 1, nwH: 1},
{x: 9, z: 0, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
{x: 9, z: 1, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
{x: 9, z: 2, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
{x: 9, z: 3, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
{x: 9, z: 4, seH: 1, swH: 1, neH: 1.25, nwH: 1.25},
{x: 10, z: 0, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 10, z: 1, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 10, z: 2, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 10, z: 3, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 10, z: 4, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 11, z: 0, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 11, z: 1, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 11, z: 2, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 11, z: 3, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25},
{x: 11, z: 4, seH: 1.25, swH: 1.25, neH: 1.25, nwH: 1.25}
*/

var games = {};

function loadRuntimeMap(game) {
  var mapTemplate = game.map.template;
  for (let tileDef of mapTemplate) {
    loadTile(game.map.runtime, tileDef);
  }
}

function loadTile(runtime, tileDef) {
  if (!(tileDef.x in runtime)) {
    runtime[tileDef.x] = {}
  }
  runtime[tileDef.x][tileDef.z] = {
    type: tileDef.hasOwnProperty('type') ? tileDef.type : "default",
    unit: null
  };
}

function createGame(game) {
  if (!games.hasOwnProperty(game)) {
    var newGame = games[game] = {
      id: game,
      winner: null,
      map: {
        runtime: {},
        slots: [
          {
            x: 0,
            z: 0,
            player: null
          },
          {
            x: 4,
            z: 4,
            player: null
          }
        ],
        template: requestMap()
      },
      players: [],
      units: {},
      unitDefinitions: {}
    }

    // Define some units
    newGame.unitDefinitions["Red Robot"] = {
      name: "Red Robot",
      cost: 12,
      health: 20,
      hitPower: 4,
      blockingPower: 0,
      attacks: 3,
      movement: 2
    };
    newGame.unitDefinitions["Blue Robot"] = {
{'fraction_non_alphanumeric': 0.2520273154075971, 'fraction_numerical': 0.11150234741784038, 'mean_word_length': 2.155892255892256, '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': '4762475', 'n_tokens_mistral': 5928, 'n_tokens_neox': 5108, 'n_words': 1664}