dropped single-item classes for all types, because it doesn't make much difference to use a list with a single item instead, especially if it's preselected. Additionally it is now easier to chain certain queries together and execute them all at once. additionally, additionally certain data can now be cahced and shared between types of the same .. type, that were previously in different instances alltogether.

And you may now specify a limit to sql-queries (while setting up a typeList), it will default to the config-limit if no value is given.
This commit is contained in:
Sarjuuk
2013-03-05 20:31:38 +01:00
parent 8a9d984eda
commit 9019c3b811
21 changed files with 1614 additions and 1429 deletions

View File

@@ -3,51 +3,133 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Achievement extends BaseType
class AchievementList extends BaseType
{
public $criteria = [];
public $tooltip = '';
public $tooltip = [];
protected $setupQuery = "SELECT * FROM ?_achievement WHERE `Id` = ?";
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM ?_achievement WHERE [filter] [cond]';
public function __construct($data)
public function __construct($conditions)
{
parent::__construct($data);
parent::__construct($conditions);
// post processing
if (!$this->template['iconString'])
$this->template['iconString'] = 'INV_Misc_QuestionMark';
while ($this->iterate())
{
if (!$this->curTpl['iconString'])
$this->templates[$this->Id]['iconString'] = 'INV_Misc_QuestionMark';
//"rewards":[[11,137],[3,138]] [type, typeId]
if (!empty($this->curTpl['rewardIds']))
{
$rewards = [];
$rewIds = explode(" ", $this->curTpl['rewardIds']);
foreach ($rewIds as $rewId)
$rewards[] = ($rewId > 0 ? [TYPE_ITEM => $rewId] : ($rewId < 0 ? [TYPE_TITLE => -$rewId] : NULL));
$this->templates[$this->Id]['rewards'] = $rewards;
}
}
$this->reset(); // restore 'iterator'
}
public function addRewardsToJScript(&$refs)
{
// collect Ids to execute in single query
$lookup = [];
while ($this->iterate())
{
$rewards = explode(" ", $this->curTpl['rewardIds']);
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
}
if (isset($lookup['item']))
(new ItemList(array(['i.entry', array_unique($lookup['item'])])))->addGlobalsToJscript($refs);
if (isset($lookup['title']))
(new TitleList(array(['Id', array_unique($lookup['title'])])))->addGlobalsToJscript($refs);
}
public function addGlobalsToJscript(&$refs)
{
if (!isset($refs['gAchievements']))
$refs['gAchievements'] = [];
while ($this->iterate())
{
$refs['gAchievements'][$this->Id] = array(
'icon' => $this->curTpl['iconString'],
'name' => Util::localizedString($this->curTpl, 'name')
);
}
}
public function getListviewData()
{
return array(
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
'id' => $this->Id,
'name' => Util::localizedString($this->template, 'name'),
'description' => Util::localizedString($this->template, 'description'),
'points' => $this->template['points'],
'faction' => $this->template['faction'] + 1,
'category' => $this->template['category'],
'parentCat' => $this->template['parentCat'],
'rewards' => empty($this->template['rewards']) ? NULL : $this->template['rewards'],
'reward' => empty($this->template['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->template, 'reward'),
'name' => Util::localizedString($this->curTpl, 'name'),
'description' => Util::localizedString($this->curTpl, 'description'),
'points' => $this->curTpl['points'],
'faction' => $this->curTpl['faction'] + 1,
'category' => $this->curTpl['category'],
'parentCat' => $this->curTpl['parentCat'],
);
if (!empty($this->curTpl['rewards']))
{
$rewards = [];
foreach ($this->curTpl['rewards'] as $pair)
$rewards[] = '['.key($pair).','.current($pair).']';
$data[$this->Id]['rewards'] = '['.implode(',', $rewards).']';
}
else if (!empty ($this->curTpl['reward']))
$data[$this->Id]['reward'] = Util::localizedString($this->curTpl, 'reward');
}
return $data;
}
// hmm, really needed? .. probably .. needs rename? .. also probably
public function getDetailedData()
{
return array(
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
'id' => $this->Id,
'name' => Util::localizedString($this->template, 'name'),
'description' => Util::localizedString($this->template, 'description'),
'points' => $this->template['points'],
'iconname' => $this->template['iconString'],
'count' => $this->template['reqCriteriaCount'],
'reward' => empty($this->template['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->template, 'reward'),
'name' => Util::localizedString($this->curTpl, 'name'),
'description' => Util::localizedString($this->curTpl, 'description'),
'points' => $this->curTpl['points'],
'iconname' => $this->curTpl['iconString'],
'count' => $this->curTpl['reqCriteriaCount'],
'reward' => empty($this->curTpl['reward_loc'.User::$localeId]) ? NULL : Util::localizedString($this->curTpl, 'reward')
);
}
return $data;
}
// only for current template
public function getCriteria($idx = -1)
{
if (empty($this->criteria))
@@ -57,55 +139,21 @@ class Achievement extends BaseType
return [];
if (is_array($result[0]))
$this->criteria = $result;
$this->criteria[$this->Id] = $result;
else
$this->criteria[] = $result;
$this->criteria[$this->Id][] = $result;
}
if ($idx < 0)
return $this->criteria;
return $this->criteria[$this->Id];
else
return $this->criteria[$idx];
return $this->criteria[$this->Id][$idx];
}
public function addGlobalsToJScript(&$gAchievements)
public function renderTooltip()
{
$gAchievements[$this->Id] = array(
'icon' => $this->template['iconString'],
'name' => Util::localizedString($this->template, 'name'),
);
}
public function addRewardsToJscript(&$gItems, &$gTitles)
{
$rewards = explode(" ", $this->template['rewardIds']);
$lookup = [];
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
if (isset($lookup['item']))
{
$rewItems = new ItemList(array(['i.entry', $lookup['item']]));
$rewItems->addGlobalsToJScript($gItems);
}
if (isset($lookup['title']))
{
$rewTitles = new TitleList(array(['Id', $lookup['title']]));
$rewTitles->addGlobalsToJScript($gTitles);
}
}
public function createTooltip()
{
if (!empty($this->tooltip))
return $this->tooltip;
if (!empty($this->tooltip[$this->Id]))
return $this->tooltip[$this->Id];
$criteria = $this->getCriteria();
$tmp = [];
@@ -121,8 +169,8 @@ class Achievement extends BaseType
if ($tmp)
$rows = array_merge($rows, $tmp);
$description = Util::localizedString($this->template, 'description');
$name = Util::localizedString($this->template, 'name');
$description = Util::localizedString($this->curTpl, 'description');
$name = Util::localizedString($this->curTpl, 'name');
$criteria = '';
$i = 0;
@@ -148,7 +196,7 @@ class Achievement extends BaseType
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
if (!$crtName)
$crtName = Item::getName($crt['value1']);
$crtName = Util::getItemName($crt['value1']);
break;
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
if (!$crtName)
@@ -184,88 +232,29 @@ class Achievement extends BaseType
$x .= '</td></tr></table>';
// Completed
$this->tooltip = $x;
$this->tooltip[$this->Id] = $x;
return $this->tooltip;
return $this->tooltip[$this->Id];
}
public function getSourceData()
{
return array(
"n" => Util::localizedString($this->template, 'name'),
"s" => $this->template['faction'],
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
"n" => Util::localizedString($this->curTpl, 'name'),
"s" => $this->curTpl['faction'],
"t" => TYPE_ACHIEVEMENT,
"ti" => $this->Id
);
}
return $data;
}
class AchievementList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_achievement WHERE [filter] [cond] GROUP BY Id ORDER BY `orderInGroup` ASC';
public function __construct($conditions)
{
// may be called without filtering
if (class_exists('AchievementFilter'))
{
$this->filter = new AchievementFilter();
if (($fiData = $this->filter->init()) === false)
return;
}
parent::__construct($conditions);
// post processing
foreach ($this->container as $k => $acv)
{
//"rewards":[[11,137],[3,138]] [what, entry] 3:item; 11:title, 6:spell(unused)
if (!empty($acv->template['rewardIds']))
{
$rewards = [];
$rewIds = explode(" ", $acv->template['rewardIds']);
foreach ($rewIds as $rewId)
$rewards[] = ($rewId > 0 ? "[3,".$rewId."]" : ($rewId < 0 ? "[11,".-$rewId."]" : NULL));
$this->container[$k]->template['rewards'] = "[".implode(",",$rewards)."]";
}
}
}
public function addRewardsToJScript(&$gItems, &$gTitles)
{
// collect Ids to execute in single query
$lookup = [];
foreach ($this->container as $id => $data)
{
$rewards = explode(" ", $data->template['rewardIds']);
foreach ($rewards as $reward)
{
if ($reward > 0)
$lookup['item'][] = $reward;
else if ($reward < 0)
$lookup['title'][] = -$reward;
}
}
if (isset($lookup['item']))
{
$rewItems = new ItemList(array(['i.entry', array_unique($lookup['item'])]));
$rewItems->addGlobalsToJScript($gItems);
}
if (isset($lookup['title']))
{
$rewTitles = new TitleList(array(['Id', array_unique($lookup['title'])]));
$rewTitles->addGlobalsToJScript($gTitles);
}
}
// run once
// run once .. should this even be here..?
public function setupAchievements()
{
set_time_limit(120);
@@ -309,21 +298,21 @@ class AchievementList extends BaseTypeList
world.achievement_dbc"
);
foreach ($this->container as $acv)
while ($this->iterate())
{
// set iconString
$icon = DB::Aowow()->SelectCell('SELECT iconname FROM ?_spellicons WHERE id = ?d', $acv->template['iconId']);
$icon = DB::Aowow()->SelectCell('SELECT iconname FROM ?_spellicons WHERE id = ?d', $this->curTpl['iconId']);
// set parentCat
$parentCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE Id = ?d', $acv->template['category']);
$parentCat = DB::Aowow()->SelectCell('SELECT parentCategory FROM ?_achievementcategory WHERE Id = ?d', $this->curTpl['category']);
// series parent(16) << child(16)
$series = $acv->template['parent'] << 16;
$series = $this->curTpl['parent'] << 16;
$series |= DB::Aowow()->SelectCell('SELECT Id FROM ?_achievement WHERE parent = ?d', $acv->Id);
// set rewards
$rewardIds = [];
if ($rStr = $acv->template['reward_loc0'])
if ($rStr = $this->curTpl['reward_loc0'])
{
// i can haz title?
@@ -384,4 +373,5 @@ class AchievementList extends BaseTypeList
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -3,19 +3,28 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Quest extends BaseType
class QuestList extends BaseType
{
public $cat1 = 0;
public $cat2 = 0;
protected $setupQuery = 'SELECT * FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE a.Id = ?';
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond] ORDER BY Id ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond]';
public function __construct($data)
// parent::__construct does the job
public function iterate($qty = 1)
{
parent::__construct($data);
$r = parent::iterate($qty);
// post process
$this->cat1 = $this->template['ZoneOrSort']; // should probably be in a method...
if (!$this->Id)
{
$this->cat1 = 0;
$this->cat2 = 0;
}
else
{
$this->cat1 = $this->curTpl['ZoneOrSort']; // should probably be in a method...
foreach (Util::$questClasses as $k => $arr)
{
if (in_array($this->cat1, $arr))
@@ -26,6 +35,10 @@ class Quest extends BaseType
}
}
return $r;
}
// static use START
public static function getName($id)
{
$n = DB::Aowow()->SelectRow('
@@ -54,11 +67,16 @@ class Quest extends BaseType
else
return 0;
}
// static use END
public function getSourceData()
{
return array(
"n" => Util::localizedString($this->template, 'Title'),
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
"n" => Util::localizedString($this->curTpl, 'Title'),
"t" => TYPE_QUEST,
"ti" => $this->Id,
"c" => $this->cat1,
@@ -66,148 +84,97 @@ class Quest extends BaseType
);
}
return $data;
}
public function getListviewData()
{
$data = array(
$data = [];
while ($this->iterate())
{
$set = array(
'category' => $this->cat1,
'category2' => $this->cat2,
'id' => $this->Id,
'level' => $this->template['Level'],
'reqlevel' => $this->template['MinLevel'],
'name' => Util::localizedString($this->template, 'Title'),
'side' => Util::sideByRaceMask($this->template['RequiredRaces'])
'level' => $this->curTpl['Level'],
'reqlevel' => $this->curTpl['MinLevel'],
'name' => Util::localizedString($this->curTpl, 'Title'),
'side' => Util::sideByRaceMask($this->curTpl['RequiredRaces'])
);
$rewards = [];
for ($i = 1; $i < 5; $i++)
if ($this->template['RewardItemId'.$i])
$rewards[] = [$this->template['RewardItemId'.$i], $this->template['RewardItemCount'.$i]];
if ($this->curTpl['RewardItemId'.$i])
$rewards[] = [$this->curTpl['RewardItemId'.$i], $this->curTpl['RewardItemCount'.$i]];
$choices = [];
for ($i = 1; $i < 7; $i++)
if ($this->template['RewardChoiceItemId'.$i])
$choices[] = [$this->template['RewardChoiceItemId'.$i], $this->template['RewardChoiceItemCount'.$i]];
if ($this->curTpl['RewardChoiceItemId'.$i])
$choices[] = [$this->curTpl['RewardChoiceItemId'.$i], $this->curTpl['RewardChoiceItemCount'.$i]];
if (!empty($rewards))
$data['itemrewards'] = $rewards;
if ($rewards)
$set['itemrewards'] = $rewards;
if (!empty($choices))
$data['itemchoices'] = $choices;
if ($choices)
$set['itemchoices'] = $choices;
if ($this->template['RewardTitleId'])
$data['titlereward'] = $this->template['RewardTitleId'];
if ($this->curTpl['RewardTitleId'])
$set['titlereward'] = $this->curTpl['RewardTitleId'];
// todo reprewards .. accesses QuestFactionReward.dbc
}
return $data;
}
public function addRewardsToJscript(&$gItems, &$gSpells, &$gTitles)
{
// items
$items = [];
for ($i = 1; $i < 5; $i++)
if ($this->template['RewardItemId'.$i])
$items[] = $this->template['RewardItemId'.$i];
for ($i = 1; $i < 7; $i++)
if ($this->template['RewardChoiceItemId'.$i])
$items[] = $this->template['RewardChoiceItemId'.$i];
if (!empty($items))
{
$items = new ItemList(array(['entry', $items]));
$items->addSelfToJScipt($gItems);
}
// spells
$spells = [];
if ($this->template['RewardSpell'])
$spells[] = $this->template['RewardSpell'];
if ($this->template['RewardSpellCast'])
$spells[] = $this->template['RewardSpellCast'];
if (!empty($spells))
{
$spells = new SpellList(array(['id', $spells]));
$spells->addSelfToJScipt($gSpells);
}
// titles
if ($tId = $this->template['RewardTitleId'])
{
$title = new Title($tId);
$title->addGlobalsToJScript($gTitles);
}
}
}
class QuestList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM quest_template a LEFT JOIN locales_quest b ON a.Id = b.entry WHERE [filter] [cond] ORDER BY Id ASC';
public function __construct($conditions)
{
// may be called without filtering
if (class_exists('QuestFilter'))
{
$this->filter = new QuestFilter();
if (($fiData = $this->filter->init()) === false)
return;
}
parent::__construct($conditions);
}
public function addRewardsToJscript(&$gItems, &$gSpells, &$gTitles)
public function addRewardsToJscript(&$refs)
{
$items = [];
$spells = [];
$titles = [];
foreach ($this->container as $quest)
while ($this->iterate())
{
// items
for ($i = 1; $i < 5; $i++)
if ($quest->template['RewardItemId'.$i])
$items[] = $quest->template['RewardItemId'.$i];
if ($this->curTpl['RewardItemId'.$i] > 0)
$items[] = $this->curTpl['RewardItemId'.$i];
for ($i = 1; $i < 7; $i++)
if ($quest->template['RewardChoiceItemId'.$i])
$items[] = $quest->template['RewardChoiceItemId'.$i];
if ($this->curTpl['RewardChoiceItemId'.$i] > 0)
$items[] = $this->curTpl['RewardChoiceItemId'.$i];
// spells
if ($quest->template['RewardSpell'])
$spells[] = $quest->template['RewardSpell'];
if ($this->curTpl['RewardSpell'] > 0)
$spells[] = $this->curTpl['RewardSpell'];
if ($quest->template['RewardSpellCast'])
$spells[] = $quest->template['RewardSpellCast'];
if ($this->curTpl['RewardSpellCast'] > 0)
$spells[] = $this->curTpl['RewardSpellCast'];
// titles
if ($quest->template['RewardTitleId'])
$titles[] = $quest->template['RewardTitleId'];
if ($this->curTpl['RewardTitleId'] > 0)
$titles[] = $this->curTpl['RewardTitleId'];
}
if (!empty($items))
{
$items = new ItemList(array(['i.entry', $items]));
$items->addGlobalsToJScript($gItems);
if ($items)
(new ItemList(array(['i.entry', $items])))->addGlobalsToJscript($refs);
if ($spells)
(new SpellList(array(['Id', $spells])))->addGlobalsToJscript($refs);
if ($titles)
(new TitleList(array(['Id', $titles])))->addGlobalsToJscript($refs);
}
if (!empty($spells))
public function renderTooltip()
{
$spells = new SpellList(array(['id', $spells]));
$spells->addGlobalsToJScript($gSpells);
// todo
}
if (!empty($titles))
public function addGlobalsToJScript(&$refs)
{
$titles = new TitleList(array(['id', $titles]));
$titles->addGlobalsToJScript($gTitles);
}
// todo
}
}

View File

@@ -3,15 +3,41 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Spell extends BaseType
class SpellList extends BaseType
{
public $tooltip = '';
public $buff = '';
public $tooltips = [];
public $buffs = [];
private $spellVars = [];
private $refSpells = [];
protected $setupQuery = 'SELECT * FROM ?_spell WHERE Id = ?d';
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_spell WHERE [filter] [cond] GROUP BY Id ORDER BY Id ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM ?_spell WHERE [filter] [cond]';
public function __construct($conditions)
{
parent::__construct($conditions);
if ($this->error)
return;
// post processing
$itemIcons = [];
// if the spell creates an item use the itemIcon instead
while ($this->iterate())
if ($this->curTpl['effect1CreateItemId'])
$itemIcons[(int)$this->curTpl['effect1CreateItemId']] = $this->Id;
if ($itemIcons)
{
$itemList = new ItemList(array(['i.entry', array_keys($itemIcons)]));
while ($itemList->iterate())
$this->templates[$itemIcons[$itemList->Id]]['createItemString'] = $itemList->getField('icon');
}
$this->reset(); // restore 'iterator'
}
// use if you JUST need the name
public static function getName($id)
@@ -21,19 +47,22 @@ class Spell extends BaseType
}
// end static use
// required for item-sets-bonuses and socket-bonuses
// required for itemSet-bonuses and socket-bonuses
public function getStatGain()
{
$stats = [];
while ($this->iterate())
{
for ($i = 1; $i <= 3; $i++)
{
if (!in_array($this->template["effect".$i."AuraId"], [13, 22, 29, 34, 35, 83, 84, 85, 99, 124, 135, 143, 158, 161, 189, 230, 235, 240, 250]))
if (!in_array($this->curTpl["effect".$i."AuraId"], [13, 22, 29, 34, 35, 83, 84, 85, 99, 124, 135, 143, 158, 161, 189, 230, 235, 240, 250]))
continue;
$mv = $this->template["effect".$i."MiscValue"];
$bp = $this->template["effect".$i."BasePoints"] + 1;
$mv = $this->curTpl["effect".$i."MiscValue"];
$bp = $this->curTpl["effect".$i."BasePoints"] + 1;
switch ($this->template["effect".$i."AuraId"])
switch ($this->curTpl["effect".$i."AuraId"])
{
case 29: // ModStat MiscVal:type
{
@@ -129,7 +158,6 @@ class Spell extends BaseType
case 143: // Resistance MiscVal:school
case 83:
case 22:
if ($mv == 1) // Armor only if explixitly specified
{
@$stats[ITEM_MOD_ARMOR] += $bp;
@@ -188,6 +216,8 @@ class Spell extends BaseType
break;
}
}
}
return $stats;
}
@@ -236,16 +266,16 @@ class Spell extends BaseType
// cache at least some lookups.. should be moved to single spellList :/
if ($lookup && !isset($this->refSpells[$lookup]))
$this->refSpells[$lookup] = new Spell($lookup);
$this->refSpells[$lookup] = new SpellList(array(['Id', $lookup]));
switch ($var)
{
case 'a': // EffectRadiusMin
case 'A': // EffectRadiusMax (ToDo)
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'RadiusMax'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'RadiusMax');
else
$base = $this->template['effect'.$effIdx.'RadiusMax'];
$base = $this->getField('effect'.$effIdx.'RadiusMax');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -254,9 +284,9 @@ class Spell extends BaseType
case 'b': // PointsPerComboPoint
case 'B':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'PointsPerComboPoint'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'PointsPerComboPoint');
else
$base = $this->template['effect'.$effIdx.'PointsPerComboPoint'];
$base = $this->getField('effect'.$effIdx.'PointsPerComboPoint');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -267,7 +297,7 @@ class Spell extends BaseType
if ($lookup > 0 && $exprData[0])
$spell = DB::Aowow()->selectRow('SELECT effect'.$exprData[0].'BasePoints, effect'.$exprData[0].'AuraId, effect'.$exprData[0].'MiscValue FROM ?_spell WHERE id=? LIMIT 1', $lookup);
else
$spell = $this->template;
$spell = $this->curTpl;
$base = $spell['effect'.$exprData[0].'BasePoints'] + 1;
@@ -307,9 +337,9 @@ class Spell extends BaseType
case 'd': // SpellDuration
case 'D': // todo: min/max?
if ($lookup)
$base = $this->refSpells[$lookup]->template['duration'];
$base = $this->refSpells[$lookup]->getField('duration');
else
$base = $this->template['duration'];
$base = $this->getField('duration');
if ($base < 0)
return Lang::$spell['untilCanceled'];
@@ -321,9 +351,9 @@ class Spell extends BaseType
case 'e': // EffectValueMultiplier
case 'E':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'ValueMultiplier'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'ValueMultiplier');
else
$base = $this->template['effect'.$effIdx.'ValueMultiplier'];
$base = $this->getField('effect'.$effIdx.'ValueMultiplier');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -332,9 +362,9 @@ class Spell extends BaseType
case 'f': // EffectDamageMultiplier
case 'F':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'DamageMultiplier'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DamageMultiplier');
else
$base = $this->template['effect'.$effIdx.'DamageMultiplier'];
$base = $this->getField('effect'.$effIdx.'DamageMultiplier');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -346,9 +376,9 @@ class Spell extends BaseType
case 'h': // ProcChance
case 'H':
if ($lookup)
$base = $this->refSpells[$lookup]->template['procChance'];
$base = $this->refSpells[$lookup]->getField('procChance');
else
$base = $this->template['procChance'];
$base = $this->getField('procChance');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -357,9 +387,9 @@ class Spell extends BaseType
case 'i': // MaxAffectedTargets
case 'I':
if ($lookup)
$base = $this->refSpells[$lookup]->template['targets'];
$base = $this->refSpells[$lookup]->getField('targets');
else
$base = $this->template['targets'];
$base = $this->getField('targets');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -372,18 +402,18 @@ class Spell extends BaseType
case 'M': // BasePoints (maxValue)
if ($lookup)
{
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'BasePoints'];
$add = $this->refSpells[$lookup]->template['effect'.$effIdx.'DieSides'];
$mv = $this->refSpells[$lookup]->template['effect'.$effIdx.'MiscValue'];
$aura = $this->refSpells[$lookup]->template['effect'.$effIdx.'AuraId'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'BasePoints');
$add = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DieSides');
$mv = $this->refSpells[$lookup]->getField('effect'.$effIdx.'MiscValue');
$aura = $this->refSpells[$lookup]->getField('effect'.$effIdx.'AuraId');
}
else
{
$base = $this->template['effect'.$effIdx.'BasePoints'];
$add = $this->template['effect'.$effIdx.'DieSides'];
$mv = $this->template['effect'.$effIdx.'MiscValue'];
$aura = $this->template['effect'.$effIdx.'AuraId'];
$base = $this->getField('effect'.$effIdx.'BasePoints');
$add = $this->getField('effect'.$effIdx.'DieSides');
$mv = $this->getField('effect'.$effIdx.'MiscValue');
$aura = $this->getField('effect'.$effIdx.'AuraId');
}
if (ctype_lower($var))
@@ -419,9 +449,9 @@ class Spell extends BaseType
case 'n': // ProcCharges
case 'N':
if ($lookup)
$base = $this->refSpells[$lookup]->template['procCharges'];
$base = $this->refSpells[$lookup]->getField('procCharges');
else
$base = $this->template['procCharges'];
$base = $this->getField('procCharges');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -431,17 +461,17 @@ class Spell extends BaseType
case 'O':
if ($lookup)
{
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'BasePoints'];
$add = $this->refSpells[$lookup]->template['effect'.$effIdx.'DieSides'];
$periode = $this->refSpells[$lookup]->template['effect'.$effIdx.'Periode'];
$duration = $this->refSpells[$lookup]->template['duration'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'BasePoints');
$add = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DieSides');
$periode = $this->refSpells[$lookup]->getField('effect'.$effIdx.'Periode');
$duration = $this->refSpells[$lookup]->getField('duration');
}
else
{
$base = $this->template['effect'.$effIdx.'BasePoints'];
$add = $this->template['effect'.$effIdx.'DieSides'];
$periode = $this->template['effect'.$effIdx.'Periode'];
$duration = $this->template['duration'];
$base = $this->getField('effect'.$effIdx.'BasePoints');
$add = $this->getField('effect'.$effIdx.'DieSides');
$periode = $this->getField('effect'.$effIdx.'Periode');
$duration = $this->getField('duration');
}
if (!$periode)
@@ -453,9 +483,9 @@ class Spell extends BaseType
case 'q': // EffectMiscValue
case 'Q':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'MiscValue'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'MiscValue');
else
$base = $this->template['effect'.$effIdx.'MiscValue'];
$base = $this->getField('effect'.$effIdx.'MiscValue');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -464,9 +494,9 @@ class Spell extends BaseType
case 'r': // SpellRange
case 'R':
if ($lookup)
$base = $this->refSpells[$lookup]->template['rangeMaxHostile'];
$base = $this->refSpells[$lookup]->getField('rangeMaxHostile');
else
$base = $this->template['rangeMaxHostile'];
$base = $this->getField('rangeMaxHostile');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -476,17 +506,17 @@ class Spell extends BaseType
case 'S':
if ($lookup)
{
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'BasePoints'];
$add = $this->refSpells[$lookup]->template['effect'.$effIdx.'DieSides'];
$mv = $this->refSpells[$lookup]->template['effect'.$effIdx.'MiscValue'];
$aura = $this->refSpells[$lookup]->template['effect'.$effIdx.'AuraId'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'BasePoints');
$add = $this->refSpells[$lookup]->getField('effect'.$effIdx.'DieSides');
$mv = $this->refSpells[$lookup]->getField('effect'.$effIdx.'MiscValue');
$aura = $this->refSpells[$lookup]->getField('effect'.$effIdx.'AuraId');
}
else
{
$base = $this->template['effect'.$effIdx.'BasePoints'];
$add = $this->template['effect'.$effIdx.'DieSides'];
$mv = $this->template['effect'.$effIdx.'MiscValue'];
$aura = $this->template['effect'.$effIdx.'AuraId'];
$base = $this->getField('effect'.$effIdx.'BasePoints');
$add = $this->getField('effect'.$effIdx.'DieSides');
$mv = $this->getField('effect'.$effIdx.'MiscValue');
$aura = $this->getField('effect'.$effIdx.'AuraId');
}
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
@@ -517,9 +547,9 @@ class Spell extends BaseType
case 't': // Periode
case 'T':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'Periode'] / 1000;
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'Periode') / 1000;
else
$base = $this->template['effect'.$effIdx.'Periode'] / 1000;
$base = $this->getField('effect'.$effIdx.'Periode') / 1000;
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -528,9 +558,9 @@ class Spell extends BaseType
case 'u': // StackCount
case 'U':
if ($lookup)
$base = $this->refSpells[$lookup]->template['stackAmount'];
$base = $this->refSpells[$lookup]->getField('stackAmount');
else
$base = $this->template['stackAmount'];
$base = $this->getField('stackAmount');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -539,9 +569,9 @@ class Spell extends BaseType
case 'v': // MaxTargetLevel
case 'V':
if ($lookup)
$base = $this->refSpells[$lookup]->template['MaxTargetLevel'];
$base = $this->refSpells[$lookup]->getField('MaxTargetLevel');
else
$base = $this->template['MaxTargetLevel'];
$base = $this->getField('MaxTargetLevel');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -550,9 +580,9 @@ class Spell extends BaseType
case 'x': // ChainTargetCount
case 'X':
if ($lookup)
$base = $this->refSpells[$lookup]->template['effect'.$effIdx.'ChainTarget'];
$base = $this->refSpells[$lookup]->getField('effect'.$effIdx.'ChainTarget');
else
$base = $this->template['effect'.$effIdx.'ChainTarget'];
$base = $this->getField('effect'.$effIdx.'ChainTarget');
if (in_array($op, $signs) && is_numeric($oparg) && is_numeric($base))
eval("\$base = $base.$op.$oparg;");
@@ -640,6 +670,10 @@ class Spell extends BaseType
// although it seems to be pretty fast, even on those pesky test-spells with extra complex tooltips (Ron Test Spell X))
public function parseText($type = 'description', $level = MAX_LEVEL)
{
// oooo..kaaayy.. parsing text in 6 or 7 easy steps
// we don't use the internal iterator here. This func has to be called for the individual template.
// otherwise it will get a bit messy, when we iterate, while we iterate *yo dawg!*
/* documentation .. sort of
bracket use
${}.x - formulas; .x is optional; x:[0-9] .. max-precision of a floatpoint-result; default: 0
@@ -711,14 +745,14 @@ class Spell extends BaseType
// step 0: get text
$data = Util::localizedString($this->template, $type);
$data = Util::localizedString($this->curTpl, $type);
if (empty($data) || $data == "[]") // empty tooltip shouldn't be displayed anyway
return null;
// step 1: if the text is supplemented with text-variables, get and replace them
if (empty($this->spellVars[$this->Id]) && $this->template['spellDescriptionVariableId'] > 0)
if (empty($this->spellVars[$this->Id]) && $this->curTpl['spellDescriptionVariableId'] > 0)
{
$spellVars = DB::Aowow()->SelectCell('SELECT vars FROM ?_spellVariables WHERE id = ?d', $this->template['spellDescriptionVariableId']);
$spellVars = DB::Aowow()->SelectCell('SELECT vars FROM ?_spellVariables WHERE id = ?d', $this->curTpl['spellDescriptionVariableId']);
$spellVars = explode("\n", $spellVars);
foreach ($spellVars as $sv)
if (preg_match('/\$(\w*\d*)=(.*)/i', trim($sv), $matches))
@@ -906,19 +940,24 @@ class Spell extends BaseType
return $str;
}
public function getBuff()
public function renderBuff($Id = 0)
{
while ($this->iterate())
{
if ($Id && $this->Id != $Id)
continue;
// doesn't have a buff
if (!Util::localizedString($this->template, 'buff'))
if (!Util::localizedString($this->curTpl, 'buff'))
return '';
$x = '<table><tr>';
// spellName
$x .= '<td><b class="q">'.Util::localizedString($this->template, 'name').'</b></td>';
$x .= '<td><b class="q">'.Util::localizedString($this->curTpl, 'name').'</b></td>';
// dispelType (if applicable)
if ($dispel = Lang::$game['di'][$this->template['dispelType']])
if ($dispel = Lang::$game['di'][$this->curTpl['dispelType']])
$x .= '<th><b class="q">'.$dispel.'</b></th>';
$x .= '</tr></table>';
@@ -929,29 +968,35 @@ class Spell extends BaseType
$x .= $this->parseText('buff').'<br>';
// duration
if ($this->template['duration'])
$x .= '<span class="q">'.sprintf(Lang::$spell['remaining'], Util::formatTime($this->template['duration'])).'<span>';
if ($this->curTpl['duration'] > 0)
$x .= '<span class="q">'.sprintf(Lang::$spell['remaining'], Util::formatTime($this->curTpl['duration'])).'<span>';
$x .= '</td></tr></table>';
$this->buff = $x;
return $this->buff;
$this->buffs[$this->Id] = $x;
}
public function getTooltip()
return $Id ? $this->buffs[$Id] : true;
}
public function renderTooltip($Id = 0)
{
while ($this->iterate())
{
if ($Id && $this->Id != $Id)
continue;
// get reagents
$reagents = [];
for ($j = 1; $j <= 8; $j++)
{
if($this->template['reagent'.$j] <= 0)
if($this->curTpl['reagent'.$j] <= 0)
continue;
$reagents[] = array(
'id' => $this->template['reagent'.$j],
'name' => Item::getName($this->template['reagent'.$j]),
'count' => $this->template['reagentCount'.$j] // if < 0 : require, but don't use
'id' => $this->curTpl['reagent'.$j],
'name' => Util::getItemName($this->curTpl['reagent'.$j]),
'count' => $this->curTpl['reagentCount'.$j] // if < 0 : require, but don't use
);
}
$reagents = array_reverse($reagents);
@@ -961,13 +1006,13 @@ class Spell extends BaseType
for ($i = 1; $i <= 2; $i++)
{
// Tools
if ($this->template['tool'.$i])
$tools[$i-1] = array('itemId' => $this->template['tool'.$i], 'name' => Item::getName($this->template['tool'.$i]));
if ($this->curTpl['tool'.$i])
$tools[$i-1] = array('itemId' => $this->curTpl['tool'.$i], 'name' => Util::getItemName($this->curTpl['tool'.$i]));
// TotemCategory
if ($this->template['toolCategory'.$i])
if ($this->curTpl['toolCategory'.$i])
{
$tc = DB::Aowow()->selectRow('SELECT * FROM aowow_totemcategory WHERE id = ?d', $this->template['toolCategory'.$i]);
$tc = DB::Aowow()->selectRow('SELECT * FROM aowow_totemcategory WHERE id = ?d', $this->curTpl['toolCategory'.$i]);
$tools[$i+1] = array('categoryMask' => $tc['categoryMask'], 'name' => Util::localizedString($tc, 'name'));
}
}
@@ -976,19 +1021,19 @@ class Spell extends BaseType
// get description
$desc = $this->parseText('description');
$reqWrapper = $this->template['rangeMaxHostile'] && ($this->template['powerCost'] > 0 || $this->template['powerCostPercent'] > 0);
$reqWrapper = $this->curTpl['rangeMaxHostile'] && ($this->curTpl['powerCost'] > 0 || $this->curTpl['powerCostPercent'] > 0);
$reqWrapper2 = $reagents ||$tools || $desc;
$x = '';
$x .= '<table><tr><td>';
$rankText = Util::localizedString($this->template, 'rank');
$rankText = Util::localizedString($this->curTpl, 'rank');
if (!empty($rankText))
$x .= '<table width="100%"><tr><td>';
// name
$x .= '<b>'.Util::localizedString($this->template, 'name').'</b>';
$x .= '<b>'.$this->names[$this->Id].'</b>';
// rank
if (!empty($rankText))
@@ -999,21 +1044,21 @@ class Spell extends BaseType
$x .= '<table width="100%"><tr><td>';
// check for custom PowerDisplay
$pt = $this->template['powerDisplayString'] ? $this->template['powerDisplayString'] : $this->template['powerType'];
$pt = $this->curTpl['powerDisplayString'] ? $this->curTpl['powerDisplayString'] : $this->curTpl['powerType'];
// power cost: pct over static
if ($this->template['powerCostPercent'] > 0)
$x .= $this->template['powerCostPercent']."% ".sprintf(Lang::$spell['pctCostOf'], strtolower(Lang::$spell['powerTypes'][$pt]));
else if ($this->template['powerCost'] > 0 || $this->template['powerPerSecond'] > 0 || $this->template['powerCostPerLevel'] > 0)
$x .= ($pt == 1 ? $this->template['powerCost'] / 10 : $this->template['powerCost']).' '.ucFirst(Lang::$spell['powerTypes'][$pt]);
if ($this->curTpl['powerCostPercent'] > 0)
$x .= $this->curTpl['powerCostPercent']."% ".sprintf(Lang::$spell['pctCostOf'], strtolower(Lang::$spell['powerTypes'][$pt]));
else if ($this->curTpl['powerCost'] > 0 || $this->curTpl['powerPerSecond'] > 0 || $this->curTpl['powerCostPerLevel'] > 0)
$x .= ($pt == 1 ? $this->curTpl['powerCost'] / 10 : $this->curTpl['powerCost']).' '.ucFirst(Lang::$spell['powerTypes'][$pt]);
// append periodic cost
if ($this->template['powerPerSecond'] > 0)
$x .= sprintf(Lang::$spell['costPerSec'], $this->template['powerPerSecond']);
if ($this->curTpl['powerPerSecond'] > 0)
$x .= sprintf(Lang::$spell['costPerSec'], $this->curTpl['powerPerSecond']);
// append level cost
if ($this->template['powerCostPerLevel'] > 0)
$x .= sprintf(Lang::$spell['costPerLevel'], $this->template['powerCostPerLevel']);
if ($this->curTpl['powerCostPerLevel'] > 0)
$x .= sprintf(Lang::$spell['costPerLevel'], $this->curTpl['powerCostPerLevel']);
$x .= '<br />';
@@ -1021,20 +1066,20 @@ class Spell extends BaseType
$x .= '</td><th>';
// ranges
if ($this->template['rangeMaxHostile'])
if ($this->curTpl['rangeMaxHostile'])
{
// minRange exists; show as range
if ($this->template['rangeMinHostile'])
$x .= sprintf(Lang::$spell['range'], $this->template['rangeMinHostile'].' - '.$this->template['rangeMaxHostile']).'<br />';
if ($this->curTpl['rangeMinHostile'])
$x .= sprintf(Lang::$spell['range'], $this->curTpl['rangeMinHostile'].' - '.$this->curTpl['rangeMaxHostile']).'<br />';
// friend and hostile differ; do color
else if ($this->template['rangeMaxHostile'] != $this->template['rangeMaxFriend'])
$x .= sprintf(Lang::$spell['range'], '<span class="q10">'.$this->template['rangeMaxHostile'].'</span> - <span class="q2">'.$this->template['rangeMaxHostile']. '</span>').'<br />';
else if ($this->curTpl['rangeMaxHostile'] != $this->curTpl['rangeMaxFriend'])
$x .= sprintf(Lang::$spell['range'], '<span class="q10">'.$this->curTpl['rangeMaxHostile'].'</span> - <span class="q2">'.$this->curTpl['rangeMaxHostile']. '</span>').'<br />';
// hardcode: "melee range"
else if ($this->template['rangeMaxHostile'] == 5)
else if ($this->curTpl['rangeMaxHostile'] == 5)
$x .= Lang::$spell['meleeRange'].'<br />';
// regular case
else
$x .= sprintf(Lang::$spell['range'], $this->template['rangeMaxHostile']).'<br />';
$x .= sprintf(Lang::$spell['range'], $this->curTpl['rangeMaxHostile']).'<br />';
}
if ($reqWrapper)
@@ -1043,11 +1088,11 @@ class Spell extends BaseType
$x .= '<table width="100%"><tr><td>';
// cast times
if ($this->template['interruptFlagsChannel'])
if ($this->curTpl['interruptFlagsChannel'])
$x .= Lang::$spell['channeled'];
else if ($this->template['castTime'])
$x .= sprintf(Lang::$spell['castIn'], $this->template['castTime'] / 1000);
else if ($this->template['attributes0'] & 0x10) // SPELL_ATTR0_ABILITY instant ability.. yeah, wording thing only
else if ($this->curTpl['castTime'])
$x .= sprintf(Lang::$spell['castIn'], $this->curTpl['castTime'] / 1000);
else if ($this->curTpl['attributes0'] & 0x10) // SPELL_ATTR0_ABILITY instant ability.. yeah, wording thing only
$x .= Lang::$spell['instantPhys'];
else // instant cast
$x .= Lang::$spell['instantMagic'];
@@ -1055,15 +1100,15 @@ class Spell extends BaseType
$x .= '</td>';
// cooldown or categorycooldown
if ($this->template['recoveryTime'])
$x.= '<th>'.sprintf(Lang::$game['cooldown'], Util::formatTime($this->template['recoveryTime'], true)).'</th>';
else if ($this->template['recoveryCategory'])
$x.= '<th>'.sprintf(Lang::$game['cooldown'], Util::formatTime($this->template['recoveryCategory'], true)).'</th>';
if ($this->curTpl['recoveryTime'])
$x.= '<th>'.sprintf(Lang::$game['cooldown'], Util::formatTime($this->curTpl['recoveryTime'], true)).'</th>';
else if ($this->curTpl['recoveryCategory'])
$x.= '<th>'.sprintf(Lang::$game['cooldown'], Util::formatTime($this->curTpl['recoveryCategory'], true)).'</th>';
$x .= '</tr>';
if ($this->template['stanceMask'])
$x.= '<tr><td colspan="2">'.Lang::$game['requires'].' '.Lang::getStances($this->template['stanceMask']).'</td></tr>';
if ($this->curTpl['stanceMask'])
$x.= '<tr><td colspan="2">'.Lang::$game['requires'].' '.Lang::getStances($this->curTpl['stanceMask']).'</td></tr>';
$x .= '</table>';
$x .= '</td></tr></table>';
@@ -1116,60 +1161,61 @@ class Spell extends BaseType
if ($reqWrapper2)
$x .= "</table>";
$this->tooltip = $x;
return $this->tooltip;
$this->tooltips[$this->Id] = $x;
}
public function getTalentHead()
return $Id ? $this->tooltips[$Id] : true;
}
public function getTalentHeadForCurrent()
{
// upper: cost :: range
// lower: time :: cool
// lower: time :: cooldown
$x = '';
// power cost: pct over static
$cost = '';
if ($this->template['powerCostPercent'] > 0)
$cost .= $this->template['powerCostPercent']."% ".sprintf(Lang::$spell['pctCostOf'], strtolower(Lang::$spell['powerTypes'][$this->template['powerType']]));
else if ($this->template['powerCost'] > 0 || $this->template['powerPerSecond'] > 0 || $this->template['powerCostPerLevel'] > 0)
$cost .= ($this->template['powerType'] == 1 ? $this->template['powerCost'] / 10 : $this->template['powerCost']).' '.ucFirst(Lang::$spell['powerTypes'][$this->template['powerType']]);
if ($this->curTpl['powerCostPercent'] > 0)
$cost .= $this->curTpl['powerCostPercent']."% ".sprintf(Lang::$spell['pctCostOf'], strtolower(Lang::$spell['powerTypes'][$this->curTpl['powerType']]));
else if ($this->curTpl['powerCost'] > 0 || $this->curTpl['powerPerSecond'] > 0 || $this->curTpl['powerCostPerLevel'] > 0)
$cost .= ($this->curTpl['powerType'] == 1 ? $this->curTpl['powerCost'] / 10 : $this->curTpl['powerCost']).' '.ucFirst(Lang::$spell['powerTypes'][$this->curTpl['powerType']]);
// append periodic cost
if ($this->template['powerPerSecond'] > 0)
$cost .= sprintf(Lang::$spell['costPerSec'], $this->template['powerPerSecond']);
if ($this->curTpl['powerPerSecond'] > 0)
$cost .= sprintf(Lang::$spell['costPerSec'], $this->curTpl['powerPerSecond']);
// append level cost
if ($this->template['powerCostPerLevel'] > 0)
$cost .= sprintf(Lang::$spell['costPerLevel'], $this->template['powerCostPerLevel']);
if ($this->curTpl['powerCostPerLevel'] > 0)
$cost .= sprintf(Lang::$spell['costPerLevel'], $this->curTpl['powerCostPerLevel']);
// ranges
$range = '';
if ($this->template['rangeMaxHostile'])
if ($this->curTpl['rangeMaxHostile'])
{
// minRange exists; show as range
if ($this->template['rangeMinHostile'])
$range .= sprintf(Lang::$spell['range'], $this->template['rangeMinHostile'].' - '.$this->template['rangeMaxHostile']);
if ($this->curTpl['rangeMinHostile'])
$range .= sprintf(Lang::$spell['range'], $this->curTpl['rangeMinHostile'].' - '.$this->curTpl['rangeMaxHostile']);
// friend and hostile differ; do color
else if ($this->template['rangeMaxHostile'] != $this->template['rangeMaxFriend'])
$range .= sprintf(Lang::$spell['range'], '<span class="q10">'.$this->template['rangeMaxHostile'].'</span> - <span class="q2">'.$this->template['rangeMaxHostile']. '</span>');
else if ($this->curTpl['rangeMaxHostile'] != $this->curTpl['rangeMaxFriend'])
$range .= sprintf(Lang::$spell['range'], '<span class="q10">'.$this->curTpl['rangeMaxHostile'].'</span> - <span class="q2">'.$this->curTpl['rangeMaxHostile']. '</span>');
// hardcode: "melee range"
else if ($this->template['rangeMaxHostile'] == 5)
else if ($this->curTpl['rangeMaxHostile'] == 5)
$range .= Lang::$spell['meleeRange'];
// regular case
else
$range .= sprintf(Lang::$spell['range'], $this->template['rangeMaxHostile']);
$range .= sprintf(Lang::$spell['range'], $this->curTpl['rangeMaxHostile']);
}
// cast times
$time = '';
if ($this->template['interruptFlagsChannel'])
if ($this->curTpl['interruptFlagsChannel'])
$time .= Lang::$spell['channeled'];
else if ($this->template['castTime'])
$time .= sprintf(Lang::$spell['castIn'], $this->template['castTime'] / 1000);
else if ($this->template['attributes0'] & 0x10) // SPELL_ATTR0_ABILITY instant ability.. yeah, wording thing only
else if ($this->curTpl['castTime'])
$time .= sprintf(Lang::$spell['castIn'], $this->curTpl['castTime'] / 1000);
else if ($this->curTpl['attributes0'] & 0x10) // SPELL_ATTR0_ABILITY instant ability.. yeah, wording thing only
$time .= Lang::$spell['instantPhys'];
else // instant cast
$time .= Lang::$spell['instantMagic'];
@@ -1177,10 +1223,10 @@ class Spell extends BaseType
// cooldown or categorycooldown
$cool = '';
if ($this->template['recoveryTime'])
$cool.= sprintf(Lang::$game['cooldown'], Util::formatTime($this->template['recoveryTime'], true)).'</th>';
else if ($this->template['recoveryCategory'])
$cool.= sprintf(Lang::$game['cooldown'], Util::formatTime($this->template['recoveryCategory'], true)).'</th>';
if ($this->curTpl['recoveryTime'])
$cool.= sprintf(Lang::$game['cooldown'], Util::formatTime($this->curTpl['recoveryTime'], true)).'</th>';
else if ($this->curTpl['recoveryCategory'])
$cool.= sprintf(Lang::$game['cooldown'], Util::formatTime($this->curTpl['recoveryCategory'], true)).'</th>';
// assemble parts
@@ -1209,48 +1255,39 @@ class Spell extends BaseType
public function getListviewData()
{
return array(
'id' => $this->Id,
'name' => Util::localizedString($this->template, 'name'),
// this is going to be .. ""fun""
$data = [];
while ($this->iterate())
{
$data[$this->Id] = array(
'name' => $this->names[$this->Id],
'icon' => $this->curTpl['iconString'],
'level' => $this->curTpl['baseLevel'],
);
}
public function addGlobalsToJScript(&$gSpells)
{
// if the spell creates an item use the itemIcon instead
if ($this->template['effect1CreateItemId'])
{
$item = new Item($this->template['effect1CreateItemId']);
$iconString = $item->template['icon'];
return $data;
}
else
$iconString = $this->template['iconString'];
$gSpells[$this->Id] = array(
'icon' => $iconString,
'name' => Util::localizedString($this->template, 'name'),
public function addGlobalsToJscript(&$refs)
{
if (!isset($refs['gSpells']))
$refs['gSpells'] = [];
while ($this->iterate())
{
$iconString = isset($this->curTpl['createItemString']) ? 'createItemString' : 'iconString';
$refs['gSpells'][$this->Id] = array(
'icon' => $this->curTpl[$iconString],
'name' => $this->names[$this->Id],
);
}
}
class SpellList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_spell WHERE [filter] [cond] GROUP BY id';
public function __construct($conditions)
{
// may be called without filtering
if (class_exists('SpellFilter'))
{
$this->filter = new SpellFilter();
if (($fiData = $this->filter->init()) === false)
return;
}
parent::__construct($conditions);
}
public function addRewardsToJScript(&$refs) { }
}
?>

View File

@@ -3,73 +3,135 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class Title extends BaseType
class TitleList extends BaseType
{
public $name = [];
public $source = [];
private $sources = [];
protected $setupQuery = "SELECT * FROM ?_titles WHERE `Id` = ?";
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]';
public function __construct($data)
{
parent::__construct($data);
// post processing
$this->name[GENDER_MALE] = Util::localizedString($this->template, 'male');
if ($this->template['female_loc0'] || $this->template['female_loc'.User::$localeId])
$this->name[GENDER_FEMALE] = Util::localizedString($this->template, 'female');
while ($this->iterate())
{
// overwrite names with gender-speciffics
$this->names[$this->Id][GENDER_MALE] = Util::localizedString($this->curTpl, 'male');
if ($this->curTpl['female_loc0'] || $this->curTpl['female_loc'.User::$localeId])
$this->names[$this->Id][GENDER_FEMALE] = Util::localizedString($this->curTpl, 'female');
// preparse sources
if (!empty($this->template['source']))
if (!empty($this->curTpl['source']))
{
$sources = explode(' ', $this->template['source']);
$sources = explode(' ', $this->curTpl['source']);
foreach ($sources as $src)
{
$src = explode(':', $src);
$this->source[$src[0]][] = $src[1];
$this->sources[$this->Id][$src[0]][] = $src[1];
}
}
}
}
public function getListviewData()
{
$data = array(
'id' => $this->Id,
'name' => $this->name[GENDER_MALE],
'side' => $this->template['side'],
'gender' => $this->template['gender'],
'expansion' => $this->template['expansion'],
'category' => $this->template['category'],
'source' => $this->source
$data = [];
$this->createSource();
while ($this->iterate())
{
$data[$this->Id] = array(
'Id' => $this->Id,
'name' => $this->names[$this->Id][GENDER_MALE],
'side' => $this->curTpl['side'],
'gender' => $this->curTpl['gender'],
'expansion' => $this->curTpl['expansion'],
'category' => $this->curTpl['category']
);
if (!empty($this->curTpl['source']))
$data[$this->Id]['source'] = $this->curTpl['source'];
}
if (isset($this->name[GENDER_FEMALE]))
$data['namefemale'] = $this->name[GENDER_FEMALE];
return $data;
}
public function addGlobalsToJScript(&$gTitles)
public function addGlobalsToJscript(&$refs)
{
$gTitles[$this->Id] = ['name' => Util::jsEscape($this->name[GENDER_MALE])];
if (!isset($refs['gTitles']))
$refs['gTitles'] = [];
if (isset($this->name[GENDER_FEMALE]))
$gTitles[$this->Id]['namefemale'] = Util::jsEscape($this->name[GENDER_FEMALE]);
while ($this->iterate())
{
$refs['gTitles'][$this->Id]['name'] = Util::jsEscape($this->names[$this->Id][GENDER_MALE]);
return true;
if (isset($this->names[$this->Id][GENDER_FEMALE]))
$refs['gTitles'][$this->Id]['namefemale'] = Util::jsEscape($this->names[$this->Id][GENDER_FEMALE]);
}
}
private function createSource()
{
$sources = array(
4 => [], // Quest
12 => [], // Achievements
13 => [] // simple text
);
while ($this->iterate())
{
if (empty($this->sources[$this->Id]))
continue;
foreach (array_keys($sources) as $srcKey)
if (isset($this->sources[$this->Id][$srcKey]))
$sources[$srcKey] = array_merge($sources[$srcKey], $this->sources[$this->Id][$srcKey]);
}
// fill in the details
if (!empty($sources[4]))
$sources[4] = (new QuestList(array(['Id', $sources[4]])))->getSourceData();
if (!empty($sources[12]))
$sources[12] = (new AchievementList(array(['Id', $sources[12]])))->getSourceData();
if (!empty($sources[13]))
$sources[13] = DB::Aowow()->SELECT('SELECT *, Id AS ARRAY_KEY FROM ?_sourceStrings WHERE Id IN (?a)', $sources[13]);
foreach ($this->sources as $Id => $src)
{
$tmp = [];
// Quest-source
if (isset($src[4]))
foreach ($src[4] as $s)
$tmp[4][] = $sources[4][$s];
// Achievement-source
if (isset($src[12]))
foreach ($src[12] as $s)
$tmp[12][] = $sources[12][$s];
// other source (only one item possible, so no iteration needed)
if (isset($src[13]))
$tmp[13] = [Util::localizedString($sources[13][$this->sources[$Id][13][0]], 'source')];
$this->templates[$Id]['source'] = json_encode($tmp);
}
}
public function getHtmlizedName($gender = GENDER_MALE)
{
return str_replace('%s', '<span class="q0">&lt;Name&gt;</span>', $this->name[$gender]);
}
return str_replace('%s', '<span class="q0">&lt;'.Lang::$main['name'].'&gt;</span>', $this->name[$gender]);
}
class TitleList extends BaseTypeList
{
protected $setupQuery = 'SELECT *, Id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
public function addRewardsToJScript(&$ref) { }
public function renderTooltip() { }
}
?>

View File

@@ -3,7 +3,7 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
class WorldEvent
class WorldEvent extends BaseType
{
public static function getName($id)

View File

@@ -19,7 +19,7 @@ define('TYPE_FACTION', 8);
define('TYPE_PET', 9);
define('TYPE_ACHIEVEMENT', 10);
define('TYPE_TITLE', 11);
define('TYPE_EVENT', 12);
define('TYPE_WORLDEVENT', 12);
define('TYPE_CLASS', 13);
define('TYPE_RACE', 14);
define('TYPE_SKILL', 15);
@@ -33,8 +33,8 @@ define('CACHETYPE_SEARCH', 3);
define('SEARCH_TYPE_REGULAR', 0x10000000);
define('SEARCH_TYPE_OPEN', 0x20000000);
define('SEARCH_TYPE_JSON', 0x40000000);
define('SEARCH_MASK_OPEN', 0x03FFFFFF);
define('SEARCH_MASK_ALL', 0x03FFFFFF);
define('SEARCH_MASK_OPEN', 0x017F807F); // open search
define('SEARCH_MASK_ALL', 0x07FFFFFF); // normal search
// Databases
define('DB_AOWOW', 0);
@@ -94,6 +94,12 @@ define('LOCALE_DE', 3);
define('LOCALE_ES', 6);
define('LOCALE_RU', 8);
// Additional info in item-listviews
define('ITEMINFO_JSON', 0x1);
define('ITEMINFO_SUBITEMS', 0x2);
define('ITEMINFO_VENDOR', 0x4);
define('ITEMINFO_LOOT', 0x8);
/*
* Game
*/
@@ -185,6 +191,7 @@ define('SPELL_SCHOOL_NATURE', 3);
define('SPELL_SCHOOL_FROST', 4);
define('SPELL_SCHOOL_SHADOW', 5);
define('SPELL_SCHOOL_ARCANE', 6);
define('SPELL_ALL_SCHOOLS', 0x7F);
// CharacterSlot
define('SLOT_HEAD', 0);

View File

@@ -20,7 +20,7 @@ require 'includes/class.database.php';
// autoload any List-Classes
spl_autoload_register(function ($class) {
if (!strpos($class, 'Mysql') && !strpos($class, 'Filter'))
if (strpos($class, 'List'))
require 'includes/class.'.strtr($class, ['List' => '']).'.php';
});
@@ -93,7 +93,7 @@ class Smarty_AoWoW extends Smarty
if (!$cache)
return false;
$cache = explode("\n", $cache, 2);
$cache = explode("\n", $cache);
@list($time, $rev) = explode(' ', $cache[0]);
$expireTime = $time + $this->config['page']['cacheTimer'];

View File

@@ -3,48 +3,19 @@
if (!defined('AOWOW_REVISION'))
die('invalid access');
class BaseType
abstract class BaseType
{
public $template = null;
public $names = [];
public $Id = 0;
public $matches = 0; // total matches unaffected by sqlLimit in config
public $error = true;
protected $templates = [];
protected $curTpl = []; // lets iterate!
protected $filter = null;
protected $setupQuery = '';
public function __construct($data)
{
if (!$this->setupQuery)
return false;
if (is_array($data))
$this->template = $data;
else
$this->template = DB::Aowow()->SelectRow($this->setupQuery, intVal($data));
if (empty($this->template))
{
$this->template = null;
return false;
}
$this->Id = isset($this->template['Id']) ? (int)$this->template['Id'] : (int)$this->template['entry'];
}
// should return data required to display a listview of any kind
public function getListviewData() { }
// should return data to extend global js variables for a certain type (e.g. g_items)
public function addGlobalsToJScript(&$ref) { }
// should return data to extend global js variables for the rewards provided by this type (e.g. g_titles)
public function addRewardsToJscript(&$ref1, &$ref2 = null, &$ref3 = null) { }
}
class BaseTypeList
{
public $container = [];
public $filter = null;
protected $setupQuery = '';
protected $matchQuery = '';
/*
* condition as array [field, value, operator]
@@ -56,19 +27,34 @@ class BaseTypeList
* ! - negated default value (NOT LIKE; <>; NOT IN)
* condition as str
* defines linking (AND || OR)
* condition as int
* defines LIMIT
*
* example:
* array(['id', 45], ['name', 'test', '!'], 'OR')
* array(['id', 45], ['name', 'test', '!'], 'OR', 5)
* results in
* WHERE id = 45 OR name NOT LIKE %test%;
* WHERE id = 45 OR name NOT LIKE %test% LIMIT 5;
*/
public function __construct($conditions)
public function __construct($conditions = [])
{
if (!$this->setupQuery)
return false;
global $AoWoWconf; // yes i hate myself..
$sql = [];
$linking = ' AND ';
$limit = ' LIMIT '.$AoWoWconf['sqlLimit'];
$className = strtr(get_class($this), ['List' => '']);
if (!$this->setupQuery || !$this->matchQuery)
return;
// may be called without filtering
if (class_exists($className.'Filter'))
{
$fiName = $className.'Filter';
$this->filter = new $fiName();
if ($this->filter->init() === false)
return;
}
foreach ($conditions as $c)
{
@@ -90,6 +76,9 @@ class BaseTypeList
else
continue;
if (isset($c[2]) && $c[2] != '!')
$op = $c[2];
if (is_array($c[1]))
{
$op = (isset($c[2]) && $c[2] == '!') ? 'NOT IN' : 'IN';
@@ -109,14 +98,12 @@ class BaseTypeList
else
continue;
if (isset($c[2]) && $c[2] != '!')
$op = $c[2];
$sql[] = $field.' '.$op.' '.$val;
}
else if (is_string($c))
$linking = $c == 'OR' ? ' OR ' : ' AND ';
else
$linking = $c == 'AND' ? ' AND ' : ' OR ';
else if (is_int($c))
$limit = $c > 0 ? ' LIMIT '.$c : '';
continue; // ignore other possibilities
}
@@ -124,37 +111,71 @@ class BaseTypeList
// todo: add strings propperly without them being escaped by simpleDB..?
$this->setupQuery = str_replace('[filter]', $this->filter && $this->filter->buildFilterQuery() ? $this->filter->query.' AND ' : NULL, $this->setupQuery);
$this->setupQuery = str_replace('[cond]', empty($sql) ? '1' : '('.implode($linking, $sql).')', $this->setupQuery);
$this->setupQuery .= $limit;
$this->matchQuery = str_replace('[filter]', $this->filter && $this->filter->buildFilterQuery() ? $this->filter->query.' AND ' : NULL, $this->matchQuery);
$this->matchQuery = str_replace('[cond]', empty($sql) ? '1' : '('.implode($linking, $sql).')', $this->matchQuery);
$rows = DB::Aowow()->Select($this->setupQuery);
$className = str_replace('List', '', get_class($this));
if (!$rows)
return;
foreach ($rows as $k => $row)
$this->container[$k] = new $className($row); // free dirty mindfuck galore here...
}
$this->matches = DB::Aowow()->SelectCell($this->matchQuery);
public function getListviewData()
foreach ($rows as $k => $tpl)
{
$data = [];
// no extra queries required, just call recursively
foreach ($this->container as $type)
$data[] = $type->getListviewData();
return $data;
$this->names[$k] = Util::localizedString($tpl, Util::getNameFieldName($tpl));
$this->templates[$k] = $tpl;
}
public function addGlobalsToJScript(&$ref)
$this->reset();
$this->error = false;
}
public function iterate($qty = 1)
{
// no extra queries required, just call recursively
foreach ($this->container as $type)
$type->addGlobalsToJScript($ref);
if (!$this->curTpl) // exceeded end of line .. array .. in last iteration
reset($this->templates);
$this->curTpl = current($this->templates);
$field = $this->curTpl ? Util::getIdFieldName($this->curTpl) : null;
$this->Id = $this->curTpl ? $this->curTpl[$field] : 0;
while ($qty--)
next($this->templates);
return $this->Id;
}
public function addRewardsToJScript(&$ref1, &$ref2 = null, &$ref3 = null)
public function reset()
{
// no extra queries required, just call recursively
foreach ($this->container as $type)
$type->addRewardsToJScript($ref1, $ref2, $ref3);
$this->curTpl = reset($this->templates);
$this->Id = $this->curTpl[Util::getIdFieldName($this->curTpl)];
}
// read-access to templates
public function getField($field)
{
if (!$this->curTpl || !isset($this->curTpl[$field]))
return null;
return $this->curTpl[$field];
}
// should return data required to display a listview of any kind
// this is a rudimentary example, that will not suffice for most Types
abstract public function getListviewData();
// should return data to extend global js variables for a certain type (e.g. g_items)
abstract public function addGlobalsToJScript(&$ref);
// should return data to extend global js variables for the rewards provided by this type (e.g. g_titles)
// rewards will not always be required and only by Achievement and Quest .. but yeah.. maybe it should be merged with addGlobalsToJScript
abstract public function addRewardsToJScript(&$ref);
// NPC, GO, Item, Quest, Spell, Achievement, Profile would require this
abstract public function renderTooltip();
}
class Lang
@@ -234,7 +255,7 @@ class Lang
public static function getMagicSchools($schoolMask)
{
$schoolMask &= 0x7F; // clamp to available schools..
$schoolMask &= SPELL_ALL_SCHOOLS; // clamp to available schools..
$tmp = [];
$i = 1;
@@ -335,7 +356,7 @@ class Util
'enus', null, 'frfr', 'dede', null, null, 'eses', null, 'ruru'
);
private static $typeStrings = array( // zero-indexed
public static $typeStrings = array( // zero-indexed
null, 'npc', 'object', 'item', 'itemset', 'quest', 'spell', 'zone', 'faction',
'pet', 'achievement', 'title', 'event', 'class', 'race', 'skill', null, 'currency'
);
@@ -1055,10 +1076,10 @@ class Util
return strtr(trim($string), array(
'\\' => '\\\\',
"'" => "\\'",
'"' => '\\"',
// '"' => '\\"',
"\r" => '\\r',
"\n" => '\\n',
'</' => '<\/',
// '</' => '<\/',
));
}
@@ -1070,7 +1091,7 @@ class Util
if (!empty($data[$field.'_loc'.User::$localeId]))
return $data[$field.'_loc'.User::$localeId];
// locale not enUS; aowow-type localization available
// locale not enUS; aowow-type localization available; add brackets
else if (User::$localeId != LOCALE_EN && isset($data[$field.'_loc0']) && !empty($data[$field.'_loc0']))
return '['.$data[$field.'_loc0'].']';
@@ -1124,7 +1145,7 @@ class Util
return sprintf(Lang::$item['ratingString'], '<!--rtg%'.$type.'-->' . $result, '<!--lvl-->' . $level);
}
public static function powerUseLocale($domain)
public static function powerUseLocale($domain = 'www')
{
foreach (Util::$localeStrings as $k => $v)
{
@@ -1138,7 +1159,6 @@ class Util
if ($domain == 'www')
{
/* todo: dont .. should use locale given by inclusion of aowowPower .. should be fixed in aowowPower.js */
User::useLocale(LOCALE_EN);
Lang::load(User::$localeString);
}
@@ -1172,8 +1192,9 @@ class Util
break;
case 3:
case 7:
$spl = new Spell($enchant['object'.$h]);
$spl = new SpellList(array(['Id', (int)$enchant['object'.$h]]));
$gain = $spl->getStatGain();
foreach ($gain as $k => $v) // array_merge screws up somehow...
@$jsonStats[$k] += $v;
break;
@@ -1219,6 +1240,35 @@ class Util
return $return;
}
// BaseType::_construct craaap!
// todo: unify names
public static function getNameFieldName($tpl)
{
if (isset($tpl['name']) || isset($tpl['name_loc0']))
return 'name';
else if (isset($tpl['title']) || isset($tpl['title_loc0']))
return 'title';
else if (isset($tpl['male']) || isset($tpl['male_loc']))
return 'male';
else
return null;
}
// BaseType::iterate craaaaaaaaap!!!
// todo: unify indizes
public static function getIdFieldName($tpl)
{
if (isset($tpl['entry']))
return 'entry';
else if (isset($tpl['Id']))
return 'Id';
else if (isset($tpl['ID']))
return 'ID';
else
return null;
}
}
?>

