Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui/nvui cleanup #16560

Merged
merged 46 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
edf0cdb
use destsToUcis from ui/chess
allanjoseph98 Dec 9, 2024
4b11790
move sanToUci to ui/chess
allanjoseph98 Dec 9, 2024
60e0b60
change some types
allanjoseph98 Dec 9, 2024
686690a
some code golf
allanjoseph98 Dec 9, 2024
c26acd4
use lichessrules chessops compat util
allanjoseph98 Dec 9, 2024
3dad0fb
golf + rename stuff to be more accurate
allanjoseph98 Dec 9, 2024
0e2b7cf
remove unused blindmode variants scala set
allanjoseph98 Dec 10, 2024
cafb9ae
type tweak
allanjoseph98 Dec 10, 2024
08dd1db
distinguish between cash and non cash variables
allanjoseph98 Dec 10, 2024
7e6b26b
rename `Style` to `MoveStyle` for clarity
allanjoseph98 Dec 10, 2024
1c067b8
cast type directly
allanjoseph98 Dec 10, 2024
2f36dac
use roles const from chessops
allanjoseph98 Dec 10, 2024
730a5f8
refactor
allanjoseph98 Dec 10, 2024
410d118
programatically render choice examples
allanjoseph98 Dec 10, 2024
e5cd01d
fix order
allanjoseph98 Dec 10, 2024
fbd6d0e
some weight loss
allanjoseph98 Dec 11, 2024
28d1180
`sanToWords` util func.
allanjoseph98 Dec 11, 2024
1a803a5
remove unused constructor parameter
allanjoseph98 Dec 12, 2024
21c1cc7
golf
allanjoseph98 Dec 12, 2024
036ca3c
correct lichess comment Regex
allanjoseph98 Dec 12, 2024
f242042
fix game start
allanjoseph98 Dec 14, 2024
79750ae
allow racingKings and antichess in nvui
allanjoseph98 Dec 14, 2024
f82f82c
refactor
allanjoseph98 Dec 16, 2024
894dac0
golf puzzle nvui
allanjoseph98 Dec 17, 2024
06d76fb
golf
allanjoseph98 Dec 18, 2024
e08c9c7
refactor:use analyse result rendering
allanjoseph98 Dec 18, 2024
23e014a
king underpromotion regex for antichess
allanjoseph98 Dec 18, 2024
eff01df
key attr regex
allanjoseph98 Dec 31, 2024
650b574
don't assume dests are available
allanjoseph98 Dec 31, 2024
4c4e607
Don't destroy chessground when the board is hidden by snabb. Required…
allanjoseph98 Dec 31, 2024
6dd0ca8
nvui study chapter select
allanjoseph98 Dec 31, 2024
bcea574
maybe pacify gh security warning
allanjoseph98 Dec 31, 2024
5a6b066
nvui study add and edit chapters
allanjoseph98 Dec 31, 2024
dfb3f54
golf
allanjoseph98 Jan 1, 2025
9b7d50f
remove debug
allanjoseph98 Jan 1, 2025
e6108d7
translate some existing commands
allanjoseph98 Jan 1, 2025
4ca3df1
refactor board commands
allanjoseph98 Jan 1, 2025
8c97326
fix puzzle i18n
allanjoseph98 Jan 1, 2025
8d24edc
some more i18n
allanjoseph98 Jan 3, 2025
4c076f9
uci is already treated as optional
allanjoseph98 Jan 3, 2025
cf05aa8
more i18n
allanjoseph98 Jan 4, 2025
ba0ada7
round i18n
allanjoseph98 Jan 4, 2025
8d02d02
golf
allanjoseph98 Jan 4, 2025
8959e5c
Merge branch 'master' into ui-nvui-cleanup
ornicar Jan 13, 2025
244671b
reconfigure chessground on every redraw
allanjoseph98 Jan 18, 2025
dbe1f76
use <select> change events for chapter changes
allanjoseph98 Jan 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
programatically render choice examples
  • Loading branch information
allanjoseph98 committed Dec 10, 2024
commit 410d118f7c42214c7f1c99d3918f0f3c3c2b5a98
34 changes: 11 additions & 23 deletions ui/nvui/src/chess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { charToRole, parseUci, roleToChar } from 'chessops/util';
import { destsToUcis, plyToTurn, sanToUci, sanWriter } from 'chess';
import { storage } from 'common/storage';

export type MoveStyle = 'uci' | 'san' | 'literate' | 'nato' | 'anna';
export type PieceStyle = 'letter' | 'white uppercase letter' | 'name' | 'white uppercase name';
export type PrefixStyle = 'letter' | 'name' | 'none';
const moveStyles = ['uci', 'san', 'literate', 'nato', 'anna'] as const;
export type MoveStyle = (typeof moveStyles)[number];
const pieceStyles = ['letter', 'white uppercase letter', 'name', 'white uppercase name'] as const;
export type PieceStyle = (typeof pieceStyles)[number];
const prefixStyles = ['letter', 'name', 'none'] as const;
export type PrefixStyle = (typeof prefixStyles)[number];
export type PositionStyle = 'before' | 'after' | 'none';
export type BoardStyle = 'plain' | 'table';

Expand Down Expand Up @@ -68,38 +71,23 @@ export function boardSetting(): Setting<BoardStyle> {

export function styleSetting(): Setting<MoveStyle> {
return makeSetting<MoveStyle>({
choices: [
['san', 'SAN: Nxf3'],
['uci', 'UCI: g1f3'],
['literate', 'Literate: knight takes f 3'],
['anna', 'Anna: knight takes felix 3'],
['nato', 'Nato: knight takes foxtrot 3'],
],
choices: moveStyles.map(s => [s, `${s}: ${renderSan('Nxf3', undefined, s)}`]),
default: 'anna', // all the rage in OTB blind chess tournaments
storage: storage.make('nvui.moveNotation'),
});
}

export function pieceSetting(): Setting<PieceStyle> {
return makeSetting<PieceStyle>({
choices: [
['letter', 'Letter: p, p'],
['white uppercase letter', 'White uppercase letter: P, p'],
['name', 'Name: pawn, pawn'],
['white uppercase name', 'White uppercase name: Pawn, pawn'],
],
choices: pieceStyles.map(p => [p, `${p}: ${renderPieceStyle('P', p)}`]),
default: 'letter',
storage: storage.make('nvui.pieceStyle'),
});
}

export function prefixSetting(): Setting<PrefixStyle> {
return makeSetting<PrefixStyle>({
choices: [
['letter', 'Letter: w/b'],
['name', 'Name: white/black'],
['none', 'None'],
],
choices: prefixStyles.map(p => [p, `${p}: ${renderPrefixStyle('white', p)}`]),
default: 'letter',
storage: storage.make('nvui.prefixStyle'),
});
Expand All @@ -123,8 +111,8 @@ const renderPieceStyle = (piece: string, pieceStyle: PieceStyle) =>
: pieceStyle === 'white uppercase letter'
? piece
: pieceStyle === 'name'
? charToRole(piece)
: `${piece}${charToRole(piece)?.slice(1)}`;
? charToRole(piece)!
: `${piece.replace('N', 'K').replace('n', 'k')}${charToRole(piece)!.slice(1)}`;

const renderPrefixStyle = (color: Color, prefixStyle: PrefixStyle): `${Color} ` | 'w' | 'b' | '' =>
prefixStyle === 'letter' ? (color[0] as 'w' | 'b') : prefixStyle === 'name' ? `${color} ` : '';
Expand Down