<commit_before>function Game() {

  this.score = 0;
  this.frameScore = 0;
  this.frameNumber = 1;
  this.firstThrow = true;
  this.spareBall = false;
  this.strikeBall = false;
  this.tenthFrameBonus = false;
  this.gameOver = false;
  this.scoreBoard = {1:[], 2:[], 3:[], 4:[], 5:[], 6:[], 7:[], 8:[], 9:[], 10:[]}
};

Game.prototype.rollBall =  function(hit) {

  if (this.frameNumber < 10 && this.gameOver === false) {

    this.addToScoreBoard(hit);
    this.frameScore += hit;
    this.isSpare(hit);
    this.isFirstThrow();
    this.isStrike(hit);
    this.resetFrameScore();
  } else if (this.frameNumber === 10 && this.gameOver === false) {
    this.addToScoreBoard(hit);
    this.frameScore += hit;
    this.isSpare();
    this.isStrike();
    this.game();
  };
};

Game.prototype.addToScoreBoard = function(hit) {
  if (this.strikeBall === true) {
    this.scoreBoard[this.frameNumber].push(hit*2);
    this.score += (hit*2);
    this.strikeBall = false;
  } else if (this.spareBall === true) {
    this.scoreBoard[this.frameNumber].push(hit*2);
    this.score += (hit*2);
    this.spareBall = false;
  } else {
    this.scoreBoard[this.frameNumber].push(hit);
    this.score += (hit);
  };
};

Game.prototype.isFirstThrow = function() {
  if (this.firstThrow === false) {
    this.frameNumber +=1;
    this.firstThrow = true;
  } else {
    this.firstThrow = false;
  };
};

Game.prototype.isStrike = function(hit) {
  if (hit === 10 && this.frameNumber != 10) {
    this.frameNumber += 1;
    this.strikeBall = true;
    this.firstThrow = true;
  } else if (hit === 10 && this.frameNumber === 10) {
    this.tenthFrameBonus = true;
  };
};

Game.prototype.isSpare = function(hit) {
  if (this.frameScore === 10 && this.frameNumber != 10 && this.firstThrow === false) {
      this.spareBall = true;
  } else if (this.frameScore === 10 && this.frameNumber === 10 && this.firstThrow === false) {
      this.tenthFrameBonus = true;
  };
};

Game.prototype.game = function() {
  if ((this.scoreBoard[10][2] === 10)) {
    this.gameOver = true;
  } else if (this.frameScore < 10 && this.scoreBoard[10][1] != null) {
    this.gameOver = true;
  } else if (this.scoreBoard[10][0]+this.scoreBoard[10][1] === 10) {
    this.gameOver = true;
};
};

Game.prototype.resetFrameScore = function() {
  if (this.firstThrow === true) {
    this.frameScore = 0;
  };
};
<commit_msg>all tests passing<commit_after>function Game() {

  this.score = 0;
  this.frameScore = 0;
  this.frameNumber = 1;
  this.firstThrow = true;
  this.spareBall = false;
  this.strikeBall = false;
  this.tenthFrameBonus = false;
  this.gameOver = false;
  this.scoreBoard = {1:[], 2:[], 3:[], 4:[], 5:[], 6:[], 7:[], 8:[], 9:[], 10:[]}
};

Game.prototype.rollBall =  function(hit) {

  if (this.frameNumber < 10 && this.gameOver === false) {

    this.addToScoreBoard(hit);
    this.frameScore += hit;
    this.isSpare(hit);
    this.isFirstThrow();
    this.isStrike(hit);
    this.resetFrameScore();
  } else if (this.frameNumber === 10 && this.gameOver === false) {
    this.addToScoreBoard(hit);
    this.frameScore += hit;
    this.isSpare();
    this.isStrike();
    this.game();
  };
};

Game.prototype.addToScoreBoard = function(hit) {
  if (this.strikeBall === true) {
    this.scoreBoard[this.frameNumber].push(hit*2);
    this.score += (hit*2);
    this.strikeBall = false;
  } else if (this.spareBall === true) {
    this.scoreBoard[this.frameNumber].push(hit*2);
    this.score += (hit*2);
    this.spareBall = false;
  } else {
    this.scoreBoard[this.frameNumber].push(hit);
    this.score += (hit);
  };
};

Game.prototype.isFirstThrow = function() {
  if (this.firstThrow === false) {
    this.frameNumber +=1;
    this.firstThrow = true;
  } else {
    this.firstThrow = false;
  };
};

Game.prototype.isStrike = function(hit) {
  if (hit === 10 && this.frameNumber != 10) {
    this.frameNumber += 1;
    this.strikeBall = true;
    this.firstThrow = true;
  } else if (hit === 10 && this.frameNumber === 10) {
    this.tenthFrameBonus = true;
  };
};

Game.prototype.isSpare = function(hit) {
  if (this.frameScore === 10 && this.frameNumber != 10 && this.firstThrow === false) {
      this.spareBall = true;
  } else if (this.frameScore === 10 && this.frameNumber === 10 && this.firstThrow === false) {
      this.tenthFrameBonus = true;
  };
};

Game.prototype.game = function() {
  if ((this.scoreBoard[10][2] != null)) {
    this.gameOver = true;
  } else if (this.scoreBoard[10][0] + this.scoreBoard[10][1] < 10) {
    this.gameOver = true;
};
};

Game.prototype.resetFrameScore = function() {
  if (this.firstThrow === true) {
    this.frameScore = 0;
  };
};

{'fraction_non_alphanumeric': 0.18776824034334763, 'fraction_numerical': 0.023819742489270386, 'mean_word_length': 3.252737226277372, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4170621', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1666, 'n_words': 315}