diff --git a/includes/shared.php b/includes/shared.php index 9b5f5248..09fe6d84 100644 --- a/includes/shared.php +++ b/includes/shared.php @@ -1,6 +1,6 @@ objectiveList = []; + $this->providedItem = []; // gather ids for lookup $olItems = $olNPCs = $olGOs = $olFactions = []; @@ -351,17 +352,18 @@ class QuestPage extends GenericPage // items $olItems[0] = array( // srcItem on idx:0 $this->subject->getField('sourceItemId'), - $this->subject->getField('sourceItemCount') + $this->subject->getField('sourceItemCount'), + false ); for ($i = 1; $i < 7; $i++) // reqItem in idx:1-6 { $id = $this->subject->getField('reqItemId'.$i); $qty = $this->subject->getField('reqItemCount'.$i); - if (!$id || !$qty || $id == $olItems[0][0]) + if (!$id || !$qty) continue; - $olItems[$i] = [$id, $qty]; + $olItems[$i] = [$id, $qty, $id == $olItems[0][0]]; } if ($ids = array_column($olItems, 0)) @@ -369,18 +371,33 @@ class QuestPage extends GenericPage $olItemData = new ItemList(array(['id', $ids])); $this->extendGlobalData($olItemData->getJSGlobals(GLOBALINFO_SELF)); - foreach ($olItems as $i => $pair) + $providedRequired = false; + foreach ($olItems as $i => list($itemId, $qty, $provided)) { - if (!$pair[0] || !in_array($pair[0], $olItemData->getFoundIDs())) + if (!$i || !$itemId || !in_array($itemId, $olItemData->getFoundIDs())) continue; + if ($provided) + $providedRequired = true; + $this->objectiveList[] = array( 'typeStr' => Util::$typeStrings[TYPE_ITEM], - 'id' => $pair[0], - 'name' => $olItemData->json[$pair[0]]['name'], - 'qty' => $pair[1] > 1 ? $pair[1] : 0, - 'quality' => 7 - $olItemData->json[$pair[0]]['quality'], - 'extraText' => $i ? '' : ' ('.Lang::quest('provided').')' + 'id' => $itemId, + 'name' => $olItemData->json[$itemId]['name'], + 'qty' => $qty > 1 ? $qty : 0, + 'quality' => 7 - $olItemData->json[$itemId]['quality'], + 'extraText' => $provided ? ' ('.Lang::quest('provided').')' : '' + ); + } + + // if providd item is not required by quest, list it below other requirements + if (!$providedRequired && $olItems[0][0] && in_array($olItems[0][0], $olItemData->getFoundIDs())) + { + $this->providedItem = array( + 'id' => $olItems[0][0], + 'name' => $olItemData->json[$olItems[0][0]]['name'], + 'qty' => $olItems[0][1] > 1 ? $olItems[0][1] : 0, + 'quality' => 7 - $olItemData->json[$olItems[0][0]]['quality'] ); } } diff --git a/template/pages/quest.tpl.php b/template/pages/quest.tpl.php index 50ca83ae..db43e72a 100644 --- a/template/pages/quest.tpl.php +++ b/template/pages/quest.tpl.php @@ -32,62 +32,52 @@ elseif ($this->offerReward): echo $this->offerReward."\n"; endif; -if ($e = $this->end): +if ($this->end || $this->objectiveList): ?>
| |
|---|---|
|
| '.$ol['text']." | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| '.$ol['name'].$ol['extraText'].''.($ol['qty'] > 1 ? ' ('.$ol['qty'].')' : null).' \n";
+ if ($o = $this->objectiveList):
+ foreach ($o as $i => $ol):
+ if (isset($ol['text'])):
+ echo '
'.$ol['text']." |
'.$ol['name'].$ol['extraText'].''.($ol['qty'] > 1 ? ' ('.$ol['qty'].')' : null).' | \n";
- $block1 = array_slice($ol['proxy'], 0, ceil(count($ol['proxy']) / 2), true);
- $block2 = array_slice($ol['proxy'], ceil(count($ol['proxy']) / 2), null, true);
+ $block1 = array_slice($ol['proxy'], 0, ceil(count($ol['proxy']) / 2), true);
+ $block2 = array_slice($ol['proxy'], ceil(count($ol['proxy']) / 2), null, true);
- echo "
';
+ else /* if (in_array($ol['typeStr'], ['npc', 'object', 'faction'])) */:
+ echo ' | | ';
+ endif;
+
+ echo ''.$ol['name'].''.($ol['extraText']).(!empty($ol['qty']) ? ' ('.$ol['qty'].')' : null)." | | ||||||||
| '; - else /* if (in_array($ol['typeStr'], ['npc', 'object', 'faction'])) */: - echo ' | ||||||||||||||
| '.$ol['name'].''.(!$this->end ? $ol['extraText'] : null).(!empty($ol['qty']) ? ' ('.$ol['qty'].')' : null)." | ||||||||||||||
| '.Lang::quest('suggestedPl').Lang::main('colon').$this->suggestedPl." |
| '; + echo ' | '.$p['name'].''.($p['qty'] ? ' ('.$ol['qty'].')' : null)." |
|---|