private function _searchCurrency($cndBase) { $result = []; $cnd = array_merge($cndBase, [$this->createLookup()]); $money = new CurrencyList($cnd); if ($data = $money->getListviewData()) { if ($this->searchMask & SEARCH_TYPE_OPEN) { foreach ($money->iterate() as $__) { $data[$money->id]['param1'] = strToLower($money->getField('iconString')); } } $result = array('type' => TYPE_CURRENCY, 'appendix' => ' (Currency)', 'matches' => $money->getMatches(), 'file' => CurrencyList::$brickFile, 'data' => $data, 'params' => []); if ($money->getMatches() > $this->maxResults) { $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_currenciesfound', $money->getMatches(), $this->maxResults); $result['params']['_truncated'] = 1; } } return $result; }
private function _searchCurrency($cndBase) { $cnd = array_merge($cndBase, [$this->createLookup()]); $money = new CurrencyList($cnd); if ($data = $money->getListviewData()) { $result['data'] = array_values($data); $osInfo = [TYPE_CURRENCY, ' (Currency)', $money->getMatches()]; if ($this->searchMask & SEARCH_TYPE_OPEN) { foreach ($money->iterate() as $id => $__) { $osInfo[3][$id] = strToLower($money->getField('iconString')); } } if ($money->getMatches() > $this->maxResults) { $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_currenciesfound', $money->getMatches(), $this->maxResults); $result['_truncated'] = 1; } return ['currency', $result, null, $osInfo]; } return false; }
public function getExtendedCost($filter = [], &$reqRating = []) { if ($this->error) { return []; } if (empty($this->vendors)) { $itemz = DB::World()->select(' SELECT nv.item AS ARRAY_KEY1, nv.entry AS ARRAY_KEY2, 0 AS eventId, nv.maxcount, nv.extendedCost FROM npc_vendor nv WHERE {nv.entry IN (?a) AND} nv.item IN (?a) UNION SELECT genv.item AS ARRAY_KEY1, c.id AS ARRAY_KEY2, ge.eventEntry AS eventId, genv.maxcount, genv.extendedCost FROM game_event_npc_vendor genv LEFT JOIN game_event ge ON genv.eventEntry = ge.eventEntry JOIN creature c ON c.guid = genv.guid WHERE {c.id IN (?a) AND} genv.item IN (?a)', empty($filter[TYPE_NPC]) || !is_array($filter[TYPE_NPC]) ? DBSIMPLE_SKIP : $filter[TYPE_NPC], array_keys($this->templates), empty($filter[TYPE_NPC]) || !is_array($filter[TYPE_NPC]) ? DBSIMPLE_SKIP : $filter[TYPE_NPC], array_keys($this->templates)); $xCosts = []; foreach ($itemz as $i => $vendors) { $xCosts = array_merge($xCosts, array_column($vendors, 'extendedCost')); } if ($xCosts) { $xCosts = DB::Aowow()->select('SELECT *, id AS ARRAY_KEY FROM ?_itemextendedcost WHERE id IN (?a)', $xCosts); } $cItems = []; foreach ($itemz as $k => $vendors) { foreach ($vendors as $l => $vInfo) { $costs = []; if (!empty($xCosts[$vInfo['extendedCost']])) { $costs = $xCosts[$vInfo['extendedCost']]; } $data = array('stock' => $vInfo['maxcount'] ?: -1, 'event' => $vInfo['eventId'], 'reqRating' => $costs ? $costs['reqPersonalRating'] : 0, 'reqBracket' => $costs ? $costs['reqArenaSlot'] : 0); // hardcode arena(103) & honor(104) if (!empty($costs['reqArenaPoints'])) { $data[-103] = $costs['reqArenaPoints']; $this->jsGlobals[TYPE_CURRENCY][103] = 103; } if (!empty($costs['reqHonorPoints'])) { $data[-104] = $costs['reqHonorPoints']; $this->jsGlobals[TYPE_CURRENCY][104] = 104; } for ($i = 1; $i < 6; $i++) { if (!empty($costs['reqItemId' . $i]) && $costs['itemCount' . $i] > 0) { $data[$costs['reqItemId' . $i]] = $costs['itemCount' . $i]; $cItems[] = $costs['reqItemId' . $i]; } } // no extended cost or additional gold required if (!$costs || $this->getField('flagsExtra') & 0x4) { if ($_ = $this->getField('buyPrice')) { $data[0] = $_; } } $vendors[$l] = $data; } $itemz[$k] = $vendors; } // convert items to currency if possible if ($cItems) { $moneyItems = new CurrencyList(array(['itemId', $cItems])); foreach ($moneyItems->getJSGlobals() as $type => $jsData) { foreach ($jsData as $k => $v) { $this->jsGlobals[$type][$k] = $v; } } foreach ($itemz as $id => $vendors) { foreach ($vendors as $l => $costs) { foreach ($costs as $k => $v) { if (in_array($k, $cItems)) { $found = false; foreach ($moneyItems->iterate() as $__) { if ($moneyItems->getField('itemId') == $k) { unset($costs[$k]); $costs[-$moneyItems->id] = $v; $found = true; break; } } if (!$found) { $this->jsGlobals[TYPE_ITEM][$k] = $k; } } } $vendors[$l] = $costs; } $itemz[$id] = $vendors; } } $this->vendors = $itemz; } $result = $this->vendors; // apply filter if given $tok = !empty($filter[TYPE_ITEM]) ? $filter[TYPE_ITEM] : null; $cur = !empty($filter[TYPE_CURRENCY]) ? $filter[TYPE_CURRENCY] : null; foreach ($result as $itemId => &$data) { $reqRating = []; foreach ($data as $npcId => $costs) { if ($tok || $cur) { $valid = false; foreach ($costs as $k => $qty) { if ((!$tok || $k == $tok) && (!$cur || $k == -$cur)) { $valid = true; break; } } if (!$valid) { unset($data[$npcId]); } } // reqRating ins't really a cost .. so pass it by ref instead of return // use highest total value if (isset($data[$npcId]) && $costs['reqRating'] && (!$reqRating || $reqRating[0] < $costs['reqRating'])) { $reqRating = [$costs['reqRating'], $costs['reqBracket']]; } } if ($reqRating) { $data['reqRating'] = $reqRating[0]; } if (empty($data)) { unset($result[$itemId]); } } return $result; }
private static function getSubjects() { foreach (self::$subjCache as $type => $ids) { $_ = array_filter(array_keys($ids), 'is_numeric'); if (!$_) { continue; } $cnd = [CFG_SQL_LIMIT_NONE, ['id', $_]]; switch ($type) { case TYPE_NPC: $obj = new CreatureList($cnd); break; case TYPE_OBJECT: $obj = new GameobjectList($cnd); break; case TYPE_ITEM: $obj = new ItemList($cnd); break; case TYPE_ITEMSET: $obj = new ItemsetList($cnd); break; case TYPE_QUEST: $obj = new QuestList($cnd); break; case TYPE_SPELL: $obj = new SpellList($cnd); break; case TYPE_ZONE: $obj = new ZoneList($cnd); break; case TYPE_FACTION: $obj = new FactionList($cnd); break; case TYPE_PET: $obj = new PetList($cnd); break; case TYPE_ACHIEVEMENT: $obj = new AchievementList($cnd); break; case TYPE_TITLE: $obj = new TitleList($cnd); break; case TYPE_WORLDEVENT: $obj = new WorldEventList($cnd); break; case TYPE_CLASS: $obj = new CharClassList($cnd); break; case TYPE_RACE: $obj = new CharRaceList($cnd); break; case TYPE_SKILL: $obj = new SkillList($cnd); break; case TYPE_CURRENCY: $obj = new CurrencyList($cnd); break; default: continue; } foreach ($obj->iterate() as $id => $__) { self::$subjCache[$type][$id] = $obj->getField('name', true); } } }