本文整理汇总了TypeScript中game.game.isPlayerPlaying方法的典型用法代码示例。如果您正苦于以下问题:TypeScript game.isPlayerPlaying方法的具体用法?TypeScript game.isPlayerPlaying怎么用?TypeScript game.isPlayerPlaying使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.game
的用法示例。
在下文中一共展示了game.isPlayerPlaying方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
示例2: userHtml
export function userHtml(ctrl: RoundController, player: Player) {
const d = ctrl.data,
user = player.user,
perf = user ? user.perfs[d.game.perf] : null,
rating = player.rating ? player.rating : (perf && perf.rating);
if (user) {
const connecting = !player.onGame && ctrl.firstSeconds && user.online;
return h('div.username.user_link.' + player.color, {
class: {
online: player.onGame,
offline: !player.onGame,
long: user.username.length > 16,
connecting
}
}, [
h('i.line' + (user.patron ? '.patron' : ''), {
attrs: {
title: connecting ? 'Connecting to the game' : (player.onGame ? 'Joined the game' : 'Left the game')
}
}),
h('a.text.ulpt', {
attrs: {
'data-pt-pos': 's',
href: '/@/' + user.username,
target: game.isPlayerPlaying(d) ? '_blank' : '_self'
}
}, user.title ? [h('span.title', user.title), ' ', user.username] : [user.username]),
rating ? h('rating', rating + (player.provisional ? '?' : '')) : null,
ratingDiff(player),
player.engine ? h('span', {
attrs: {
'data-icon': 'j',
title: ctrl.trans.noarg('thisPlayerUsesChessComputerAssistance')
}
}) : null
]);
}
const connecting = !player.onGame && ctrl.firstSeconds;
return h('div.username.user_link', {
class: {
online: player.onGame,
offline: !player.onGame,
connecting
}
}, [
h('i.line', {
attrs: {
title: connecting ? 'Connecting to the game' : (player.onGame ? 'Joined the game' : 'Left the game')
}
}),
h('name', player.name || 'Anonymous')
]);
}
示例3: drag
export function drag(ctrl: RoundController, e: cg.MouchEvent): void {
if (e.button !== undefined && e.button !== 0) return; // only touch or left click
if (ctrl.replaying() || !game.isPlayerPlaying(ctrl.data)) return;
const el = e.target as HTMLElement,
role = el.getAttribute('data-role') as cg.Role,
color = el.getAttribute('data-color') as cg.Color,
number = el.getAttribute('data-nb');
if (!role || !color || number === '0') return;
e.stopPropagation();
e.preventDefault();
dragNewPiece(ctrl.chessground.state, { color, role }, e);
}
示例4: pocket
export default function pocket(ctrl: RoundController, color: Color, position: Position) {
const step = round.plyStep(ctrl.data, ctrl.ply);
if (!step.crazy) return;
const droppedRole = ctrl.justDropped,
preDropRole = ctrl.preDrop,
pocket = step.crazy.pockets[color === 'white' ? 0 : 1],
usablePos = position === (ctrl.flip ? 'top' : 'bottom'),
usable = usablePos && !ctrl.replaying() && game.isPlayerPlaying(ctrl.data),
activeColor = color === ctrl.data.player.color;
const capturedPiece = ctrl.justCaptured;
const captured = capturedPiece && (capturedPiece['promoted'] ? 'pawn' : capturedPiece.role);
return h('div.pocket.is2d.' + position, {
class: { usable },
hook: {
insert: vnode => {
eventNames.forEach(name => {
(vnode.elm as HTMLElement).addEventListener(name, (e: cg.MouchEvent) => {
if (position === (ctrl.flip ? 'top' : 'bottom')) drag(ctrl, e);
})
});
}
}
}, pieceRoles.map(role => {
let nb = pocket[role] || 0;
if (activeColor) {
if (droppedRole === role) nb--;
if (captured === role) nb++;
}
return h('piece.' + role + '.' + color, {
class: { premove: activeColor && preDropRole === role },
attrs: {
'data-role': role,
'data-color': color,
'data-nb': nb,
}
});
}));
}
示例5: makeConfig
function makeConfig(ctrl: RoundController): Config {
const data = ctrl.data, hooks = ctrl.makeCgHooks(),
step = plyStep(data, ctrl.ply),
playing = game.isPlayerPlaying(data);
return {
fen: step.fen,
orientation: boardOrientation(data, ctrl.flip),
turnColor: step.ply % 2 === 0 ? 'white' : 'black',
lastMove: util.uci2move(step.uci),
check: !!step.check,
coordinates: data.pref.coords !== 0,
addPieceZIndex: ctrl.data.pref.is3d,
autoCastle: data.game.variant.key === 'standard',
highlight: {
lastMove: data.pref.highlight,
check: data.pref.highlight
},
events: {
move: hooks.onMove,
dropNewPiece: hooks.onNewPiece
},
movable: {
free: false,
color: playing ? data.player.color : undefined,
dests: playing ? util.parsePossibleMoves(data.possibleMoves) : {},
showDests: data.pref.destination,
rookCastle: data.pref.rookCastle,
events: {
after: hooks.onUserMove,
afterNewPiece: hooks.onUserNewPiece
}
},
animation: {
enabled: true,
duration: data.pref.animationDuration
},
premovable: {
enabled: data.pref.enablePremove,
showDests: data.pref.destination,
castle: data.game.variant.key !== 'antichess',
events: {
set: hooks.onPremove,
unset: hooks.onCancelPremove
}
},
predroppable: {
enabled: data.pref.enablePremove && data.game.variant.key === 'crazyhouse',
events: {
set: hooks.onPredrop,
unset() { hooks.onPredrop(undefined) }
}
},
draggable: {
enabled: data.pref.moveEvent > 0,
showGhost: data.pref.highlight
},
selectable: {
enabled: data.pref.moveEvent !== 1
},
drawable: {
enabled: true
},
disableContextMenu: true
};
}