Quest Detail Page:

properly distinguish between provided, required and provided-required items
This commit is contained in:
Sarjuuk
2015-07-01 21:13:22 +02:00
parent a3c9b52073
commit cc886b4db9
3 changed files with 78 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
define('AOWOW_REVISION', 1); define('AOWOW_REVISION', 2);
define('CLI', PHP_SAPI === 'cli'); define('CLI', PHP_SAPI === 'cli');

View File

@@ -344,6 +344,7 @@ class QuestPage extends GenericPage
/*******************/ /*******************/
$this->objectiveList = []; $this->objectiveList = [];
$this->providedItem = [];
// gather ids for lookup // gather ids for lookup
$olItems = $olNPCs = $olGOs = $olFactions = []; $olItems = $olNPCs = $olGOs = $olFactions = [];
@@ -351,17 +352,18 @@ class QuestPage extends GenericPage
// items // items
$olItems[0] = array( // srcItem on idx:0 $olItems[0] = array( // srcItem on idx:0
$this->subject->getField('sourceItemId'), $this->subject->getField('sourceItemId'),
$this->subject->getField('sourceItemCount') $this->subject->getField('sourceItemCount'),
false
); );
for ($i = 1; $i < 7; $i++) // reqItem in idx:1-6 for ($i = 1; $i < 7; $i++) // reqItem in idx:1-6
{ {
$id = $this->subject->getField('reqItemId'.$i); $id = $this->subject->getField('reqItemId'.$i);
$qty = $this->subject->getField('reqItemCount'.$i); $qty = $this->subject->getField('reqItemCount'.$i);
if (!$id || !$qty || $id == $olItems[0][0]) if (!$id || !$qty)
continue; continue;
$olItems[$i] = [$id, $qty]; $olItems[$i] = [$id, $qty, $id == $olItems[0][0]];
} }
if ($ids = array_column($olItems, 0)) if ($ids = array_column($olItems, 0))
@@ -369,18 +371,33 @@ class QuestPage extends GenericPage
$olItemData = new ItemList(array(['id', $ids])); $olItemData = new ItemList(array(['id', $ids]));
$this->extendGlobalData($olItemData->getJSGlobals(GLOBALINFO_SELF)); $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; continue;
if ($provided)
$providedRequired = true;
$this->objectiveList[] = array( $this->objectiveList[] = array(
'typeStr' => Util::$typeStrings[TYPE_ITEM], 'typeStr' => Util::$typeStrings[TYPE_ITEM],
'id' => $pair[0], 'id' => $itemId,
'name' => $olItemData->json[$pair[0]]['name'], 'name' => $olItemData->json[$itemId]['name'],
'qty' => $pair[1] > 1 ? $pair[1] : 0, 'qty' => $qty > 1 ? $qty : 0,
'quality' => 7 - $olItemData->json[$pair[0]]['quality'], 'quality' => 7 - $olItemData->json[$itemId]['quality'],
'extraText' => $i ? '' : '&nbsp;('.Lang::quest('provided').')' 'extraText' => $provided ? '&nbsp;('.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']
); );
} }
} }

View File

