+ return move;
+ }
+
+ getBasicMove(psq1, sq2, tr) {
+ let moves = [];
+ if (Array.isArray(psq1)) psq1 = { x: psq1[0], y: psq1[1] };
+ let m = this.getBasicMove_aux(psq1, sq2, tr, "initMove");
+ while (!!m.next) {
+ // Last move ended on bomb or banana, direction change
+ V.PlayOnBoard(this.board, m);
+ moves.push(m);
+ m = this.getBasicMove_aux(
+ { x: m.appear[0].x, y: m.appear[0].y }, m.next);
+ }
+ for (let i=moves.length-1; i>=0; i--) V.UndoOnBoard(this.board, moves[i]);
+ moves.push(m);
+ // Now merge moves into one
+ let move = {};
+ // start is wrong for Toadette moves --> it's fixed later
+ move.start = { x: psq1.x, y: psq1.y };
+ move.end = !!sq2 ? { x: sq2[0], y: sq2[1] } : { x: psq1.x, y: psq1.y };
+ let lm = moves[moves.length-1];
+ if (this.subTurn == 1 && !!lm.end.effect)
+ move.end.effect = lm.end.effect;
+ if (moves.length == 1) {
+ move.appear = moves[0].appear;
+ move.vanish = moves[0].vanish;
+ }
+ else {
+ // Keep first vanish and last appear (if any)
+ move.appear = lm.appear;
+ move.vanish = moves[0].vanish;
+ if (
+ move.vanish.length >= 1 &&
+ move.appear.length >= 1 &&
+ move.vanish[0].x == move.appear[0].x &&
+ move.vanish[0].y == move.appear[0].y
+ ) {
+ // Loopback on initial square:
+ move.vanish.shift();
+ move.appear.shift();
+ }
+ for (let i=1; i < moves.length - 1; i++) {
+ for (let v of moves[i].vanish) {
+ // Only vanishing objects, not appearing at init move
+ if (
+ v.c == 'a' &&
+ (
+ moves[0].appear.length == 1 ||
+ moves[0].appear[1].x != v.x ||
+ moves[0].appear[1].y != v.y
+ )
+ ) {
+ move.vanish.push(v);
+ }
+ }
+ }
+ // Final vanish is our piece, but others might be relevant
+ // (for some egg bonuses at least).
+ for (let i=1; i < lm.vanish.length; i++) {
+ if (
+ lm.vanish[i].c != 'a' ||
+ moves[0].appear.length == 1 ||
+ moves[0].appear[1].x != lm.vanish[i].x ||
+ moves[0].appear[1].y != lm.vanish[i].y
+ ) {
+ move.vanish.push(lm.vanish[i]);
+ }
+ }