nvui refactor WIP
parent
588a625fe5
commit
0139f101a3
|
@ -32,6 +32,7 @@
|
||||||
"ui/dasher",
|
"ui/dasher",
|
||||||
"ui/editor",
|
"ui/editor",
|
||||||
"ui/game",
|
"ui/game",
|
||||||
|
"ui/nvui",
|
||||||
"ui/insight",
|
"ui/insight",
|
||||||
"ui/learn",
|
"ui/learn",
|
||||||
"ui/lobby",
|
"ui/lobby",
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"name": "nvui",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "lichess.org non-visual user interface",
|
||||||
|
"main": "dist/main.js",
|
||||||
|
"types": "dist/main",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/ornicar/lila"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"chess",
|
||||||
|
"lichess",
|
||||||
|
"non-visual",
|
||||||
|
"blind",
|
||||||
|
"accessibility"
|
||||||
|
],
|
||||||
|
"author": "Thibault Duplessis",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/ornicar/lila/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/ornicar/lila",
|
||||||
|
"scripts": {
|
||||||
|
"compile": "tsc"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/lichess": "1.0.0",
|
||||||
|
"game": "1.0.0",
|
||||||
|
"typescript": "^3"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { h } from 'snabbdom'
|
||||||
|
import { VNode } from 'snabbdom/vnode'
|
||||||
|
// import { GameData } from 'game';
|
||||||
|
import { Pieces } from 'chessground/types';
|
||||||
|
|
||||||
|
export function piecesHtml(pieces: Pieces, style: string): VNode {
|
||||||
|
return h('div', ['white', 'black'].map(color => {
|
||||||
|
const lists: any = [];
|
||||||
|
['king', 'queen', 'rook', 'bishop', 'knight', 'pawn'].forEach(role => {
|
||||||
|
const keys = [];
|
||||||
|
for (let key in pieces) {
|
||||||
|
if (pieces[key]!.color === color && pieces[key]!.role === role) keys.push(key);
|
||||||
|
}
|
||||||
|
if (keys.length) lists.push([`${role}${keys.length > 1 ? 's' : ''}`, ...keys]);
|
||||||
|
});
|
||||||
|
return h('div', [
|
||||||
|
h('h3', `${color} pieces`),
|
||||||
|
...lists.map((l: any) =>
|
||||||
|
`${l[0]}: ${l.slice(1).map((k: string) => renderKey(k, style)).join(', ')}`
|
||||||
|
).join(', ')
|
||||||
|
]);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
const anna: { [letter: string]: string } = { a: 'anna', b: 'bella', c: 'cesar', d: 'david', e: 'eva', f: 'felix', g: 'gustav', h: 'hector' };
|
||||||
|
export function renderKey(key: string, style: string): string {
|
||||||
|
return (style === 'anna' || style === 'full') ? `${anna[key[0]]} ${key[1]}` : key;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
import * as chess from './chess';
|
||||||
|
|
||||||
|
export { chess };
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"include": ["src/*.ts"],
|
||||||
|
"exclude": [],
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist",
|
||||||
|
"declaration": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noEmitOnError": true,
|
||||||
|
"alwaysStrict": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"target": "es5",
|
||||||
|
"lib": ["DOM", "ES5"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,7 @@
|
||||||
"chessground": "^7.3",
|
"chessground": "^7.3",
|
||||||
"common": "1.0.0",
|
"common": "1.0.0",
|
||||||
"game": "1.0.0",
|
"game": "1.0.0",
|
||||||
|
"nvui": "1.0.0",
|
||||||
"snabbdom": "ornicar/snabbdom#0.7.1-lichess"
|
"snabbdom": "ornicar/snabbdom#0.7.1-lichess"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { Step, DecodedDests, Position, Redraw } from '../interfaces';
|
||||||
import { Player } from 'game';
|
import { Player } from 'game';
|
||||||
import { files } from 'chessground/types';
|
import { files } from 'chessground/types';
|
||||||
import { invRanks } from 'chessground/util';
|
import { invRanks } from 'chessground/util';
|
||||||
|
import { renderKey } from 'nvui/chess';
|
||||||
|
|
||||||
type Sans = {
|
type Sans = {
|
||||||
[key: string]: Uci;
|
[key: string]: Uci;
|
||||||
|
@ -284,11 +285,6 @@ function readSan(s: Step, style: string) {
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
|
|
||||||
const anna: { [letter: string]: string } = { a: 'anna', b: 'bella', c: 'cesar', d: 'david', e: 'eva', f: 'felix', g: 'gustav', h: 'hector' };
|
|
||||||
function annaKey(key: string, style: string): string {
|
|
||||||
return (style === 'anna' || style === 'full') ? `${anna[key[0]]} ${key[1]}` : key;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderPlayer(ctrl: RoundController, player: Player) {
|
function renderPlayer(ctrl: RoundController, player: Player) {
|
||||||
return player.ai ? ctrl.trans('aiNameLevelAiLevel', 'Stockfish', player.ai) : userHtml(ctrl, player);
|
return player.ai ? ctrl.trans('aiNameLevelAiLevel', 'Stockfish', player.ai) : userHtml(ctrl, player);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue