当前位置: 首页>>代码示例>>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;未经允许,请勿转载。