private function createRewards() { $rewards = []; // moneyReward / maxLevelCompensation $comp = $this->subject->getField('rewardMoneyMaxLevel'); $questMoney = $this->subject->getField('rewardOrReqMoney'); if ($questMoney > 0) { $rewards['money'] = Util::formatMoney($questMoney); if ($comp > 0) { $rewards['money'] .= ' ' . sprintf(Lang::quest('expConvert'), Util::formatMoney($questMoney + $comp), MAX_LEVEL); } } else { if ($questMoney <= 0 && $questMoney + $comp > 0) { $rewards['money'] = sprintf(Lang::quest('expConvert2'), Util::formatMoney($questMoney + $comp), MAX_LEVEL); } } // itemChoices if (!empty($this->subject->choices[$this->typeId][TYPE_ITEM])) { $c = $this->subject->choices[$this->typeId][TYPE_ITEM]; $choiceItems = new ItemList(array(['id', array_keys($c)])); if (!$choiceItems->error) { $this->extendGlobalData($choiceItems->getJSGlobals()); foreach ($choiceItems->Iterate() as $id => $__) { $rewards['choice'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $choiceItems->getField('name', true), 'quality' => $choiceItems->getField('quality'), 'qty' => $c[$id], 'globalStr' => 'g_items'); } } } // itemRewards if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM])) { $ri = $this->subject->rewards[$this->typeId][TYPE_ITEM]; $rewItems = new ItemList(array(['id', array_keys($ri)])); if (!$rewItems->error) { $this->extendGlobalData($rewItems->getJSGlobals()); foreach ($rewItems->Iterate() as $id => $__) { $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'name' => $rewItems->getField('name', true), 'quality' => $rewItems->getField('quality'), 'qty' => $ri[$id], 'globalStr' => 'g_items'); } } } if (!empty($this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY])) { $rc = $this->subject->rewards[$this->typeId][TYPE_ITEM][TYPE_CURRENCY]; $rewCurr = new CurrencyList(array(['id', array_keys($rc)])); if (!$rewCurr->error) { $this->extendGlobalData($rewCurr->getJSGlobals()); foreach ($rewCurr->Iterate() as $id => $__) { $rewards['items'][] = array('typeStr' => Util::$typeStrings[TYPE_CURRENCY], 'id' => $id, 'name' => $rewCurr->getField('name', true), 'quality' => 1, 'qty' => $rc[$id] * ($_side == 2 ? -1 : 1), 'globalStr' => 'g_gatheredcurrencies'); } } } // spellRewards $displ = $this->subject->getField('rewardSpell'); $cast = $this->subject->getField('rewardSpellCast'); if (!$cast && $displ) { $cast = $displ; $displ = 0; } if ($cast || $displ) { $rewSpells = new SpellList(array(['id', [$displ, $cast]])); $this->extendGlobalData($rewSpells->getJSGlobals()); if (User::isInGroup(U_GROUP_EMPLOYEE)) { $extra = null; if ($_ = $rewSpells->getEntry($displ)) { $extra = sprintf(Lang::quest('spellDisplayed'), $displ, Util::localizedString($_, 'name')); } if ($_ = $rewSpells->getEntry($cast)) { $rewards['spells']['extra'] = $extra; $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } } else { $teach = []; foreach ($rewSpells->iterate() as $id => $__) { if ($_ = $rewSpells->canTeachSpell()) { foreach ($_ as $idx) { $teach[$rewSpells->getField('effect' . $idx . 'TriggerSpell')] = $id; } } } if ($_ = $rewSpells->getEntry($displ)) { $rewards['spells']['extra'] = null; $rewards['spells'][$teach ? 'learn' : 'cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $displ, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } else { if (($_ = $rewSpells->getEntry($cast)) && !$teach) { $rewards['spells']['extra'] = null; $rewards['spells']['cast'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $cast, 'name' => Util::localizedString($_, 'name'), 'globalStr' => 'g_spells'); } else { $taught = new SpellList(array(['id', array_keys($teach)])); if (!$taught->error) { $this->extendGlobalData($taught->getJSGlobals()); $rewards['spells']['extra'] = null; foreach ($taught->iterate() as $id => $__) { $rewards['spells']['learn'][] = array('typeStr' => Util::$typeStrings[TYPE_SPELL], 'id' => $id, 'name' => $taught->getField('name', true), 'globalStr' => 'g_spells'); } } } } } } return $rewards; }