- if (this.getPiece(x, y) == V.CHAMPION)
- return this.getPotentialChampionMoves([x, y]);
- return super.getPotentialMovesFrom([x, y]);
+ let moves = undefined;
+ const piece = this.getPiece(x, y);
+ if (piece == V.PHOENIX)
+ moves = this.getPotentialPhoenixMoves([x, y]);
+ else moves = super.getPotentialMovesFrom([x, y]);
+ // Add "taking ball in place" move (at most one in list)
+ for (let m of moves) {
+ if (
+ m.vanish.length == 2 &&
+ m.vanish[1].p != 'a' &&
+ m.vanish[0].c != m.vanish[1].c &&
+ Object.keys(V.HAS_BALL_DECODE).includes(m.appear[0].p)
+ ) {
+ const color = this.turn;
+ const oppCol = V.GetOppCol(color);
+ moves.push(
+ new Move({
+ appear: [
+ new PiPo({
+ x: x,
+ y: y,
+ c: color,
+ p: m.appear[0].p
+ }),
+ new PiPo({
+ x: m.vanish[1].x,
+ y: m.vanish[1].y,
+ c: oppCol,
+ p: V.HAS_BALL_DECODE[m.vanish[1].p]
+ })
+ ],
+ vanish: [
+ new PiPo({
+ x: x,
+ y: y,
+ c: color,
+ p: piece
+ }),
+ new PiPo({
+ x: m.vanish[1].x,
+ y: m.vanish[1].y,
+ c: oppCol,
+ p: m.vanish[1].p
+ })
+ ],
+ end: { x: m.end.x, y: m.end.y }
+ })
+ );
+ break;
+ }
+ }
+ return moves;