-
Notifications
You must be signed in to change notification settings - Fork 4
/
row-win.js
33 lines (30 loc) · 716 Bytes
/
row-win.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
33
//Detect row win
export class RowWinInspector {
constructor(columns) {
this.column = columns;
}
// this.column = [{} {} {} {}]
// arr[i][j]
//column = [1, 2, 3, 4]
/*
[*][*][*][*]
[*][*][*][*]
[*][*][*][*]
[*][*][*][*]
[*][*][*][*]
*/
inspect() {
for (let i = 5; i >= 0; i--) {
if (this.column[0].getTokenAt(i) !== null) {
if (
this.column[0].getTokenAt(i) === this.column[1].getTokenAt(i) &&
this.column[0].getTokenAt(i) === this.column[2].getTokenAt(i) &&
this.column[0].getTokenAt(i) === this.column[3].getTokenAt(i)
) {
return this.column[0].getTokenAt(i);
}
}
}
return 0;
}
}