- super.pieces()['k'].moves[0].steps.forEach(step => {
- let [i, j] = [x + step[0], y + step[1]];
- while (
- this.onBoard(i, j) &&
- (
- this.board[i][j] == "" ||
- this.getPiece(i, j) == V.INVISIBLE_QUEEN ||
- (
- this.getColor(i, j) == 'a' &&
- [V.EGG, V.MUSHROOM].includes(this.getPiece(i, j))
- )
- )
- ) {
- i += step[0];
- j += step[1];
- }
- if (this.onBoard(i, j)) {
- const colIJ = this.getColor(i, j);
- if (colIJ != this.turn) {
- // May just destroy a bomb or banana:
- let shellCapture = new Move({
- start: {x: x, y: y},
- end: {x: i, y: j},
- appear: [],
- vanish: [
- new PiPo({x: i, y: j, c: colIJ, p: this.getPiece(i, j)})
- ]
- });
- shellCapture.shell = true; //easier play()
- shellCapture.choice = 'z'; //to display in showChoices()
- moves.push(shellCapture);
- }
- }
+ let shellCaptures = this.getPotentialMovesOf('y', [x, y]);
+ shellCaptures.forEach(sc => {
+ sc.shell = true; //easier play()
+ sc.choice = 'z'; //to display in showChoices()
+ // Fix move (Rifle style):
+ sc.vanish.shift();
+ sc.appear.shift();