study server eval WIP
parent
23476115d4
commit
6ad5b08180
|
@ -129,7 +129,7 @@ object Study extends LilaController {
|
|||
pov = UserAnalysis.makePov(initialFen, chapter.setup.variant)
|
||||
division = analysis.isDefined option Env.game.divider(
|
||||
id = chapter.id.value,
|
||||
pgnMoves = chapter.root.mainline.map(_.move.uci.uci)(scala.collection.breakOut),
|
||||
pgnMoves = chapter.root.mainline.map(_.move.san).toVector,
|
||||
variant = chapter.setup.variant,
|
||||
initialFen = initialFen
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@ final class Divider {
|
|||
def apply(game: Game, initialFen: Option[FEN]): Division =
|
||||
apply(game.id, game.pgnMoves, game.variant, initialFen)
|
||||
|
||||
def apply(id: Game.ID, pgnMoves: PgnMoves, variant: Variant, initialFen: Option[FEN]) =
|
||||
def apply(id: Game.ID, pgnMoves: => PgnMoves, variant: Variant, initialFen: Option[FEN]) =
|
||||
if (!Variant.divisionSensibleVariants(variant)) Division.empty
|
||||
else cache.get(id, _ => chess.Replay.boards(
|
||||
moveStrs = pgnMoves,
|
||||
|
|
|
@ -145,7 +145,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
}]
|
||||
}
|
||||
});
|
||||
if (lichess.analyse) lichess.analyse.onChange();
|
||||
lichess.pubsub.emit('analysis.change.trigger')();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -37,7 +37,8 @@ module.exports = function(element, cfg) {
|
|||
});
|
||||
};
|
||||
var lastFen, lastPly;
|
||||
cfg.onChange = function(fen, path, mainlinePly) {
|
||||
|
||||
lichess.pubsub.on('analysis.change', function(fen, path, mainlinePly) {
|
||||
if (lastPly === mainlinePly) return;
|
||||
lastPly = typeof mainlinePly === 'undefined' ? lastPly : mainlinePly;
|
||||
var chart, point, $chart = $("#adv_chart");
|
||||
|
@ -70,7 +71,7 @@ module.exports = function(element, cfg) {
|
|||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
});
|
||||
cfg.onToggleComputer = function(v) {
|
||||
setTimeout(function() {
|
||||
if (v) $('div.analysis_menu a.computer_analysis').mousedown();
|
||||
|
|
|
@ -158,6 +158,8 @@ export default class AnalyseCtrl {
|
|||
});
|
||||
if (this.music && set !== 'music') this.music = null;
|
||||
});
|
||||
|
||||
li.pubsub.on('analysis.change.trigger', this.onChange);
|
||||
}
|
||||
|
||||
initialize(data: AnalyseData, merge: boolean): void {
|
||||
|
@ -297,10 +299,7 @@ export default class AnalyseCtrl {
|
|||
};
|
||||
|
||||
private onChange: () => void = throttle(300, () => {
|
||||
if (this.opts.onChange) {
|
||||
const mainlinePly = this.onMainline ? this.node.ply : false;
|
||||
this.opts.onChange!(this.node.fen, this.path, mainlinePly);
|
||||
}
|
||||
li.pubsub.emit('analysis.change')(this.node.fen, this.path, this.onMainline ? this.node.ply : false);
|
||||
});
|
||||
|
||||
private updateHref: () => void = li.fp.debounce(() => {
|
||||
|
|
|
@ -86,7 +86,6 @@ export interface AnalyseOpts {
|
|||
study?: any;
|
||||
tagTypes?: string;
|
||||
practice?: StudyPracticeData;
|
||||
onChange?: (fen: Fen, path: Tree.Path, mainlinePly: Ply | false) => void;
|
||||
onToggleComputer?: (v: boolean) => void;
|
||||
relay?: RelayData;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export function view(ctrl: ServerEvalCtrl): VNode | undefined {
|
|||
|
||||
if (!ctrl.open()) return;
|
||||
|
||||
return h('div.server_eval', {
|
||||
return h('div#adv_chart.server_eval', {
|
||||
hook: {
|
||||
insert(vnode) {
|
||||
window.lichess.requestIdleCallback(() => {
|
||||
|
|
Loading…
Reference in New Issue