public function loadModel($id) { $model = Spell::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $model->formatInfo(); return $model; }
public function getTalents() { if (empty($this->_talents)) { $talentHandler = new WowTalents($this->class_id); $this->_talents = $talentHandler->talentTrees; $build = null; foreach ($this->_talents as $i => $tree) { $this->_talents[$i]['count'] = 0; foreach ($tree['talents'] as $k => $tal) { $checked = false; $points = 0; if ($tal['keyAbility']) { $tSpell = Spell::model()->findByPk($tal['ranks'][0]['id']); $name = $tSpell->spellname_loc0; $spellRanks = Yii::app()->db->createCommand("SELECT spellID\n FROM wow_spells\n WHERE spellicon = {$tSpell->spellicon} AND\n spellname_loc0 = :name")->bindParam(':name', $name)->queryColumn(); foreach ($spellRanks as $spell) { if (in_array($spell, $this->_spells)) { $checked = true; $build .= 1; $points = 1; $this->_talents[$i]['count']++; break; } } } else { foreach ($tal['ranks'] as $j => $spell) { if (in_array($spell['id'], $this->_spells)) { $checked = true; $build .= $j + 1; $points = $j + 1; $this->_talents[$i]['count'] += $j + 1; break; } } } if (!$checked) { $build .= 0; } $this->_talents[$i]['talents'][$k]['points'] = $points; } } $this->_talents['build'] = $build; $this->_talents['maxTreeNo'] = 0; for ($i = 0; $i < 3; $i++) { if ($this->_talents[$i]['count'] > $this->_talents[$this->_talents['maxTreeNo']]['count']) { $this->_talents['maxTreeNo'] = $i; } } $this->_talents['name'] = $this->_talents[$this->_talents['maxTreeNo']]['name']; $this->_talents['icon'] = $this->_talents[$this->_talents['maxTreeNo']]['icon']; if ($this->_talents[0]['count'] == 0 && $this->_talents[1]['count'] == 0 && $this->_talents[2]['count'] == 0) { // have no talents $this->_talents['maxTreeNo'] = -1; $this->_talents['icon'] = 'inv_misc_questionmark'; $this->_talents['name'] = 'No Talents'; } } return $this->_talents; }
public function getSet() { if (!$this->_set) { $item_set = Yii::app()->db->createCommand("SELECT * FROM wow_itemset WHERE id = {$this->itemset} LIMIT 1")->queryRow(); $this->_set['name'] = $item_set['name_loc0']; $this->_set['items'] = $this->dbConnection->createCommand("SELECT entry, name FROM item_template WHERE itemset = {$this->itemset}")->queryAll(); $this->_set['count'] = count($this->_set['items']); for ($i = 1; $i < 8; $i++) { if ($item_set['spell' . $i] > 0) { $spell = Spell::model()->findByPk($item_set['spell' . $i]); $spell->formatInfo(); $this->_set['bonuses'][$item_set['bonus' . $i]] = $spell; unset($spell); } } ksort($this->_set['bonuses']); } return $this->_set; }
public function getTalentTrees() { $talentTrees = Yii::app()->cache->get('talentTrees_' . $this->_class); if (!$talentTrees) { $tab_class = $this->getTalentTabForClass(); $talentTrees = array(); for ($i = 0; $i < 3; $i++) { $current_tab = Yii::app()->db->createCommand("SELECT * FROM `wow_talent` WHERE `tab` = {$tab_class[$i]} ORDER BY tab, row, col")->queryAll(); if (!$current_tab) { continue; } $talentTrees[$i]['name'] = $this->names[$i]; $talentTrees[$i]['icon'] = $this->icons[$i]; $talentTrees[$i]['treeNo'] = $i; $talentTrees[$i]['overlayColor'] = "#cc33cc"; $talentTrees[$i]['description'] = "Заклинатель, который подчиняет себе разрушительные силы стихий."; foreach ($current_tab as $tal) { $talent = array(); $talent['id'] = $tal['id']; $talent['y'] = $tal['row']; $talent['x'] = $tal['col']; if ($tal['required']) { $talent['req'] = $tal['required']; } $tSpell = Spell::model()->findByPk($tal['rank1']); $tSpell->formatInfo(); $talent['name'] = $tSpell->spellname_loc0; $talent['icon'] = $tSpell->iconName; $talent['ranks'] = array(); $talent['ranks'][] = array('description' => $tSpell->info, 'id' => $tal['rank1']); if ($tal['rank2']) { $tSpell = Spell::model()->findByPk($tal['rank2']); $tSpell->formatInfo(); $talent['ranks'][] = array('description' => $tSpell->info, 'id' => $tal['rank2']); } if ($tal['rank3']) { $tSpell = Spell::model()->findByPk($tal['rank3']); $tSpell->formatInfo(); $talent['ranks'][] = array('description' => $tSpell->info, 'id' => $tal['rank3']); } if ($tal['rank4']) { $tSpell = Spell::model()->findByPk($tal['rank4']); $tSpell->formatInfo(); $talent['ranks'][] = array('description' => $tSpell->info, 'id' => $tal['rank4']); } if ($tal['rank5']) { $tSpell = Spell::model()->findByPk($tal['rank5']); $tSpell->formatInfo(); $talent['ranks'][] = array('description' => $tSpell->info, 'id' => $tal['rank5']); } $talent['maxpoints'] = count($talent['ranks']); if ($tal['singlePoint']) { $talent['keyAbility'] = true; } else { $talent['keyAbility'] = false; } $talentTrees[$i]['talents'][] = $talent; } } Yii::app()->cache->set('talentTrees_' . $this->_class, $talentTrees); } return $talentTrees; }