stricter puzzle types
parent
067ad321d6
commit
b692b72646
|
@ -68,7 +68,7 @@ export interface CevalCtrl {
|
|||
variant: Variant;
|
||||
setHovering: (fen: string, uci?: string) => void;
|
||||
multiPv: StoredProp<number>;
|
||||
start: (path: string, steps: Step[], threatMode: boolean, deeper: boolean) => void;
|
||||
start: (path: string, steps: Step[], threatMode?: boolean, deeper?: boolean) => void;
|
||||
stop(): void;
|
||||
threads: StoredProp<number> | undefined;
|
||||
hashSize: StoredProp<number> | undefined;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { build as treeBuild, ops as treeOps, path as treePath } from 'tree';
|
||||
import { ctrl as cevalCtrl } from 'ceval';
|
||||
import { build as treeBuild, ops as treeOps, path as treePath, TreeWrapper } from 'tree';
|
||||
import { ctrl as cevalCtrl, CevalCtrl } from 'ceval';
|
||||
import { readDests, decomposeUci, sanToRole } from 'chess';
|
||||
import { opposite } from 'chessground/util';
|
||||
import keyboard from './keyboard';
|
||||
|
@ -22,7 +22,7 @@ import { Redraw, Vm, Controller, PuzzleOpts, PuzzleData, PuzzleRound, PuzzleVote
|
|||
export default function(opts: PuzzleOpts, redraw: Redraw): Controller {
|
||||
|
||||
let vm: Vm = {} as Vm;
|
||||
var data, tree, ceval, moveTest;
|
||||
var data: PuzzleData, tree: TreeWrapper, ceval: CevalCtrl, moveTest;
|
||||
const ground = prop<CgApi | undefined>(undefined);
|
||||
const threatMode = prop(false);
|
||||
|
||||
|
@ -39,7 +39,7 @@ export default function(opts: PuzzleOpts, redraw: Redraw): Controller {
|
|||
|
||||
function withGround<A>(f: (cg: CgApi) => A): A | undefined {
|
||||
const g = ground();
|
||||
if (g) return f(g);
|
||||
return g && f(g);
|
||||
}
|
||||
|
||||
function initiate(fromData: PuzzleData): void {
|
||||
|
@ -156,13 +156,13 @@ export default function(opts: PuzzleOpts, redraw: Redraw): Controller {
|
|||
}
|
||||
|
||||
function addNode(node: Tree.Node, path: Tree.Path): void {
|
||||
var newPath = tree.addNode(node, path);
|
||||
const newPath = tree.addNode(node, path)!;
|
||||
jump(newPath);
|
||||
reorderChildren(path);
|
||||
redraw();
|
||||
withGround(function(g) { g.playPremove(); });
|
||||
|
||||
var progress = moveTest();
|
||||
const progress = moveTest();
|
||||
if (progress) applyProgress(progress);
|
||||
redraw();
|
||||
speech.node(node, false);
|
||||
|
|
|
@ -99,8 +99,9 @@ export interface PuzzlePrefs {
|
|||
export interface PuzzleData {
|
||||
puzzle: Puzzle;
|
||||
game: {
|
||||
treeParts: Tree.Node[];
|
||||
};
|
||||
user: PuzzleUser;
|
||||
user: PuzzleUser | undefined;
|
||||
voted: boolean | null | undefined;
|
||||
}
|
||||
|
||||
|
@ -115,10 +116,11 @@ export interface Puzzle {
|
|||
vote: number;
|
||||
color: Color;
|
||||
lines: Lines;
|
||||
branch: any;
|
||||
}
|
||||
|
||||
export interface PuzzleRound {
|
||||
user: PuzzleUser | false;
|
||||
user: PuzzleUser;
|
||||
round?: {
|
||||
ratingDiff: number;
|
||||
win: boolean;
|
||||
|
|
|
@ -78,4 +78,5 @@ export default function(ctrl: Controller): MaybeVNode {
|
|||
if (ctrl.vm.lastFeedback === 'good') return good(ctrl);
|
||||
if (ctrl.vm.lastFeedback === 'retry') return retry(ctrl);
|
||||
if (ctrl.vm.lastFeedback === 'fail') return fail(ctrl);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ const historySize = 15;
|
|||
function render(ctrl: Controller): VNode {
|
||||
const data = ctrl.getData();
|
||||
const slots: any[] = [];
|
||||
for (let i = 0; i < historySize; i++) slots[i] = data.user.recent[i] || null;
|
||||
return h('div.puzzle__history', slots.map(function(s) {
|
||||
if (s) return h('a', {
|
||||
for (let i = 0; i < historySize; i++) slots[i] = data.user!.recent[i] || null;
|
||||
return h('div.puzzle__history', slots.map((s) => {
|
||||
return s && h('a', {
|
||||
class: {
|
||||
current: data.puzzle.id === s[0],
|
||||
win: s[1] >= 0,
|
||||
|
|
|
@ -120,16 +120,18 @@ function puzzleGlyph(ctx: Ctx, node: Tree.Node): MaybeVNode {
|
|||
name: ctx.ctrl.trans.noarg('bestMove'),
|
||||
symbol: '✓'
|
||||
});
|
||||
case 'fail':
|
||||
return renderGlyph({
|
||||
name: ctx.ctrl.trans.noarg('puzzleFailed'),
|
||||
symbol: '✗'
|
||||
});
|
||||
case 'retry':
|
||||
return renderGlyph({
|
||||
name: ctx.ctrl.trans.noarg('goodMove'),
|
||||
symbol: '?!'
|
||||
});
|
||||
case 'fail':
|
||||
return renderGlyph({
|
||||
name: ctx.ctrl.trans.noarg('puzzleFailed'),
|
||||
symbol: '✗'
|
||||
});
|
||||
case 'retry':
|
||||
return renderGlyph({
|
||||
name: ctx.ctrl.trans.noarg('goodMove'),
|
||||
symbol: '?!'
|
||||
});
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
"extends": "../tsconfig.base.json",
|
||||
"include": ["src/*.ts", "src/*.js"],
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitReturns": false
|
||||
"noImplicitAny": false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue