コード例 #1
0
ファイル: roundView.js プロジェクト: salvob41/lichobile
function renderContent(ctrl, isPortrait) {
  const material = chessground.board.getMaterialDiff(ctrl.chessground.data);
  const player = renderPlayTable(ctrl, ctrl.data.player, material[ctrl.data.player.color], 'player', isPortrait);
  const opponent = renderPlayTable(ctrl, ctrl.data.opponent, material[ctrl.data.opponent.color], 'opponent', isPortrait);
  const bounds = utils.getBoardBounds(helper.viewportDim(), isPortrait, helper.isIpadLike(), 'game');
  const board = m.component(Board, {
    data: ctrl.data,
    chessgroundCtrl: ctrl.chessground,
    bounds,
    isPortrait
  });

  if (isPortrait)
    return [
      opponent,
      board,
      player,
      renderGameActionsBar(ctrl, isPortrait)
    ];
  else
    return [
      board,
      <section key="table" className="table">
        <header key="table-header" className="tableHeader">
          {gameInfos(ctrl)}
        </header>
        <section key="players-table" className="playersTable">
          {opponent}
          {renderReplayTable(ctrl)}
          {player}
        </section>
        {renderGameActionsBar(ctrl, isPortrait)}
      </section>
    ];
}
コード例 #2
0
ファイル: otbView.js プロジェクト: jkells/lichobile
function renderContent(ctrl, pieceTheme) {
  const flip = settings.otb.flipPieces();
  const wrapperClasses = helper.classSet({
    'otb': true,
    'mode_flip': flip,
    'mode_facing': !flip,
    'turn_white': ctrl.chessground.data.turnColor === 'white',
    'turn_black': ctrl.chessground.data.turnColor === 'black'
  });
  const material = chessground.board.getMaterialDiff(ctrl.chessground.data);
  const playerName = i18n(ctrl.data.player.color);
  const opponentName = i18n(ctrl.data.opponent.color);
  const replayTable = renderReplayTable(ctrl.replay);
  const isPortrait = helper.isPortrait();
  const bounds = getBoardBounds(helper.viewportDim(), isPortrait, helper.isIpadLike(), 'game');
  const board = m.component(Board, {
    data: ctrl.data,
    chessgroundCtrl: ctrl.chessground,
    bounds,
    isPortrait,
    wrapperClasses,
    customPieceTheme: pieceTheme
  });

  if (isPortrait)
    return [
      renderAntagonist(ctrl, opponentName, material[ctrl.data.opponent.color], 'opponent', isPortrait),
      board,
      renderAntagonist(ctrl, playerName, material[ctrl.data.player.color], 'player', isPortrait),
      renderGameActionsBar(ctrl, 'otb')
    ];
  else
    return [
      board,
      <section key="table" className="table">
        <section className="playersTable offline">
          {renderAntagonist(ctrl, opponentName, material[ctrl.data.opponent.color], 'opponent', isPortrait)}
          {replayTable}
          {renderAntagonist(ctrl, playerName, material[ctrl.data.player.color], 'player', isPortrait)}
        </section>
        {renderGameActionsBar(ctrl, 'otb')}
      </section>
    ];
}
コード例 #3
0
ファイル: roundView.js プロジェクト: Manuelp2/lichobile
function renderContent(ctrl, isPortrait) {
  const material = chessground.board.getMaterialDiff(ctrl.chessground.data);
  const player = renderPlayTable(ctrl, ctrl.data.player, material[ctrl.data.player.color], 'player', isPortrait);
  const opponent = renderPlayTable(ctrl, ctrl.data.opponent, material[ctrl.data.opponent.color], 'opponent', isPortrait);
  const bounds = utils.getBoardBounds(helper.viewportDim(), isPortrait, helper.isIpadLike(), helper.isLandscapeSmall(), 'game');
  const board = Board(
    ctrl.data,
    ctrl.chessground,
    bounds,
    isPortrait,
    null,
    null,
    null,
    gameApi.mandatory(ctrl.data) && gameApi.nbMoves(ctrl.data, ctrl.data.player.color) === 0 ?
      i18n('youHaveNbSecondsToMakeYourFirstMove', ctrl.data.tournament.nbSecondsForFirstMove) : null
  );

  if (isPortrait) {
    return [
      opponent,
      board,
      player,
      renderGameActionsBar(ctrl, isPortrait)
    ];
  } else {
    return [
      board,
      <section key="table" className="table">
        <header key="table-header" className="tableHeader">
          {gameInfos(ctrl)}
        </header>
        <section key="players-table" className="playersTable">
          {opponent}
          {renderReplayTable(ctrl)}
          {player}
        </section>
        {renderGameActionsBar(ctrl, isPortrait)}
      </section>
    ];
  }
}
コード例 #4
0
ファイル: aiView.js プロジェクト: ofirkris/lichobile
function content(ctrl) {

  const material = chessground.board.getMaterialDiff(ctrl.chessground.data);
  const replayTable = renderReplayTable(ctrl.replay);
  const isPortrait = helper.isPortrait();

  if (isPortrait)
    return [
      renderAntagonist(ctrl, m('h2', ctrl.getOpponent().name), material[ctrl.data.opponent.color], 'opponent', isPortrait),
      renderBoard(ctrl.data.game.variant.key, ctrl.chessground),
      renderAntagonist(ctrl, '', material[ctrl.data.player.color], 'player', isPortrait),
      renderGameActionsBar(ctrl, 'ai')
    ];
  else if (helper.isLandscape() && helper.isVeryWideScreen())
    return [
      renderBoard(ctrl.data.game.variant.key, ctrl.chessground),
      <section key="table" className="table">
        <section className="playersTable offline">
          {renderAntagonist(ctrl, [sideSelector(), opponentSelector()], material[ctrl.data.opponent.color], 'opponent', isPortrait)}
          {replayTable}
          {renderEndedGameStatus(ctrl.actions)}
          {renderAntagonist(ctrl, '', material[ctrl.data.player.color], 'player', isPortrait)}
        </section>
        {renderGameActionsBarTablet(ctrl, 'ai')}
      </section>
    ];
  else
    return [
      renderBoard(ctrl.data.game.variant.key, ctrl.chessground),
      <section key="table" className="table">
        <section className="playersTable offline">
          {renderAntagonist(ctrl, m('h2', ctrl.getOpponent().name), material[ctrl.data.opponent.color], 'opponent', isPortrait)}
          {replayTable}
          {renderAntagonist(ctrl, '', material[ctrl.data.player.color], 'player', isPortrait)}
        </section>
        {renderGameActionsBar(ctrl, 'ai')}
      </section>
    ];
}
コード例 #5
0
ファイル: trainingCtrl.js プロジェクト: nodejsfy/lichobile
 this.reload = function(cfg) {
   this.data = makeData(cfg);
   chessground.board.reset(this.chessground.data);
   chessground.anim(puzzle.reload, this.chessground.data)(this.data, cfg);
   setTimeout(this.playInitialMove, 1000);
 }.bind(this);
コード例 #6
0
ファイル: trainingCtrl.js プロジェクト: ofirkris/lichobile
 this.reload = function(cfg) {
   this.data = data(cfg);
   chessground.board.reset(this.chessground.data);
   chessground.anim(puzzle.reload, this.chessground.data)(this.data, cfg);
   this.initiate();
 }.bind(this);