本文整理汇总了TypeScript中game.game类的典型用法代码示例。如果您正苦于以下问题:TypeScript game类的具体用法?TypeScript game怎么用?TypeScript game使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了game类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderTablePlay
function renderTablePlay(ctrl: RoundController) {
const d = ctrl.data,
loading = isLoading(ctrl),
submit = button.submitMove(ctrl),
icons = (loading || submit) ? [] : [
game.abortable(d) ? button.standard(ctrl, undefined, 'L', 'abortGame', 'abort') :
button.standard(ctrl, game.takebackable, 'i', 'proposeATakeback', 'takeback-yes', ctrl.takebackYes),
ctrl.drawConfirm ? button.drawConfirm(ctrl) : button.standard(ctrl, ctrl.canOfferDraw, '2', 'offerDraw', 'draw-yes', () => ctrl.offerDraw(true)),
ctrl.resignConfirm ? button.resignConfirm(ctrl) : button.standard(ctrl, game.resignable, 'b', 'resign', 'resign-confirm', () => ctrl.resign(true))
],
buttons: MaybeVNodes = loading ? [loader()] : (submit ? [submit] : [
button.forceResign(ctrl),
button.threefoldClaimDraw(ctrl),
button.cancelDrawOffer(ctrl),
button.answerOpponentDrawOffer(ctrl),
button.cancelTakebackProposition(ctrl),
button.answerOpponentTakebackProposition(ctrl),
(d.tournament && game.nbMoves(d, d.player.color) === 0) ? tournamentStartWarning(ctrl) : null
]);
return [
renderReplay(ctrl),
h('div.control.icons', {
class: { 'confirm': !!(ctrl.drawConfirm || ctrl.resignConfirm) }
}, icons),
h('div.control.buttons', buttons),
renderPlayer(ctrl, bottomPlayer(ctrl))
];
}
示例2: findCurrentPath
export function findCurrentPath(c: AnalyseCtrl): Tree.Path | undefined {
return (game.playable(c.data) && c.initialPath) || (
c.retro && c.retro.current() && c.retro.current().prev.path
) || (
c.study && c.study.data.chapter.relay && c.study.data.chapter.relay.path
);
}
示例3: renderResult
function renderResult(ctrl: RoundController) {
let result;
if (status.finished(ctrl.data)) switch (ctrl.data.game.winner) {
case 'white':
result = '1-0';
break;
case 'black':
result = '0-1';
break;
default:
result = '½-½';
}
if (result || status.aborted(ctrl.data)) {
const winner = game.getPlayer(ctrl.data, ctrl.data.game.winner);
return h('div.result_wrap', [
result ? h('p.result', result) : null,
h('p.status', {
hook: {
insert: _ => {
if (ctrl.autoScroll) ctrl.autoScroll();
else setTimeout(() => ctrl.autoScroll(), 200);
}
}
}, [
h('div', gameView.status(ctrl)),
winner ? h('div', ctrl.trans.noarg(winner.color + 'IsVictorious')) : null
])
]);
}
return;
}
示例4: truncateFen
window.lichess.storage.make('ceval.fen').listen(ev => {
const d = ctrl.data;
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;
}
});
示例5: wheel
function wheel(ctrl: RoundController, e: WheelEvent): boolean {
if (game.isPlayerPlaying(ctrl.data)) return true;
e.preventDefault();
if (e.deltaY > 0) keyboard.next(ctrl);
else if (e.deltaY < 0) keyboard.prev(ctrl);
ctrl.redraw();
return false;
}
示例6: renderPlayer
function renderPlayer(data: AnalyseData, color: Color): VNode {
const p = game.getPlayer(data, color);
if (p.user) return h('a.user_link.ulpt', {
attrs: { href: '/@/' + p.user.username }
}, [
h('span', p.user.username),
renderRatingDiff(p.ratingDiff)
]);
return h('span', p.name || (p.ai ? 'Stockfish level ' + p.ai : 'Anonymous'));
}
示例7: goBerserk
function goBerserk(ctrl: RoundController) {
if (!game.berserkableBy(ctrl.data)) return;
if (ctrl.goneBerserk[ctrl.data.player.color]) return;
return h('button.fbt.berserk.hint--bottom-left', {
attrs: { 'data-hint': "GO BERSERK! Half the time, bonus point" },
hook: bind('click', ctrl.goBerserk)
}, [
h('span', justIcon('`'))
]);
}
示例8: nodeClasses
export function nodeClasses(c: AnalyseCtrl, path: Tree.Path): NodeClasses {
const current = (path === c.initialPath && game.playable(c.data)) || (
c.retro && c.retro.current() && c.retro.current().prev.path === path
);
return {
active: path === c.path,
context_menu: path === c.contextMenuPath,
current,
nongame: !current && !!c.gamePath && treePath.contains(path, c.gamePath) && path !== c.gamePath
};
}
示例9: analysisButton
function analysisButton(ctrl: RoundController): VNode | null {
const d = ctrl.data,
url = router.game(d, analysisBoardOrientation(d)) + '#' + ctrl.ply;
return game.replayable(d) ? h('a.button', {
attrs: { href: url },
hook: util.bind('click', _ => {
// force page load in case the URL is the same
if (location.pathname === url.split('#')[0]) location.reload();
})
}, ctrl.trans.noarg('analysis')) : null;
}
示例10: moretime
export function moretime(ctrl: RoundController) {
return game.moretimeable(ctrl.data) ? h('a.moretime.hint--bottom-left', {
attrs: {
'data-hint': ctrl.data.clock ? ctrl.trans('giveNbSeconds', ctrl.data.clock.moretime) :
ctrl.trans.noarg('giveMoreTime')
},
hook: util.bind('click', ctrl.socket.moreTime)
}, [
h('span', util.justIcon('O'))
]) : null;
}