<commit_before>define(['core/game', 'renderer', 'gameclient', 'core/playermanager'], function(Game, Renderer, GameClient, PlayerManager) {
  var App = function(config) {
    this.config = config;
  };

  App.prototype.init = function(width, height) {
    var token,
      _this = this;

    this.width = width;
    this.height = height;

    this.playing = false;

    this.playerManager = new PlayerManager(this);

    this.game = new Game(this);
    this.game.init(width, height);

    this.gameClient = new GameClient(this, this.game, this.playerManager);

    this.renderer = new Renderer(this);
    this.renderer.init();

    this.gameClient.init(function() {
      token = _this.getToken()
      if (token) {
        _this.gameClient.requestPlayer(token);
      }

      _this.game.updatePlayerStats();
      _this.renderer.updateControls();
      _this.renderer.updateLeaderboard();
      _this.renderer.updatePlayersOnline();
      _this.renderer.handleConnect();
      _this.run();
    });
  };

  App.prototype.run = function() {
    var _this = this;

    // "the loop"
    requestAnimationFrame(function() {
      // go to next generation
      if (_this.game.isTimeToTick()) {
        _this.game.tick();
        _this.game.updatePlayerStats();
        _this.renderer.updateControls();
        _this.renderer.updateLeaderboard();
      }

      _this.renderer.renderChanges();
      _this.run();
    });

  };

  App.prototype.getState = function() {
    var livingCells = this.game.grid.getLivingCells().map(function(cell) {
        return {
          x: cell.x,
          y: cell.y,
          alive: cell.alive,
          playerId: cell.playerId
        };
      }),
      players = this.playerManager.getPlayers().map(function(player) {
        return player.transmission();
      }),
      generation = this.game.generation,
      timeBeforeTick = (this.game.nextTick - Date.now());

    return {
      livingCells: livingCells,
      players: players,
      generation: generation,
      timeBeforeTick: timeBeforeTick
    };
  };

  App.prototype.isPlaying = function() {
    return this.playing;
  };

  App.prototype.setPlaying = function(playing) {
    this.playing = playing;

    this.renderer.hideOverlay();
    this.renderer.updateControls();
    this.renderer.setAccentColor(this.playerManager.getLocalPlayer().color);
  };

  App.prototype.setToken = function(token) {
    localStorage.setItem('token', token);
    return token;
  };

  App.prototype.getToken = function() {
    var token = localStorage.getItem('token');
    return (token) ? token : false;
  };

  App.prototype.deleteToken = function() {
    delete localStorage.token;
  };
<commit_msg>Fixed favicon bug.<commit_after>define(['core/game', 'renderer', 'gameclient', 'core/playermanager'], function(Game, Renderer, GameClient, PlayerManager) {
  var App = function(config) {
    this.config = config;
  };

  App.prototype.init = function(width, height) {
    var token,
      _this = this;

    this.width = width;
    this.height = height;

    this.playing = false;

    this.playerManager = new PlayerManager(this);

    this.game = new Game(this);
    this.game.init(width, height);

    this.gameClient = new GameClient(this, this.game, this.playerManager);

    this.renderer = new Renderer(this);
    this.renderer.init();

    this.gameClient.init(function() {
      token = _this.getToken()
      if (token) {
        _this.gameClient.requestPlayer(token);
      }

      _this.game.updatePlayerStats();
      _this.renderer.updateControls();
      _this.renderer.updateLeaderboard();
      _this.renderer.updatePlayersOnline();
      _this.renderer.handleConnect();
      _this.run();
    });
  };

  App.prototype.run = function() {
    var _this = this;

    // "the loop"
    requestAnimationFrame(function() {
      // go to next generation
      if (_this.game.isTimeToTick()) {
        _this.game.tick();
        _this.game.updatePlayerStats();
        _this.renderer.updateControls();
        _this.renderer.updateLeaderboard();
      }

      _this.renderer.renderChanges();
      _this.run();
    });

  };

  App.prototype.getState = function() {
    var livingCells = this.game.grid.getLivingCells().map(function(cell) {
        return {
          x: cell.x,
          y: cell.y,
          alive: cell.alive,
          playerId: cell.playerId
        };
      }),
      players = this.playerManager.getPlayers().map(function(player) {
        return player.transmission();
      }),
      generation = this.game.generation,
      timeBeforeTick = (this.game.nextTick - Date.now());

    return {
      livingCells: livingCells,
      players: players,
      generation: generation,
      timeBeforeTick: timeBeforeTick
    };
  };

  App.prototype.isPlaying = function() {
    return this.playing;
  };

  App.prototype.setPlaying = function(playing) {
    this.playing = playing;

    this.renderer.hideOverlay();
    this.renderer.updateControls();
    this.renderer.setAccentColor(this.playerManager.getLocalPlayer().color);
    this.renderer.setFaviconColor(this.playerManager.getLocalPlayer().color);
  };

  App.prototype.setToken = function(token) {
    localStorage.setItem('token', token);
    return token;
  };

  App.prototype.getToken = function() {
    var token = localStorage.getItem('token');
    return (token) ? token : false;
  };

  App.prototype.deleteToken = function() {
    delete localStorage.token;
  };

{'fraction_non_alphanumeric': 0.13640536074903617, 'fraction_numerical': 0.0, 'mean_word_length': 2.721311475409836, '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': '5476082', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1637, 'n_words': 277}