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


TypeScript game.isPlayerPlaying方法代碼示例

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


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

示例1: 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

示例2: userHtml

export function userHtml(ctrl: RoundController, player: Player) {
  const d = ctrl.data,
  user = player.user,
  perf = user ? user.perfs[d.game.perf] : null,
  rating = player.rating ? player.rating : (perf && perf.rating);
  if (user) {
    const connecting = !player.onGame && ctrl.firstSeconds && user.online;
    return h('div.username.user_link.' + player.color, {
      class: {
        online: player.onGame,
        offline: !player.onGame,
        long: user.username.length > 16,
        connecting
      }
    }, [
      h('i.line' + (user.patron ? '.patron' : ''), {
        attrs: {
          title: connecting ? 'Connecting to the game' : (player.onGame ? 'Joined the game' : 'Left the game')
        }
      }),
      h('a.text.ulpt', {
        attrs: {
          'data-pt-pos': 's',
          href: '/@/' + user.username,
          target: game.isPlayerPlaying(d) ? '_blank' : '_self'
        }
      }, user.title ? [h('span.title', user.title), ' ', user.username] : [user.username]),
      rating ? h('rating', rating + (player.provisional ? '?' : '')) : null,
      ratingDiff(player),
      player.engine ? h('span', {
        attrs: {
          'data-icon': 'j',
          title: ctrl.trans.noarg('thisPlayerUsesChessComputerAssistance')
        }
      }) : null
    ]);
  }
  const connecting = !player.onGame && ctrl.firstSeconds;
  return h('div.username.user_link', {
    class: {
      online: player.onGame,
      offline: !player.onGame,
      connecting
    }
  }, [
    h('i.line', {
      attrs: {
        title: connecting ? 'Connecting to the game' : (player.onGame ? 'Joined the game' : 'Left the game')
      }
    }),
    h('name', player.name || 'Anonymous')
  ]);
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:53,代碼來源:user.ts

示例3: drag

export function drag(ctrl: RoundController, e: cg.MouchEvent): void {
  if (e.button !== undefined && e.button !== 0) return; // only touch or left click
  if (ctrl.replaying() || !game.isPlayerPlaying(ctrl.data)) return;
  const el = e.target as HTMLElement,
  role = el.getAttribute('data-role') as cg.Role,
  color = el.getAttribute('data-color') as cg.Color,
  number = el.getAttribute('data-nb');
  if (!role || !color || number === '0') return;
  e.stopPropagation();
  e.preventDefault();
  dragNewPiece(ctrl.chessground.state, { color, role }, e);
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:12,代碼來源:crazyCtrl.ts

示例4: pocket

export default function pocket(ctrl: RoundController, color: Color, position: Position) {
  const step = round.plyStep(ctrl.data, ctrl.ply);
  if (!step.crazy) return;
  const droppedRole = ctrl.justDropped,
  preDropRole = ctrl.preDrop,
  pocket = step.crazy.pockets[color === 'white' ? 0 : 1],
  usablePos = position === (ctrl.flip ? 'top' : 'bottom'),
  usable = usablePos && !ctrl.replaying() && game.isPlayerPlaying(ctrl.data),
  activeColor = color === ctrl.data.player.color;
  const capturedPiece = ctrl.justCaptured;
  const captured = capturedPiece && (capturedPiece['promoted'] ? 'pawn' : capturedPiece.role);
  return h('div.pocket.is2d.' + position, {
    class: { usable },
    hook: {
      insert: vnode => {
        eventNames.forEach(name => {
          (vnode.elm as HTMLElement).addEventListener(name, (e: cg.MouchEvent) => {
            if (position === (ctrl.flip ? 'top' : 'bottom')) drag(ctrl, e);
          })
        });
      }
    }
  }, pieceRoles.map(role => {
    let nb = pocket[role] || 0;
    if (activeColor) {
      if (droppedRole === role) nb--;
      if (captured === role) nb++;
    }
    return h('piece.' + role + '.' + color, {
      class: { premove: activeColor && preDropRole === role },
      attrs: {
        'data-role': role,
        'data-color': color,
        'data-nb': nb,
      }
    });
  }));
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:38,代碼來源:crazyView.ts

示例5: makeConfig

function makeConfig(ctrl: RoundController): Config {
  const data = ctrl.data, hooks = ctrl.makeCgHooks(),
  step = plyStep(data, ctrl.ply),
  playing = game.isPlayerPlaying(data);
  return {
    fen: step.fen,
    orientation: boardOrientation(data, ctrl.flip),
    turnColor: step.ply % 2 === 0 ? 'white' : 'black',
    lastMove: util.uci2move(step.uci),
    check: !!step.check,
    coordinates: data.pref.coords !== 0,
    addPieceZIndex: ctrl.data.pref.is3d,
    autoCastle: data.game.variant.key === 'standard',
    highlight: {
      lastMove: data.pref.highlight,
      check: data.pref.highlight
    },
    events: {
      move: hooks.onMove,
      dropNewPiece: hooks.onNewPiece
    },
    movable: {
      free: false,
      color: playing ? data.player.color : undefined,
      dests: playing ? util.parsePossibleMoves(data.possibleMoves) : {},
      showDests: data.pref.destination,
      rookCastle: data.pref.rookCastle,
      events: {
        after: hooks.onUserMove,
        afterNewPiece: hooks.onUserNewPiece
      }
    },
    animation: {
      enabled: true,
      duration: data.pref.animationDuration
    },
    premovable: {
      enabled: data.pref.enablePremove,
      showDests: data.pref.destination,
      castle: data.game.variant.key !== 'antichess',
      events: {
        set: hooks.onPremove,
        unset: hooks.onCancelPremove
      }
    },
    predroppable: {
      enabled: data.pref.enablePremove && data.game.variant.key === 'crazyhouse',
      events: {
        set: hooks.onPredrop,
        unset() { hooks.onPredrop(undefined) }
      }
    },
    draggable: {
      enabled: data.pref.moveEvent > 0,
      showGhost: data.pref.highlight
    },
    selectable: {
      enabled: data.pref.moveEvent !== 1
    },
    drawable: {
      enabled: true
    },
    disableContextMenu: true
  };
}
開發者ID:lexisvar,項目名稱:lila,代碼行數:65,代碼來源:ground.ts


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