-
Notifications
You must be signed in to change notification settings - Fork 0
/
captureCalculator.js
44 lines (36 loc) · 1.06 KB
/
captureCalculator.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
34
35
36
37
38
39
40
41
42
43
44
function CaptureCalculator(_boardMap) {
this.inheritFrom = BoardUtilities;
this.inheritFrom(); //Inheritance, yay
this._stones = _boardMap;
this._visited = new Array();
this.visited = function(){ return this._visited }
this._captures = new Array();
this.captures = function(){ return this._captures }
this.player = undefined;
this.capturesForMove = function(_coords, _player){
this.player = _player;
this.adjacentSpots(_coords).each(function(c){
if(this.isPlayer(c,this.player)){ alert(c) }
}.bind(this));
}
this.capturesForMoveHelper = function(_coords){ //TODO: figure this shit out
if(this.isVisited(_coords)){
return true;
}
else if(this.isOpponent(_coords)){
this.captures().push(_coords);
return this.adjacent;
}
}
this.isVisited = function(_coords){
if(this.visited().include(_coords)){
return true
} else {
this._visited.push(_coords);
return false
}
}
this.isOpponent = function(_coords){
return this.isPlayer(this.otherPlayer(this.player))
}
}