本文整理汇总了TypeScript中tree.ops类的典型用法代码示例。如果您正苦于以下问题:TypeScript ops类的具体用法?TypeScript ops怎么用?TypeScript ops使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ops类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function(initialNode: Tree.Node, solution, color: Color) {
treeOps.updateAll(solution, function(node) {
if ((color === 'white') === (node.ply % 2 === 1)) node.puzzle = 'good';
});
const solutionNode = treeOps.childById(initialNode, solution.id);
if (solutionNode) treeOps.merge(solutionNode, solution);
else initialNode.children.push(solution);
};
开发者ID:ddugovic,项目名称:lila,代码行数:11,代码来源:solution.ts
示例2: renderInlined
function renderInlined(ctx: Ctx, nodes: Tree.Node[], opts: Opts): MaybeVNodes | undefined {
// only 2 branches
if (!nodes[1] || nodes[2] || nodes[0].forceVariation) return;
// only if second branch has no sub-branches
if (treeOps.hasBranching(nodes[1], 6)) return;
return renderMoveAndChildrenOf(ctx, nodes[0], {
parentPath: opts.parentPath,
isMainline: opts.isMainline,
inline: nodes[1]
});
}
开发者ID:ddugovic,项目名称:lila,代码行数:11,代码来源:inlineView.ts
示例3: initiate
function initiate(fromData) {
data = fromData;
tree = treeBuild(treeOps.reconstruct(data.game.treeParts));
var initialPath = treePath.fromNodeList(treeOps.mainlineNodeList(tree.root));
// play | try | view
vm.mode = 'play';
vm.loading = false;
vm.round = undefined;
vm.voted = undefined;
vm.justPlayed = undefined;
vm.resultSent = false;
vm.lastFeedback = 'init';
vm.initialPath = initialPath;
vm.initialNode = tree.nodeAtPath(initialPath);
setPath(treePath.init(initialPath));
setTimeout(function() {
jump(initialPath);
redraw();
}, 500);
// just to delay button display
vm.canViewSolution = false;
setTimeout(function() {
vm.canViewSolution = true;
redraw();
}, 5000);
moveTest = moveTestBuild(vm, data.puzzle);
withGround(function(g) {
g.setAutoShapes([]);
g.setShapes([]);
showGround(g);
});
instanciateCeval();
history.replaceState(null, '', '/training/' + data.puzzle.id);
};
开发者ID:ddugovic,项目名称:lila,代码行数:40,代码来源:ctrl.ts
示例4: function
export default function(ctrl: AnalyseCtrl): VNode[] | undefined {
const study = ctrl.study;
if (!study || ctrl.embed) return;
const tags = study.data.chapter.tags,
playerNames = {
white: findTag(tags, 'white')!,
black: findTag(tags, 'black')!
};
if (!playerNames.white && !playerNames.black && !treeOps.findInMainline(ctrl.tree.root, n => !!n.clock)) return;
const clocks = renderClocks(ctrl),
ticking = !isFinished(study.data.chapter) && ctrl.turnColor();
return (['white', 'black'] as Color[]).map(color =>
renderPlayer(tags, clocks, playerNames, color, ticking === color, ctrl.bottomColor() !== color));
}
开发者ID:ornicar,项目名称:lila,代码行数:14,代码来源:playerBars.ts
示例5: viewSolution
function viewSolution() {
if (!vm.canViewSolution) return;
sendResult(false);
vm.mode = 'view';
mergeSolution(vm.initialNode, data.puzzle.branch, data.puzzle.color);
reorderChildren(vm.initialPath, true);
// try and play the solution next move
var next = vm.node.children[0];
if (next && next.puzzle === 'good') userJump(vm.path + next.id);
else {
var firstGoodPath = treeOps.takePathWhile(vm.mainline, function(node) {
return node.puzzle !== 'good';
});
if (firstGoodPath) userJump(firstGoodPath + tree.nodeAtPath(firstGoodPath).children[0].id);
}
vm.autoScrollRequested = true;
redraw();
startCeval();
};
开发者ID:ddugovic,项目名称:lila,代码行数:21,代码来源:ctrl.ts
示例6: nextNodeBest
function nextNodeBest() {
return treeOps.withMainlineChild(vm.node, function(n) {
// return n.eval ? n.eval.pvs[0].moves[0] : null;
return n.eval ? n.eval.best : undefined;
});
};
开发者ID:ddugovic,项目名称:lila,代码行数:6,代码来源:ctrl.ts
示例7: setPath
function setPath(path) {
vm.path = path;
vm.nodeList = tree.getNodeList(path);
vm.node = treeOps.last(vm.nodeList)!;
vm.mainline = treeOps.mainlineNodeList(tree.root);
};
开发者ID:ddugovic,项目名称:lila,代码行数:6,代码来源:ctrl.ts
注:本文中的tree.ops类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论