public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'nova_neo', 'name' => 'Luna Blaster Neo', 'subweapon_id' => Subweapon::findOne(['key' => 'splashbomb'])->id, 'special_id' => Special::findOne(['key' => 'bombrush'])->id]); $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'h3reelgun_d', 'name' => 'H-3 Nozzlenose D', 'subweapon_id' => Subweapon::findOne(['key' => 'pointsensor'])->id, 'special_id' => Special::findOne(['key' => 'supershot'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'nova_neo', 'name' => 'Luna Blaster Neo']); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'h3reelgun_d', 'name' => 'H-3 Nozzlenose D']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'slosher'])->id, 'key' => 'hissen_hue', 'name' => 'Tri-Slosher Nouveau', 'subweapon_id' => Subweapon::findOne(['key' => 'chasebomb'])->id, 'special_id' => Special::findOne(['key' => 'supersensor'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'hissen_hue', 'name' => 'Tri-Slosher Nouveau']); $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'rapid_elite_deco', 'name' => 'Rapid Blaster Pro Deco', 'subweapon_id' => Subweapon::findOne(['key' => 'poison'])->id, 'special_id' => Special::findOne(['key' => 'megaphone'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'rapid_elite_deco', 'name' => 'Rapid Blaster Pro Deco']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'charger'])->id, 'key' => 'liter3k_scope_custom', 'name' => 'Custom E-liter 3K Scope', 'subweapon_id' => Subweapon::findOne(['key' => 'jumpbeacon'])->id, 'special_id' => Special::findOne(['key' => 'daioika'])->id]); $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'longblaster_custom', 'name' => 'Custom Range Blaster', 'subweapon_id' => Subweapon::findOne(['key' => 'splashbomb'])->id, 'special_id' => Special::findOne(['key' => 'daioika'])->id]); $mainWeapon = DeathReasonType::findOne(['key' => 'main'])->id; $this->batchInsert('death_reason', ['type_id', 'key', 'name'], [[$mainWeapon, 'liter3k_scope_custom', 'Custom E-liter 3K Scope'], [$mainWeapon, 'longblaster_custom', 'Custom Range Blaster']]); }
/** * Displays homepage. * * @return mixed */ public function actionIndex() { $responses = Responses::find()->all(); $autos = Cars::find()->all(); $special = Special::find()->all(); $cars = []; foreach ($autos as $auto) { if (!in_array($auto->name, $cars)) { $cars[] = $auto->name; } } return $this->render('index', ['responses' => $responses, 'cars' => $cars, 'special' => $special]); }
public function rules() { return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () { return substr($this->rule, 0, 1) !== '@'; }], [['rule'], 'validateGameMode', 'when' => function () { return substr($this->rule, 0, 1) === '@'; }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () { return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true); }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '@'; }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '+'; }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '*'; }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose']]; }
public function rules() { return [[['screen_name'], 'exist', 'targetClass' => User::className(), 'targetAttribute' => 'screen_name'], [['lobby'], 'exist', 'targetClass' => Lobby::className(), 'targetAttribute' => 'key'], [['rule'], 'exist', 'targetClass' => Rule::className(), 'targetAttribute' => 'key', 'when' => function () { return substr($this->rule, 0, 1) !== '@'; }], [['rule'], 'validateGameMode', 'when' => function () { return substr($this->rule, 0, 1) === '@'; }], [['map'], 'exist', 'targetClass' => Map::className(), 'targetAttribute' => 'key'], [['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key', 'when' => function () { return !in_array(substr($this->weapon, 0, 1), ['@', '+', '*'], true); }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => WeaponType::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '@'; }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Subweapon::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '+'; }], [['weapon'], 'validateWeapon', 'params' => ['modelClass' => Special::className()], 'when' => function () { return substr($this->weapon, 0, 1) === '*'; }], [['result'], 'boolean', 'trueValue' => 'win', 'falseValue' => 'lose'], [['term'], 'in', 'range' => ['this-period', 'last-period', '24h', 'today', 'yesterday', 'term']], [['term_from', 'term_to'], 'date', 'format' => 'yyyy-M-d H:m:s']]; }
public function makeUpdate() { $currentSpecialId = null; $fh = fopen(__FILE__, 'rt'); fseek($fh, __COMPILER_HALT_OFFSET__, SEEK_SET); while (!feof($fh)) { $line = rtrim(fgets($fh)); if ($line != '') { if (substr($line, 0, 1) !== ' ') { $currentSpecialId = Special::findOne(['key' => $line])->id; } else { $line = trim($line); $weaponId = Weapon::findOne(['key' => $line])->id; (yield [$weaponId, $currentSpecialId]); } } } fclose($fh); }
/** * @return \yii\db\ActiveQuery */ public function getSpecial() { return $this->hasOne(Special::className(), ['id' => 'special_id']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'slosher'])->id, 'key' => 'screwslosher_neo', 'name' => 'Sloshing Machine Neo', 'subweapon_id' => Subweapon::findOne(['key' => 'pointsensor'])->id, 'special_id' => Special::findOne(['key' => 'supershot'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'screwslosher_neo', 'name' => 'Sloshing Machine Neo']); }
/** * Finds the Special model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Special the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Special::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'splatling'])->id, 'key' => 'hydra', 'name' => 'Hydra Splatling', 'subweapon_id' => Subweapon::findOne(['key' => 'splashbomb'])->id, 'special_id' => Special::findOne(['key' => 'supersensor'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'hydra', 'name' => 'Hydra Splatling']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'charger'])->id, 'key' => 'bamboo14mk2', 'name' => 'Bamboozler 14 Mk II', 'subweapon_id' => Subweapon::findOne(['key' => 'poison'])->id, 'special_id' => Special::findOne(['key' => 'supersensor'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'bamboo14mk2', 'name' => 'mboozler 14 Mk II']); }
public function __construct() { $this->specials = Special::orderByRaw('RAND()')->get(); }
private function convertWeapons2Special($in) { $ret = []; foreach (Special::find()->all() as $spe) { $ret[$spe->key] = (object) ['name' => Yii::t('app-special', $spe->name), 'count' => 0, 'sum_kill' => 0, 'sum_death' => 0, 'win_count' => 0, 'avg_kill' => null, 'avg_death' => null, 'wp' => null, 'encounter_3' => null, 'encounter_4' => null]; } foreach ($in->weapons as $weapon) { $o = $ret[$weapon->special->key]; $o->count += $weapon->count; $o->sum_kill += $weapon->sum_kill; $o->sum_death += $weapon->sum_death; $o->win_count += $weapon->win_count; } foreach ($ret as $o) { if ($o->count > 0) { $o->avg_kill = $o->sum_kill / $o->count; $o->avg_death = $o->sum_death / $o->count; $o->wp = $o->win_count * 100 / $o->count; $encounterRate = $o->count / $in->player_count; $o->encounter_3 = 100 * (1 - pow(1 - $encounterRate, 3)); $o->encounter_4 = 100 * (1 - pow(1 - $encounterRate, 4)); $o->encounter_r = $encounterRate * 100; } } usort($ret, function ($a, $b) { foreach (['count', 'wp', 'avg_kill', 'avg_death'] as $key) { $tmp = $b->{$key} - $a->{$key}; if ($tmp != 0) { return $tmp; } } return strnatcasecmp($a->name, $b->name); }); return $ret; }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'bold_neo', 'name' => 'Neo Sploosh-o-matic', 'subweapon_id' => Subweapon::findOne(['key' => 'pointsensor'])->id, 'special_id' => Special::findOne(['key' => 'daioika'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'bold_neo', 'name' => 'Neo Sploosh-o-matic']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'roller'])->id, 'key' => 'carbon_deco', 'name' => 'Carbon Roller Deco', 'subweapon_id' => Subweapon::findOne(['key' => 'chasebomb'])->id, 'special_id' => Special::findOne(['key' => 'bombrush'])->id]); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'shooter'])->id, 'key' => 'rapid_elite', 'name' => 'Rapid Blaster Pro', 'subweapon_id' => Subweapon::findOne(['key' => 'chasebomb'])->id, 'special_id' => Special::findOne(['key' => 'supershot'])->id]); $mainWeapon = DeathReasonType::findOne(['key' => 'main'])->id; $this->insert('death_reason', ['type_id' => $mainWeapon, 'key' => 'rapid_elite', 'name' => 'Rapid Blaster Pro']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'slosher'])->id, 'key' => 'bucketslosher_deco', 'name' => 'Slosher Deco', 'subweapon_id' => Subweapon::findOne(['key' => 'splashshield'])->id, 'special_id' => Special::findOne(['key' => 'daioika'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'bucketslosher_deco', 'name' => 'Slosher Deco']); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Special $special) { $picture = $special->attachment; $special->delete(); if ($picture) { if (file_exists($picture->path)) { unlink($picture->path); } $picture->delete(); } return redirect()->route('admin.special.index'); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'splatling'])->id, 'key' => 'splatspinner_collabo', 'name' => 'Zink Mini Splatling', 'subweapon_id' => Subweapon::findOne(['key' => 'poison'])->id, 'special_id' => Special::findOne(['key' => 'barrier'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'splatspinner_collabo', 'name' => 'Zink Mini Splatling']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'roller'])->id, 'key' => 'hokusai_hue', 'name' => 'Octobrush Nouveau', 'subweapon_id' => Subweapon::findOne(['key' => 'splashbomb'])->id, 'special_id' => Special::findOne(['key' => 'supershot'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'hokusai_hue', 'name' => 'Octobrush Nouveau']); }
public function rules() { return [[['weapon'], 'exist', 'targetClass' => Weapon::className(), 'targetAttribute' => 'key'], [['type'], 'exist', 'targetClass' => WeaponType::className(), 'targetAttribute' => 'key'], [['sub'], 'exist', 'targetClass' => Subweapon::className(), 'targetAttribute' => 'key'], [['special'], 'exist', 'targetClass' => Special::className(), 'targetAttribute' => 'key']]; }
private function makeWeaponsListSpecials(User $user) { $query = Special::find()->andWhere(['in', 'id', array_map(function ($model) { return $model->special_id; }, Weapon::findAll($this->getUsedWeaponIdList($user)))]); $ret = []; foreach ($query->all() as $item) { $ret['*' . $item->key] = Yii::t('app-special', $item->name); } if (count($ret) < 2) { return []; } asort($ret); return [Yii::t('app', 'Special') => $ret]; }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'slosher'])->id, 'key' => 'screwslosher', 'name' => 'Sloshing Machine', 'subweapon_id' => Subweapon::findOne(['key' => 'splashbomb'])->id, 'special_id' => Special::findOne(['key' => 'bombrush'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'screwslosher', 'name' => 'Sloshing Machine']); }
public function safeUp() { $this->insert('weapon', ['type_id' => WeaponType::findOne(['key' => 'splatling'])->id, 'key' => 'barrelspinner_deco', 'name' => 'Heavy Splatling Deco', 'subweapon_id' => Subweapon::findOne(['key' => 'pointsensor'])->id, 'special_id' => Special::findOne(['key' => 'daioika'])->id]); $this->insert('death_reason', ['type_id' => DeathReasonType::findOne(['key' => 'main'])->id, 'key' => 'barrelspinner_deco', 'name' => 'Heavy Splatling Deco']); }
private function makeWeaponsListSpecials() { $ret = []; foreach (Special::find()->all() as $item) { $ret['*' . $item->key] = Yii::t('app-special', $item->name); } asort($ret); return [Yii::t('app', 'Special') => $ret]; }