当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript router.game函数代码示例

本文整理汇总了TypeScript中game/router.game函数的典型用法代码示例。如果您正苦于以下问题:TypeScript game函数的具体用法?TypeScript game怎么用?TypeScript game使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了game函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: analysisButton

function analysisButton(ctrl: RoundController): VNode | null {
  const d = ctrl.data,
    url = gameRoute(d, analysisBoardOrientation(d)) + '#' + ctrl.ply;
  return game.replayable(d) ? h('a.fbt', {
    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:ornicar,项目名称:lila,代码行数:11,代码来源:button.ts

示例2: parseInt

 hook: util.bind('mousedown', e => {
   const target = e.target as HTMLElement;
   const ply = parseInt(target.getAttribute('data-ply') || '');
   if (!isNaN(ply)) ctrl.userJump(ply);
   else {
     const action = target.getAttribute('data-act') || (target.parentNode as HTMLElement).getAttribute('data-act');
     if (action === 'flip') {
       if (d.tv) location.href = '/tv/' + d.tv.channel + (d.tv.flip ? '' : '?flip=1');
       else if (d.player.spectator) location.href = gameRoute(d, d.opponent.color);
       else ctrl.flipNow();
     }
   }
 }, ctrl.redraw)
开发者ID:ornicar,项目名称:lila,代码行数:13,代码来源:replay.ts

示例3: if

 hook: util.bind('click', e => {
   const d = ctrl.data;
   if (d.game.rematch) location.href = gameRoute(d.game.rematch, d.opponent.color);
   else if (d.player.offeringRematch) {
     d.player.offeringRematch = false;
     ctrl.socket.send('rematch-no');
   }
   else if (d.opponent.onGame) {
     d.player.offeringRematch = true;
     ctrl.socket.send('rematch-yes');
   }
   else if (!(e.target as HTMLElement).classList.contains('disabled')) ctrl.challengeRematch();
 }, ctrl.redraw)
开发者ID:ornicar,项目名称:lila,代码行数:13,代码来源:button.ts

示例4: analysisButton

export function analysisButton(ctrl: RoundController): VNode | undefined {
  const forecastCount = ctrl.data.forecastCount;
  return game.userAnalysable(ctrl.data) ? h('a.fbt.analysis', {
    class: {
      'text': !!forecastCount
    },
    attrs: {
      title: ctrl.trans.noarg('analysis'),
      href: gameRoute(ctrl.data, ctrl.data.player.color) + '/analysis#' + ctrl.ply,
      'data-icon': 'A'
    }
  }, forecastCount ? ['' + forecastCount] : []
  ) : undefined
}
开发者ID:ornicar,项目名称:lila,代码行数:14,代码来源:replay.ts

示例5: analyseButton

function analyseButton(ctrl: RoundController) {
  const showInfo = ctrl.forecastInfo(),
    forecastCount = ctrl.data.forecastCount;
  const data: VNodeData = {
    class: {
      'hint--top': !showInfo,
      'hint--bottom': showInfo,
      'glowed': showInfo,
      'text': !!forecastCount
    },
    attrs: {
      'data-hint': ctrl.trans.noarg('analysis'),
      href: gameRoute(ctrl.data, ctrl.data.player.color) + '/analysis#' + ctrl.ply
    }
  };
  if (showInfo) data.hook = {
    insert(vnode) {
      setTimeout(() => {
        $(vnode.elm as HTMLElement).powerTip({
          closeDelay: 200,
          placement: 'n'
        }).data('powertipjq', $(vnode.elm as HTMLElement).siblings('.forecast-info').clone().removeClass('none')).powerTip('show');
      }, 1000);
    }
  };
  return [
    h('a.fbt.analysis', data, [
      h('span', {
        attrs: { 'data-icon': 'A' },
        class: {text: !!forecastCount}
      }),
      forecastCount ? '' + forecastCount : undefined
    ]),
    showInfo ? h('div.forecast-info.info.none', [
      h('strong.title.text', util.justIcon(''), 'Speed up your game!'),
      h('span.content', 'Use the analysis board to create conditional premoves.')
    ]) : null
  ];
}
开发者ID:ddugovic,项目名称:lila,代码行数:39,代码来源:replay.ts

示例6: function

export default function(ctrl: AnalyseCtrl): VNode {
  if (ctrl.nvui) return ctrl.nvui.render(ctrl);
  const concealOf = makeConcealOf(ctrl),
  study = ctrl.study,
  showCevalPvs = !(ctrl.retro && ctrl.retro.isSolving()) && !ctrl.practice,
  menuIsOpen = ctrl.actionMenu.open,
  chapter = study && study.data.chapter,
  studyStateClass = chapter ? chapter.id + study!.vm.loading : 'nostudy',
  gamebookPlay = ctrl.gamebookPlay(),
  gamebookPlayView = gamebookPlay && gbPlay.render(gamebookPlay),
  gamebookEditView = gbEdit.running(ctrl) ? gbEdit.render(ctrl) : undefined,
  relayEdit = study && study.relay && relayManager(study.relay),
  playerBars = renderPlayerBars(ctrl),
  gaugeDisplayed = ctrl.showEvalGauge(),
  needsInnerCoords = !!gaugeDisplayed || !!playerBars;
  return h('div.analyse.cg-512', [
    h('div.' + studyStateClass, {
      hook: {
        insert: _ => {
          if (firstRender) {
            firstRender = false;
            if (ctrl.data.pref.coords === 1) li.loadedCss[innerCoordsCss] = true;
          }
          else li.pubsub.emit('reset_zoom')();
          forceInnerCoords(ctrl, needsInnerCoords);
        },
        update(_, _2) {
          forceInnerCoords(ctrl, needsInnerCoords);
        }
      },
      class: {
        'gauge_displayed': gaugeDisplayed,
        'no_computer': !ctrl.showComputer(),
        'gb_edit': !!gamebookEditView,
        'gb_play': !!gamebookPlayView,
        'relay_edit': !!relayEdit,
        'player_bars': !!playerBars,
      }
    }, [
      h('div.lichess_game', {
        hook: {
          insert: _ => li.pubsub.emit('content_loaded')()
        }
      }, [
        visualBoard(ctrl, playerBars),
        h('div.lichess_ground', gamebookPlayView || [
          menuIsOpen || playerBars ? null : renderClocks(ctrl),
          menuIsOpen ? null : crazyView(ctrl, ctrl.topColor(), 'top'),
          ...(menuIsOpen ? [actionMenu(ctrl)] : [
            cevalView.renderCeval(ctrl),
            showCevalPvs ? cevalView.renderPvs(ctrl) : null,
            renderAnalyse(ctrl, concealOf),
            gamebookEditView ? null : forkView(ctrl, concealOf),
            retroView(ctrl) || practiceView(ctrl) || explorerView(ctrl)
          ]),
          menuIsOpen ? null : crazyView(ctrl, ctrl.bottomColor(), 'bottom'),
          buttons(ctrl),
          gamebookEditView || relayEdit
        ])
      ])
    ]),
    ctrl.embed ? null : h('div.underboard', {
      class: { no_computer: !ctrl.showComputer() }
    }, [
      h('div.center', ctrl.study ? studyView.underboard(ctrl) : [inputs(ctrl)]),
      h('div.right', [acplView(ctrl)])
    ]),
    ctrl.embed || synthetic(ctrl.data) ? null : h('div.analeft', [
      ctrl.forecast ? forecastView(ctrl, ctrl.forecast) : null,
      playable(ctrl.data) ? h('div.back_to_game',
        h('a.button.text', {
          attrs: {
            href: ctrl.data.player.id ? router.player(ctrl.data) : router.game(ctrl.data),
            'data-icon': 'i'
          }
        }, ctrl.trans('backToGame'))
      ) : null
    ])
  ]);
}
开发者ID:ddugovic,项目名称:lila,代码行数:80,代码来源:view.ts

示例7: function

export default function(ctrl: AnalyseCtrl): VNode {
  if (ctrl.nvui) return ctrl.nvui.render(ctrl);
  const concealOf = makeConcealOf(ctrl),
    study = ctrl.study,
    showCevalPvs = !(ctrl.retro && ctrl.retro.isSolving()) && !ctrl.practice,
    menuIsOpen = ctrl.actionMenu.open,
    chapter = study && study.data.chapter,
    gamebookPlay = ctrl.gamebookPlay(),
    gamebookPlayView = gamebookPlay && gbPlay.render(gamebookPlay),
    gamebookEditView = gbEdit.running(ctrl) ? gbEdit.render(ctrl) : undefined,
    playerBars = renderPlayerBars(ctrl),
    clocks = !playerBars && renderClocks(ctrl),
    gaugeOn = ctrl.showEvalGauge(),
    needsInnerCoords = !!gaugeOn || !!playerBars;
  return h('main.analyse.variant-' + ctrl.data.game.variant.key + (chapter ? '.' + chapter.id : ''), {
    hook: {
      insert: vn => {
        forceInnerCoords(ctrl, needsInnerCoords);
        if (!!playerBars != $('body').hasClass('header-margin')) {
          li.raf(() => {
            $('body').toggleClass('header-margin', !!playerBars);
            ctrl.redraw();
          });
        }
        gridHacks.start(vn.elm as HTMLElement);
      },
      update(_, _2) {
        forceInnerCoords(ctrl, needsInnerCoords);
      },
      postpatch(old, vnode) {
        if (old.data!.gaugeOn !== gaugeOn) li.dispatchEvent(document.body, 'chessground.resize');
        vnode.data!.gaugeOn = gaugeOn;
      }
    },
    class: {
      'comp-off': !ctrl.showComputer(),
      'gauge-on': gaugeOn,
      'has-players': !!playerBars,
      'has-clocks': !!clocks
    }
  }, [
    ctrl.keyboardHelp ? keyboardView(ctrl) : null,
    ctrl.study ? studyView.overboard(ctrl.study) : null,
    h('div.analyse__board.main-board', {
      hook: (window.lichess.hasTouchEvents || ctrl.gamebookPlay()) ? undefined : bind('wheel', (e: WheelEvent) => wheel(ctrl, e))
    }, [
      ...(clocks || []),
      playerBars ? playerBars[ctrl.bottomIsWhite() ? 1 : 0] : null,
      chessground.render(ctrl),
      playerBars ? playerBars[ctrl.bottomIsWhite() ? 0 : 1] : null,
      renderPromotion(ctrl)
    ]),
    gaugeOn ? cevalView.renderGauge(ctrl) : null,
    menuIsOpen ? null : crazyView(ctrl, ctrl.topColor(), 'top'),
    gamebookPlayView || h('div.analyse__tools', [
      ...(menuIsOpen ? [actionMenu(ctrl)] : [
        cevalView.renderCeval(ctrl),
        showCevalPvs ? cevalView.renderPvs(ctrl) : null,
        renderAnalyse(ctrl, concealOf),
        gamebookEditView,
        retroView(ctrl) || practiceView(ctrl) || explorerView(ctrl)
      ])
    ]),
    menuIsOpen ? null : crazyView(ctrl, ctrl.bottomColor(), 'bottom'),
    gamebookPlayView ? null : controls(ctrl),
    ctrl.embed ? null : h('div.analyse__underboard', {
      hook: (ctrl.synthetic || playable(ctrl.data)) ? undefined : onInsert(elm => serverSideUnderboard(elm, ctrl))
    }, ctrl.study ? studyView.underboard(ctrl) : [inputs(ctrl)]),
    acplView(ctrl),
    ctrl.embed ? null : (
      ctrl.studyPractice ? studyPracticeView.side(ctrl.study!) :
      h('aside.analyse__side', {
        hook: onInsert(elm => {
          ctrl.opts.$side && ctrl.opts.$side.length && $(elm).replaceWith(ctrl.opts.$side);
          $(elm).append($('.streamers').clone().removeClass('none'));
        })
      },
        ctrl.studyPractice ? [studyPracticeView.side(ctrl.study!)] : (
          ctrl.study ? [studyView.side(ctrl.study)] : [
            ctrl.forecast ? forecastView(ctrl, ctrl.forecast) : null,
            (!ctrl.synthetic && playable(ctrl.data)) ? h('div.back-to-game',
              h('a.button.button-empty.text', {
                attrs: {
                  href: router.game(ctrl.data),
                  'data-icon': 'i'
                }
              }, ctrl.trans.noarg('backToGame'))
            ) : null
          ]
        )
      )
    ),
    study && study.relay && relayManager(study.relay),
    ctrl.opts.chat && h('section.mchat', {
      hook: onInsert(_ => {
        if (ctrl.opts.chat.instance) ctrl.opts.chat.instance.destroy();
        ctrl.opts.chat.parseMoves = true;
        li.makeChat(ctrl.opts.chat, chat => {
          ctrl.opts.chat.instance = chat;
        });
//.........这里部分代码省略.........
开发者ID:ornicar,项目名称:lila,代码行数:101,代码来源:view.ts


注:本文中的game/router.game函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。