{"size": 630, "ext": "js", "max_stars_repo_path": "src/Frame.js", "max_stars_repo_name": "eballantine/bowling-challenge", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Frame.js", "max_issues_repo_name": "eballantine/bowling-challenge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Frame.js", "max_forks_repo_name": "eballantine/bowling-challenge", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.5294117647, "max_line_length": 64, "alphanum_fraction": 0.5857142857}
class Frame {

  constructor() {
    this.currentRoll = 0;
    this.rollsRemaining = 2;
    this.frameScore = 0;
    this.closed = false;
  }

  addRoll(pins) {
    this.currentRoll++;
    this.frameScore += pins;
    this.updateRollsRemaining();
  }
  
  isStrike() {
    return this.currentRoll == 1 && this.frameScore == 10;
  }

  isSplit() {
    return this.currentRoll == 2 && this.frameScore == 10;
  }

  isFrameOver() {
    return this.closed === false && this.rollsRemaining === 0;
  }

  updateRollsRemaining() {
    if (this.isStrike() === false && this.isSplit() === false) {
      this.rollsRemaining--;
    }
  }
}
