Skip to content

Commit

Permalink
Started on bonus addition
Browse files Browse the repository at this point in the history
  • Loading branch information
sblausten committed Jul 27, 2017
1 parent fbcf664 commit dd3610b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If open command does not work on your machine, just copy the full path of the Sp

- [x] I want to have two rolls per frame

- [ ] I want to end a frame when I score 10 in first roll
- [x] I want to end a frame when I score 10 in first roll

- [x] I want to keep track of my score for each roll including skipped ones

Expand Down
7 changes: 7 additions & 0 deletions spec/units/ScoreCardSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ describe('ScoreCard', function () {
expect(card.getLastFrame()).toEqual([5, 0]);
});
});

describe('checkSpare', function () {
it('sets spare to true if second score in frame brings total to 10', function () {
card.card = [[1, 1], [5, 5]];
expect(card.isSpareFrame()).toBeTrue;
});
});
});
1 change: 1 addition & 0 deletions src/Frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function Frame (card) {
}

Frame.prototype = {

processRoll: function () {
if (this.getRollCount() < 2 && this.remainder() > 0) {
var roll = this.roll();
Expand Down
4 changes: 4 additions & 0 deletions src/ScoreCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ ScoreCard.prototype = {

getLastFrame: function () {
return this.getCard()[this.getCard().length - 1];
},

isSpareFrame: function () {
this.getLastFrame().reduce(function (total, val) { return total + val; }, 0) === 10;
}
};

0 comments on commit dd3610b

Please sign in to comment.