+ if (bagOfPieces.length >= 1)
+ return Random.sample(bagOfPieces);
+ return null;
+ };
+ const color = this.turn;
+ let em = null;
+ switch (move.egg) {
+ case "luigi":
+ case "waluigi":
+ // Change color of friendly or enemy piece, king excepted
+ const oldColor = (move.egg == "waluigi" ? color : C.GetOppCol(color));
+ const newColor = C.GetOppCol(oldColor);
+ const coords = getRandomPiece(oldColor);
+ if (coords) {
+ const piece = this.getPiece(coords[0], coords[1]);
+ em = new Move({
+ appear: [
+ new PiPo({x: coords[0], y: coords[1], c: newColor, p: piece})
+ ],
+ vanish: [
+ new PiPo({x: coords[0], y: coords[1], c: oldColor, p: piece})
+ ]
+ });
+ }
+ break;
+ case "bowser":
+ em = new Move({
+ appear: [
+ new PiPo({
+ x: move.end.x,
+ y: move.end.y,
+ c: color,
+ p: V.IMMOBILIZE_CODE[move.appear[0].p]
+ })
+ ],
+ vanish: [
+ new PiPo({
+ x: move.end.x,
+ y: move.end.y,
+ c: color,
+ p: move.appear[0].p
+ })
+ ]
+ });
+ break;
+ case "koopa":
+ // Reverse move
+ em = new Move({
+ appear: [
+ new PiPo({
+ x: move.start.x, y: move.start.y, c: color, p: move.appear[0].p
+ })
+ ],
+ vanish: [
+ new PiPo({
+ x: move.end.x, y: move.end.y, c: color, p: move.appear[0].p
+ })
+ ]
+ });
+ if (this.board[move.start.x][move.start.y] != "") {
+ // Pawn or knight let something on init square
+ em.vanish.push(new PiPo({
+ x: move.start.x,
+ y: move.start.y,
+ c: 'a',
+ p: this.getPiece(move.start.x, move.start.y)
+ }));
+ }
+ break;
+ case "chomp":
+ // Eat piece
+ em = new Move({
+ appear: [],
+ vanish: [
+ new PiPo({
+ x: move.end.x, y: move.end.y, c: color, p: move.appear[0].p
+ })
+ ],
+ end: {x: move.end.x, y: move.end.y}
+ });
+ break;
+ }
+ if (em && move.egg != "koopa")
+ em.noAnimate = true; //static move
+ return em;
+ }
+
+ getMushroomEffect(move) {
+ if (typeof move.start.x == "string") //drop move (toadette)
+ return null;
+ let step = [move.end.x - move.start.x, move.end.y - move.start.y];
+ if ([0, 1].some(i => Math.abs(step[i]) >= 2 && Math.abs(step[1-i]) != 1)) {
+ // Slider, multi-squares: normalize step
+ for (let j of [0, 1])
+ step[j] = step[j] / Math.abs(step[j]) || 0;
+ }
+ const nextSquare = [move.end.x + step[0], move.end.y + step[1]];
+ const afterSquare =
+ [nextSquare[0] + step[0], nextSquare[1] + step[1]];
+ let nextMove = null;
+ if (this.onBoard(nextSquare[0], nextSquare[1])) {
+ this.playOnBoard(move); //HACK for getBasicMove()
+ nextMove = this.getBasicMove([move.end.x, move.end.y], nextSquare);
+ this.undoOnBoard(move);