本文整理汇总了TypeScript中chess.renderEval函数的典型用法代码示例。如果您正苦于以下问题:TypeScript renderEval函数的具体用法?TypeScript renderEval怎么用?TypeScript renderEval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了renderEval函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderMove
export function renderMove(ctx: Ctx, node: Tree.Node): VNode[] {
const ev: any = cevalView.getBestEval({client: node.ceval, server: node.eval}) || {};
return [h('san', fixCrazySan(node.san!))]
.concat((node.glyphs && ctx.showGlyphs) ? renderGlyphs(node.glyphs) : [])
.concat(ctx.showEval ? (
defined(ev.cp) ? [renderEval(normalizeEval(ev.cp))] : (
defined(ev.mate) ? [renderEval('#' + ev.mate)] : []
)
) : []);
}
示例2: range
}, range(multiPv).map(function(i) {
if (!pvs[i]) return h('div.pv');
const san = pv2san(instance.variant.key, node.fen, threat, pvs[i].moves.slice(0, 12), pvs[i].mate);
return h('div.pv', threat ? {} : {
attrs: { 'data-uci': pvs[i].moves[0] }
}, [
multiPv > 1 ? h('strong', defined(pvs[i].mate) ? ('#' + pvs[i].mate) : renderEval(pvs[i].cp!)) : null,
h('span', san)
]);
}));
示例3: renderMove
export function renderMove(ctx, node): MaybeVNodes {
const ev = node.eval || node.ceval || {};
return [
node.san,
defined(ev.cp) ? renderEval(normalizeEval(ev.cp)) : (
defined(ev.mate) ? renderEval('#' + ev.mate) : null
),
puzzleGlyph(ctx, node)
];
}
示例4: renderCeval
export function renderCeval(ctrl: ParentCtrl): VNode | undefined {
const instance = ctrl.getCeval(), trans = ctrl.trans;
if (!instance.allowed() || !instance.possible || !ctrl.showComputer()) return;
const enabled = instance.enabled(),
evs = ctrl.currentEvals(),
threatMode = ctrl.threatMode(),
threat = threatMode && ctrl.getNode().threat,
bestEv = threat || getBestEval(evs);
let pearl: VNode | string, percent: number;
if (bestEv && typeof bestEv.cp !== 'undefined') {
pearl = renderEval(bestEv.cp);
percent = evs.client ? Math.min(100, Math.round(100 * evs.client.depth / (evs.client.maxDepth || instance.effectiveMaxDepth()))) : 0;
} else if (bestEv && defined(bestEv.mate)) {
pearl = '#' + bestEv.mate;
percent = 100;
} else if (ctrl.gameOver()) {
pearl = '-';
percent = 0;
} else {
pearl = enabled ? h('i.ddloader') : h('i');
percent = 0;
}
if (threatMode) {
if (threat) percent = Math.min(100, Math.round(100 * threat.depth / threat.maxDepth));
else percent = 0;
}
const mandatoryCeval = ctrl.mandatoryCeval && ctrl.mandatoryCeval();
const progressBar: VNode | null = enabled ? h('div.bar', h('span', {
class: { threat: threatMode },
attrs: { style: `width: ${percent}%` },
hook: {
postpatch: (old, vnode) => {
if (old.data!.percent > percent || !!old.data!.threatMode != threatMode) {
const el = vnode.elm as HTMLElement;
const p = el.parentNode as HTMLElement;
p.removeChild(el);
p.appendChild(el);
}
vnode.data!.percent = percent;
vnode.data!.threatMode = threatMode;
}
}
})) : null;
const body: Array<VNode | null> = enabled ? [
h('pearl', [pearl]),
h('div.engine', [
...(threatMode ? [trans.noarg('showThreat')] : engineName(instance)),
h('span.info',
ctrl.gameOver() ? [trans.noarg('gameOver')] :
(threatMode ? [threatInfo(ctrl, threat)] : localEvalInfo(ctrl, evs))
)
])
] : [
pearl ? h('pearl', [pearl]) : null,
h('help', [
...engineName(instance),
h('br'),
trans.noarg('inLocalBrowser')
])
];
const switchButton: VNode | null = mandatoryCeval ? null : h('div.switch', {
attrs: { title: trans.noarg('toggleLocalEvaluation') + ' (l)' }
}, [
h('input#analyse-toggle-ceval.cmn-toggle.cmn-toggle--subtle', {
attrs: {
type: 'checkbox',
checked: enabled
},
hook: {
insert: vnode => (vnode.elm as HTMLElement).addEventListener('change', ctrl.toggleCeval)
}
}),
h('label', { attrs: { 'for': 'analyse-toggle-ceval' } })
])
return h('div.ceval' + (enabled ? '.enabled' : ''), {
class: {
computing: percent < 100 && instance.isComputing()
}
}, [
progressBar,
...body,
threatButton(ctrl),
switchButton
]);
}