X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FChakart%2Fclass.js;h=9b62150b8baffe25531aa31818801106ea4619e9;hp=04036246d4fe4e0054c0ec8026fce6c5e9f17a49;hb=b0cf998b1f63aa23916ab35a3d978b6972d273c5;hpb=c7c2f41c6f3e1aaf02a8539afd85336c9d923213 diff --git a/variants/Chakart/class.js b/variants/Chakart/class.js index 0403624..9b62150 100644 --- a/variants/Chakart/class.js +++ b/variants/Chakart/class.js @@ -141,7 +141,7 @@ export class ChakartRules extends ChessRules { b: Array.toObject(pieces, allCapts.slice(6, 12)) }; this.reserve = { w: {}, b: {} }; //to be replaced by this.captured - this.effect = ""; + this.moveStack = []; } // For Toadette bonus @@ -186,10 +186,57 @@ export class ChakartRules extends ChessRules { // TODO: rethink from here: + +// allow pawns + // queen invisible move, king shell: special functions + +// prevent pawns from capturing invisible queen (post) +// post-process: + +//events : playPlusVisual after mouse up, playReceived (include animation) on opp move +// ==> if move.cont (banana...) self re-call playPlusVisual (rec ?) + + // Initial call: effects resolved after playing getPotentialMovesFrom([x, y]) { let moves = []; - if (this.subTurn == 1) { - moves = super.getPotentialMovesFrom([x, y]); + switch (this.getPiece(x, y)) { + case 'p': + moves = this.getPawnMovesFrom([x, y]); //apply promotions + break; + case 'q': + moves = this.getQueenMovesFrom([x, y]); + break; + case 'k', + moves = this.getKingMoves([x, y]); + break; + default: + moves = super.getPotentialMovesFrom([x, y]); + } + return moves; + } + + + + tryMoveFollowup(move) { + if (this.getColor(move.end.x, move.end.y) == 'a') { + // effect, or bonus/malus + const endType = this.getPiece(m.end.x, m.end.y); + if (endType == V.EGG) + this.applyRandomBonus(m); + else { + this.moveStack.push(m); + switch (endType) { + case V.BANANA: + this.randomRedirect( + case V.BOMB: + case V.MUSHROOM: + // aller dans direction, saut par dessus pièce adverse + // ou amie (tjours), new step si roi caval pion + } + } + } + + const finalPieces = V.PawnSpecs.promotions; const color = this.turn; const lastRank = (color == "w" ? 0 : 7); @@ -271,8 +318,8 @@ export class ChakartRules extends ChessRules { // Helper for getBasicMove(): banana/bomb effect getRandomSquare([x, y], steps) { - const validSteps = steps.filter(s => V.OnBoard(x + s[0], y + s[1])); - const step = validSteps[randInt(validSteps.length)]; + const validSteps = steps.filter(s => this.onBoard(x + s[0], y + s[1])); + const step = validSteps[Random.randInt(validSteps.length)]; return [x + step[0], y + step[1]]; } @@ -923,7 +970,8 @@ export class ChakartRules extends ChessRules { - +/// if any of my pieces was immobilized, it's not anymore. + //if play set a piece immobilized, then mark it prePlay(move) { if (move.effect == "toadette") this.reserve = this.captured;