Пример #1
0
 /**
  * Creates a new DotaEvent model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new DotaEventForm();
     $model->league_ids = $model->selectedEventLeagues;
     $model->players_list = DotaPlayer::getActivePlayersList();
     $model->preparePlayersForEdit();
     $model->prepareHeroesForEdit();
     $dataProviderPlayersStat = DotaEventPlayerStat::searchPlayersStatInEvent($model->id);
     //		if(isset($_POST['DotaEventForm'])) {
     //			echo'<pre>';print_r($_POST);echo'</pre>';die;
     //		}
     //$model->load(Yii::$app->request->post());
     //if($model->validate()) {
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save();
         $DotaEventPlayerStat = Yii::$app->request->post('DotaEventPlayerStat', []);
         $this->checkPlayersStat($model, $DotaEventPlayerStat);
         $this->checkLeagues($model);
         //проверяем изменения в лигах
         $this->checkTeams($model);
         //проверяем изменения в командах
         Yii::$app->session->setFlash('success', Yii::t('app', 'Saved'));
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'dataProviderPlayersStat' => $dataProviderPlayersStat]);
     }
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DotaPlayer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['account_id' => $this->account_id, 'steamid' => $this->steamid, 'timecreated' => $this->timecreated, 'country_id' => $this->country_id, 'status' => $this->status, 'team_id' => $this->team]);
     $query->andFilterWhere(['like', 'personaname', $this->personaname])->andFilterWhere(['like', 'realname', $this->realname])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'middlename', $this->middlename])->andFilterWhere(['like', 'profileurl', $this->profileurl])->andFilterWhere(['like', 'avatar', $this->avatar])->andFilterWhere(['like', 'avatarmedium', $this->avatarmedium])->andFilterWhere(['like', 'avatarfull', $this->avatarfull])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDotaPlayers()
 {
     return $this->hasMany(DotaPlayer::className(), ['team_id' => 'team_id']);
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAccount()
 {
     return $this->hasOne(DotaPlayer::className(), ['account_id' => 'account_id']);
 }
Пример #5
0
$this->title = Yii::t('app', 'Dota Players');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="dota-player-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Dota Player'), ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Import'), ['import'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'account_id', 'steamid', 'personaname', 'realname', ['attribute' => 'team', 'format' => 'text', 'content' => function ($data) {
    return $data->teamName;
}, 'filter' => DotaTeam::getTeamsListDropDown()], ['attribute' => 'status', 'format' => 'text', 'content' => function ($data) {
    return $data->statusName;
}, 'filter' => DotaPlayer::getStatusValuesList()], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '75']]]]);
?>

</div>
Пример #6
0
 /**
  * считает кол-во очков у ивента
  * @param $event DotaEvent
  */
 public static function calculateScores($event)
 {
     $params = DotaParams::loadParams();
     $account_ids = [];
     foreach ($event->dotaEventPlayerStat as $player) {
         $account_ids[] = $player->account_id;
     }
     $player_roles = DotaPlayer::getPlayersRolesList($account_ids);
     foreach ($event->dotaEventPlayerStat as $player) {
         $level = $player->level + $player->level_corr;
         $kills = $player->kills + $player->kills_corr;
         $deaths = $player->deaths + $player->deaths_corr;
         $assists = $player->assists + $player->assists_corr;
         $gold_per_min = $player->gold_per_min + $player->gold_per_min_corr;
         $xp_per_min = $player->xp_per_min + $player->xp_per_min_corr;
         $scores = $level * $player_roles[$player->account_id] + $kills * $params['ratio_kills'] + $deaths * $params['ratio_deaths'] + $assists * $params['ratio_assists'] + $gold_per_min * $params['ratio_gold_per_min'] + $xp_per_min * $params['ratio_xp_per_min'];
         $player->scores = $scores;
         $player->save();
     }
 }
Пример #7
0
 /**
  * возвращает информацию по игрокам на которых была сделана ставка
  *
  * @return \yii\db\ActiveQuery
  */
 public function getDraftPlayersInfo()
 {
     return $this->hasMany(DotaPlayer::className(), ['account_id' => 'account_id'])->viaTable('{{%dota_draft_player}}', ['draft_id' => 'id']);
 }
Пример #8
0
 private static function _addPlayerInfoInBase($data, $account_id, $team_id = 0)
 {
     $res = -1;
     if (isset($data[0]) && count($data[0])) {
         $model = new DotaPlayer();
         $model->attributes = $data[0];
         $model->account_id = $account_id;
         if ($team_id > 0) {
             $model->team_id = $team_id;
         }
         //$img_paths = explode('/', $model->avatar);
         //$model->avatar = $img_paths[(count($img_paths)-1)];
         $model->profileurl = '';
         $model->avatar = '';
         $model->avatarmedium = '';
         $model->avatarfull = '';
         if ($model->validate()) {
             $model->save();
             $res = $model->account_id;
         } else {
         }
         //echo'<pre>';print_r($model);echo'</pre>';die;
     }
     return $res;
 }