<commit_before>var Controller = function(shape) {
  this.elements = generateRandomElements();

  this.gameBoard = new TetrisBoard({
    tetrinimo: new Tetrinimo({
      element: this.elements.pop(),
      shape: getRandomShape()
    }),
    createNextTetrinimo: this.createNextTetrinimo.bind(this),
    showGameOver: this.showGameOver.bind(this)
  });

  this.gameView = new BrowserView({
    gameBoard: this.gameBoard,
    cycleDropBlock: this.cycleDropBlock
  });

  this.gameView.previewBoard.tetrinimo = new Tetrinimo({
    element: this.elements.pop(),
    shape: getRandomShape()
  });
  this.gameView.drawAllBoards();
  this.gameState = 'gameover';

  addEventListener('keydown', function(event) {
    if(this.gameState === 'gameover') {
      var keyPressed = KEY_CODES[event.keyCode];
      if(keyPressed == 'space') {
        event.preventDefault();
        this.startGame();
      }
    }
  }.bind(this));
  addEventListener('mousedown', function(event) {
    if(event.target.nodeName == 'BUTTON' && this.gameState === 'gameover') {
      var buttonPressed = event.target.dataset.key;
      if(buttonPressed == 'space') {
        this.startGame();
      }
    }
  }.bind(this));
}
Controller.prototype.startGame = function() {
  this.gameState = 'inProgress';
  this.gameView.animateGame();
  this.gameView.previewBoard.blit();
  this.gameView.tableBoard.showElement(this.gameBoard.tetrinimo.element);
  this.gameView.updateElementDescrip();

  this.cycleDropBlock();
};
Controller.prototype.cycleDropBlock = function (args) {
  var dropDelay = args ? FAST_DROP : DROP_DELAY;
  this.gameBoard.blit();
  if(this.gameBoard.dropInterval) {
    clearInterval(this.gameBoard.dropInterval);
  }
  this.gameBoard.dropInterval = setInterval(
    this.gameBoard.dropBlock.bind(this.gameBoard),
    dropDelay
  );
};
Controller.prototype.createNextTetrinimo = function() {
  this.gameBoard.tetrinimo = this.gameView.previewBoard.tetrinimo;
  if(this.elements.length <= 0) {
    this.elements = generateRandomElements();<commit_msg>Update controller to get drop delay from current level<commit_after>var Controller = function(shape) {
  this.elements = generateRandomElements();
  this.level = 0;

  this.gameBoard = new TetrisBoard({
    tetrinimo: new Tetrinimo({
      element: this.elements.pop(),
      shape: getRandomShape()
    }),
    createNextTetrinimo: this.createNextTetrinimo.bind(this),
    showGameOver: this.showGameOver.bind(this)
  });

  this.gameView = new BrowserView({
    gameBoard: this.gameBoard,
    cycleDropBlock: this.cycleDropBlock,
  });

  this.gameView.level = this.level;
  this.gameView.previewBoard.tetrinimo = new Tetrinimo({
    element: this.elements.pop(),
    shape: getRandomShape()
  });
  this.gameView.drawAllBoards();
  this.gameState = 'gameover';

  addEventListener('keydown', function(event) {
    if(this.gameState === 'gameover') {
      var keyPressed = KEY_CODES[event.keyCode];
      if(keyPressed == 'space') {
        event.preventDefault();
        this.startGame();
      }
    }
  }.bind(this));
  addEventListener('mousedown', function(event) {
    if(event.target.nodeName == 'BUTTON' && this.gameState === 'gameover') {
      var buttonPressed = event.target.dataset.key;
      if(buttonPressed == 'space') {
        this.startGame();
      }
    }
  }.bind(this));
}
Controller.prototype.startGame = function() {
  this.gameState = 'inProgress';
  this.gameView.animateGame();
  this.gameView.previewBoard.blit();
  this.gameView.tableBoard.showElement(this.gameBoard.tetrinimo.element);
  this.gameView.updateElementDescrip();

  this.cycleDropBlock();
};
Controller.prototype.cycleDropBlock = function (args) {
  var dropDelay = args ? FAST_DROP : DROP_DELAY[this.level];
  this.gameBoard.blit();
  if(this.gameBoard.dropInterval) {
    clearInterval(this.gameBoard.dropInterval);
  }
  this.gameBoard.dropInterval = setInterval(
    this.gameBoard.dropBlock.bind(this.gameBoard),
    dropDelay
  );
};
Controller.prototype.createNextTetrinimo = function() {
  this.gameBoard.tetrinimo = this.gameView.previewBoard.tetrinimo;
  if(this.elements.length <= 0) {
    this.elements = generateRandomElements();
{'fraction_non_alphanumeric': 0.13998082454458294, 'fraction_numerical': 0.0007190795781399808, 'mean_word_length': 3.9443127962085307, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3894093', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1322, 'n_words': 197}