typesafe ui/round WIP
This commit is contained in:
parent
15dcaf51c9
commit
b2c386ae28
|
@ -25,6 +25,7 @@ export interface Game {
|
|||
threefold?: boolean;
|
||||
boosted?: boolean;
|
||||
rematch?: string;
|
||||
rated?: boolean;
|
||||
}
|
||||
|
||||
export interface Status {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { plyStep } from './round';
|
||||
import { game } from 'game';
|
||||
import RoundController from './ctrl';
|
||||
|
||||
var found = false;
|
||||
|
||||
|
@ -7,21 +8,21 @@ function truncateFen(fen) {
|
|||
return fen.split(' ')[0];
|
||||
}
|
||||
|
||||
export function subscribe(ctrl) {
|
||||
export function subscribe(ctrl: RoundController) {
|
||||
// allow everyone to cheat against the AI
|
||||
if (ctrl.data.opponent.ai) return;
|
||||
// allow registered players to use assistance in casual games
|
||||
if (!ctrl.data.game.rated && ctrl.userId) return;
|
||||
if (!ctrl.data.game.rated && ctrl.opts.userId) return;
|
||||
window.lichess.storage.make('ceval.fen').listen(function(ev) {
|
||||
var d = ctrl.data;
|
||||
if (!found && ev.newValue && ctrl.vm.ply > 14 && game.playable(d) &&
|
||||
truncateFen(plyStep(d, ctrl.vm.ply).fen) === truncateFen(ev.newValue)) {
|
||||
if (!found && ev.newValue && ctrl.ply > 14 && game.playable(d) &&
|
||||
truncateFen(plyStep(d, ctrl.ply).fen) === truncateFen(ev.newValue)) {
|
||||
$.post('/jslog/' + d.game.id + d.player.id + '?n=ceval');
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function publish(ctrl, move) {
|
||||
export function publish(ctrl: RoundController, move) {
|
||||
if (ctrl.data.opponent.ai) window.lichess.storage.set('ceval.fen', move.fen);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue