use round last ply for ceval comparison

pull/5145/head
Thibault Duplessis 2019-05-24 13:21:28 +02:00
parent c2502ea5ba
commit 845b59b8e4
2 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { plyStep } from './round';
import { lastStep } from './round';
import RoundController from './ctrl';
import { ApiMove, RoundData } from './interfaces';
@ -20,9 +20,9 @@ export function subscribe(ctrl: RoundController): void {
const v = ev.newValue;
if (!v) return;
else if (v.startsWith('start:')) return li.storage.set('round.ongoing', v);
const d = ctrl.data;
if (!found && ctrl.ply > 14 && ctrl.isPlaying() &&
truncateFen(plyStep(d, ctrl.ply).fen) === truncateFen(v)) {
const d = ctrl.data, step = lastStep(ctrl.data);
if (!found && step.ply > 14 && ctrl.isPlaying() &&
truncateFen(step.fen) === truncateFen(v)) {
$.post('/jslog/' + d.game.id + d.player.id + '?n=ceval');
found = true;
}

View File

@ -5,7 +5,11 @@ export function firstPly(d: RoundData): number {
}
export function lastPly(d: RoundData): number {
return d.steps[d.steps.length - 1].ply;
return lastStep(d).ply;
}
export function lastStep(d: RoundData): Step {
return d.steps[d.steps.length - 1];
}
export function plyStep(d: RoundData, ply: number): Step {