forked from algorithm0r/Empty--GameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Number.js
29 lines (25 loc) · 774 Bytes
/
Number.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
class Number {
constructor(board, num, x, y) {
Object.assign(this, {board, num, x, y})
this.image = this.getNumberImage(this.num)
}
clicked() {
let flagcount = 0
Object.values(this.board.getSurroundingSquares(this.x, this.y)).forEach(s => {
if(s.square.isFlagged) {
flagcount++
}
})
console.log(flagcount)
if(flagcount == this.num) {
Object.values(this.board.getSurroundingSquares(this.x, this.y)).forEach(s => {
if(s.square.covered) {
s.square.leftClicked();
}
})
}
}
getNumberImage(n) {
return ASSET_MANAGER.getAsset(SPRITES_PATH + "Tile" + n + ".png")
}
}