當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tree.ops類代碼示例

本文整理匯總了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;未經允許,請勿轉載。