Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion translation/source/nvui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<string name="moveToPieceByType">Move to squares using piece names. For example: repeated k will move to every square where there is a knight. Use uppercase to invert order.</string>
<string name="moveToRank">Move to rank 1 to 8.</string>
<string name="moveToFile">Move to file a to h.</string>
<string name="announcePieceLocations">Announce locations of pieces. Example: p capital N for white knights, p lowercase k for black king.</string>
<string name="announcePieceLocations">Announce locations of pieces. Example: p capital N for white knights, p lowercase k for black king, p capital A for all white pieces.</string>
<string name="announcePiecesOnRankOrFile">Announce pieces on a rank or a file. Example: s a, s 1.</string>
<string name="goToBoard">Go to the board. Default square is e-4. You can specify a square: board a-1 or b a-1 will take you to square a-1.</string>
<string name="movePiece">To move a piece, use standard algebraic notation.</string>
Expand Down
2 changes: 1 addition & 1 deletion ui/@types/lichess/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ interface I18n {
announceLastMove: string;
/** Announce piece captured in last move. */
announceLastMoveCapture: string;
/** Announce locations of pieces. Example: p capital N for white knights, p lowercase k for black king. */
/** Announce locations of pieces. Example: p capital N for white knights, p lowercase k for black king, p capital A for all white pieces. */
announcePieceLocations: string;
/** Announce pieces on a rank or a file. Example: s a, s 1. */
announcePiecesOnRankOrFile: string;
Expand Down
34 changes: 18 additions & 16 deletions ui/lib/src/nvui/chess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,27 @@ export const renderSan = (san: San | undefined, uci: Uci | undefined, style: Mov
)
.join(' ');

const renderPiecesByColor = (pieces: Pieces, style: MoveStyle, color: Color): string => {
return ROLES.slice()
.reverse()
.reduce<{ role: Role; keys: Key[] }[]>(
(lists, role) =>
lists.concat({
role,
keys: keysWithPiece(pieces, role, color),
}),
[],
)
.filter(l => l.keys.length)
.map(l => `${transRole(l.role)}: ${l.keys.map(k => renderKey(k, style)).join(', ')}`)
.join(', ');
};

export const renderPieces = (pieces: Pieces, style: MoveStyle): VNode =>
h(
'div.pieces',
COLORS.map(color =>
h(`div.${color}-pieces`, [
h('h3', i18n.site[color]),
ROLES.slice()
.reverse()
.reduce<{ role: Role; keys: Key[] }[]>(
(lists, role) =>
lists.concat({
role,
keys: keysWithPiece(pieces, role, color),
}),
[],
)
.filter(l => l.keys.length)
.map(l => `${transRole(l.role)}: ${l.keys.map(k => renderKey(k, style)).join(', ')}`)
.join(', '),
]),
h(`div.${color}-pieces`, [h('h3', i18n.site[color]), renderPiecesByColor(pieces, style, color)]),
),
);

Expand All @@ -161,6 +162,7 @@ const keysWithPiece = (pieces: Pieces, role?: Role, color?: Color): Key[] =>

export function renderPieceKeys(pieces: Pieces, p: string, style: MoveStyle): string {
const color: Color = p === p.toUpperCase() ? 'white' : 'black';
if (p.toLowerCase() == 'a') return renderPiecesByColor(pieces, style, color);
const role = charToRole(p)!;
const keys = keysWithPiece(pieces, role, color);
let pieceStr = transPieceStr(role, color, i18n);
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/src/nvui/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const commands: () => Commands = memoize(() => ({
piece: {
help: i18n.nvui.announcePieceLocations,
apply(c: string, pieces: Pieces, style: MoveStyle): string | undefined {
return tryC(c, /^\/?p ([pnbrqk])$/i, p => renderPieceKeys(pieces, p, style));
return tryC(c, /^\/?p ([apnbrqk])$/i, p => renderPieceKeys(pieces, p, style));
},
},
scan: {
Expand Down
Loading