From d19adae7d4ec57931c21b5b41fa1a0578fd37a22 Mon Sep 17 00:00:00 2001 From: Christopher Field Date: Fri, 30 Jan 2026 12:53:25 -0500 Subject: [PATCH] Updating Asli prison colors to show colors before swap. --- src/games/asli.ts | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/games/asli.ts b/src/games/asli.ts index b9bffb6d..71a14131 100644 --- a/src/games/asli.ts +++ b/src/games/asli.ts @@ -709,33 +709,27 @@ export class AsliGame extends GameBase { } pstr += pieces.join(""); } - // pstr = pstr.replace(/-{4}/g, "_"); - const hasPrison = this.prison.reduce((prev, curr) => prev + curr, 0) > 0; + const hasPrison = this.prison[0] > 0 || this.prison[1] > 0; const prisonPiece: Glyph[] = []; + prisonPiece.push({ + name: hasPrison ? "piece" : "piece-borderless", + colour: this.getPrisonColour(swapPrison), + scale: 0.85 + }); if (hasPrison) { - prisonPiece.push({ - name: "piece", - colour: this.prison[0] > 0 ? this.getPlayerColour(swapPrison ? 2 : 1) : this.getPlayerColour(swapPrison ? 1 : 2), - scale: 0.85, - }); prisonPiece.push({ text: this.prison[0] > 0 ? this.prison[0].toString() : this.prison[1].toString(), colour: { func: "bestContrast", fg: ["_context_background", "_context_fill", "_context_label"], - bg: this.prison[0] > 0 ? this.getPlayerColour(swapPrison ? 2 : 1) : this.getPlayerColour(swapPrison ? 1 : 2), + bg: this.getPrisonColour(swapPrison) }, scale: 0.75, - rotate: null, - }); - } else { - prisonPiece.push({ - name: "piece-borderless", - colour: "_context_background", - scale: 0.85, + rotate: null }); } + // Build rep const rep: APRenderRep = { board: { @@ -868,6 +862,20 @@ export class AsliGame extends GameBase { } } + public getPrisonColour(swapPrison: boolean): number|string { + if (this.prison[0] === 0 && this.prison[1] === 0) { + return "_context_background"; + } + let swap = swapPrison; + if (this.stack.length > 2 && this.stack[2].lastmove !== "pass") { + swap = !swap; + } + if (this.prison[1] > 0) { + swap = !swap; + } + return swap ? 2 : 1; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public serialize(opts?: {strip?: boolean, player?: number}): string { const json = JSON.stringify(this.state(), replacer);