@@ -32,27 +32,16 @@ elseif ($this->offerReward):
echo $this->offerReward."\n"; echo $this->offerReward."\n";
endif; endif;
if ($e = $this->end): if ($this->end || $this->objectiveList):
?> ?>
<table class="iconlist"> <table class="iconlist">
<tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td><?php echo $e; ?></td></tr>
<?php if ($s = $this->suggestedPl): ?>
<tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td><?php echo Lang::quest('suggestedPl').Lang::main('colon').$s; ?></td></tr>
<?php endif; ?>
</table>
<?php <?php
endif; if ($this->end):
echo " <tr><th><p style=\"height: 26px; width: 30px;\">&nbsp;</p></th><td>".$this->end."</td></tr>\n";
if ($o = $this->objectiveList):
if ($e = $this->end):
echo " <div class=\"pad\"></div>\n";
echo ' '.Lang::quest('providedItem').Lang::main('colon')."\n";
endif; endif;
?>
<table class="iconlist">
<?php
foreach ($o as $i => $ol):
if ($o = $this->objectiveList):
foreach ($o as $i => $ol):
if (isset($ol['text'])): if (isset($ol['text'])):
echo ' <tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td>'.$ol['text']."</td></tr>\n"; echo ' <tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td>'.$ol['text']."</td></tr>\n";
elseif (!empty($ol['proxy'])): // this implies creatures elseif (!empty($ol['proxy'])): // this implies creatures
@@ -83,11 +72,12 @@ if ($o = $this->objectiveList):
echo ' <tr><th><ul><li><var>&nbsp;</var></li></ul></th>'; echo ' <tr><th><ul><li><var>&nbsp;</var></li></ul></th>';
endif; endif;
echo '<td><span class="q'.(isset($ol['quality']) ? $ol['quality'] : null).'"><a href="?'.$ol['typeStr'].'='.$ol['id'].'">'.$ol['name'].'</a></span>'.(!$this->end ? $ol['extraText'] : null).(!empty($ol['qty']) ? '&nbsp;('.$ol['qty'].')' : null)."</td></tr>\n"; echo '<td><span class="q'.(isset($ol['quality']) ? $ol['quality'] : null).'"><a href="?'.$ol['typeStr'].'='.$ol['id'].'">'.$ol['name'].'</a></span>'.($ol['extraText']).(!empty($ol['qty']) ? '&nbsp;('.$ol['qty'].')' : null)."</td></tr>\n";
endif; endif;
endforeach; endforeach;
endif;
if ($this->suggestedPl && !$this->end): if ($this->suggestedPl):
echo ' <tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td>'.Lang::quest('suggestedPl').Lang::main('colon').$this->suggestedPl."</td></tr>\n"; echo ' <tr><th><p style="height: 26px; width: 30px;">&nbsp;</p></th><td>'.Lang::quest('suggestedPl').Lang::main('colon').$this->suggestedPl."</td></tr>\n";
endif; endif;
?> ?>
@@ -95,7 +85,7 @@ if ($o = $this->objectiveList):
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($this->objectiveList as $k => $i): foreach ($o as $k => $i):
if (isset($i['typeStr']) && ($i['typeStr'] == 'item' || $i['typeStr'] == 'spell')): if (isset($i['typeStr']) && ($i['typeStr'] == 'item' || $i['typeStr'] == 'spell')):
echo " \$WH.ge('iconlist-icon-".$k."').appendChild(g_".$i['typeStr']."s.createIcon(".$i['id'].", 0, ".$i['qty']."));\n"; echo " \$WH.ge('iconlist-icon-".$k."').appendChild(g_".$i['typeStr']."s.createIcon(".$i['id'].", 0, ".$i['qty']."));\n";
endif; endif;
@@ -103,6 +93,22 @@ if ($o = $this->objectiveList):
?> ?>
//]]></script> //]]></script>
<?php <?php
if ($p = $this->providedItem):
echo " <div class=\"pad\"></div>\n";
echo ' '.Lang::quest('providedItem').Lang::main('colon')."\n";
echo " <table class=\"iconlist\">\n";
echo ' <tr><th align="right" id="iconlist-icon-'.count($this->objectiveList).'"></th>';
echo '<td><span class="q'.$p['quality'].'"><a href="?item='.$p['id'].'">'.$p['name'].'</a></span>'.($p['qty'] ? '&nbsp;('.$ol['qty'].')' : null)."</td></tr>\n";
?>
</table>
<script type="text/javascript">//<![CDATA[
<?php
echo " \$WH.ge('iconlist-icon-".count($this->objectiveList)."').appendChild(g_items.createIcon(".$p['id'].", 0, ".$p['qty']."));\n";
?>
//]]></script>
<?php
endif;
endif; endif;
$this->brick('mapper'); $this->brick('mapper');