-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (23 loc) · 853 Bytes
/
main.js
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
30
31
32
document.addEventListener("DOMContentLoaded", () => {
let defaultBoardWidth = 10; //Sets default width of the board
//Creating a instance of gridManager
const gridManager = new GridMananger(defaultBoardWidth);
//Inherting properties of score to rules
Rules.prototype = Object.create(Score.prototype);
Rules.prototype.constructor = Rules;
//Creating an instance of rules
const rules = new Rules(gridManager);
rules.newGame();
//Click listeners
document.getElementById('restart-button').addEventListener('click', gridRefresh);
document.getElementById('shuffle-button').addEventListener('click', gridShuffle);
//Driver functions
function gridRefresh() {
gridManager.gridRefresh();
rules.newGame()
}
//shuffles the game
function gridShuffle() {
gridManager.gridShuffle();
}
})