forked from makersacademy/bowling-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.js
More file actions
29 lines (23 loc) · 698 Bytes
/
interface.js
File metadata and controls
29 lines (23 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*jshint esversion: 6 */
$(document).ready(function() {
var game = new BowlingGame();
$('#submit_pins').on('click', function() {
var pinsString = $('#pins_hit').val();
var pins = parseInt(pinsString);
console.log(pins);
game.roll(pins);
updateFrameNumberInterface();
});
$('#final-score').on('click', function() { // event listener
$('#score').text(game.score());
});
function updateFrameNumberInterface() {
var frameNumber = game.frameNumber();
if (frameNumber < 11) {
$('#frame').text(Math.floor(game.frameNumber()));
} else {
$('#frame').text(10);
}
}
updateFrameNumberInterface(1); // sets default frame number as 1
});