- // After moving, add stones captured in "step" direction from new location
- // [x, y] to mv.vanish (if any captured stone!)
- addCapture([x, y], step, move) {
- let [i, j] = [x + step[0], y + step[1]];
- const oppCol = V.GetOppCol(move.vanish[0].c);
- while (
- this.onBoard(i, j) &&
- this.board[i][j] != "" &&
- this.getColor(i, j) == oppCol
- ) {
- move.vanish.push(new PiPo({ x: i, y: j, c: oppCol, p: 's' }));
- [i, j] = [i + step[0], j + step[1]];
- }
- return (move.vanish.length >= 2);
- }
-
-
- // TODO from here
-
-
- getPotentialMovesFrom([x, y]) {
- const L0 = this.captures.length;
- const captures = this.captures[L0 - 1];
- const L = captures.length;
+ getPotentialMovesFrom([x, y], justCapt) {
+ // After moving, add stones captured in "step" direction from new location
+ // [x, y] to mv.vanish (if any captured stone!)
+ const oppCol = C.GetOppTurn(this.turn);
+ const addCapture = ([x, y], step, move) => {
+ let [i, j] = [x + step[0], y + step[1]];
+ while (
+ this.onBoard(i, j) &&
+ this.board[i][j] != "" &&
+ this.getColor(i, j) == oppCol
+ ) {
+ move.vanish.push(new PiPo({ x: i, y: j, c: oppCol, p: 's' }));
+ [i, j] = [i + step[0], j + step[1]];
+ }
+ return (move.vanish.length >= 2);
+ };
+ const stepToArrow = (s, forward) => {
+ const baseShift = (forward ? 0 : 8),
+ colShift = (this.playerColor=='w' ? 0 : 4);
+ const doShift = (c) => {
+ return String.fromCharCode(
+ 97 + (c.charCodeAt(0) - 97 + colShift) % 8 + baseShift);
+ };
+ switch (s) {
+ case "-1_0": return doShift('a');
+ case "-1_1": return doShift('b');
+ case "0_1": return doShift('c');
+ case "1_1": return doShift('d');
+ case "1_0": return doShift('e');
+ case "1_-1": return doShift('f');
+ case "0_-1": return doShift('g');
+ case "-1_-1": return doShift('h');
+ }
+ return ''; //never reached
+ };
+ const L = this.captures.length;