/** * @return \yii\db\ActiveQuery */ public function getEventHeroStat() { return $this->hasMany(DotaEventHeroStat::className(), ['event_id' => 'id']); }
/** * обновляет кол-во очков по ставке пользователя в MixedDraft * * @param int $draft_id * @param int $event_id * @param $data * @return bool */ public static function setScoresForMixedDraft($draft_id = 0, $event_id = 0, $data) { //echo'<pre>';print_r($draft_id);echo'</pre>';//die; //echo'<pre>';print_r($event_id);echo'</pre>';//die; //echo'<pre>';print_r($data);echo'</pre>';die; $scores = DotaEventPlayerStat::getSummScoresForAccounts($event_id, $data['players']); //echo'<pre>';print_r($scores);echo'</pre>';//die; $scores += DotaEventHeroStat::getSummScoresForHeroes($event_id, $data['heroes']); //echo'<pre>';print_r($scores);echo'</pre>';die; $data = ['`scores`' => $scores]; $where = ['`id` = ' . $draft_id]; return self::updateRow($data, $where); }
/** * Updates an existing DotaEvent model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $task = Yii::$app->request->post('task', 'save'); //echo'<pre>';print_r($_POST);echo'</pre>';die; $model->league_ids = $model->selectedEventLeagues; $model->team_ids = $model->selectedEventTeams; //$model->players_list = DotaPlayer::getActivePlayersList(); if (count($model->team_ids) > 0) { $model->players_list = DotaTeam::getTeamsListWithPlayers($model->team_ids); } else { $model->players_list = []; } //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->heroes_list = DotaHero::getActiveHeroesList(); $model->preparePlayersForEdit(); $model->prepareHeroesForEdit(); /* $rr = DotaEventTeam::find() ->joinWith('team') ->joinWith('') ->where(['event_id'=>$id]) echo'<pre>';print_r($model->dotaEventTeams->joinWith('dotaPlayers'));echo'</pre>';die; */ $dataProviderPlayersStat = DotaEventPlayerStat::searchPlayersStatInEvent($model->id); $dataProviderHeroesStat = DotaEventHeroStat::searchHeroesStatInEvent($model->id); //echo'<pre>';print_r($dataProviderHeroesStat->models);echo'</pre>';die; //echo'<pre>';print_r(DotaTeam::getTeamsListWithPlayers($model->team_ids));echo'</pre>';die; //$model->load(Yii::$app->request->post()); //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; if ($model->load(Yii::$app->request->post()) && $model->validate()) { //if ($model->validate()) { $event = DotaEvent::findOne($model->id); //echo'<pre>';print_r($event->dotaEventPlayerStat);echo'</pre>';die; //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->save(); $DotaEventPlayerStat = Yii::$app->request->post('DotaEventPlayerStat', []); $this->checkPlayersStat($model, $DotaEventPlayerStat); $this->checkLeagues($model); //проверяем изменения в лигах $this->checkTeams($model); //проверяем изменения в командах if (!is_null($model->price_pd) && !is_null($model->price_md_p)) { $this->checkPlayers($model); } //проверяем изменения в игроках if (!is_null($model->price_hd) && !is_null($model->price_md_h)) { $this->checkHeroes($model); } //проверяем изменения в героях Yii::$app->session->setFlash('success', Yii::t('app', 'Saved')); if ($task == 'apply') { return $this->redirect(['update', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { //echo'<pre>';print_r($model);echo'</pre>';//die; return $this->render('update', ['model' => $model, 'dataProviderPlayersStat' => $dataProviderPlayersStat, 'dataProviderHeroesStat' => $dataProviderHeroesStat, 'last_update_info' => LastStatUpdate::LoadDota()]); } }
/** * @return bool */ public static function updateDotaDraftPrizes() { // 1. получить список активных фантазий (активность из event) $events = DotaEvent::getActualEventsList(); $event_ids = ArrayHelper::map($events, 'id', 'id'); $fantasies = DotaFantasy::getActiveFantasies($event_ids); echo '<pre>'; print_r($fantasies); echo '</pre>'; //die; $DotaDraft = new DotaDraft(); foreach ($fantasies as $fantasy) { $fantasyModel = DotaFantasy::findOne($fantasy['id']); $stat_heroes_on_event = DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id); $stat_players_on_event = DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id); //echo'<pre>';print_r($fantasyModel->name);echo'</pre>';//die; //echo'<pre>';var_dump($stat_heroes_on_event);echo'</pre>';//die; //echo'<pre>';var_dump($stat_players_on_event);echo'</pre>';//die; //если статистики по матчам еще нет - дальше не обрабатываем if (DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id) === false && DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id) === false) { continue; } //echo'<pre>';print_r($fantasy_id);echo'</pre>';die; $DotaFantasy = new DotaFantasy(); $places = $DotaFantasy->calculatePlacesInFantasy($fantasyModel); //echo'<pre>';print_r($places);echo'</pre>';//die; //проверка корректности расчета процентов по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places) === false) return 1; $prizes = $DotaFantasy->calculatePrizesInFantasy($fantasyModel, $places); echo '<pre>'; print_r($prizes); echo '</pre>'; //die; //проверка корректности расчета сумм по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places, $fantasyModel->prize_pool) === false) return 2; $DotaDraft->updatePrizeValues($prizes, $fantasy['id']); /* foreach($prizes as $user_id=>$value) { $values = [ 'prize' => $value, ]; $where = [ 'fantasy_id = ' . $fantasy['id'], 'user_id = ' . $user_id, ]; $DotaDraft->updateRow($values, $where); } */ } //die; return true; }