Exemple #1
0
 public function getNewFightsArenaCount()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'id_player = :id_player AND is_new = :is_new';
     $criteria->params = array(':id_player' => $this->id, ':is_new' => 1);
     $count = ArenaJoiners::model()->count($criteria);
     return $count;
 }
Exemple #2
0
 public function actionMyFightsComplete()
 {
     $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id));
     $ship = Ship::model()->findByAttributes(array('id' => $player->id));
     $criteria = new CDbCriteria();
     $criteria->condition = 'id_player = :id_player AND ( status = :die OR status = :win OR status = :nothing )';
     $criteria->params = array(':id_player' => $player->id, ':die' => ArenaJoiners::$STATUS_LOOSE, ':win' => ArenaJoiners::$STATUS_WIN, ':nothing' => ArenaJoiners::$STATUS_NOTHING);
     $joins = ArenaJoiners::model()->findAll($criteria);
     $pks = [];
     foreach ($joins as $join) {
         array_push($pks, $join->id_room);
     }
     $rooms = ArenaRoom::model()->findAllByPk($pks);
     if ($rooms != null) {
         foreach ($rooms as $key => $game) {
             $winner_ship = null;
             if ($game->winner_id != 0) {
                 $winner_ship = Ship::model()->findByAttributes(array('id' => $game->winner_id));
             }
             ////////////////////////////////////////////////////////////////////
             // Если игрок продал корабль или НИЧЬЯ
             ////////////////////////////////////////////////////////////////////
             $game->winner_ship = $winner_ship;
         }
     }
     $this->render('show_my_fights', array('player' => $player, 'ship' => $ship, 'joins' => $joins, 'rooms' => $rooms));
 }
Exemple #3
0
 public function getAllFighters()
 {
     $fighters = ArenaJoiners::model()->findAllByAttributes(array('id_room' => $this->id));
     return $fighters;
 }