- if (move.vanish.length == 2 && move.appear.length == 1) {
- // Capture: update reserves
- this.Reserve[move.vanish
- const pIdx = ['p', 'r', 'n', 'b', 'q'].indexOf(move.vanish[1].p);
- // TODO
- if normal
- ? ChessRules.PIECES.findIndex(p => p == move.vanish[1].p)
- : V.NON_VIOLENT.findIndex(p => p == move.vanish[1].p);
- const rPiece = (normal ? V.NON_VIOLENT : ChessRules.PIECES)[pIdx];
- this.reserve[move.vanish[1].c][rPiece]++;
+ if (
+ (move.vanish.length == 2 && move.appear.length == 1) ||
+ move.vanish.length == 0 //drop
+ ) {
+ const trPiece =
+ (move.vanish.length > 0 ? move.vanish[1].p : move.appear[0].p);
+ const normal = V.V_PIECES.includes(trPiece);
+ const pIdx = (normal ? V.V_PIECES : V.NV_PIECES).indexOf(trPiece);
+ const resPiece = (normal ? V.NV_PIECES : V.V_PIECES)[pIdx];
+ if (move.vanish.length > 0) {
+ super.updateReserve(C.GetOppTurn(this.turn), resPiece,
+ this.reserve[C.GetOppTurn(this.turn)][resPiece] + 1);
+ }
+ else {
+ super.updateReserve(this.turn, resPiece,
+ this.reserve[this.turn][resPiece] - 1);
+ }