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


PHP Command::setup方法代码示例

本文整理汇总了PHP中Command::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::setup方法的具体用法?PHP Command::setup怎么用?PHP Command::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Command的用法示例。


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

示例1: play

 public function play()
 {
     $command = '';
     if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED) {
         $command = $this->selectCharacter();
     } elseif ($this->player['phase'] == Player::PHASE_DRAW_HIGH_NOON) {
         $command = $this->drawOneTurnCard();
     } elseif ($this->player['phase'] == Player::PHASE_DYNAMITE) {
         $command = $this->drawDynamite();
     } elseif ($this->player['phase'] == Player::PHASE_JAIL) {
         $command = $this->drawJail();
     } elseif ($this->player['phase'] == Player::PHASE_RATTLESNAKE) {
         $command = $this->drawRattlesnake();
     } elseif ($this->player['phase'] == Player::PHASE_DRAW) {
         $command = $this->draw();
     } elseif ($this->player['phase'] == Player::PHASE_PLAY) {
         if ($this->player['possible_choices'] != '') {
             $command = $this->chooseCards();
         } else {
             $command = $this->playCards();
         }
     } elseif ($this->player['phase'] == Player::PHASE_UNDER_ATTACK) {
         $command = $this->reactToAttack();
     } elseif ($this->player['phase'] == Player::PHASE_HIGH_NOON) {
         $command = $this->takeLifeDown();
     } else {
         $this->whatToDo();
     }
     if ($command) {
         Log::logAiAction('ai player ' . $this->player['id'] . ': ' . $command);
         Command::setup($command, $this->game, $this->player);
     }
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:33,代码来源:AbstractStrategy.php

