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): ?> - -suggestedPl): ?> - - -

 

 

objectiveList): - if ($e = $this->end): - echo "
\n"; - echo ' '.Lang::quest('providedItem').Lang::main('colon')."\n"; + if ($this->end): + echo "

 

".$this->end."\n"; endif; -?> - - $ol): - if (isset($ol['text'])): - echo ' \n"; - elseif (!empty($ol['proxy'])): // this implies creatures - echo ' \n"; + elseif (!empty($ol['proxy'])): // this implies creatures + echo ' \n"; + elseif (isset($ol['typeStr'])): + if (in_array($ol['typeStr'], ['item', 'spell'])): + echo ' '; + else /* if (in_array($ol['typeStr'], ['npc', 'object', 'faction'])) */: + echo ' '; + endif; + + echo '\n"; endif; + endforeach; + endif; - echo " \n"; - elseif (isset($ol['typeStr'])): - if (in_array($ol['typeStr'], ['item', 'spell'])): - echo ' '; - else /* if (in_array($ol['typeStr'], ['npc', 'object', 'faction'])) */: - echo ' '; - endif; - - echo '\n"; - endif; - endforeach; - - if ($this->suggestedPl && !$this->end): + if ($this->suggestedPl): echo ' \n"; endif; ?> @@ -95,7 +85,7 @@ if ($o = $this->objectiveList): providedItem): + echo "
\n"; + echo ' '.Lang::quest('providedItem').Lang::main('colon')."\n"; + echo "

 

'.$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 "
\n"; - foreach ($block1 as $pId => $name): - echo ' \n"; - endforeach; - echo "
  •  
'.$name."
\n"; - - if ($block2): // may be empty echo "
\n"; - foreach ($block2 as $pId => $name): + foreach ($block1 as $pId => $name): echo ' \n"; endforeach; echo "
  •  
'.$name."
\n"; + + if ($block2): // may be empty + echo "
\n"; + foreach ($block2 as $pId => $name): + echo ' \n"; + endforeach; + echo "
  •  
'.$name."
\n"; + endif; + + echo "
  •  
'.$ol['name'].''.($ol['extraText']).(!empty($ol['qty']) ? ' ('.$ol['qty'].')' : null)."
  •  
'.$ol['name'].''.(!$this->end ? $ol['extraText'] : null).(!empty($ol['qty']) ? ' ('.$ol['qty'].')' : null)."

 

'.Lang::quest('suggestedPl').Lang::main('colon').$this->suggestedPl."
\n"; + echo ' '; + echo '\n"; +?> +
'.$p['name'].''.($p['qty'] ? ' ('.$ol['qty'].')' : null)."
+ + +brick('mapper');