/** * Returns list of items that stored in guild bank * @category Guilds class * @example Guilds::BuildGuildBankItemList() * @return array **/ public function BuildGuildBankItemList() { if (!$this->guildId) { $this->Log()->writeError('%s : guildId not defined', __METHOD__); return false; } $items_list = $this->cDB->select("SELECT `item_entry` AS `id`, `item_guid` AS `seed`, `SlotId` AS `slot`, `TabId` AS `bag` FROM `guild_bank_item` WHERE `guildid`=?", $this->guildId); $count_items = count($items_list); for ($i = 0; $i < $count_items; $i++) { $tmp_durability = Items::GetItemDurabilityByItemGuid($items_list[$i]['seed']); $items_list[$i]['durability'] = $tmp_durability['current']; $items_list[$i]['maxDurability'] = $tmp_durability['max']; unset($tmp_durability); $items_list[$i]['icon'] = Items::getItemIcon($items_list[$i]['id']); $items_list[$i]['name'] = Items::getItemName($items_list[$i]['id']); $items_list[$i]['qi'] = Items::GetItemInfo($items_list[$i]['id'], 'quality'); $items_list[$i]['quantity'] = Items::GetItemDataField(ITEM_FIELD_STACK_COUNT, 0, 0, $items_list[$i]['seed']); $items_list[$i]['randomPropertiesId'] = 0; $tmp_classinfo = Items::GetItemSubTypeInfo($items_list[$i]['id']); $items_list[$i]['subtype'] = ''; $items_list[$i]['subtypeLoc'] = $tmp_classinfo['subclass_name']; $items_list[$i]['type'] = $tmp_classinfo['key']; $items_list[$i]['slot']++; } return $items_list; }
public function AdvancedItemsSearch($count = false) { if ((!$this->get_array || !is_array($this->get_array)) && !$this->searchQuery) { $this->Log()->writeError('%s : start failed', __METHOD__); return false; } if (!isset($this->get_array['source'])) { $this->Log()->writeError('%s : get_array[source] not defined', __METHOD__); return false; } $allowedDungeon = false; // Get item IDs first (if $this->searchQuery) $item_id_array = array(); if ($this->searchQuery) { if ($this->_loc == 0) { $_item_ids = $this->wDB->select("SELECT `entry` FROM `item_template` WHERE `name` LIKE ? LIMIT 200", '%' . $this->searchQuery . '%'); } else { $_item_ids = $this->wDB->select("SELECT `entry` FROM `item_template` WHERE `name` LIKE ? OR `entry` IN (SELECT `entry` FROM `locales_item` WHERE `name_loc" . $this->_loc . "` LIKE ?) LIMIT 200", '%' . $this->searchQuery . '%', '%' . $this->searchQuery . '%'); } if (is_array($_item_ids)) { foreach ($_item_ids as $id) { $item_id_array[] = $id['entry']; } } } $quality_types = array('pr' => 0, 'cn' => 1, 'un' => 2, 're' => 3, 'ec' => 4, 'lg' => 5, 'hm' => 7); $slot_types = array('head' => 1, 'neck' => 2, 'shoulders' => 3, 'shirt' => 4, 'chest' => 5, 'waist' => 6, 'legs' => 7, 'feet' => 8, 'wrists' => 9, 'hands' => 10, 'finger' => 11, 'trinket' => 12, 'back' => 16, 'offhand' => 22); switch ($this->get_array['source']) { case 'all': case 'quest': if ($this->get_array['source'] == 'quest') { $quest_items_query = $this->wDB->select("SELECT `RewChoiceItemId1`, `RewChoiceItemId2`, `RewChoiceItemId3`, `RewChoiceItemId4`, `RewChoiceItemId5`, `RewChoiceItemId6`, `RewItemId1`, `RewItemId2`, `RewItemId3`, `RewItemId4` FROM `quest_template` ORDER BY `entry` DESC LIMIT 800"); if (!$quest_items_query) { return false; } $qItems = array(); foreach ($quest_items_query as $qItem) { for ($i = 1; $i < 6; $i++) { if (isset($qItem['RewChoiceItemId' . $i]) && $qItem['RewChoiceItemId' . $i] > 0) { $qItems[] = $qItem['RewChoiceItemId' . $i]; } if (isset($qItem['RewItemId' . $i]) && $qItem['RewItemId' . $i] > 0) { $qItems[] = $qItem['RewItemId' . $i]; } } } if (!$qItems) { return false; } } $sql_query = "SELECT `entry` AS `id`, `name`, `ItemLevel`, `Quality` AS `rarity`, `displayid`, `bonding`, `flags`, `duration` FROM `item_template`"; $andor = false; $type_info = false; if (isset($this->get_array['type']) && !empty($this->get_array['type'])) { /* Type */ if ($this->get_array['type'] != 'all') { if ($this->get_array['type'] == 'misc') { $this->get_array['type'] = 'miscellaneous'; } $type_info = $this->aDB->selectCell("SELECT `type` FROM `armory_item_sources` WHERE `key`=? AND `parent`=0", $this->get_array['type']); if ($type_info === false) { $this->Log()->writeLog('%s : type for key %s not found in `armory_item_sources`', __METHOD__, $this->get_array['type']); return false; } $sql_query = sprintf("SELECT `entry` AS `id`, `name`, `ItemLevel`, `Quality` AS `rarity`, `displayid`, `bonding`, `flags`, `duration` FROM `item_template` WHERE `class`=%d", $type_info); $andor = true; } /* Subtype */ if (isset($this->get_array['subTp']) && !empty($this->get_array['subTp'])) { if ($this->get_array['subTp'] != 'all' && $type_info !== false) { $subtype_info = $this->aDB->selectRow("SELECT `type`, `subtype` FROM `armory_item_sources` WHERE `key`=? AND `parent`=?", $this->get_array['subTp'], $type_info); if ($subtype_info) { $sql_query .= sprintf(" AND `subclass`=%d", $subtype_info['subtype']); $andor = true; } else { $this->Log()->writeLog('%s : subtype for subTp %s not found in `armory_item_sources`', __METHOD__, $this->get_array['subTp']); } } } /* Required level */ if (isset($this->get_array['rqrMin']) && !empty($this->get_array['rqrMin']) && (isset($this->get_array['rqrMax']) && !empty($this->get_array['rqrMax']))) { if ($andor) { $sql_query .= sprintf(" AND `RequiredLevel` BETWEEN %d AND %d", (int) $this->get_array['rqrMin'], (int) $this->get_array['rqrMax']); } else { $sql_query .= sprintf(" WHERE `RequiredLevel` BETWEEN %d AND %d", (int) $this->get_array['rqrMin'], (int) $this->get_array['rqrMax']); $andor = true; } } elseif (isset($this->get_array['rqrMin']) && !empty($this->get_array['rqrMin'])) { if ($andor) { $sql_query .= sprintf(" AND `RequiredLevel` >= %d", (int) $this->get_array['rqrMin']); } else { $sql_query .= sprintf(" WHERE `RequiredLevel` >= %d", (int) $this->get_array['rqrMin']); $andor = true; } } elseif (isset($this->get_array['rqrMax']) && !empty($this->get_array['rqrMax'])) { if ($andor) { $sql_query .= sprintf(" AND `RequiredLevel` <= %d", (int) $this->get_array['rqrMax']); } else { $sql_query .= sprintf(" WHERE `RequiredLevel` <= %d", (int) $this->get_array['rqrMax']); $andor = true; } } /* Quality */ if (isset($this->get_array['rrt']) && !empty($this->get_array['rrt'])) { if (isset($quality_types[$this->get_array['rrt']])) { if ($andor) { $sql_query .= sprintf(" AND `Quality`=%d", $quality_types[$this->get_array['rrt']]); } else { $sql_query .= sprintf(" WHERE `Quality`=%d", $quality_types[$this->get_array['rrt']]); $andor = true; } } } /* Usable by */ if (isset($this->get_array['usbleBy']) && !empty($this->get_array['usbleBy'])) { $usable_by = (int) $this->get_array['usbleBy']; $classes_mask = array(1 => 1, 2 => 2, 3 => 4, 4 => 8, 5 => 16, 6 => 32, 7 => 64, 8 => 128, 9 => 256, 11 => 1024); if (isset($classes_mask[$usable_by])) { if ($andor) { $sql_query .= sprintf(" AND `AllowableClass`&%d", $classes_mask[$usable_by]); } else { $sql_query .= sprintf(" WHERE `AllowableClass`&%d", $classes_mask[$usable_by]); $andor = true; } } } /* Class types */ /* // TODO if(isset($this->get_array['classType']) && !empty($this->get_array['classType'])) { switch($this->get_array['classType']) { case 'tank': break; case 'melee': break; case 'caster': break; case 'healer': break; case 'dot': // Warlock: damage only break; case 'dd': // Warlock: damage + crit break; } }*/ /* Slot */ if (isset($this->get_array['slot']) && !empty($this->get_array['slot'])) { if (isset($slot_types[$this->get_array['slot']])) { if ($andor) { $sql_query .= sprintf(" AND `InventoryType`=%d", $slot_types[$this->get_array['slot']]); } else { $sql_query .= sprintf(" WHERE `InventoryType`=%d", $slot_types[$this->get_array['slot']]); $andor = true; } } } /* Search string */ if (isset($this->searchQuery) && !empty($this->searchQuery)) { if ($andor) { if ($this->_loc == 0) { $sql_query .= sprintf(" AND `name` LIKE '%s' ORDER BY `ItemLevel` LIMIT 200", '%' . mysql_escape_string($this->searchQuery) . '%'); } else { $sql_query .= sprintf(" AND `name` LIKE '%s' OR `entry` IN (SELECT `entry` FROM `locales_item` WHERE `name_loc%d` LIKE '%s') ORDER BY `ItemLevel` LIMIT 200", '%' . mysql_escape_string($this->searchQuery) . '%', $this->_loc, '%' . mysql_escape_string($this->searchQuery) . '%'); } } else { if ($this->_loc == 0) { $sql_query .= sprintf(" WHERE `name` LIKE '%s' ORDER BY `ItemLevel` LIMIT 200", '%' . mysql_escape_string($this->searchQuery) . '%'); } else { $sql_query .= sprintf(" WHERE `name` LIKE '%s' OR `entry` IN (SELECT `entry` FROM `locales_item` WHERE `name_loc%d` LIKE '%s') ORDER BY `ItemLevel` LIMIT 200", '%' . mysql_escape_string($this->searchQuery) . '%', $this->_loc, '%' . mysql_escape_string($this->searchQuery) . '%'); } } } else { if ($this->get_array['source'] == 'quest') { $q_items_count = count($qItems); if ($andor) { $sql_query .= " AND `entry` IN ("; } else { $sql_query .= " WHERE `entry` IN ("; } for ($i = 0; $i < $q_items_count; $i++) { if ($i) { $sql_query .= ', '; } $sql_query .= $qItems[$i]; } $sql_query .= ')'; } $sql_query .= " ORDER BY `ItemLevel` DESC LIMIT 200"; } } else { if (isset($this->searchQuery) && !empty($this->searchQuery)) { if ($this->_loc == 0) { $sql_query .= sprintf(" WHERE `name` LIKE '%s'", '%' . mysql_escape_string($this->searchQuery) . '%'); } else { $sql_query .= sprintf(" WHERE `name` LIKE '%s' OR `entry` IN (SELECT `entry` FROM `locales_item` WHERE `name_loc%d` LIKE '%s'", '%' . mysql_escape_string($this->searchQuery) . '%', $this->_loc, '%' . mysql_escape_string($this->searchQuery) . '%'); } } $sql_query .= " ORDER BY `ItemLevel` DESC LIMIT 200"; } $items_query = $this->wDB->select($sql_query); unset($sql_query); break; case 'dungeon': if (!isset($this->get_array['dungeon'])) { $this->get_array['dungeon'] = 'all'; } if (!isset($this->get_array['difficulty'])) { $this->get_array['difficulty'] = 'all'; } if (!isset($this->get_array['boss'])) { $this->get_array['boss'] = 'all'; } $sql_query = null; if (self::IsExtendedCost()) { $item_extended_cost = $this->aDB->selectCell("SELECT `item` FROM `armory_item_sources` WHERE `key`=? LIMIT 1", $this->get_array['dungeon']); if (!$item_extended_cost) { return false; } $extended_cost = $this->aDB->select("SELECT `id` FROM `armory_extended_cost` WHERE `item1`=? OR `item2`=? OR `item3`=? OR `item4`=? OR `item5`=?", $item_extended_cost, $item_extended_cost, $item_extended_cost, $item_extended_cost, $item_extended_cost); if (!$extended_cost) { return false; } $cost_ids = array(); foreach ($extended_cost as $cost) { $cost_ids[] = $cost['id']; } if ($this->searchQuery && is_array($item_id_array)) { $items_query = $this->wDB->select("\n SELECT DISTINCT\n `item_template`.`entry` AS `id`,\n `item_template`.`name`,\n `item_template`.`ItemLevel`,\n `item_template`.`Quality` AS `rarity`,\n `item_template`.`displayid`,\n `item_template`.`bonding`,\n `item_template`.`flags`,\n `item_template`.`duration`\n FROM `item_template` AS `item_template`\n LEFT JOIN `npc_vendor` AS `npc_vendor` ON `npc_vendor`.`item`=`item_template`.`entry`\n WHERE `npc_vendor`.`ExtendedCost` IN (?a) AND `npc_vendor`.`item` IN (?a)\n ORDER BY `item_template`.`ItemLevel` DESC LIMIT 200", $cost_ids, $item_id_array); } else { $items_query = $this->wDB->select("\n SELECT DISTINCT\n `item_template`.`entry` AS `id`,\n `item_template`.`name`,\n `item_template`.`ItemLevel`,\n `item_template`.`Quality` AS `rarity`,\n `item_template`.`displayid`,\n `item_template`.`bonding`,\n `item_template`.`flags`,\n `item_template`.`duration`\n FROM `item_template` AS `item_template`\n LEFT JOIN `npc_vendor` AS `npc_vendor` ON `npc_vendor`.`item`=`item_template`.`entry`\n WHERE `npc_vendor`.`ExtendedCost` IN (?a)\n ORDER BY `item_template`.`ItemLevel` DESC LIMIT 200", $cost_ids); } } else { $allowedDungeon = true; $instance_data = Utils::GetDungeonData($this->get_array['dungeon']); if (!is_array($instance_data) || !isset($instance_data['difficulty'])) { return false; } switch ($this->get_array['difficulty']) { case 'all': $difficulty = null; switch ($instance_data['difficulty']) { case 1: // 10 Man if ($instance_data['is_heroic'] == 1) { $sql_query .= "SELECT `lootid_1`, `lootid_3`, `type` FROM `armory_instance_data`"; } else { $sql_query .= "SELECT `lootid_1`, `type` FROM `armory_instance_data`"; } break; case 2: // 25 Man if ($instance_data['is_heroic'] == 1) { $sql_query .= "SELECT `lootid_2`, `lootid_4`, `type` FROM `armory_instance_data`"; } else { $sql_query .= "SELECT `lootid_2`, `type` FROM `armory_instance_data`"; } break; default: if ($instance_data['is_heroic'] == 1) { $sql_query .= "SELECT `lootid_1`, `lootid_2`, `lootid_3`, `lootid_4`, `type` FROM `armory_instance_data`"; } else { $sql_query .= "SELECT `lootid_1`, `lootid_2`, `type` FROM `armory_instance_data`"; } break; } break; case 'normal': switch ($instance_data['difficulty']) { case 2: // 25 Man (icc/toc) $sql_query .= "SELECT `lootid_2`, `type` FROM `armory_instance_data`"; break; case 1: // 10 Man (icc/toc) // 10 Man (icc/toc) default: // All others $sql_query .= "SELECT `lootid_1`, `type` FROM `armory_instance_data`"; break; } $difficulty = 'n'; break; case 'heroic': switch ($instance_data['difficulty']) { // instance diffuclty, not related to get_array['difficulty'] case 1: // 10 Man (icc/toc) $sql_query .= "SELECT `lootid_3` `type` FROM `armory_instance_data`"; break; case 2: // 25 Man (icc/toc) $sql_query .= "SELECT `lootid_4`, `type` FROM `armory_instance_data`"; break; default: // All others $sql_query .= "SELECT `lootid_2`, `type` FROM `armory_instance_data`"; break; } $difficulty = 'h'; break; } if (isset($this->get_array['dungeon']) && $this->get_array['dungeon'] != 'all' && !empty($this->get_array['dungeon'])) { $instance_id = Utils::GetDungeonId($this->get_array['dungeon']); $sql_query .= sprintf(" WHERE `instance_id`=%d", $instance_id); } if (isset($this->get_array['boss']) && $this->get_array['boss'] != 'all' && !empty($this->get_array['boss'])) { if (is_numeric($this->get_array['boss'])) { $sql_query .= sprintf(" AND `id`=%d OR `lootid_1`=%d OR `lootid_2`=%d OR `lootid_3`=%d OR `lootid_4`=%d", $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss'], $this->get_array['boss']); } else { $sql_query .= sprintf(" AND `key`='%s'", $this->get_array['boss']); } } $boss_lootids = $this->aDB->select($sql_query); if (!$boss_lootids) { return false; } $loot_table = array(); $loot_template = null; foreach ($boss_lootids as $loot_id) { for ($i = 1; $i < 5; $i++) { if (isset($loot_id['lootid_' . $i])) { $loot_table[] = $loot_id['lootid_' . $i]; if ($loot_id['type'] == 'object') { $loot_template = '`gameobject_loot_template`'; $source_type = 'sourceType.creatureDrop'; } elseif ($loot_id['type'] == 'npc') { $loot_template = '`creature_loot_template`'; $source_type = 'sourceType.gameObjectDrop'; } } } } if ($this->get_array['boss'] != 'all') { $current_instance_key = $this->get_array['dungeon']; $current_dungeon_data = $this->aDB->selectRow("SELECT `id`, `map`, `name_" . $this->_locale . "` AS `name` FROM `armory_instance_template` WHERE `key`=? LIMIT 1", $current_instance_key); } if ($this->searchQuery && is_array($item_id_array)) { $items_query = $this->wDB->select("\n SELECT\n `item_template`.`entry` AS `id`,\n `item_template`.`name`,\n `item_template`.`ItemLevel`,\n `item_template`.`Quality` AS `rarity`,\n `item_template`.`displayid`,\n `item_template`.`bonding`,\n `item_template`.`flags`,\n `item_template`.`duration`,\n `creature_loot_template`.`entry`,\n `creature_loot_template`.`item`,\n `creature_loot_template`.`ChanceOrQuestChance`\n FROM `item_template` AS `item_template`\n LEFT JOIN `creature_loot_template` AS `creature_loot_template` ON `creature_loot_template`.`item`=`item_template`.`entry`\n WHERE `creature_loot_template`.`entry` IN (?a) AND `creature_loot_template`.`item` IN (?a)\n ORDER BY `item_template`.`ItemLevel` DESC LIMIT 200", $loot_table, $item_id_array); if (!$items_query) { $items_query = $this->wDB->select("\n SELECT\n `item_template`.`entry` AS `id`,\n `item_template`.`name`,\n `item_template`.`ItemLevel`,\n `item_template`.`Quality` AS `rarity`,\n `item_template`.`displayid`,\n `item_template`.`bonding`,\n `item_template`.`flags`,\n `item_template`.`duration`,\n `gameobject_loot_template`.`entry`,\n `gameobject_loot_template`.`item`,\n `gameobject_loot_template`.`ChanceOrQuestChance`\n FROM `item_template` AS `item_template`\n LEFT JOIN `gameobject_loot_template` AS `gameobject_loot_template` ON `gameobject_loot_template`.`item`=`item_template`.`entry`\n WHERE `gameobject_loot_template`.`entry` IN (?a) AND `gameobject_loot_template`.`item` IN (?a)\n ORDER BY `item_template`.`ItemLevel` DESC LIMIT 200", $loot_table, $item_id_array); } } else { $items_query = $this->wDB->select("\n SELECT\n `item_template`.`entry` AS `id`,\n `item_template`.`name`,\n `item_template`.`ItemLevel`,\n `item_template`.`Quality` AS `rarity`,\n `item_template`.`displayid`,\n `item_template`.`bonding`,\n `item_template`.`flags`,\n `item_template`.`duration`,\n " . $loot_template . ".`entry`,\n " . $loot_template . ".`item`,\n " . $loot_template . ".`ChanceOrQuestChance`\n FROM `item_template` AS `item_template`\n LEFT JOIN " . $loot_template . " AS " . $loot_template . " ON " . $loot_template . ".`item`=`item_template`.`entry`\n WHERE " . $loot_template . ".`entry` IN (?a)\n ORDER BY `item_template`.`ItemLevel` DESC LIMIT 200", $loot_table); } } break; case 'reputation': if (!isset($this->get_array['faction'])) { $this->get_array['faction'] = 'all'; } if ($this->get_array['faction'] == 'all' || $this->get_array['faction'] == -1) { $items_query = $this->wDB->select("SELECT `entry` AS `id`, `name`, `ItemLevel`, `Quality` AS `rarity`, `displayid`, `bonding`, `flags`, `duration` FROM `item_template` WHERE `RequiredReputationFaction` > 0 ORDER BY `ItemLevel` DESC LIMIT 200", $this->get_array['faction']); } else { $items_query = $this->wDB->select("SELECT `entry` AS `id`, `name`, `ItemLevel`, `Quality` AS `rarity`, `displayid`, `bonding`, `flags`, `duration` FROM `item_template` WHERE `RequiredReputationFaction`=? ORDER BY `ItemLevel` DESC LIMIT 200", $this->get_array['faction']); } break; } if (!isset($items_query) || !is_array($items_query)) { $this->Log()->writeError('%s : unable to get items for "%s" query (current locale: %s, locId: %d) ', __METHOD__, $this->searchQuery, $this->_locale, $this->_loc); return false; } $items_result = array(); $exists_items = array(); $i = 0; foreach ($items_query as $item) { if (isset($exists_items[$item['id']])) { continue; // do not add the same items to result array } if ($i >= 200) { if ($count) { return count($exists_items); } else { return $items_result; } } elseif (!$count) { if ($this->get_array['source'] == 'dungeon' && $allowedDungeon && isset($this->get_array['boss']) && $this->get_array['boss'] == 'all') { $current_instance_key = Utils::GetBossDungeonKey($item['entry']); $current_dungeon_data = $this->aDB->selectRow("SELECT `id`, `map`, `name_" . $this->_locale . "` AS `name` FROM `armory_instance_template` WHERE `key`=? LIMIT 1", $current_instance_key); } $items_result[$i]['data'] = array(); $items_result[$i]['filters'] = array(); $items_result[$i]['data']['id'] = $item['id']; if ($this->_locale != 'en_gb' || $this->_locale != 'en_us') { $items_result[$i]['data']['name'] = Items::getItemName($item['id']); } else { $items_result[$i]['data']['name'] = $item['name']; } if (self::CanAuction($item)) { $items_result[$i]['data']['canAuction'] = 1; } $items_result[$i]['data']['rarity'] = $item['rarity']; $items_result[$i]['data']['icon'] = $this->aDB->selectCell("SELECT `icon` FROM `armory_icons` WHERE `displayid`=?", $item['displayid']); $items_result[$i]['filters'][0] = array('name' => 'itemLevel', 'value' => $item['ItemLevel']); $items_result[$i]['filters'][1] = array('name' => 'relevance', 'value' => 100); switch ($this->get_array['source']) { case 'dungeon': if (isset($current_dungeon_data) && $allowedDungeon && is_array($current_dungeon_data)) { $items_result[$i]['filters'][2] = array('areaId' => $current_dungeon_data['id'], 'areaKey' => $current_instance_key, 'areaName' => $current_dungeon_data['name'], 'name' => 'source', 'value' => $source_type); } elseif (!$allowedDungeon && self::IsExtendedCost()) { $items_result[$i]['filters'][2] = array('name' => 'source', 'value' => 'sourceType.vendor'); } break; case 'reputation': $items_result[$i]['filters'][2] = array('name' => 'source', 'value' => 'sourceType.factionReward'); break; case 'quest': $items_result[$i]['filters'][2] = array('name' => 'source', 'value' => 'sourceType.questReward'); break; case 'pvpAlliance': case 'pvpHorde': break; } } $exists_items[$item['id']] = $item['id']; $i++; } if ($count == true) { return count($exists_items); } return $items_result; }
private function CreateAdditionalItemTooltip($itemID, XMLHandler $xml, Characters $characters, $parent = false, $comparsion = false) { if (!$xml) { return false; } elseif ($parent == true && is_array($comparsion)) { return false; // both variables can't have 'true' value. } // Item comparsion mode $realm = false; if (is_array($comparsion) && isset($this->realmData[$comparsion['realm_id']])) { $realm = $this->realmData[$comparsion['realm_id']]; } $data = $this->wDB->selectRow("SELECT * FROM `item_template` WHERE `entry`=?", $itemID); if (!$data) { return false; } $isCharacter = $characters->CheckPlayer(); $xml->XMLWriter()->startElement('id'); $xml->XMLWriter()->text($itemID); $xml->XMLWriter()->endElement(); //id $xml->XMLWriter()->startElement('name'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['name']); } else { $xml->XMLWriter()->text(Items::getItemName($itemID)); } $xml->XMLWriter()->endElement(); //name $xml->XMLWriter()->startElement('icon'); $xml->XMLWriter()->text(Items::getItemIcon($itemID, $data['displayid'])); $xml->XMLWriter()->endElement(); //icon // 3.2.x heroic item flag if ($data['Flags'] == 8 || $data['Flags'] == 4104 && $data['itemset'] > 0) { $xml->XMLWriter()->startElement('heroic'); $xml->XMLWriter()->text(1); $xml->XMLWriter()->endElement(); //heroic } $xml->XMLWriter()->startElement('overallQualityId'); $xml->XMLWriter()->text($data['Quality']); $xml->XMLWriter()->endElement(); //overallQualityId $xml->XMLWriter()->startElement('bonding'); $xml->XMLWriter()->text($data['bonding']); $xml->XMLWriter()->endElement(); //bonding $xml->XMLWriter()->startElement('maxCount'); $xml->XMLWriter()->text($data['maxcount']); $xml->XMLWriter()->endElement(); //maxCount if ($data['startquest'] > 0) { $xml->XMLWriter()->startElement('startQuestId'); $xml->XMLWriter()->text($data['startquest']); $xml->XMLWriter()->endElement(); //startQuestId } $xml->XMLWriter()->startElement('classId'); $xml->XMLWriter()->text($data['class']); $xml->XMLWriter()->endElement(); //classId $xml->XMLWriter()->startElement('equipData'); $xml->XMLWriter()->startElement('inventoryType'); $xml->XMLWriter()->text($data['InventoryType']); $xml->XMLWriter()->endElement(); //inventoryType $xml->XMLWriter()->startElement('subclassName'); $xml->XMLWriter()->text(Items::GetItemSubTypeInfo($itemID, true, $data)); $xml->XMLWriter()->endElement(); //subclassName if ($data['class'] == ITEM_CLASS_CONTAINER) { $xml->XMLWriter()->startElement('containerSlots'); $xml->XMLWriter()->text($data['ContainerSlots']); $xml->XMLWriter()->endElement(); //containerSlots } $xml->XMLWriter()->endElement(); //equipData if ($data['class'] == ITEM_CLASS_WEAPON) { $xml->XMLWriter()->startElement('damageData'); $xml->XMLWriter()->startElement('damage'); $xml->XMLWriter()->startElement('type'); $xml->XMLWriter()->text('0'); $xml->XMLWriter()->endElement(); //type $xml->XMLWriter()->startElement('min'); $xml->XMLWriter()->text($data['dmg_min1']); $xml->XMLWriter()->endElement(); //min $xml->XMLWriter()->startElement('max'); $xml->XMLWriter()->text($data['dmg_max1']); $xml->XMLWriter()->endElement(); //max $xml->XMLWriter()->endElement(); //damage $xml->XMLWriter()->startElement('speed'); $xml->XMLWriter()->text(round($data['delay'] / 1000, 2)); $xml->XMLWriter()->endElement(); //speed $xml->XMLWriter()->startElement('dps'); $dps = null; for ($jj = 1; $jj <= 2; $jj++) { $d_type = $data['dmg_type' . $jj]; $d_min = $data['dmg_min' . $jj]; $d_max = $data['dmg_max' . $jj]; if ($d_max > 0 && $data['class'] != ITEM_CLASS_PROJECTILE) { $delay = $data['delay'] / 1000; if ($delay > 0) { $dps = $dps + round(($d_max + $d_min) / (2 * $delay), 1); } if ($jj > 1) { $delay = 0; } } } $xml->XMLWriter()->text($dps); $xml->XMLWriter()->endElement(); //dps $xml->XMLWriter()->endElement(); //damageData } if ($data['block'] > 0) { $xml->XMLWriter()->startElement('blockValue'); $xml->XMLWriter()->text($data['block']); $xml->XMLWriter()->endElement(); //blockValue } if ($data['fire_res'] > 0) { $xml->XMLWriter()->startElement('fireResist'); $xml->XMLWriter()->text($data['fire_res']); $xml->XMLWriter()->endElement(); //fireResist } if ($data['nature_res'] > 0) { $xml->XMLWriter()->startElement('natureResist'); $xml->XMLWriter()->text($data['nature_res']); $xml->XMLWriter()->endElement(); //natureResist } if ($data['frost_res'] > 0) { $xml->XMLWriter()->startElement('frostResist'); $xml->XMLWriter()->text($data['frost_res']); $xml->XMLWriter()->endElement(); //frostResist } if ($data['shadow_res'] > 0) { $xml->XMLWriter()->startElement('shadowResist'); $xml->XMLWriter()->text($data['shadow_res']); $xml->XMLWriter()->endElement(); //shadowResist } if ($data['arcane_res'] > 0) { $xml->XMLWriter()->startElement('arcaneResist'); $xml->XMLWriter()->text($data['arcane_res']); $xml->XMLWriter()->endElement(); //arcaneResist } for ($i = 1; $i < 11; $i++) { if ($data['stat_type' . $i] > 0 && $data['stat_value' . $i] > 0) { $bonus_template = Items::GetItemBonusTemplate($data['stat_type' . $i]); $xml->XMLWriter()->startElement($bonus_template); $xml->XMLWriter()->text($data['stat_value' . $i]); $xml->XMLWriter()->endElement(); } } $xml->XMLWriter()->startElement('armor'); if ($data['ArmorDamageModifier'] > 0) { $xml->XMLWriter()->writeAttribute('armorBonus', 1); } $xml->XMLWriter()->text($data['armor']); $xml->XMLWriter()->endElement(); //armor $ench_array = array(1 => 'head', 2 => 'neck', 3 => 'shoulder', 4 => 'shirt', 5 => 'chest', 6 => 'belt', 7 => 'legs', 8 => 'boots', 9 => 'wrist', 10 => 'gloves', 11 => 'ring1', 12 => 'trinket1', 13 => 'mainhand', 14 => 'offhand', 15 => 'relic', 16 => 'back', 17 => 'stave', 19 => 'tabard', 20 => 'chest', 21 => 'mainhand', 22 => '', 23 => 'offhand', 24 => '', 25 => 'thrown', 26 => 'gun', 28 => 'sigil'); if (isset($ench_array[$data['InventoryType']])) { $itemSlotName = $ench_array[$data['InventoryType']]; } else { $itemSlotName = false; } if (!$parent && $isCharacter && $itemSlotName) { $enchantment = $characters->getCharacterEnchant($itemSlotName, $characters->GetGUID()); if ($enchantment) { $xml->XMLWriter()->startElement('enchant'); $xml->XMLWriter()->text($this->aDB->selectCell("SELECT `text_" . $this->_locale . "` FROM `armory_enchantment` WHERE `id`=? LIMIT 1", $enchantment)); $xml->XMLWriter()->endElement(); //enchant } } // Random property if ($data['RandomProperty'] > 0 || $data['RandomSuffix'] > 0) { if (!$isCharacter) { $xml->XMLWriter()->startElement('randomEnchantData'); $xml->XMLWriter()->endElement(); //randomEnchantData } if ($itemSlotName) { $rPropInfo = Items::GetRandomPropertiesData($itemID, $characters->GetGUID(), $characters->GetEquippedItemGuidBySlot($itemSlotName)); } else { $rPropInfo = Items::GetRandomPropertiesData($itemID, $characters->GetGUID()); } if ($isCharacter && !$parent && is_array($rPropInfo)) { $xml->XMLWriter()->startElement('randomEnchantData'); $xml->XMLWriter()->startElement('suffix'); $xml->XMLWriter()->text($rPropInfo['suffix']); $xml->XMLWriter()->endElement(); //enchant if (is_array($rPropInfo['data'])) { foreach ($rPropInfo['data'] as $randProp) { $xml->XMLWriter()->startElement('enchant'); $xml->XMLWriter()->text($randProp); $xml->XMLWriter()->endElement(); //enchant } } $xml->XMLWriter()->endElement(); //randomEnchantData } } $xml->XMLWriter()->startElement('socketData'); $socket_data = false; $socketBonusCheck = array(); for ($i = 1; $i < 4; $i++) { if ($data['socketColor_' . $i] > 0) { switch ($data['socketColor_' . $i]) { case 1: $color = 'Meta'; $socket_data = array('color' => 'Meta'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 1) { $socket_data['match'] = '1'; } } break; case 2: $socket_data = array('color' => 'Red'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 6 || $currentColor == 10 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; case 4: $socket_data = array('color' => 'Yellow'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 6 || $currentColor == 12 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; case 8: $socket_data = array('color' => 'Blue'); $gem = Items::extractSocketInfo($characters->GetGUID(), $itemID, $i, $characters->GetEquippedItemGuidBySlot($itemSlotName)); if ($gem && !$parent) { $socket_data['enchant'] = $gem['enchant']; $socket_data['icon'] = $gem['icon']; $currentColor = $this->aDB->selectCell("SELECT `color` FROM `armory_gemproperties` WHERE `spellitemenchantement`=? LIMIT 1", $gem['enchant_id']); if ($currentColor == 10 || $currentColor == 12 || $currentColor == 14) { $socket_data['match'] = '1'; } } break; } if (is_array($socket_data)) { $xml->XMLWriter()->startElement('socket'); foreach ($socket_data as $socket_key => $socket_value) { $xml->XMLWriter()->writeAttribute($socket_key, $socket_value); } $xml->XMLWriter()->endElement(); //socket $color = false; } } } if (isset($socketBonusCheck)) { $socketBonusCheckCount = count($socketBonusCheck); $socketMatches = 0; foreach ($socketBonusCheck as $socket) { if ($socket['color'] == $socket['current']) { $socketMatches++; } elseif ($socket['color'] == 2 && ($socket['current'] == 6 || $socket['current'] == 10 || $socket['current'] == 14)) { $socketMatches++; } elseif ($socket['color'] == 4 && ($socket['current'] == 6 || $socket['current'] == 12 || $socket['current'] == 14)) { $socketMatches++; } elseif ($socket['color'] == 8 && ($socket['current'] == 10 || $socket['current'] == 12 || $socket['current'] == 14)) { $socketMatches++; } } if ($socketBonusCheckCount == $socketMatches) { $socket_data['match'] = '1'; } } if ($data['socketBonus'] > 0) { $bonus_text = $this->aDB->selectCell("SELECT `text_" . $this->_locale . "` FROM `armory_enchantment` WHERE `id`=?", $data['socketBonus']); $xml->XMLWriter()->startElement('socketMatchEnchant'); $xml->XMLWriter()->text($bonus_text); $xml->XMLWriter()->endElement(); //socketMatchEnchant } $xml->XMLWriter()->endElement(); //socketData $allowable_classes = Items::AllowableClasses($data['AllowableClass']); if ($allowable_classes) { $xml->XMLWriter()->startElement('allowableClasses'); foreach ($allowable_classes as $al_class) { $xml->XMLWriter()->startElement('class'); $xml->XMLWriter()->text($al_class); $xml->XMLWriter()->endElement(); //class } $xml->XMLWriter()->endElement(); //allowableClasses } $allowable_races = Items::AllowableRaces($data['AllowableRace']); if ($allowable_races) { $xml->XMLWriter()->startElement('allowableRaces'); foreach ($allowable_races as $al_race) { $xml->XMLWriter()->startElement('race'); $xml->XMLWriter()->text($al_race); $xml->XMLWriter()->endElement(); //race } $xml->XMLWriter()->endElement(); //allowableRaces } if ($data['RequiredSkill'] > 0) { $xml->XMLWriter()->startElement('requiredSkill'); $xml->XMLWriter()->writeAttribute('name', $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_skills` WHERE `id`=?", $data['RequiredSkill'])); $xml->XMLWriter()->writeAttribute('rank', $data['RequiredSkillRank']); $xml->XMLWriter()->endElement(); //requiredSkill } if ($data['RequiredReputationFaction'] > 0) { $xml->XMLWriter()->startElement('requiredFaction'); $xml->XMLWriter()->writeAttribute('name', $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_faction` WHERE `id`=?", $data['RequiredReputationFaction'])); $xml->XMLWriter()->writeAttribute('rep', $data['RequiredReputationRank']); $xml->XMLWriter()->endElement(); //requiredFaction } $xml->XMLWriter()->startElement('requiredLevel'); $xml->XMLWriter()->text($data['RequiredLevel']); $xml->XMLWriter()->endElement(); //requiredLevel $xml->XMLWriter()->startElement('itemLevel'); $xml->XMLWriter()->text($data['ItemLevel']); $xml->XMLWriter()->endElement(); //itemLevel if ($data['itemset'] > 0) { $xml->XMLWriter()->startElement('setData'); $itemsetName = $this->aDB->selectCell("SELECT `name_" . $this->_locale . "` FROM `armory_itemsetinfo` WHERE `id`=?", $data['itemset']); $xml->XMLWriter()->startElement('name'); $xml->XMLWriter()->text($itemsetName); $xml->XMLWriter()->endElement(); $setdata = $this->aDB->selectRow("SELECT * FROM `armory_itemsetinfo` WHERE `id`=?", $data['itemset']); // t9/t10 Onyxia trinkets if ($data['itemset'] >= 843 && $data['itemset'] != 881 && $data['itemset'] != 882) { // Get itemset info from other table (armory_itemsetdata) $currentSetData = $this->aDB->selectRow("SELECT * FROM `armory_itemsetdata` WHERE `original`=? AND (`item1`=? OR `item2`=? OR `item3`=? OR `item4`=? OR `item5`=?)", $data['itemset'], $itemID, $itemID, $itemID, $itemID, $itemID); if ($currentSetData) { for ($i = 1; $i < 6; $i++) { if (Items::IsItemExists($currentSetData['item' . $i])) { $xml->XMLWriter()->startElement('item'); $xml->XMLWriter()->writeAttribute('name', Items::getItemName($currentSetData['item' . $i])); if ($characters->IsItemEquipped($currentSetData['item' . $i])) { $xml->XMLWriter()->writeAttribute('equipped', 1); } $xml->XMLWriter()->endElement(); //item } } } } else { for ($i = 1; $i < 10; $i++) { if (isset($setdata['item' . $i]) && Items::IsItemExists($setdata['item' . $i])) { $xml->XMLWriter()->startElement('item'); $xml->XMLWriter()->writeAttribute('name', Items::getItemName($setdata['item' . $i])); $xml->XMLWriter()->endElement(); //item } } } $itemsetbonus = Items::GetItemSetBonusInfo($setdata); if (is_array($itemsetbonus)) { foreach ($itemsetbonus as $item_bonus) { $xml->XMLWriter()->startElement('setBonus'); $xml->XMLWriter()->writeAttribute('desc', $item_bonus['desc']); $xml->XMLWriter()->writeAttribute('threshold', $item_bonus['threshold']); $xml->XMLWriter()->endElement(); //setBonus } } $xml->XMLWriter()->endElement(); //setData } $xml->XMLWriter()->startElement('spellData'); $spellData = 0; $spellInfo = false; for ($i = 1; $i < 6; $i++) { if ($data['spellid_' . $i] > 0) { $spellData = 1; $spell_tmp = $this->aDB->selectRow("SELECT * FROM `armory_spell` WHERE `id`=?", $data['spellid_' . $i]); if ($this->_locale == 'en_gb' || $this->_locale == 'ru_ru') { $tmp_locale = $this->_locale; } else { $tmp_locale = 'en_gb'; } if (!isset($spell_tmp['Description_' . $tmp_locale])) { continue; } $spellInfo = $this->spellReplace($spell_tmp, Utils::ValidateText($spell_tmp['Description_' . $tmp_locale])); if ($spellInfo) { $spellData = 2; $spellInfo = str_replace('"', '"', $spellInfo); $xml->XMLWriter()->startElement('spell'); $xml->XMLWriter()->startElement('trigger'); $xml->XMLWriter()->text($data['spelltrigger_' . $i]); $xml->XMLWriter()->endElement(); //trigger $xml->XMLWriter()->startElement('desc'); $xml->XMLWriter()->text($spellInfo); $xml->XMLWriter()->endElement(); //desc $xml->XMLWriter()->endElement(); //spell } } } if ($spellData == 1 && !empty($data['description'])) { $xml->XMLWriter()->startElement('spell'); $xml->XMLWriter()->startElement('trigger'); $xml->XMLWriter()->text(6); $xml->XMLWriter()->endElement(); //trigger $xml->XMLWriter()->startElement('desc'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['description']); } else { $xml->XMLWriter()->text(Items::GetItemDescription($itemID)); } $xml->XMLWriter()->endElement(); //desc if (!$parent) { for ($k = 1; $k < 4; $k++) { if ($spell_tmp['EffectItemType_' . $k] > 0 && Items::IsItemExists($spell_tmp['EffectItemType_' . $k])) { $xml->XMLWriter()->startElement('itemTooltip'); self::ItemTooltip($spell_tmp['EffectItemType_' . $k], $xml, $characters, true); $xml->XMLWriter()->endElement(); //itemTooltip $spellreagents = $this->GetSpellItemCreateReagentsInfo($spell_tmp['EffectItemType_' . $k]); if (is_array($spellreagents)) { foreach ($spellreagents as $reagent) { $xml->XMLWriter()->startElement('reagent'); $xml->XMLWriter()->writeAttribute('count', $reagent['count']); $xml->XMLWriter()->writeAttribute('name', $reagent['name']); $xml->XMLWriter()->endElement(); //reagent } } else { $xml->XMLWriter()->startElement('reag'); $xml->XMLWriter()->endElement(); //reagent } } } } $xml->XMLWriter()->endElement(); //spell } $xml->XMLWriter()->endElement(); //spellData if (!empty($data['description']) && $data['description'] != $spellInfo && $spellData != 1) { $xml->XMLWriter()->startElement('desc'); if ($this->_locale == 'en_gb' || $this->_locale == 'en_us') { $xml->XMLWriter()->text($data['description']); } else { $xml->XMLWriter()->text(Items::GetItemDescription($itemID)); } $xml->XMLWriter()->endElement(); //desc } if (!$parent) { $itemSource = Items::GetItemSource($itemID); if (is_array($itemSource)) { $xml->XMLWriter()->startElement('itemSource'); foreach ($itemSource as $source_key => $source_value) { $xml->XMLWriter()->writeAttribute($source_key, $source_value); } $xml->XMLWriter()->endElement(); //itemSource } if ($itemSource['value'] == 'sourceType.vendor' && ($reqArenaRating = Items::IsRequiredArenaRating($itemID))) { $xml->XMLWriter()->startElement('requiredPersonalArenaRating'); $xml->XMLWriter()->writeAttribute('personalArenaRating', $reqArenaRating); $xml->XMLWriter()->endElement(); //requiredPersonalArenaRating } } }
/** * @todo enchantments **/ public function GetCharacterItemInfo($slot) { if (!$this->guid) { $this->Log()->writeError('%s : player guid not provided', __METHOD__); return false; } $item_id = $this->getCharacterEquip($slot['slot']); if (!$item_id) { $this->Log()->writeLog('%s : unable to get item_id for player %d (%s); slotid is %s (nothing equipped?)', __METHOD__, $this->guid, $this->name, $slot['slot']); return false; } $durability = Items::getItemDurability($this->guid, $item_id); $gems = array('g0' => Items::extractSocketInfo($this->guid, $item_id, 1), 'g1' => Items::extractSocketInfo($this->guid, $item_id, 2), 'g2' => Items::extractSocketInfo($this->guid, $item_id, 3)); $item_data = $this->wDB->selectRow("SELECT `name`, `displayid`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=?", $item_id); $enchantment = $this->getCharacterEnchant($slot['slot']); $item_info = array('displayInfoId' => $item_data['displayid'], 'durability' => $durability['current'], 'icon' => Items::getItemIcon($item_id, $item_data['displayid']), 'id' => $item_id, 'level' => $item_data['ItemLevel'], 'maxDurability' => $durability['max'], 'name' => $this->_locale == 'en_gb' || $this->_locale == 'en_us' ? $item_data['name'] : Items::getItemName($item_id), 'permanentEnchantIcon' => 0, 'permanentEnchantItemId' => 0, 'permanentenchant' => null, 'pickUp' => 'PickUpLargeChain', 'putDown' => 'PutDownLArgeChain', 'randomPropertiesId' => 0, 'rarity' => $item_data['Quality'], 'seed' => 0, 'slot' => $slot['slotid']); for ($i = 0; $i < 3; $i++) { if ($gems['g' . $i]['item'] > 0) { $item_info['gem' . $i . 'Id'] = $gems['g' . $i]['item']; $item_info['gemIcon' . $i] = $gems['g' . $i]['icon']; } } return $item_info; }
/** * Returns list of items that stored in guild bank * @category Guilds class * @example Guilds::BuildGuildBankItemList() * @return array **/ public function BuildGuildBankItemList() { if (!$this->guildId) { return false; } $items = $this->cDB->select("SELECT `item_entry` AS `entry` FROM `guild_bank_item` WHERE `guildid`=?", $this->guildId); if ($items) { $count = count($items); for ($i = 0; $i < $count; $i++) { $items[$i]['name'] = Items::getItemName($items[$i]['entry']); $items[$i]['icon'] = Items::getItemIcon($items[$i]['entry']); $items[$i]['Quality'] = Items::getItemInfo($items[$i]['entry'], 'quality'); } return $items; } return false; }