Makers Academy - Week 5/6 - Solo Weekend Challenge
Create a ten-pin bowling game in Javascript, with complete functionality and adherence to the rules and scoring of ten-pin bowling for one player.
A bowling game consists of 10 frames in which the player tries to knock down the 10 pins. In every frame the player can roll one or two times. The actual number depends on strikes and spares. The score of a frame is the number of knocked down pins plus bonuses for strikes and spares. After every frame the 10 pins are reset.
The player has a strike if he knocks down all 10 pins with the first roll in a frame. The frame ends immediately (since there are no pins left for a second roll). The bonus for that frame is the number of pins knocked down by the next two rolls. That would be the next frame, unless the player rolls another strike.
The player has a spare if the knocks down all 10 pins with the two rolls of a frame. The bonus for that frame is the number of pins knocked down by the next roll (first roll of next frame).
If the player rolls a strike or spare in the 10th frame they can roll the additional balls for the bonus. But they can never roll more than 3 balls in the 10th frame. The additional rolls only count for the bonus not for the regular frame count.
10, 10, 10 in the 10th frame gives 30 points (10 points for the regular first strike and 20 points for the bonus).
1, 9, 10 in the 10th frame gives 20 points (10 points for the regular spare and 10 points for the bonus).
A Gutter Game is when the player never hits a pin (20 zero scores).
A Perfect Game is when the player rolls 12 strikes (10 regular strikes and 2 strikes for the bonus in the 10th frame). The Perfect Game scores 300 points.
Create a nice interactive animated interface with jQuery.
More about ten pin bowling here: Wikipedia
$ git clone https://github.com/treborb/bowling-challenge.git
$ cd bowling-challenge
$ open SpecRunner.html
From there, you can open the Chrome developer tools console and run the following example commands to play:
game = new Game();
game.start();
game.bowl(n); // where n is the number of pins to be knocked down
$ open index.html
OR
$ npm start
$ open http://localhost:3000
Click the "Start" button to start the power bar.
Try to let the power bar get as close to the top as you can and then click the "Bowl" button.
On the first roll of a frame, if you stop the power bar at the top, you'll knock ten pins down. The bottom of the power bar is zero pins.
On the second roll of a frame, if you stop the power bar at the top, you'll knock down all of the remaining pins. The bottom of the power bar is zero pins.
The scoreboard updates as you go along.
See if you can get score perfect game!
There are two ways to run the tests, the first relies on having NPM (Node Package Manager) and Grunt installed:
$ npm update
$ grunt jasmine
Or to run the tests in the web browser:
$ open SpecRunner.html