mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Pages/Item
* fixed fractional buy price for items sold in stacks in infobox (fixes #362) * fixed filter criteria enums being generally invalid
This commit is contained in:
@@ -1254,7 +1254,7 @@ abstract class Filter
|
|||||||
$unsetme = true;
|
$unsetme = true;
|
||||||
break;
|
break;
|
||||||
case FILTER_CR_ENUM:
|
case FILTER_CR_ENUM:
|
||||||
if (!Util::checkNumeric($_crs[$i], NUM_REQ_INT))
|
if (!Util::checkNumeric($_crs[$i], NUM_CAST_INT))
|
||||||
$unsetme = true;
|
$unsetme = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,8 @@ class ItemPage extends genericPage
|
|||||||
{
|
{
|
||||||
$vendors = $this->subject->getExtendedCost()[$this->subject->id];
|
$vendors = $this->subject->getExtendedCost()[$this->subject->id];
|
||||||
$stack = $this->subject->getField('buyCount');
|
$stack = $this->subject->getField('buyCount');
|
||||||
$each = $this->subject->getField('stackable') > 1 ? '[color=q0] ('.Lang::item('each').')[/color]' : null;
|
$divisor = $stack;
|
||||||
|
$each = '';
|
||||||
$handled = [];
|
$handled = [];
|
||||||
$costList = [];
|
$costList = [];
|
||||||
foreach ($vendors as $npcId => $entries)
|
foreach ($vendors as $npcId => $entries)
|
||||||
@@ -229,29 +230,52 @@ class ItemPage extends genericPage
|
|||||||
|
|
||||||
if ($c < 0) // currency items (and honor or arena)
|
if ($c < 0) // currency items (and honor or arena)
|
||||||
{
|
{
|
||||||
$currency[] = -$c.','.($qty / $stack);
|
if (is_float($qty / $stack))
|
||||||
|
$divisor = 1;
|
||||||
|
|
||||||
|
$currency[] = [-$c, $qty];
|
||||||
$this->extendGlobalIds(Type::CURRENCY, -$c);
|
$this->extendGlobalIds(Type::CURRENCY, -$c);
|
||||||
}
|
}
|
||||||
else if ($c > 0) // plain items (item1,count1,item2,count2,...)
|
else if ($c > 0) // plain items (item1,count1,item2,count2,...)
|
||||||
{
|
{
|
||||||
$tokens[$c] = $c.','.($qty / $stack);
|
if (is_float($qty / $stack))
|
||||||
|
$divisor = 1;
|
||||||
|
|
||||||
|
$tokens[] = [$c, $qty];
|
||||||
$this->extendGlobalIds(Type::ITEM, $c);
|
$this->extendGlobalIds(Type::ITEM, $c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// display every cost-combination only once
|
// display every cost-combination only once
|
||||||
if (in_array(md5(serialize($data)), $handled))
|
$hash = md5(serialize($data));
|
||||||
|
if (in_array($hash, $handled))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$handled[] = md5(serialize($data));
|
$handled[] = $hash;
|
||||||
|
|
||||||
$cost = isset($data[0]) ? '[money='.($data[0] / $stack) : '[money';
|
if (isset($data[0]))
|
||||||
|
{
|
||||||
|
if (is_float($data[0] / $stack))
|
||||||
|
$divisor = 1;
|
||||||
|
|
||||||
|
$cost = '[money='.($data[0] / $divisor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$cost = '[money';
|
||||||
|
|
||||||
|
$stringify = function(&$v) use ($divisor) { return $v = $v[0] . ',' . ($v[1] / $divisor); };
|
||||||
|
|
||||||
if ($tokens)
|
if ($tokens)
|
||||||
|
{
|
||||||
|
array_walk($tokens, $stringify, $divisor);
|
||||||
$cost .= ' items='.implode(',', $tokens);
|
$cost .= ' items='.implode(',', $tokens);
|
||||||
|
}
|
||||||
|
|
||||||
if ($currency)
|
if ($currency)
|
||||||
|
{
|
||||||
|
array_walk($currency, $stringify, $divisor);
|
||||||
$cost .= ' currency='.implode(',', $currency);
|
$cost .= ' currency='.implode(',', $currency);
|
||||||
|
}
|
||||||
|
|
||||||
$cost .= ']';
|
$cost .= ']';
|
||||||
|
|
||||||
@@ -259,6 +283,11 @@ class ItemPage extends genericPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($stack > 1 && $divisor > 1)
|
||||||
|
$each = '[color=q0] ('.Lang::item('each').')[/color]';
|
||||||
|
else if ($stack > 1)
|
||||||
|
$each = '[color=q0] ('.$stack.')[/color]';
|
||||||
|
|
||||||
if (count($costList) == 1)
|
if (count($costList) == 1)
|
||||||
$infobox[] = Lang::item('cost').Lang::main('colon').$costList[0].$each;
|
$infobox[] = Lang::item('cost').Lang::main('colon').$costList[0].$each;
|
||||||
else if (count($costList) > 1)
|
else if (count($costList) > 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user