本文整理汇总了TypeScript中tree.path.size方法的典型用法代码示例。如果您正苦于以下问题:TypeScript path.size方法的具体用法?TypeScript path.size怎么用?TypeScript path.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree.path
的用法示例。
在下文中一共展示了path.size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
return function() {
if (vm.mode === 'view') return;
if (!pathOps.contains(vm.path, vm.initialPath)) return;
var playedByColor = vm.node.ply % 2 === 1 ? 'white' : 'black';
if (playedByColor !== puzzle.color) return;
var nodes = vm.nodeList.slice(pathOps.size(vm.initialPath) + 1).map(function(node) {
return {
uci: node.uci,
castle: node.san.startsWith('O-O')
};
});
var progress = puzzle.lines;
for (var i in nodes) {
if (progress[nodes[i].uci]) progress = progress[nodes[i].uci];
else if (nodes[i].castle) progress = progress[altCastles[nodes[i].uci]] || 'fail';
else progress = 'fail';
if (typeof progress === 'string') break;
}
if (typeof progress === 'string') {
vm.node.puzzle = progress;
return progress;
}
var nextKey = Object.keys(progress)[0]
if (progress[nextKey] === 'win') {
vm.node.puzzle = 'win';
return 'win';
}
// from here we have a next move
vm.node.puzzle = 'good';
var opponentUci = decomposeUci(nextKey);
var promotion = opponentUci[2] ? sanToRole[opponentUci[2].toUpperCase()] : null;
var move: any = {
orig: opponentUci[0],
dest: opponentUci[1],
fen: vm.node.fen,
path: vm.path
};
if (promotion) move.promotion = promotion;
return move;
};