public function before_save_process($bean, $event, $arguments) { require_once 'include/entryPoint.php'; require_once 'modules/Campaigns/utils.php'; $py = new Spell(); $bean->dep_num_c = join('', $py->getInitial($bean->name, 'utf-8', 'utf-8')); }
/** * Spend mana for a spell * * @param Spell $spell * * @return bool */ public function spendMana($spell) { $this->mp -= $spell->getCost(); if ($this->mp <= 0) { return false; } return true; }
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 pinyin($data = '') { return Spell::parse(trim($data)); }
public function isSpellAvailable(Spell $spell) { if ($spell instanceof Effect && $spell->isActive()) { return false; } return $spell->getCost() <= $this->playerMana; }
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 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 formatInfo() { $regExp = "/\\\$+(?:([\\/,*])?([0-9]*);)?([d+\\;(\\d*)?([1-9]*)([A-z])([1-3]*)(([A-z, ]*)\\:([A-z, ]*)\\;)?/"; $info = $this->tooltip_loc0; $attributes = $this->attributes; //TODO: rewrite after support $this in PHP 5.4.0 $this->info = preg_replace_callback($regExp, function ($match) use($attributes) { $select = ''; $match[5] = $match[5] ? $match[5] : '1'; $match[4] = strtolower($match[4]); switch ($match[4]) { case 'z': return "[Home]"; case 'l': return $match[8]; case 'g': return $match[7]; case 'h': $select = 'procChance'; break; case 'u': return ''; //$this->RegExpU($match); //$this->RegExpU($match); case 'v': $select = 'affected_target_level'; break; case 'q': $select = 'effect' . $match[5] . 'MiscValue'; break; case 'i': $select = 'spellTargets'; break; case 'b': $select = 'effect' . $match[5] . 'PointsPerComboPoint'; break; case 'm': case 's': $select = 'effect' . $match[5] . 'BasePoints'; break; case 'a': $select = 'effect' . $match[5] . 'radius'; break; case 'd': $select = 'durationID'; break; case 'o': $select = 'durationID, effect' . $match[5] . 'Amplitude, effect' . $match[5] . 'BasePoints'; break; case 't': $select = 'effect' . $match[5] . 'Amplitude'; break; case 'n': $select = 'procCharges'; break; case 'x': $select = 'effect' . $match[5] . 'ChainTarget'; break; default: break; } if ($match[3]) { $command = Yii::app()->db->createCommand()->select($select)->from('wow_spells')->where('spellID = :spellID'); if ($match[4] == 'o') { $value = $command->queryRow(false, array(':spellID' => $match[3])); } else { $value = $command->queryScalar(array(':spellID' => $match[3])); } } elseif ($match[4] == 'o') { $value = array($attributes['durationID'], $attributes['effect' . $match[5] . 'Amplitude'], $attributes['effect' . $match[5] . 'BasePoints']); } else { $value = $attributes[$select]; } if (is_array($value)) { $value = Spell::GetRealDuration($value[0], $value[1], $match[5]) * ($value[2] + 1); } if ($match[4] == 's' or $match[4] == 'm') { $value += 1; } elseif ($match[4] == 'i' and !$value) { $value = 'nearby'; } elseif ($match[4] == 'a') { $value = Spell::GetRadius($value, $match[5]); } elseif ($match[4] == 'd') { $value = Spell::GetDuration($value) . ' sec'; } elseif ($match[4] == 't') { $value /= 1000; } if ($match[2]) { if ($match[1] == "/") { $value = abs(($value + 1) / $match[2]); } else { if ($match[1] == "*") { $value = abs(($value + 1) * $match[2]); } } } return $value; }, $info); }
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; }