From 79750ae3f7f276f6e4156ff4b7047b3edacd85b2 Mon Sep 17 00:00:00 2001 From: Allan Joseph Date: Sat, 14 Dec 2024 07:56:37 +0000 Subject: [PATCH] allow racingKings and antichess in nvui --- ui/analyse/src/plugins/analyse.nvui.ts | 2 +- ui/nvui/src/chess.ts | 9 ++++----- ui/round/src/plugins/round.nvui.ts | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/analyse/src/plugins/analyse.nvui.ts b/ui/analyse/src/plugins/analyse.nvui.ts index c3892c777bb7b..5eccd74d676d0 100644 --- a/ui/analyse/src/plugins/analyse.nvui.ts +++ b/ui/analyse/src/plugins/analyse.nvui.ts @@ -163,7 +163,7 @@ export function initModule(ctrl: AnalyseController) { }, renderBoard( ctrl.chessground.state.pieces, - ctrl.data.player.color, + ctrl.data.game.variant.key === 'racingKings' ? 'white' : ctrl.data.player.color, pieceStyle.get(), prefixStyle.get(), positionStyle.get(), diff --git a/ui/nvui/src/chess.ts b/ui/nvui/src/chess.ts index 07dd3a507a9a9..ead58d86a4f18 100644 --- a/ui/nvui/src/chess.ts +++ b/ui/nvui/src/chess.ts @@ -55,8 +55,7 @@ const skipToFile: { [letter: string]: Files } = { const symbolToFile = (char: string): Files => skipToFile[char] ?? ''; -export const supportedVariant = (key: VariantKey): boolean => - !['antichess', 'racingKings', 'crazyhouse'].includes(key); +export const supportedVariant = (key: VariantKey): boolean => key !== 'crazyhouse'; export function boardSetting(): Setting { return makeSetting({ @@ -483,7 +482,7 @@ export function possibleMovesHandler( rawMoves = chessgroundDests(fromSetup); } - const possibleCaptures = rawMoves + const possibleMoves = rawMoves ?.get(pos) ?.map(i => { const p = pieces.get(i); @@ -492,13 +491,13 @@ export function possibleMovesHandler( }) ?.filter(i => ev.key === 'm' || i.includes('captures')); $boardLive.text( - !possibleCaptures ? 'None' : !possibleCaptures.length ? 'No captures' : possibleCaptures.join(', '), + !possibleMoves ? 'None' : !possibleMoves.length ? 'No captures' : possibleMoves.join(', '), ); }; } const promotionRegex = /^([a-h]x?)?[a-h](1|8)=\w$/; -const uciPromotionRegex = /^([a-h][1-8])([a-h](1|8))[qrbn]$/; +const uciPromotionRegex = /^([a-h][1-8])([a-h](1|8))\w$/; export function inputToLegalUci(input: string, fen: string, chessground: CgApi): string | undefined { const legalUcis = destsToUcis(chessground.state.movable.dests!), diff --git a/ui/round/src/plugins/round.nvui.ts b/ui/round/src/plugins/round.nvui.ts index 9e7210ffd7a58..410d42e38d8a4 100644 --- a/ui/round/src/plugins/round.nvui.ts +++ b/ui/round/src/plugins/round.nvui.ts @@ -186,7 +186,7 @@ export function initModule(): NvuiPlugin { }, renderBoard( ctrl.chessground.state.pieces, - ctrl.data.player.color, + ctrl.data.game.variant.key === 'racingKings' ? 'white' : ctrl.data.player.color, pieceStyle.get(), prefixStyle.get(), positionStyle.get(),