Exemplo n.º 1
0
 protected function __advanceState($nowState)
 {
     if (!isset($this->room)) {
         throw new InternalErrorException('room was not set');
     }
     if ($nowState !== $this->room->state) {
         //現在の状態が異なっている場合
         return null;
     }
     if (!$this->room->isAllMatesStateChanged()) {
         return null;
     }
     $nowState = $this->__checkState();
     $resultArray = ['result' => 'success'];
     switch ($nowState) {
         case 'open':
             //人の募集
             if ($this->room->SitDownAllMate()) {
                 $this->room->shuffleCast();
                 $newMyInfo = Mate::find($this->myInfo->id);
                 $this->myInfo = $newMyInfo;
                 $this->room->setStateTimeLimit('20seconds');
                 $this->room->setState('ready');
             }
             break;
         case 'ready':
             //準備完了
             $this->__initMates();
             $this->room->day = 0;
             $this->room->setStateTimeLimit('200 second');
             $this->room->setState('day');
             break;
         case 'day':
             //お昼
             $this->room->setState('day_select');
             break;
         case 'day_select':
             // お昼の選択(追放会議)
             if ($this->__voteAndKill() === null) {
                 //まだ追放が決まらない場合
                 $this->room->setStateTimeLimit('80 second');
                 $this->room->setState('day_append');
                 break;
             }
             $this->room->push();
             $triumph = $this->__checkTriumph();
             if ($triumph == null) {
                 $this->room->setState('night_select');
             } else {
                 //$this->room->setState('end');
                 $this->room->setState('end_' . $triumph);
             }
             break;
         case 'day_append':
             //追加の追放会議
             $this->room->setState('day_append_select');
             break;
         case 'day_append_select':
             // 追加の追放会議選択
             if ($this->__voteAndKill() === null) {
                 //まだ追放が決まらない場合
                 $this->room->setState('night_select');
                 $this->room->setStateTimeLimit('80 second');
                 break;
             }
             $triumph = $this->__checkTriumph();
             if ($triumph != null) {
                 //$this->room->setState('end');
                 $this->room->setState('end_' . $triumph);
             } else {
                 $this->room->setState('night_select');
             }
             break;
         case 'night_select':
             //夜のアクション選択
             $this->__jinrohAttackWithAvoid();
             $triumph = $this->__checkTriumph();
             if ($triumph != null) {
                 $this->room->setState('end_' . $triumph);
             } else {
                 $this->room->day++;
                 $this->room->setStateTimeLimit('200 second');
                 $this->room->setState('day');
             }
             break;
         default:
             return null;
             break;
     }
     if (isset($triumph)) {
         $resultArray['triumph'] = $triumph;
     }
     return $resultArray;
 }