本文整理汇总了TypeScript中chessground/fen.read函数的典型用法代码示例。如果您正苦于以下问题:TypeScript read函数的具体用法?TypeScript read怎么用?TypeScript read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
export function main(ctrl: RoundController): VNode {
const d = ctrl.data,
cgState = ctrl.chessground && ctrl.chessground.state,
topColor = d[ctrl.flip ? 'player' : 'opponent'].color,
bottomColor = d[ctrl.flip ? 'opponent' : 'player'].color;
let material: MaterialDiff, score: number = 0;
if (d.pref.showCaptured) {
let pieces = cgState ? cgState.pieces : fenRead(plyStep(ctrl.data, ctrl.ply).fen);
material = util.getMaterialDiff(pieces);
score = util.getScore(pieces) * (bottomColor === 'white' ? 1 : -1);
} else material = emptyMaterialDiff;
const checks: CheckCount = (d.player.checks || d.opponent.checks) ?
util.countChecks(ctrl.data.steps, ctrl.ply) :
util.noChecks;
return ctrl.nvui ? ctrl.nvui.render(ctrl) : h('div.round__app.variant-' + d.game.variant.key, {
class: { 'move-confirm': !!(ctrl.moveToSubmit || ctrl.dropToSubmit) },
hook: util.onInsert(gridHacks.start)
}, [
h('div.round__app__board.main-board' + (ctrl.data.pref.blindfold ? '.blindfold' : ''), {
hook: window.lichess.hasTouchEvents ? undefined : util.bind('wheel', (e: WheelEvent) => wheel(ctrl, e))
}, [
renderGround(ctrl),
promotion.view(ctrl)
]),
crazyView(ctrl, topColor, 'top') || renderMaterial(material[topColor], -score, 'top', checks[topColor]),
...renderTable(ctrl),
crazyView(ctrl, bottomColor, 'bottom') || renderMaterial(material[bottomColor], score, 'bottom', checks[bottomColor]),
ctrl.keyboardMove ? keyboardMove(ctrl.keyboardMove) : null
])
};
示例2: main
export function main(ctrl: RoundController): VNode {
const d = ctrl.data,
cgState = ctrl.chessground && ctrl.chessground.state,
topColor = d[ctrl.flip ? 'player' : 'opponent'].color,
bottomColor = d[ctrl.flip ? 'opponent' : 'player'].color;
let material: MaterialDiff, score: number = 0;
if (d.pref.showCaptured) {
let pieces = cgState ? cgState.pieces : fenRead(plyStep(ctrl.data, ctrl.ply).fen);
material = util.getMaterialDiff(pieces);
score = util.getScore(pieces) * (bottomColor === 'white' ? 1 : -1);
} else material = emptyMaterialDiff;
const checks: CheckCount = (d.player.checks || d.opponent.checks) ?
util.countChecks(ctrl.data.steps, ctrl.ply) :
util.noChecks;
return ctrl.nvui ? ctrl.nvui.render(ctrl) : h('div.round.cg-512', [
h('div.lichess_game.gotomove.variant_' + d.game.variant.key + (ctrl.data.pref.blindfold ? '.blindfold' : ''), {
hook: {
insert: () => window.lichess.pubsub.emit('content_loaded')()
}
}, [
h('div.lichess_board_wrap', [
h('div.lichess_board.' + d.game.variant.key, {
hook: util.bind('wheel', (e: WheelEvent) => wheel(ctrl, e))
}, [renderGround(ctrl)]),
promotion.view(ctrl)
]),
h('div.lichess_ground', [
crazyView(ctrl, topColor, 'top') || renderMaterial(material[topColor], -score, checks[topColor]),
renderTable(ctrl),
crazyView(ctrl, bottomColor, 'bottom') || renderMaterial(material[bottomColor], score, checks[bottomColor])
])
]),
h('div.underboard', [
h('div.center', {
hook: {
insert: vnode => {
if (ctrl.opts.crosstableEl) {
const el = (vnode.elm as HTMLElement);
el.insertBefore(ctrl.opts.crosstableEl, el.firstChild);
}
}
}
}, [
ctrl.keyboardMove ? keyboardMove(ctrl.keyboardMove) : null
])
])
]);
};
示例3: main
export function main(ctrl: RoundController): VNode {
const d = ctrl.data,
cgState = ctrl.chessground && ctrl.chessground.state,
topColor = d[ctrl.flip ? 'player' : 'opponent'].color,
bottomColor = d[ctrl.flip ? 'opponent' : 'player'].color;
let material: cg.MaterialDiff, score: number = 0;
if (d.pref.showCaptured) {
var pieces = cgState ? cgState.pieces : fenRead(plyStep(ctrl.data, ctrl.ply).fen);
material = util.getMaterialDiff(pieces);
score = util.getScore(pieces) * (bottomColor === 'white' ? 1 : -1);
} else material = emptyMaterialDiff;
return h('div.round.cg-512', [
h('div.lichess_game.gotomove.variant_' + d.game.variant.key, {
hook: {
insert: () => window.lichess.pubsub.emit('content_loaded')()
}
}, [
d.blind ? blindBoard(ctrl) : visualBoard(ctrl),
h('div.lichess_ground', [
crazyView(ctrl, topColor, 'top') || renderMaterial(material[topColor], -score, d.player.checks),
renderTable(ctrl),
crazyView(ctrl, bottomColor, 'bottom') || renderMaterial(material[bottomColor], score, d.opponent.checks)
])
]),
h('div.underboard', [
h('div.center', {
hook: {
insert: vnode => {
if (ctrl.opts.crosstableEl) {
const el = (vnode.elm as HTMLElement);
el.insertBefore(ctrl.opts.crosstableEl, el.firstChild);
}
}
}
}, [
ctrl.keyboardMove ? keyboardMove(ctrl.keyboardMove) : null
])
])
]);
};