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


TypeScript game.game類代碼示例

本文整理匯總了TypeScript中game.game的典型用法代碼示例。如果您正苦於以下問題:TypeScript game類的具體用法?TypeScript game怎麽用?TypeScript game使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了game類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: renderTablePlay

function renderTablePlay(ctrl: RoundController) {
  const d = ctrl.data,
  loading = isLoading(ctrl),
  submit = button.submitMove(ctrl),
  icons = (loading || submit) ? [] : [
    game.abortable(d) ? button.standard(ctrl, undefined, 'L', 'abortGame', 'abort') :
    button.standard(ctrl, game.takebackable, 'i', 'proposeATakeback', 'takeback-yes', ctrl.takebackYes),
    ctrl.drawConfirm ? button.drawConfirm(ctrl) : button.standard(ctrl, ctrl.canOfferDraw, '2', 'offerDraw', 'draw-yes', () => ctrl.offerDraw(true)),
    ctrl.resignConfirm ? button.resignConfirm(ctrl) : button.standard(ctrl, game.resignable, 'b', 'resign', 'resign-confirm', () => ctrl.resign(true))
  ],
  buttons: MaybeVNodes = loading ? [loader()] : (submit ? [submit] : [
    button.forceResign(ctrl),
    button.threefoldClaimDraw(ctrl),
    button.cancelDrawOffer(ctrl),
    button.answerOpponentDrawOffer(ctrl),
    button.cancelTakebackProposition(ctrl),
    button.answerOpponentTakebackProposition(ctrl),
    (d.tournament && game.nbMoves(d, d.player.color) === 0) ? tournamentStartWarning(ctrl) : null
  ]);
  return [
    renderReplay(ctrl),
    h('div.control.icons', {
      class: { 'confirm': !!(ctrl.drawConfirm || ctrl.resignConfirm) }
    }, icons),
    h('div.control.buttons', buttons),
    renderPlayer(ctrl, bottomPlayer(ctrl))
  ];
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:28,代碼來源:table.ts

示例2: findCurrentPath

export function findCurrentPath(c: AnalyseCtrl): Tree.Path | undefined {
  return (game.playable(c.data) && c.initialPath) || (
    c.retro && c.retro.current() && c.retro.current().prev.path
  ) || (
    c.study && c.study.data.chapter.relay && c.study.data.chapter.relay.path
  );
}
開發者ID:luanlv,項目名稱:lila,代碼行數:7,代碼來源:treeView.ts

示例3: renderResult

function renderResult(ctrl: RoundController) {
  let result;
  if (status.finished(ctrl.data)) switch (ctrl.data.game.winner) {
    case 'white':
      result = '1-0';
      break;
    case 'black':
      result = '0-1';
      break;
    default:
      result = '½-½';
  }
  if (result || status.aborted(ctrl.data)) {
    const winner = game.getPlayer(ctrl.data, ctrl.data.game.winner);
    return h('div.result_wrap', [
      result ? h('p.result', result) : null,
      h('p.status', {
        hook: {
          insert: _ => {
            if (ctrl.autoScroll) ctrl.autoScroll();
            else setTimeout(() => ctrl.autoScroll(), 200);
          }
        }
      }, [
        h('div', gameView.status(ctrl)),
        winner ? h('div', ctrl.trans.noarg(winner.color + 'IsVictorious')) : null
      ])
    ]);
  }
  return;
}
開發者ID:luanlv,項目名稱:lila,代碼行數:31,代碼來源:replay.ts

示例4: truncateFen

 window.lichess.storage.make('ceval.fen').listen(ev => {
   const d = ctrl.data;
   if (!found && ev.newValue && ctrl.ply > 14 && game.playable(d) &&
     truncateFen(plyStep(d, ctrl.ply).fen) === truncateFen(ev.newValue)) {
     $.post('/jslog/' + d.game.id + d.player.id + '?n=ceval');
     found = true;
   }
 });
開發者ID:lexisvar,項目名稱:lila,代碼行數:8,代碼來源:cevalSub.ts

示例5: wheel

function wheel(ctrl: RoundController, e: WheelEvent): boolean {
  if (game.isPlayerPlaying(ctrl.data)) return true;
  e.preventDefault();
  if (e.deltaY > 0) keyboard.next(ctrl);
  else if (e.deltaY < 0) keyboard.prev(ctrl);
  ctrl.redraw();
  return false;
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:8,代碼來源:main.ts

示例6: renderPlayer

function renderPlayer(data: AnalyseData, color: Color): VNode {
  const p = game.getPlayer(data, color);
  if (p.user) return h('a.user_link.ulpt', {
    attrs: { href: '/@/' + p.user.username }
  }, [
    h('span', p.user.username),
    renderRatingDiff(p.ratingDiff)
  ]);
  return h('span', p.name || (p.ai ? 'Stockfish level ' + p.ai : 'Anonymous'));
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:10,代碼來源:acpl.ts

示例7: goBerserk

function goBerserk(ctrl: RoundController) {
  if (!game.berserkableBy(ctrl.data)) return;
  if (ctrl.goneBerserk[ctrl.data.player.color]) return;
  return h('button.fbt.berserk.hint--bottom-left', {
    attrs: { 'data-hint': "GO BERSERK! Half the time, bonus point" },
    hook: bind('click', ctrl.goBerserk)
  }, [
    h('span', justIcon('`'))
  ]);
}
開發者ID:luanlv,項目名稱:lila,代碼行數:10,代碼來源:clockView.ts

示例8: nodeClasses

export function nodeClasses(c: AnalyseCtrl, path: Tree.Path): NodeClasses {
  const current = (path === c.initialPath && game.playable(c.data)) || (
    c.retro && c.retro.current() && c.retro.current().prev.path === path
  );
  return {
    active: path === c.path,
    context_menu: path === c.contextMenuPath,
    current,
    nongame: !current && !!c.gamePath && treePath.contains(path, c.gamePath) && path !== c.gamePath
  };
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:11,代碼來源:treeView.ts

示例9: analysisButton

function analysisButton(ctrl: RoundController): VNode | null {
  const d = ctrl.data,
  url = router.game(d, analysisBoardOrientation(d)) + '#' + ctrl.ply;
  return game.replayable(d) ? h('a.button', {
    attrs: { href: url },
    hook: util.bind('click', _ => {
      // force page load in case the URL is the same
      if (location.pathname === url.split('#')[0]) location.reload();
    })
  }, ctrl.trans.noarg('analysis')) : null;
}
開發者ID:mate-amargo,項目名稱:lila,代碼行數:11,代碼來源:button.ts

示例10: moretime

export function moretime(ctrl: RoundController) {
  return game.moretimeable(ctrl.data) ? h('a.moretime.hint--bottom-left', {
    attrs: {
      'data-hint': ctrl.data.clock ? ctrl.trans('giveNbSeconds', ctrl.data.clock.moretime) :
      ctrl.trans.noarg('giveMoreTime')
    },
    hook: util.bind('click', ctrl.socket.moreTime)
  }, [
    h('span', util.justIcon('O'))
  ]) : null;
}
開發者ID:mate-amargo,項目名稱:lila,代碼行數:11,代碼來源:button.ts


注:本文中的game.game類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。