diff --git a/includes/class.item.php b/includes/class.item.php index 4876eb1f..7a719418 100644 --- a/includes/class.item.php +++ b/includes/class.item.php @@ -675,25 +675,31 @@ class ItemList extends BaseType // recipe handling (some stray Techniques have subclass == 0), place at bottom of tooltipp if ($this->curTpl['class'] == ITEM_CLASS_RECIPE && ($this->curTpl['subclass'] || $this->curTpl['BagFamily'] == 16)) { - $craftSpell = new SpellList(array(['s.id', (int)$this->curTpl['spellid_2']])); - $craftItem = new ItemList(array(['i.entry', (int)$craftSpell->curTpl["effect1CreateItemId"]])); - $reagentItems = []; + $spell = $this->curTpl['spellid_1'] == 483 ? (int)$this->curTpl['spellid_2'] : (int)$this->curTpl['spellid_1']; + $craftSpell = new SpellList(array(['s.id', $spell])); + $craftItem = new ItemList(array(['i.entry', (int)$craftSpell->curTpl['effect1CreateItemId']])); + if ($desc = $this->getField('description', true)) + $x .= ''.Lang::$item['trigger'][0].' '.$desc.'
'; + + if ($itemTT = $craftItem->renderTooltip(null, $interactive)) + $xCraft = '

'.$itemTT.'
'; + + $reagentItems = []; for ($i = 1; $i <= 8; $i++) if ($rId = $craftSpell->getField('reagent'.$i)) $reagentItems[$rId] = $craftSpell->getField('reagentCount'.$i); - $reagents = new ItemList(array(['i.entry', array_keys($reagentItems)])); - $reqReag = []; + if (isset($xCraft) && $reagentItems) + { + $reagents = new ItemList(array(['i.entry', array_keys($reagentItems)])); + $reqReag = []; - $x .= ''.Lang::$item['trigger'][0].' '.$this->getField('description', true).'
'; + foreach ($reagents->iterate() as $__) + $reqReag[] = ''.$reagents->getField('name', true).' ('.$reagentItems[$reagents->id].')'; - $xCraft = '

'.$craftItem->renderTooltip(null, $interactive).'

'; - - foreach ($reagents->iterate() as $__) - $reqReag[] = ''.$reagents->getField('name', true).' ('.$reagentItems[$reagents->id].')'; - - $xCraft .= ''.Lang::$game['requires2']." ".implode(", ", $reqReag).''; + $xCraft .= '
'.Lang::$game['requires2'].' '.implode(', ', $reqReag).''; + } } diff --git a/includes/class.spell.php b/includes/class.spell.php index 251d34e0..1836e952 100644 --- a/includes/class.spell.php +++ b/includes/class.spell.php @@ -501,6 +501,8 @@ class SpellList extends BaseType $gt = $GT = function($a, $b) { return $a > $b; }; $gte = $GTE = function($a, $b) { return $a <= $b; }; $floor = $FLOOR = function($a) { return floor($a); }; + $max = $MAX = function($a, $b) { return max($a, $b); }; + $min = $MIN = function($a, $b) { return min($a, $b); }; if (preg_match_all('/\$[a-z]+\b/i', $formula, $vars)) { @@ -526,6 +528,8 @@ class SpellList extends BaseType $gt = $GT = !$this->interactive ? 'GT' : sprintf(Util::$dfnString, 'GT(a, b)
a > b', 'GT'); $gte = $GTE = !$this->interactive ? 'GTE' : sprintf(Util::$dfnString, 'GTE(a, b)
a <= b', 'GT'); $floor = $FLOOR = !$this->interactive ? 'FLOOR' : sprintf(Util::$dfnString, 'FLOOR(a)', 'FLOOR'); + $min = $MIN = !$this->interactive ? 'MIN' : sprintf(Util::$dfnString, 'MIN(a, b)', 'MIN'); + $max = $MAX = !$this->interactive ? 'MAX' : sprintf(Util::$dfnString, 'MAX(a, b)', 'MAX'); $pl = $PL = !$this->interactive ? 'PL' : sprintf(Util::$dfnString, 'LANG.level', 'PL'); // note the " ! diff --git a/includes/utilities.php b/includes/utilities.php index 5083455a..2788b48d 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -172,8 +172,7 @@ abstract class BaseType foreach ($rows as $k => $tpl) $this->templates[$k] = $tpl; - $this->curTpl = reset($this->templates); - $this->id = key($this->templates); + $this->reset(); // push first element for instant use $this->error = false; } @@ -198,7 +197,7 @@ abstract class BaseType protected function reset() { - unset($this->curTpl); // kill reference or it will 'bleed' into the next iteration + unset($this->curTpl); // kill reference or strange stuff will happen $this->curTpl = reset($this->templates); $this->id = key($this->templates); } @@ -785,15 +784,15 @@ class SmartyAoWoW extends Smarty { foreach ($this->jsGlobals as $type => $ids) { + foreach ($ids as $k => $id) // filter already generated data, maybe we can save a lookup or two + if (isset($this->_tpl_vars['jsGlobals'][$type][1][$id])) + unset($ids[$k]); + if (!$ids) continue; $this->initJSGlobal($type); - foreach ($ids as $k => $id) // filter already generated data, maybe we can save a lookup or two - if (isset($this->_tpl_vars['jsGlobals'][$type][1][$id])) - unset($ids[$k]); - switch ($type) { case TYPE_NPC: (new CreatureList(array(['ct.entry', $ids], 0)))->addGlobalsToJscript($this, GLOBALINFO_SELF); break;