Tooltips/Items

* skipping an error, when handling heirloom-armor with scaled level on external tooltips
   the tooltip will now be displayed but without the armor-class changing at level 40
 * prevent assigning arbitrary randomEnchantments to items (e.g. Warglaive of Azzinoth of the Whale)
This commit is contained in:
Sarjuuk
2015-08-04 19:02:23 +02:00
parent ef686c9c57
commit 320ad252d1
4 changed files with 32 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
<?php
define('AOWOW_REVISION', 11);
define('AOWOW_REVISION', 12);
define('CLI', PHP_SAPI === 'cli');

View File

@@ -439,6 +439,17 @@ class ItemList extends BaseType
interactive (set to place javascript/anchors to manipulate level and ratings or link to filters (static tooltips vs popup tooltip))
subOf (tabled layout doesn't work if used as sub-tooltip in other item or spell tooltips; use line-break instead)
*/
public function getField($field, $localized = false, $enhance = [])
{
$res = parent::getField($field, $localized);
if ($field == 'name' && !empty($enhance['r']))
if ($this->getRandEnchantForItem($enhance['r']))
$res .= ' '.Util::localizedString($this->enhanceR, 'name');
return $res;
}
public function renderTooltip($interactive = false, $subOf = 0, $enhance = [])
{
if ($this->error)
@@ -455,20 +466,20 @@ class ItemList extends BaseType
if (!empty($enhance['r']))
{
if ($rndEnch = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE Id = ?d', $enhance['r']))
if ($this->getRandEnchantForItem($enhance['r']))
{
$_name .= ' '.Util::localizedString($rndEnch, 'name');
$_name .= ' '.Util::localizedString($this->enhanceR, 'name');
$randEnchant = '';
for ($i = 1; $i < 6; $i++)
{
if ($rndEnch['enchantId'.$i] <= 0)
if ($this->enhanceR['enchantId'.$i] <= 0)
continue;
$enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $rndEnch['enchantId'.$i]);
if ($rndEnch['allocationPct'.$i] > 0)
$enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $this->enhanceR['enchantId'.$i]);
if ($this->enhanceR['allocationPct'.$i] > 0)
{
$amount = intVal($rndEnch['allocationPct'.$i] * $this->generateEnchSuffixFactor());
$amount = intVal($this->enhanceR['allocationPct'.$i] * $this->generateEnchSuffixFactor());
$randEnchant .= '<span>'.str_replace('$i', $amount, Util::localizedString($enchant, 'name')).'</span><br />';
}
else
@@ -1080,6 +1091,17 @@ class ItemList extends BaseType
return $x;
}
private function getRandEnchantForItem($randId)
{
// is it available for this item? .. does it even exist?!
if (empty($this->enhanceR))
if (DB::World()->selectCell('SELECT 1 FROM item_enchantment_template WHERE entry = ?d AND ench = ?d', abs($this->getField('randomEnchant')), abs($randId)))
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE Id = ?d', $randId))
$this->enhanceR = $_;
return !empty($this->enhanceR);
}
// from Trinity
public function generateEnchSuffixFactor()
{

View File

@@ -983,7 +983,7 @@ class ItemPage extends genericPage
return '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.', {})';
$x = '$WowheadPower.registerItem(\''.$itemString.'\', '.User::$localeId.", {\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($this->subject->getField('name', true))."',\n";
$x .= "\tname_".User::$localeString.": '".Util::jsEscape($this->subject->getField('name', true, $this->enhancedTT))."',\n";
$x .= "\tquality: ".$this->subject->getField('quality').",\n";
$x .= "\ticon: '".urlencode($this->subject->getField('iconString'))."',\n";
$x .= "\ttooltip_".User::$localeString.": '".Util::jsEscape($this->subject->renderTooltip(false, 0, $this->enhancedTT))."'\n";

View File

@@ -1378,7 +1378,8 @@ $WH.g_setTooltipLevel = function(tooltip, level) {
}
// Always keep the base armor type
return prefix + g_itemset_types[_];
return $WH.isset('g_itemset_types') ? prefix + g_itemset_types[_] : _all; // sarjuuk: LANG is not available if the tooltip is included externaly
// return prefix + g_itemset_types[_];
});
// Update min-max damage