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


TypeScript chess.renderSan函數代碼示例

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


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

示例1: renderCurrentNode

function renderCurrentNode(node: Tree.Node, style: Style): string {
  if (!node.san || !node.uci) return 'Initial position';
  return [
    moveView.plyToTurn(node.ply),
    renderSan(node.san, node.uci, style),
    renderComments(node, style)
  ].join(' ');
}
開發者ID:ornicar,項目名稱:lila,代碼行數:8,代碼來源:nvui.ts

示例2: h

 analysisNodes.filter(n => (n.ply % 2 === 1) === (color === 'white')).map(node =>
   h('option', {
     attrs: {
       value: node.ply,
       selected: node.ply === ctrl.node.ply
     }
   }, [
     moveView.plyToTurn(node.ply),
     renderSan(node.san!, node.uci, style),
     renderComments(node, style)
   ].join(' '))
開發者ID:ornicar,項目名稱:lila,代碼行數:11,代碼來源:nvui.ts

示例3: renderSan

 nodes.forEach(node => {
   if (!node.san || !node.uci) return;
   path += node.id;
   const content: MaybeVNodes = [
     node.ply & 1 ? moveView.plyToTurn(node.ply) + ' ' : null,
     renderSan(node.san, node.uci, style)
   ];
   res.push(h('move', {
     attrs: { p: path },
     class: { active: path === currentPath }
   }, content));
   res.push(renderComments(node, style));
   res.push(', ');
   if (node.ply % 2 === 0) res.push(h('br'));
 });
開發者ID:ornicar,項目名稱:lila,代碼行數:15,代碼來源:nvui.ts

示例4: was

 comment.text.replace(/Best move was (.+)\./, (_, san) =>
   'Best move was ' + renderSan(san, undefined, style)) :
開發者ID:ornicar,項目名稱:lila,代碼行數:2,代碼來源:nvui.ts

示例5: function

window.lichess.RoundNVUI = function(redraw: Redraw) {

  const notify = new Notify(redraw),
    moveStyle = styleSetting();

  window.lichess.pubsub.on('socket.in.message', line => {
    if (line.u === 'lichess') notify.set(line.t);
  });
  window.lichess.pubsub.on('round.suggestion', notify.set);

  return {
    render(ctrl: RoundController): VNode {
      const d = ctrl.data, step = plyStep(d, ctrl.ply), style = moveStyle.get(),
        variantNope = !supportedVariant(d.game.variant.key) && 'Sorry, this variant is not supported in blind mode.';
      if (!ctrl.chessground) {
        ctrl.setChessground(Chessground(document.createElement("div"), {
          ...makeCgConfig(ctrl),
          animation: { enabled: false },
          drawable: { enabled: false },
          coordinates: false
        }));
        if (variantNope) setTimeout(() => notify.set(variantNope), 3000);
      }
      return h('div.nvui', [
        h('h1', 'Textual representation'),
        h('h2', 'Game info'),
        ...(['white', 'black'].map((color: Color) => h('p', [
          color + ' player: ',
          renderPlayer(ctrl, ctrl.playerByColor(color))
        ]))),
        h('p', `${d.game.rated ? 'Rated' : 'Casual'} ${d.game.perf}`),
        d.clock ? h('p', `Clock: ${d.clock.initial / 60} + ${d.clock.increment}`) : null,
        h('h2', 'Moves'),
        h('p.moves', {
          attrs: {
            role : 'log',
            'aria-live': 'off'
          }
        }, renderMoves(d.steps.slice(1), style)),
        h('h2', 'Pieces'),
        h('div.pieces', renderPieces(ctrl.chessground.state.pieces, style)),
        h('h2', 'Game status'),
        h('div.status', {
          attrs: {
            role : 'status',
            'aria-live' : 'assertive',
            'aria-atomic' : true
          }
        }, [ctrl.data.game.status.name === 'started' ? 'Playing' : renderResult(ctrl)]),
        h('h2', 'Last move'),
        h('p.lastMove', {
          attrs: {
            'aria-live' : 'assertive',
            'aria-atomic' : true
          }
        }, renderSan(step.san, step.uci, style)),
        ...(ctrl.isPlaying() ? [
          h('h2', 'Move form'),
          h('form', {
            hook: onInsert(el => {
              const $form = $(el as HTMLFormElement),
                $input = $form.find('.move').val('').focus();
              $form.submit(onSubmit(ctrl, notify.set, moveStyle.get, $input));
            })
          }, [
            h('label', [
              d.player.color === d.game.player ? 'Your move' : 'Waiting',
              h('input.move.mousetrap', {
                attrs: {
                  name: 'move',
                  'type': 'text',
                  autocomplete: 'off',
                  autofocus: true,
                  disabled: !!variantNope,
                  title: variantNope
                }
              })
            ])
          ])
        ]: []),
        h('h2', 'Your clock'),
        h('div.botc', anyClock(ctrl, 'bottom')),
        h('h2', 'Opponent clock'),
        h('div.topc', anyClock(ctrl, 'top')),
        notify.render(),
        h('h2', 'Actions'),
        ...(ctrl.data.player.spectator ? renderTableWatch(ctrl) : (
          game.playable(ctrl.data) ? renderTablePlay(ctrl) : renderTableEnd(ctrl)
        )),
        h('h2', 'Board'),
        h('pre.board', renderBoard(ctrl.chessground.state.pieces, ctrl.data.player.color)),
        h('h2', 'Settings'),
        h('label', [
          'Move notation',
          renderSetting(moveStyle, ctrl.redraw)
        ]),
        h('h2', 'Commands'),
        h('p', [
          'Type these commands in the move input.', h('br'),
          '/c: Read clocks.', h('br'),
//.........這裏部分代碼省略.........
開發者ID:ornicar,項目名稱:lila,代碼行數:101,代碼來源:nvui.ts

示例6:

 steps.forEach(s => {
   if (s.ply & 1) res.push((Math.ceil(s.ply / 2)) + ' ');
   res.push(renderSan(s.san, s.uci, style) + ', ');
   if (s.ply % 2 === 0) res.push(h('br'));
 });
開發者ID:ornicar,項目名稱:lila,代碼行數:5,代碼來源:nvui.ts


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