template['iconString'])
$this->template['iconString'] = 'INV_Misc_QuestionMark';
}
public function getListviewData()
{
return 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'),
);
}
// hmm, really needed? .. probably .. needs rename? .. also probably
public function getDetailedData()
{
return 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'),
);
}
public function getCriteria($idx = -1)
{
if (empty($this->criteria))
{
$result = DB::Aowow()->Select('SELECT * FROM ?_achievementcriteria WHERE `refAchievement` = ? ORDER BY `order` ASC', $this->Id);
if (!$result)
return array();
if (is_array($result[0]))
$this->criteria = $result;
else
$this->criteria[] = $result;
}
if ($idx < 0)
return $this->criteria;
else
return $this->criteria[$idx];
}
public function addSelfToJScript(&$gAchievements)
{
$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->addSelfToJScript($gItems);
}
if (isset($lookup['title']))
{
$rewTitles = new TitleList(array(['Id', $lookup['title']]));
$rewTitles->addSelfToJScript($gTitles);
}
}
public function createTooltip()
{
if (!empty($this->tooltip))
return $this->tooltip;
$criteria = $this->getCriteria();
$tmp = array();
$rows = array();
$i = 0;
foreach ($criteria as $_row)
{
if($i++ % 2)
$tmp[] = $_row;
else
$rows[] = $_row;
}
if ($tmp)
$rows = array_merge($rows, $tmp);
$description = Util::localizedString($this->template, 'description');
$name = Util::localizedString($this->template, 'name');
$criteria = '';
$i = 0;
foreach ($rows as $crt)
{
// we could show them, but the tooltips are cluttered
if (($crt['complete_flags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms <= 0)
continue;
$crtName = Util::jsEscape(Util::localizedString($crt, 'name'));
switch ($crt['type'])
{
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
if (!$crtName)
$crtName = Spell::getName($crt['value1']);
break;
case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
if (!$crtName)
$crtName = Item::getName($crt['value1']);
break;
case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
if (!$crtName)
$crtName = Faction::getName($crt['value1']);
$crtName .= ' ('.Lang::getReputationLevelForPoints($crt['value2']).')';
break;
}
if ($crt['complete_flags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER)
$criteria .= '- '.Util::jsEscape(htmlspecialchars($crtName)).' '.number_format($crt['value2' ] / 10000).'
';
else
$criteria .= '- '.Util::jsEscape(htmlspecialchars($crtName)).'
';
if (++$i == round(count($rows)/2))
$criteria .= '
| '; $x .= Util::jsEscape(htmlspecialchars($name)); $x .= ' |
| ';
if ($description)
$x .= ' '.Util::jsEscape(htmlspecialchars($description)).' '; if ($criteria) { $x .= ' '.Lang::$achievement['criteria'].':'; $x .= '
|