本文整理汇总了PHP中ItemList::Iterate方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemList::Iterate方法的具体用法?PHP ItemList::Iterate怎么用?PHP ItemList::Iterate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::Iterate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRewards
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;
}