本文整理汇总了TypeScript中chessground/util.opposite函数的典型用法代码示例。如果您正苦于以下问题:TypeScript opposite函数的具体用法?TypeScript opposite怎么用?TypeScript opposite使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了opposite函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
n.threat.pvs.slice(1).forEach(function(pv) {
const shift = winningChances.povDiff(opposite(color as Color), pv, n.threat!.pvs[0]);
if (shift > 0.2 || isNaN(shift) || shift < 0) return;
shapes = shapes.concat(makeAutoShapesFromUci(pv.moves[0], 'paleRed', {
lineWidth: Math.round(11 - shift * 45) // 11 to 2
}));
});
示例2: featured
function featured(f): VNode {
return h('div.tour__featured', [
featuredPlayer(f[opposite(f.color)]),
miniBoard(f),
featuredPlayer(f[f.color])
]);
}
示例3: view
export function view(ctrl: AnalyseCtrl) {
if (!promoting) return;
var pieces = ['queen', 'knight', 'rook', 'bishop'];
if (ctrl.data.game.variant.key === "antichess") pieces.push('king');
return renderPromotion(ctrl, promoting.dest, pieces,
util.opposite(ctrl.chessground.state.turnColor),
ctrl.chessground.state.orientation);
}
示例4: opposite
return xhr.tablebase(opts.tablebaseEndpoint, effectiveVariant, fen).then((res: TablebaseData) => {
const move = res.moves[0];
return {
fen: fen,
best: move && move.uci,
winner: res.checkmate ? opposite(colorOf(fen)) : (
res.stalemate ? undefined : winnerOf(fen, move!)
)
} as SimpleTablebaseHit
});
示例5: getMaterialDiff
export function getMaterialDiff(pieces: cg.Pieces): MaterialDiff {
const diff: MaterialDiff = {
white: { king: 0, queen: 0, rook: 0, bishop: 0, knight: 0, pawn: 0 },
black: { king: 0, queen: 0, rook: 0, bishop: 0, knight: 0, pawn: 0 },
};
for (let k in pieces) {
const p = pieces[k]!, them = diff[opposite(p.color)];
if (them[p.role] > 0) them[p.role]--;
else diff[p.color][p.role]++;
}
return diff;
}
示例6: renderEnd
function renderEnd(root: AnalyseCtrl, end: string): VNode {
const isMate = end === 'checkmate';
const color = isMate ? opposite(root.turnColor()) : root.turnColor();
return h('div.player', [
color ? h('div.no-square', h('piece.king.' + color)) : h('div.icon.off', '!'),
h('div.instruction', [
h('strong', root.trans.noarg(end)),
isMate ?
h('em', h('color', root.trans.noarg(color === 'white' ? 'whiteWinsGame' : 'blackWinsGame'))) :
h('em', root.trans.noarg('theGameIsADraw'))
])
]);
}
示例7: renderEnd
function renderEnd(color: Color, end: string): VNode {
if (end === 'checkmate') color = opposite(color);
return h('div.player', [
color ? h('div.no-square', h('piece.king.' + color)) : h('div.icon.off', '!'),
h('div.instruction', [
h('strong', endText[end]),
h('em', end === 'checkmate' ? [
h('color', color),
' wins.'
] : ['The game is a draw.'])
])
]);
}
示例8: featuredPlayer
function featuredPlayer(f, orientation) {
const p = f[orientation === 'top' ? opposite(f.color) : f.color];
return h('div.vstext.' + orientation, [
p.berserk ? h('i', {
attrs: {
'data-icon': '`',
title: 'Berserk'
}
}) : null,
h('strong', '#' + p.rank),
renderPlayer(p, true, true, false)
]);
}
示例9: function
var makeCgOpts = function() {
const node = vm.node;
const color: Color = node.ply % 2 === 0 ? 'white' : 'black';
const dests = readDests(node.dests);
const movable = (vm.mode === 'view' || color === data.puzzle.color) ? {
color: (dests && Object.keys(dests).length > 0) ? color : null,
dests: dests || {}
} : {
color: null,
dests: {}
};
const config = {
fen: node.fen,
orientation: data.puzzle.color,
turnColor: color,
movable: movable,
premovable: {
enabled: false
},
check: !!node.check,
lastMove: uciToLastMove(node.uci)
};
if (node.ply >= vm.initialNode.ply) {
if (!dests && !node.check) {
// premove while dests are loading from server
// can't use when in check because it highlights the wrong king
config.turnColor = opposite(color);
config.movable.color = color;
config.premovable.enabled = true;
} else if (vm.mode !== 'view' && color !== data.puzzle.color) {
config.movable.color = data.puzzle.color;
config.premovable.enabled = true;
}
}
vm.cgConfig = config;
return config;
};
示例10: h
];
const nothing = !ctrl.completion()[1];
return [
h('div.player', [
h('div.no-square', h('piece.king.' + ctrl.color)),
h('div.instruction', [
h('em', nothing ?
'No mistakes found for ' + ctrl.color :
'Done reviewing ' + ctrl.color + ' mistakes'),
h('div.choices.end', [
nothing ? null : h('a', {
hook: bind('click', ctrl.reset)
}, 'Do it again'),
h('a', {
hook: bind('click', flip)
}, 'Review ' + opposite(ctrl.color) + ' mistakes')
])
])
])
];
},
};
function renderFeedback(root: AnalyseCtrl, fb) {
const ctrl: RetroCtrl = root.retro!;
const current = ctrl.current();
if (ctrl.isSolving() && current && root.path !== current.prev.path)
return feedback.offTrack(ctrl);
if (fb === 'find') return current ? feedback.find(ctrl) :
feedback.end(ctrl, root.flip, root.hasFullComputerAnalysis);
return feedback[fb](ctrl);