From 3b749025de319a4583af23d64c59bb041d79fc1a Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 28 Mar 2020 15:30:57 +0100 Subject: [PATCH] Items/Itemsets * fixed erronous linking to the baseline set for virtual sets * display items from the same set, for the same slot in the 'see also' tab --- includes/types/item.class.php | 27 ++++++++++++++++++++++++--- pages/item.php | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/includes/types/item.class.php b/includes/types/item.class.php index b37f62c1..2cfa3b6a 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -979,10 +979,31 @@ class ItemList extends BaseType $pieces = []; if ($setId = $this->getField('itemset')) { - // while Ids can technically be used multiple times the only difference in data are the items used. So it doesn't matter what we get - $itemset = new ItemsetList(array(['id', $setId])); + $condition = [ + ['refSetId', $setId], + // ['quality', $this->curTpl['quality']], + ['minLevel', $this->curTpl['itemLevel'], '<='], + ['maxLevel', $this->curTpl['itemLevel'], '>='] + ]; + + $itemset = new ItemsetList($condition); if (!$itemset->error && $itemset->pieceToSet) { + // handle special cases where: + // > itemset has items of different qualities (handled by not limiting for this in the initial query) + // > itemset is virtual and multiple instances have the same itemLevel but not quality (filter below) + if ($itemset->getMatches() > 1) + { + foreach ($itemset->iterate() as $id => $__) + { + if ($itemset->getField('quality') == $this->curTpl['quality']) + { + $itemset->pieceToSet = array_filter($itemset->pieceToSet, function($x) use ($id) { return $id == $x; }); + break; + } + } + } + $pieces = DB::Aowow()->select(' SELECT b.id AS ARRAY_KEY, b.name_loc0, b.name_loc2, b.name_loc3, b.name_loc4, b.name_loc6, b.name_loc8, GROUP_CONCAT(a.id SEPARATOR \':\') AS equiv FROM ?_items a, ?_items b @@ -996,7 +1017,7 @@ class ItemList extends BaseType $xSet = '
'.Lang::item('setName', [''.$itemset->getField('name', true).'', 0, count($pieces)]).''; - if ($skId = $itemset->getField('skillId')) // bonus requires skill to activate + if ($skId = $itemset->getField('skillId')) // bonus requires skill to activate { $xSet .= '
'.sprintf(Lang::game('requires'), ''.SkillList::getName($skId).''); diff --git a/pages/item.php b/pages/item.php index 92d5fce6..819d2db3 100644 --- a/pages/item.php +++ b/pages/item.php @@ -677,6 +677,9 @@ class ItemPage extends genericPage ] ); + if ($_ = $this->subject->getField('itemset')) + $conditions[1][] = ['AND', ['slot', $_slot], ['itemset', $_]]; + $saItems = new ItemList($conditions); if (!$saItems->error) {