示例2: createResponse

 protected function createResponse()
 {
     $playerRepository = new PlayerRepository();
     $count = $playerRepository->getCountByGameAndCharakter($this->game['id'], 0);
     if ($count === 0) {
         return Command::setup('command=start', $this->game);
     }
     return '';
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:9,代码来源:ChooseCharacterCommand.php

示例3: main

 public function main()
 {
     $gameId = intval(Utils::post('game'));
     $gameRepository = new GameRepository();
     $game = $gameRepository->getOneById($gameId);
     $commandParams = array();
     $commandParams['command'] = addslashes(Utils::post('command'));
     $commandParams['useCharacter'] = intval(Utils::post('useCharacter'));
     $commandParams['playCardId'] = intval(Utils::post('playCard'));
     if ($commandParams['playCardId']) {
         $cardRepository = new CardRepository(TRUE);
         $card = $cardRepository->getOneById($commandParams['playCardId']);
         $commandParams['playCardName'] = str_replace('-', '', $card->getItemAlias());
     }
     // TODO mozno ich niekedy bude viac
     $commandParams['additionalCardsId'] = intval(Utils::post('additionalCard'));
     if ($commandParams['additionalCardsId']) {
         $cardRepository = new CardRepository(TRUE);
         $card = $cardRepository->getOneById($commandParams['additionalCardsId']);
         $commandParams['additionalCardsName'] = str_replace('-', '', $card->getItemAlias());
     }
     $commandParams['enemyPlayerId'] = intval(Utils::post('player'));
     if ($commandParams['enemyPlayerId']) {
         $playerRepository = new PlayerRepository();
         $player = $playerRepository->getOneById($commandParams['enemyPlayerId']);
         if ($player) {
             $user = $player->getUser();
             if ($user) {
                 $commandParams['enemyPlayerUsername'] = $user['username'];
             }
         }
     }
     if ($commandParams['command'] == 'fanning') {
         $commandParams['additionalEnemyPlayerId'] = intval(Utils::post('additionalPlayer'));
         if ($commandParams['additionalEnemyPlayerId']) {
             $playerRepository = new PlayerRepository();
             $player = $playerRepository->getOneById($commandParams['additionalEnemyPlayerId']);
             if ($player) {
                 $user = $player->getUser();
                 if ($user) {
                     $commandParams['additionalEnemyPlayerUsername'] = $user['username'];
                 }
             }
         }
     }
     // TODO brawl tu dava addslashes
     if ($commandParams['command'] == 'brawl') {
         $commandParams['enemyCardsId'] = addslashes(Utils::post('card'));
     } elseif ($commandParams['command'] == 'choose_cards') {
         $commandParams['selectedCards'] = addslashes(Utils::post('card'));
     } else {
         $commandParams['enemyCardsId'] = intval(Utils::post('card'));
         if ($commandParams['enemyCardsId']) {
             $cardRepository = new CardRepository(TRUE);
             $card = $cardRepository->getOneById($commandParams['enemyCardsId']);
             $commandParams['enemyCardsName'] = str_replace('-', '', $card->getItemAlias());
         }
     }
     $commandParams['place'] = addslashes(Utils::post('place'));
     if (Utils::post('peyoteColor')) {
         $commandParams['peyoteColor'] = addslashes(Utils::post('peyoteColor'));
     }
     if (Utils::post('text')) {
         $commandParams['text'] = addslashes(Utils::post('text'));
     }
     $params = array();
     foreach ($commandParams as $key => $value) {
         $params[] = $key . '=' . $value;
     }
     $commandString = implode('&', $params);
     Log::command($commandString);
     Command::setup($commandString, $game);
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:73,代码来源:ExecuteCommand.php

示例4: setup

 protected function setup()
 {
     $roomAlias = Utils::get('identifier');
     $roomRepository = new RoomRepository();
     $room = $roomRepository->getOneByAlias($roomAlias);
     $loggedUser = LoggedUser::whoIsLogged();
     if ($room) {
         $gameRepository = new GameRepository();
         // $gameRepository->addAdditionalWhere(array('column' => 'status', 'value' => Game::GAME_STATUS_ENDED, 'xxx' => '!='));
         $gameRepository->addOrderBy(array('id' => 'DESC'));
         $game = $gameRepository->getOneByRoom($room['id']);
         if (Utils::post()) {
             $message = addslashes(trim(Utils::post('message')));
             if ($message != '') {
                 if (strpos($message, '.') === 0) {
                     $response = Command::setup('command=' . substr($message, 1), $game);
                 } else {
                     $response = Command::setup('command=say&text=' . $message . '&room=' . $room['id'] . '&game=' . $game['id'], $game);
                 }
                 Room::updateUserLastActivity($loggedUser['id'], $room['id']);
             } elseif (Utils::post('create')) {
                 $response = Command::setup('command=create', $game);
             } elseif (Utils::post('join')) {
                 $response = Command::setup('command=join', $game);
             } elseif (Utils::post('add_ai_player')) {
                 $response = Command::setup('command=add_ai_player', $game);
             } elseif (Utils::post('start')) {
                 $response = Command::setup('command=init', $game);
             } elseif (Utils::post('choose_character')) {
                 $response = Command::setup('command=choose_character&selectedCharacter=' . Utils::post('character'), $game);
             } elseif (Utils::post('choose_cards')) {
                 $commandParams = array();
                 $commandParams['command'] = 'choose_cards';
                 $commandParams['selectedCards'] = array();
                 if (Utils::post('card')) {
                     $commandParams['selectedCards'] = implode(',', Utils::post('card'));
                 }
                 $params = array();
                 foreach ($commandParams as $key => $value) {
                     $params[] = $key . '=' . $value;
                 }
                 $commandString = implode('&', $params);
                 $response = Command::setup($commandString, $game);
             }
             Utils::redirect(Utils::getActualUrl(), FALSE);
             // TODO tu by sa mohol spravit redirect asi lebo respons bude v db
             MySmarty::assign('response', $response);
         }
         $gameBox = new GameBox();
         $gameBox->setRoom($room);
         if ($game !== NULL) {
             $gameBox->setGame($game);
         }
         MySmarty::assign('gameBox', $gameBox->render());
         $chatBox = new ChatBox();
         $chatBox->setRoom($room);
         if ($game !== NULL) {
             $chatBox->setGame($game);
         }
         MySmarty::assign('chatBox', $chatBox->render());
     } else {
         // TODO 404 room not found
     }
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:64,代码来源:RoomDetailBox.php


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