Skip to content

Commit

Permalink
allow racingKings and antichess in nvui
Browse files Browse the repository at this point in the history
  • Loading branch information
allanjoseph98 committed Dec 14, 2024
1 parent f242042 commit 79750ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ui/analyse/src/plugins/analyse.nvui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 4 additions & 5 deletions ui/nvui/src/chess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BoardStyle> {
return makeSetting<BoardStyle>({
Expand Down Expand Up @@ -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);
Expand All @@ -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!),
Expand Down
2 changes: 1 addition & 1 deletion ui/round/src/plugins/round.nvui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 79750ae

Please sign in to comment.