예제 #1
0
 public static function GetItemInfo($ItemID)
 {
     global $FCCore;
     $Statement = Items::$WConnection->prepare('
         SELECT
             it.*,
             LOWER(fi.iconname) as icon
         FROM
             item_template it
         LEFT JOIN ' . $FCCore['Database']['database'] . '.freedomcore_icons fi ON
             it.displayid = fi.id
         WHERE
             entry = :itemid
     ');
     $Statement->bindParam(':itemid', $ItemID);
     $Statement->execute();
     $Result = $Statement->fetch(PDO::FETCH_ASSOC);
     if (empty($Result) || $ItemID != $Result['entry']) {
         return false;
     } else {
         $Result['subclass'] = Items::ItemSubClass($Result['class'], $Result['subclass']);
         $Result['class'] = Items::ItemClass($Result['class']);
         $Result['BuyPrice'] = Text::MoneyToCoins($Result['BuyPrice']);
         $Result['SellPrice'] = Text::MoneyToCoins($Result['SellPrice']);
         $Result['bond_translation'] = Items::BondTranslation($Result['bonding']);
         $Result['it_translation'] = Items::InventoryTypeTranslation($Result['InventoryType']);
         if ($Result['RequiredSkill'] != 0) {
             $Result['SkillData'] = Items::GetSkillReqs($Result['RequiredSkill'], $Result['RequiredSkillRank']);
         }
         $StatsCount = 0;
         for ($i = 1; $i <= 10; $i++) {
             if ($Result['stat_type' . $i] != 0) {
                 $StatsCount++;
             }
         }
         if ($StatsCount > 0) {
             for ($i = 1; $i <= $StatsCount; $i++) {
                 $Result['stat_translation' . $i] = Items::StatTranslation($Result['stat_type' . $i]);
             }
         }
         for ($i = 1; $i <= 3; $i++) {
             if ($Result['socketColor_' . $i] != 0) {
                 $Result['socket' . $i] = Items::SocketDescription($Result['socketColor_' . $i]);
             }
         }
         for ($i = 1; $i <= 5; $i++) {
             if ($Result['spellid_' . $i] != 0 && $Result['spellid_' . $i] != -1) {
                 $Result['spt_translation' . $i] = Items::SpellTrigger($Result['spelltrigger_' . $i]);
                 $Result['spell_data' . $i] = Spells::SpellInfo($Result['spellid_' . $i]);
                 if (strstr($Result['name'], $Result['spell_data' . $i]['Name'])) {
                     $Result['spell_data' . $i]['SearchForCreature'] = Items::FindCreatureBySpell($Result['spellid_' . $i]);
                 }
             }
         }
         if ($Result['socketBonus'] != 0) {
             $Result['socketBonusDescription'] = Items::SocketBonus($Result['socketBonus']);
         }
         $Result['itemsetinfo'] = Items::GetItemSetInfo($ItemID);
         if ($Result['GemProperties'] != 0) {
             $Result['gem_bonus'] = Items::getGemBonus($Result['GemProperties']);
         }
         return $Result;
     }
 }
 public static function GetSingleItem($ItemID, $JSONP)
 {
     $NewArray = [];
     $Item = Items::GetItemInfo($ItemID);
     if ($Item != false) {
         $NewArray['id'] = $Item['entry'];
         foreach (array('description', 'name', 'icon', 'stackable') as $Field) {
             $NewArray[$Field] = $Item[$Field];
         }
         $NewArray['allowableClasses'] = 'NYI';
         $NewArray['itemBind'] = $Item['bonding'];
         for ($i = 1; $i <= 10; $i++) {
             if ($Item['stat_type' . $i] != 0) {
                 $NewArray['bonusStats'][] = ['stat' => $Item['stat_type' . $i], 'amount' => $Item['stat_value' . $i]];
             }
         }
         for ($i = 1; $i <= 5; $i++) {
             if ($Item['spellid_' . $i] != -1 && $Item['spellid_' . $i] != 0) {
                 $NewArray['itemSpells'][] = ['spellId' => $Item['spell_data' . $i]['SpellID'], 'spell' => ['id' => $Item['spell_data' . $i]['SpellID'], 'name' => $Item['spell_data' . $i]['Name'], 'icon' => $Item['spell_data' . $i]['icon'], 'description' => $Item['spell_data' . $i]['Description']]];
             }
         }
         if (isset($Item['BuyPrice']['gold'])) {
             $FinalBuyPrice = $Item['BuyPrice']['gold'];
         }
         if (isset($Item['BuyPrice']['silver'])) {
             $FinalBuyPrice = $Item['BuyPrice']['silver'];
         }
         if (isset($Item['BuyPrice']['copper'])) {
             $FinalBuyPrice = $Item['BuyPrice']['copper'];
         }
         $NewArray['buyPrice'] = $FinalBuyPrice;
         $NewArray['itemClass'] = $Item['class']['class'];
         $NewArray['itemSubClass'] = $Item['subclass']['subclass'];
         $NewArray['containerSlots'] = $Item['ContainerSlots'];
         if ($Item['class']['class'] == 2) {
             if ($Item['dmg_min1'] != 0) {
                 $DPS = ($Item['dmg_min1'] + $Item['dmg_max1']) / 2 / ($Item['delay'] / 1000);
                 $DamageMin = $Item['dmg_min1'];
                 $DamageMax = $Item['dmg_max1'];
             } elseif ($Item['dmg_min2'] != 0) {
                 $DPS = ($Item['dmg_min2'] + $Item['dmg_max2']) / 2 / ($Item['delay'] / 1000);
                 $DamageMin = $Item['dmg_min2'];
                 $DamageMax = $Item['dmg_max2'];
             }
             $NewArray['weaponInfo'] = ['damage' => ['min' => $DamageMin, 'max' => $DamageMax, 'exactMin' => number_format((double) $DamageMin, 1, '.', ''), 'exactMax' => number_format((double) $DamageMax, 1, '.', '')], 'weaponSpeed' => $Item['delay'] / 1000, 'dps' => $DPS];
         }
         $NewArray['inventoryType'] = $Item['InventoryType'];
         $NewArray['itemLevel'] = $Item['ItemLevel'];
         $NewArray['maxCount'] = $Item['maxcount'];
         $NewArray['maxDurability'] = $Item['MaxDurability'];
         $NewArray['minFactionId'] = $Item['RequiredReputationFaction'];
         $NewArray['minReputation'] = $Item['RequiredReputationRank'];
         $NewArray['quality'] = $Item['Quality'];
         if (isset($Item['SellPrice']['gold'])) {
             $FinalSellPrice = $Item['SellPrice']['gold'];
         }
         if (isset($Item['SellPrice']['silver'])) {
             $FinalSellPrice = $Item['SellPrice']['silver'];
         }
         if (isset($Item['SellPrice']['copper'])) {
             $FinalSellPrice = $Item['SellPrice']['copper'];
         }
         $NewArray['sellPrice'] = $FinalSellPrice;
         $NewArray['requiredSkill'] = $Item['RequiredSkill'];
         $NewArray['requiredLevel'] = $Item['RequiredLevel'];
         $NewArray['requiredSkillRank'] = $Item['RequiredSkillRank'];
         $SocketsCount = 0;
         for ($i = 1; $i <= 3; $i++) {
             if ($Item['socketColor_' . $i] != 0) {
                 $NewArray['socketInfo']['sockets'][] = ['type' => Items::SocketDescription($Item['socketColor_' . $i])['type']];
                 $SocketsCount++;
             }
         }
         if ($SocketsCount > 0) {
             $NewArray['socketInfo']['socketBonus'] = $Item['socketBonusDescription'];
         }
         $NewArray['baseArmor'] = $Item['armor'];
         if ($SocketsCount > 0) {
             $NewArray['hasSockets'] = true;
         } else {
             $NewArray['hasSockets'] = false;
         }
         $NewArray['displayInfoId'] = $Item['displayid'];
         return parent::Encode($NewArray, $JSONP);
     } else {
         return parent::GenerateResponse(404, true);
     }
 }