View File

@@ -96,12 +96,12 @@ if ($_type & 0x18) { // 3 | 4
$iList = new ItemList($conditions);
$items = [];
foreach ($iList->container as $id => $item)
while ($iList->iterate())
{
$item->getJsonStats($pieceAssoc);
$iList->extendJsonStats($pieceAssoc);
$stats = [];
foreach ($item->json as $k => $v)
foreach ($iList->json[$iList->Id] as $k => $v)
{
if (!$v && $k != 'classs' && $k != 'subclass')
continue;
@@ -109,10 +109,10 @@ if ($_type & 0x18) { // 3 | 4
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
}
foreach ($item->itemMods as $k => $v)
foreach ($iList->itemMods[$iList->Id] as $k => $v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$v.'';
$items[$id] = "\t{".implode(',', $stats)."}";
$items[$iList->Id] = "\t{".implode(',', $stats)."}";
}
echo implode(",\n", $items)."\n],[\n";

View File

@@ -97,7 +97,8 @@ function signin()
function signup()
{
/* $username = Get(GET_STRING, 'username', 'POST');
/*
$username = Get(GET_STRING, 'username', 'POST');
$password = Get(GET_STRING, 'password', 'POST');
$pwd2 = Get(GET_STRING, 'password2', 'POST');
$email = Get(GET_STRING, 'email', 'POST');

View File

@@ -4,8 +4,8 @@ if (!defined('AOWOW_REVISION'))
die('invalid access');
$pageData = array(
'summary' => '[]',
'items' => []
'items' => null,
'summary' => '[]'
);
$compareString = '';
@@ -48,22 +48,23 @@ if ($compareString)
$pageData['summary'] = "[".implode(',', $outSet)."]";
$iList = new ItemList(array(['i.entry', $items]));
foreach ($iList->container as $item)
while ($iList->iterate())
{
$item->getJsonStats();
$iList->extendJsonStats();
$stats = [];
foreach ($item->json as $k => $v)
foreach ($iList->json[$iList->Id] as $k => $v)
$stats[] = is_numeric($v) || $v[0] == "{" ? '"'.$k.'":'.$v.'' : '"'.$k.'":"'.$v.'"';
foreach ($item->itemMods as $k => $v)
foreach ($iList->itemMods[$iList->Id] as $k => $v)
if ($v)
$stats[] = '"'.Util::$itemMods[$k].'":'.$v;
$pageData['items'][] = [
$item->Id,
Util::jsEscape(Util::localizedString($item->template, 'name')),
$item->template['Quality'],
$item->template['icon'],
$iList->Id,
Util::jsEscape($iList->names[$iList->Id]),
$iList->getField('Quality'),
$iList->getField('icon'),
"{".implode(",", $stats)."}"
];
}

View File

@@ -11,20 +11,18 @@ if (!defined('AOWOW_REVISION'))
// require 'includes/class.community.php'; // wo dont need those .. yet
$id = intVal($pageParam);
$item = new Item($id);
$item = new ItemList(array(['i.entry', $id]));
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_ITEM, $id, -1, User::$localeId]);
if (isset($_GET['xml']))
{
// output item info as xml
// why should i implement this..?
}
else if (isset($_GET['power']))
die('unsupported, as i do not see the point');
if (isset($_GET['power']))
{
header('Content-type: application/x-javascript; charsetUTF-8');
Util::powerUseLocale($_GET['domain']);
Util::powerUseLocale(@$_GET['domain']);
$enh = [];
$itemString = $id;
@@ -50,21 +48,20 @@ else if (isset($_GET['power']))
$itemString .= 's';
}
// : are not accepted in filenames
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_ITEM, str_replace(':', ',', $itemString), -1, User::$localeId]);
// output json for tooltips
if (!$smarty->loadCache($cacheKeyTooltip, $x))
{
if (!$item->template)
if ($item->error)
die('$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.', {})');
$item->createTooltip($enh);
$item->renderTooltip($enh);
$x .= '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.", {\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($item->name)."',\n";
$x .= "\tquality: ".$item->template['Quality'].",\n";
$x .= "\ticon: '".Util::jsEscape($item->template['icon'])."',\n";
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($item->tooltip)."'\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($item->names[$item->Id])."',\n";
$x .= "\tquality: ".$item->getField('Quality').",\n";
$x .= "\ticon: '".Util::jsEscape($item->getField('icon'))."',\n";
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($item->tooltip[$item->Id])."'\n";
$x .= "});";
$smarty->saveCache($cacheKeyTooltip, $x);

View File

@@ -8,33 +8,33 @@ if (!defined('AOWOW_REVISION'))
// require 'includes/allquests.php';
// require 'includes/class.community.php'; // not needed .. yet
$id = intVal($pageParam);
$spell = new Spell($id);
$Id = intVal($pageParam);
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_SPELL, $id, -1, User::$localeId]);
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_SPELL, $id, -1, User::$localeId]);
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_SPELL, $Id, -1, User::$localeId]);
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_SPELL, $Id, -1, User::$localeId]);
if (isset($_GET['power']))
{
header('Content-type: application/x-javascript; charsetUTF-8');
Util::powerUseLocale($_GET['domain']);
Util::powerUseLocale(@$_GET['domain']);
if (!$smarty->loadCache($cacheKeyTooltip, $x))
{
$spell = new Spell($id);
if (!$spell->template)
die('$WowheadPower.registerSpell(\''.$id.'\', '.User::$localeId.', {})');
$spell = new SpellList(array(['Id', $Id]));
$x = '$WowheadPower.registerSpell('.$id.', '.User::$localeId.",{\n";
if ($n = Util::localizedString($spell->template, 'spellname'))
if ($spell->error)
die('$WowheadPower.registerSpell('.$Id.', '.User::$localeId.', {});');
$x = '$WowheadPower.registerSpell('.$Id.', '.User::$localeId.", {\n";
if ($n = $spell->names[$Id])
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($n)."',\n";
if ($i = $spell->template['iconString'])
if ($i = $spell->getField('iconString'))
$x .= "\ticon: '".Util::jsEscape($i)."',\n";
if ($spell->getTooltip())
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($spell->tooltip)."'";
if ($spell->getBuff())
$x .= ",\n\tbuff_".User::$localeString.": '".Util::jsEscape($spell->buff)."'\n";
if ($t = $spell->renderTooltip($Id))
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($t)."'";
if ($b = $spell->renderBuff($Id))
$x .= ",\n\tbuff_".User::$localeString.": '".Util::jsEscape($b)."'\n";
$x .= '});';
$smarty->saveCache($cacheKeyTooltip, $x);
@@ -42,16 +42,14 @@ if (isset($_GET['power']))
die($x);
}
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
$spell = new SpellList(array(['Id', $Id]));
// v there be dragons v
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
unset($spell);
// Spelldata
if ($spellObj = new Spell($id))
if ($spellObj = new SpellList(array(['Id', $Id])))
{
$row = $spellObj->template; // equivalent to 5 layers of panzertape
@@ -142,7 +140,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
$spell['stances'] = Lang::getStances($row['stanceMask']);
// Btt - Buff TollTip
if ($buff = $spellObj->getBuff())
if ($buff = $spellObj->renderBuff())
$spell['btt'] = $buff;
// Iterate through all effects:
@@ -566,7 +564,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
FROM ?_spellicons s, ?_achievementcriteria c, ?_achievement a
LEFT JOIN (?_zones z) ON a.map != -1 AND a.map = z.mapID
WHERE
a.iconId = s.id
a.icon = s.id
AND a.id = c.refAchievement
AND c.type IN (?a)
AND c.value1 = ?d

View File

@@ -12,43 +12,54 @@ $cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_TITLE, $Id, -1, User::$locale
if (!$smarty->loadCache($cacheKeyPage, $pageData))
{
$title = new Title($Id);
if ($title->template)
$title = new TitleList(array(['Id', $Id]));
if ($title->error)
{
$title->addGlobalsToJScript($pageData['gTitles']);
$smarty->updatePageVars(array(
'subject' => ucfirst(Lang::$game['title']),
'id' => $Id,
'notFound' => sprintf(Lang::$main['pageNotFound'], Lang::$game['title']),
));
$smarty->assign('lang', Lang::$main);
$smarty->display('404.tpl');
exit();
}
else
{
$title->addGlobalsToJscript($pageData);
$infobox = [];
$colon = User::$localeId == LOCALE_FR ? ' : ' : ': '; // Je suis un prick! <_<
if ($title->template['side'] == 1)
if ($title->getField('side') == 1)
$infobox[] = Lang::$main['side'].$colon.'[span class=alliance-icon]'.Lang::$game['alliance'].'[/span]';
else if ($title->template['side'] == 2)
else if ($title->getField('side') == 2)
$infobox[] = Lang::$main['side'].$colon.'[span class=horde-icon]'.Lang::$game['horde'].'[/span]';
else
$infobox[] = Lang::$main['side'].$colon.Lang::$main['both'];
if ($title->template['gender'])
$infobox[] = Lang::$main['gender'].$colon.'[span class='.($title->template['gender'] == 2 ? 'female' : 'male').'-icon]'.Lang::$main['sex'][$title->template['gender']].'[/span]';
if ($g = $title->getField('gender'))
$infobox[] = Lang::$main['gender'].$colon.'[span class='.($g == 2 ? 'female' : 'male').'-icon]'.Lang::$main['sex'][$g].'[/span]';
if ($title->template['eventId'])
$infobox[] = Lang::$game['eventShort'].$colon.'[url=?event='.$title->template['eventId'].']'.WorldEvent::getName($title->template['eventId']).'[/url]';
if ($e = $title->getField('eventId'))
$infobox[] = Lang::$game['eventShort'].$colon.'[url=?event='.$e.']'.WorldEvent::getName($e).'[/url]';
$pageData = array(
'page' => array(
'name' => $title->getHtmlizedName(),
'id' => $title->Id,
'expansion' => Util::$expansionString[$title->template['expansion']]
'id' => $Id,
'expansion' => Util::$expansionString[$title->getField('expansion')]
),
'infobox' => '[li][ul]'.implode('[/ul][ul]', $infobox).'[/ul][/li]',
);
foreach ($title->source as $type => $entries)
foreach ($title->sources[$Id] as $type => $entries)
{
// todo: hidden-/visibleCols by actual use
switch ($type)
{
case 4:
$quests = new QuestList(array(['id', $entries]));
$quests->addRewardsToJscript($pageData['gItems'], $pageData['gSpells'], $pageData['gTitles']);
$quests = new QuestList(array(['Id', $entries]));
$quests->addRewardsToJscript($pageData);
$pageData['page']['questReward'] = $quests->getListviewData();
$pageData['page']['questParams'] = array(
@@ -59,9 +70,9 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
);
break;
case 12:
$acvs = new AchievementList(array(['id', $entries]));
$acvs->addGlobalsToJScript($pageData['gAchievements']);
$acvs->addRewardsToJscript($pageData['gItems'], $pageData['gTitles']);
$acvs = new AchievementList(array(['Id', $entries]));
$acvs->addGlobalsToJscript($pageData);
$acvs->addRewardsToJscript($pageData);
$pageData['page']['acvReward'] = $acvs->getListviewData();
$pageData['page']['acvParams'] = array(
@@ -76,30 +87,21 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
}
}
$pageData['title'] = ucFirst(trim(str_replace('%s', '', str_replace(',', '', $title->name[0]))));
$pageData['path'] = '[0, 10, '.$title->getField('category').']';
$smarty->saveCache($cacheKeyPage, $pageData);
}
else
{
$smarty->updatePageVars(array(
'subject' => ucfirst(Lang::$game['title']),
'id' => $Id,
'notFound' => sprintf(Lang::$main['pageNotFound'], Lang::$game['title']),
));
$smarty->assign('lang', Lang::$main);
$smarty->display('404.tpl');
exit();
}
}
$smarty->updatePageVars(array(
'title' => $pageData['title']." - ".ucfirst(Lang::$game['title']),
'path' => "[0, 10, ".$title->template['category']."]",
'path' => $pageData['path'],
'tab' => 0, // for g_initHeader($tab)
'type' => TYPE_TITLE, // 11:Titles
'typeId' => $Id
));
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "title" OR page = "*")');
foreach ($announcements as $k => $v)

View File

@@ -19,65 +19,14 @@ if (!$smarty->loadCache($cacheKey, $pageData))
$titles = new TitleList(isset($cat) ? array(['category', (int)$cat]) : []);
$listview = $titles->getListviewData();
$sources = array(
4 => [], // Quest
12 => [], // Achievement
13 => [] // DB-Text
$pageData = array(
'page' => $listview,
'params' => array(
'parent' => false,
'tabs' => false
)
);
// parse sources
foreach ($listview as $lvTitle)
{
if(!isset($lvTitle['source']))
continue;
foreach (array_keys($sources) as $srcKey)
if (isset($lvTitle['source'][$srcKey]))
$sources[$srcKey] = array_merge($sources[$srcKey], $lvTitle['source'][$srcKey]);
}
// replace with suitable objects
if (!empty($sources[4]))
$sources[4] = new QuestList(array(['Id', $sources[4]]));
if (!empty($sources[12]))
$sources[12] = new AchievementList(array(['Id', $sources[12]]));
if (!empty($sources[13]))
$sources[13] = DB::Aowow()->SELECT('SELECT *, Id AS ARRAY_KEY FROM ?_sourceStrings WHERE Id IN (?a)', $sources[13]);
foreach ($listview as $k => $lvTitle)
{
if(!isset($lvTitle['source']))
continue;
// Quest-source
if (isset($lvTitle['source'][4]))
{
$ids = $lvTitle['source'][4];
$listview[$k]['source'][4] = [];
foreach ($ids as $id)
$listview[$k]['source'][4][] = $sources[4]->container[$id]->getSourceData();
}
// Achievement-source
if (isset($lvTitle['source'][12]))
{
$ids = $lvTitle['source'][12];
$listview[$k]['source'][12] = [];
foreach ($ids as $id)
$listview[$k]['source'][12][] = $sources[12]->container[$id]->getSourceData();
}
// other source (only one item possible, so no iteration needed)
if (isset($lvTitle['source'][13]))
$listview[$k]['source'][13] = [$sources[13][$lvTitle['source'][13][0]]];
$listview[$k]['source'] = json_encode($listview[$k]['source']);
}
$pageData['page'] = $listview;
$smarty->saveCache($cacheKey, $pageData);
}

View File

@@ -55,7 +55,7 @@ if (!defined('AOWOW_REVISION'))
// from g_item_slots: 13:"One-Hand", 26:"Ranged", 17:"Two-Hand",
$slotPointer = [13, 17, 26, 26, 13, 17, 17, 13, 17, null, 17, null, null, 13, null, 13, null, null, null, null, 17];
$locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU];
$enchantSpells = new SpellList([['effect1Id', '=', '53'], ['name_loc0', 'NOT LIKE', 'QA%']]); // enchantItemPermanent && !qualityAssurance
$enchantSpells = new SpellList([['effect1Id', 53], ['name_loc0', 'QA%', '!']]); // enchantItemPermanent && !qualityAssurance
$castItems = [];
$jsonEnchants = [];
@@ -72,29 +72,29 @@ if (!defined('AOWOW_REVISION'))
$enchantsOut = [];
foreach ($enchantSpells->spellList as $spl)
while ($enchantSpells->iterate())
{
$enchant = DB::Aowow()->SelectRow('SELECT * FROM ?_itemEnchantment WHERE Id = ?d', $spl->template['effect1MiscValue']);
$enchant = DB::Aowow()->SelectRow('SELECT * FROM ?_itemEnchantment WHERE Id = ?d', $enchantSpells->getField('effect1MiscValue'));
if (!$enchant) // 'shouldn't' happen
continue;
// slots have to be recalculated
$slot = 0;
if ($spl->template['equippedItemClass'] == 4) // armor
if ($enchantSpells->getField('equippedItemClass') == 4) // armor
{
if ($invType = $spl->template['equippedItemInventoryTypeMask'])
$slot = $spl->template['equippedItemInventoryTypeMask'] >> 1;
if ($invType = $enchantSpells->getField('equippedItemInventoryTypeMask'))
$slot = $enchantSpells->getField('equippedItemInventoryTypeMask') >> 1;
else /* if (equippedItemSubClassMask == 64) */ // shields have it their own way <_<
$slot = (1 << (14 - 1));
}
else if ($spl->template['equippedItemClass'] == 2) // weapon
else if ($enchantSpells->getField('equippedItemClass') == 2) // weapon
{
foreach ($slotPointer as $i => $sp)
{
if (!$sp)
continue;
if ((1 << $i) & $spl->template['equippedItemSubClassMask'])
if ((1 << $i) & $enchantSpells->getField('equippedItemSubClassMask'))
{
if ($sp == 13) // also mainHand & offHand *siiigh*
$slot |= ((1 << (21 - 1)) | (1 << (22 - 1)));
@@ -112,7 +112,7 @@ if (!defined('AOWOW_REVISION'))
$ench = array(
'name' => [], // set by skill or item
'quality' => -1, // modified if item
'icon' => strToLower($spl->template['iconString']), // item over spell
'icon' => strToLower($enchantSpells->getField('iconString')), // item over spell
'source' => [], // <0: item; >0:spell
'skill' => -1, // modified if skill
'slots' => [], // determied per spell but set per item
@@ -132,37 +132,38 @@ if (!defined('AOWOW_REVISION'))
$ench['jsonequip']['reqlevel'] = $enchant['requiredLevel'];
// check if the spell has an entry in skill_line_ability -> Source:Profession
if ($skill = DB::Aowow()->SelectCell('SELECT skillId FROM ?_skill_line_ability WHERE spellId = ?d', $spl->Id))
if ($skill = DB::Aowow()->SelectCell('SELECT skillId FROM ?_skill_line_ability WHERE spellId = ?d', $enchantSpells->Id))
{
$ench['name'][] = Util::jsEscape(Util::localizedString($spl->template, 'name'));
$ench['source'][] = $spl->Id;
$ench['name'][] = Util::jsEscape($enchantSpells->names[$enchantSpells->Id]));
$ench['source'][] = $enchantSpells->Id;
$ench['skill'] = $skill;
$ench['slots'][] = $slot;
}
// check if this item can be cast via item -> Source:Item
if (!isset($castItems[$spl->Id]))
$castItems[$spl->Id] = new ItemList([['spellid_1', '=', $spl->Id], ['name', 'NOT LIKE', 'Scroll of Enchant%']]); // do not reuse enchantment scrolls
if (!isset($castItems[$enchantSpells->Id]))
$castItems[$enchantSpells->Id] = new ItemList([['spellid_1', $enchantSpells->Id], ['name', 'Scroll of Enchant%', '!']]); // do not reuse enchantment scrolls
foreach ($castItems[$spl->Id]->container as $item)
$cI &= $castItems[$enchantSpells->Id]; // this construct is a bit .. unwieldy
while ($cI->iterate())
{
$ench['name'][] = Util::jsEscape(Util::localizedString($item->template, 'name'));
$ench['source'][] = -$item->Id;
$ench['icon'] = strTolower($item->template['icon']);
$ench['name'][] = Util::jsEscape($cI->names[$cI->Id]);
$ench['source'][] = -$cI->Id;
$ench['icon'] = strTolower($cI->getField('icon'));
$ench['slots'][] = $slot;
if ($item->template['Quality'] > $ench['quality'])
$ench['quality'] = $item->template['Quality'];
if ($cI->getField('Quality') > $ench['quality'])
$ench['quality'] = $cI->getField('Quality');
if ($item->template['AllowableClass'] > 0)
if ($cI->getField('AllowableClass') > 0)
{
$ench['classes'] = $item->template['AllowableClass'];
$ench['jsonequip']['classes'] = $item->template['AllowableClass'];
$ench['classes'] = $cI->getField('AllowableClass');
$ench['jsonequip']['classes'] = $cI->getField('AllowableClass');
}
if (!isset($ench['jsonequip']['reqlevel']))
if ($item->template['RequiredLevel'] > 0)
$ench['jsonequip']['reqlevel'] = $item->template['RequiredLevel'];
if ($cI->getField('RequiredLevel') > 0)
$ench['jsonequip']['reqlevel'] = $cI->getField('RequiredLevel');
}
// enchant spell not in use

View File

@@ -127,6 +127,13 @@ if (!defined('AOWOW_REVISION'))
echo "script set up in ".Util::execTime()."<br>\n";
$glyphSpells = [];
foreach ($glyphList as $pop)
if ($pop['glyphEffect'])
$glyphSpells[] = $pop['glyphEffect'];
$glyphSpells = new SpellList(array(['Id', $glyphSpells]));
foreach ($locales as $lId)
{
User::useLocale($lId);
@@ -138,16 +145,17 @@ if (!defined('AOWOW_REVISION'))
if (!$pop['glyphEffect'])
continue;
$spl = new Spell($pop['glyphEffect']);
while ($glyphSpells->Id != $pop['glyphEffect'])
$glyphSpells->iterate();
if ($spl->template['effect1Id'] != 6 && $spl->template['effect2Id'] != 6 && $spl->template['effect3Id'] != 6)
if ($glyphSpells->getField('effect1Id') != 6 && $glyphSpells->getField('effect2Id') != 6 && $glyphSpells->getField('effect3Id') != 6)
continue;
if ($pop['itemId'] == 42958) // Crippling Poison has no skillLine.. oO => hardcode
{
$glyphsOut[$pop['itemId']] = array(
'name' => Util::jsEscape(Util::localizedString($pop, 'name')),
'description' => Util::jsEscape($spl->parseText()),
'description' => Util::jsEscape($glyphSpells->parseText()),
'icon' => 'ability_poisonsting',
'type' => 0,
'classs' => $pop['classs'],
@@ -158,7 +166,7 @@ if (!defined('AOWOW_REVISION'))
continue;
}
$description = $spl->parseText();
$description = $glyphSpells->parseText();
$spellFamily = $class2Family[$pop['classs']];
$classId = $pop['classs'] - 1;
$skill = 0;
@@ -181,11 +189,11 @@ if (!defined('AOWOW_REVISION'))
while (empty($icons) && $i < 3)
{
$i++;
$m1 = $spl->template['effect1SpellClassMask'.$l[$i]];
$m2 = $spl->template['effect2SpellClassMask'.$l[$i]];
$m3 = $spl->template['effect3SpellClassMask'.$l[$i]];
$m1 = $glyphSpells->getField('effect1SpellClassMask'.$l[$i]);
$m2 = $glyphSpells->getField('effect2SpellClassMask'.$l[$i]);
$m3 = $glyphSpells->getField('effect3SpellClassMask'.$l[$i]);
if ($spl->template['effect'.$i.'Id'] != 6 || (!$m1 && !$m2 && !$m3))
if ($glyphSpells->getField('effect'.$i.'Id') != 6 || (!$m1 && !$m2 && !$m3))
continue;
$where = "SpellFamilyId = ?d AND ((SpellFamilyFlags3 & 0xFFFFFFFF) & ?d OR (SpellFamilyFlags2 & 0xFFFFFFFF) & ?d OR (SpellFamilyFlags1 & 0xFFFFFFFF) & ?d)";

View File

@@ -113,7 +113,7 @@ if (!defined('AOWOW_REVISION'))
// costy and locale-independant -> cache
if (!isset($jsonBonus[$set['spell'.$i]]))
{
$bSpell = new Spell($set['spell'.$i]);
$bSpell = new SpellList(array(['Id', $set['spell'.$i]]));
$jsonBonus[$set['spell'.$i]] = $bSpell->getStatGain();
}

View File

@@ -114,12 +114,12 @@ if (!defined('AOWOW_REVISION'))
for ($k = 0; $k <= ($m - 1); $k++)
{
$tSpell = new Spell($talents[$j]['rank'.($k + 1)]);
$tSpell = new SpellList(array(['Id', $talents[$j]['rank'.($k + 1)]]));
$d[] = $tSpell->parseText();
$s[] = $talents[$j]['rank'.($k + 1)];
if ($talents[$j]['isSpell'])
$t[] = $tSpell->getTalentHead();
$t[] = $tSpell->getTalentHeadForCurrent();
}
if ($talents[$j]['dependsOn'])

View File

@@ -14,7 +14,7 @@
<div id="lv-titles" class="listview"></div>
<script type="text/javascript">
{include file='bricks/title_table.tpl' data=$data.page params=null}
{include file='bricks/title_table.tpl' data=$data.page params=$data.params}
</script>
<div class="clear"></div>