本文整理汇总了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);
};
示例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]
});
}
示例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);
};
示例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));
}
示例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();
};
示例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;
});
};
示例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);
};