comparison Main.lua @ 219:09d8ee2c1551

Record stats for items with upgrade IDs, skipping those which have been reforged for now. Upped DB_VERSION to 15.
author James D. Callahan III <jcallahan@curse.com>
date Fri, 25 Jan 2013 15:47:56 -0600
parents 54e268151cd2
children 62434c87d375
comparison
equal deleted inserted replaced
218:54e268151cd2 219:09d8ee2c1551
30 30
31 31
32 ----------------------------------------------------------------------- 32 -----------------------------------------------------------------------
33 -- Local constants. 33 -- Local constants.
34 ----------------------------------------------------------------------- 34 -----------------------------------------------------------------------
35 local DB_VERSION = 14 35 local DB_VERSION = 15
36 local DEBUGGING = false 36 local DEBUGGING = false
37 local EVENT_DEBUG = false 37 local EVENT_DEBUG = false
38 38
39 39
40 local DATABASE_DEFAULTS = { 40 local DATABASE_DEFAULTS = {
347 self.encounter_data[instance_token] = self.encounter_data[instance_token] or {} 347 self.encounter_data[instance_token] = self.encounter_data[instance_token] or {}
348 self.encounter_data[instance_token].stats = self.encounter_data[instance_token].stats or {} 348 self.encounter_data[instance_token].stats = self.encounter_data[instance_token].stats or {}
349 349
350 return self.encounter_data 350 return self.encounter_data
351 end 351 end
352
353 end 352 end
354 353
355 354
356 local function CurrentLocationData() 355 local function CurrentLocationData()
357 if _G.GetCurrentMapAreaID() ~= current_area_id then 356 if _G.GetCurrentMapAreaID() ~= current_area_id then
798 end) 797 end)
799 self:SetCurrentAreaID("OnEnable") 798 self:SetCurrentAreaID("OnEnable")
800 end 799 end
801 800
802 801
802 local ScrapeItemUpgradeStats
803 do
804 local intermediary = {}
805
806 function ScrapeItemUpgradeStats(item_id, item_link, upgrade_id)
807 local create_entry
808
809 table.wipe(intermediary)
810 DatamineTT:SetHyperlink(item_link)
811
812 for line_index = 1, DatamineTT:NumLines() do
813 local left_text = _G["WDPDatamineTTTextLeft" .. line_index]:GetText()
814
815 if not left_text then
816 return
817 end
818 local amount, stat = left_text:match("+(.-) (.*)")
819
820 if amount and stat then
821 if stat:find("Reforged") then
822 return
823 end
824 create_entry = true
825 intermediary[stat:lower():gsub(" ", "_"):gsub("|r", "")] = tonumber(amount)
826 end
827 end
828
829 if not create_entry then
830 return
831 end
832 local item = DBEntry("items", item_id)
833 item.upgrades = item.upgrades or {}
834 item.upgrades[upgrade_id] = item.upgrades[upgrade_id] or {}
835
836 for stat, amount in pairs(intermediary) do
837 item.upgrades[upgrade_id][stat] = amount
838 end
839 end
840 end -- do-block
841
842
803 local function RecordItemData(item_id, item_link, durability) 843 local function RecordItemData(item_id, item_link, durability)
804 local item = DBEntry("items", item_id)
805 local item_string = select(3, item_link:find("^|%x+|H(.+)|h%[.+%]")) 844 local item_string = select(3, item_link:find("^|%x+|H(.+)|h%[.+%]"))
845 local item
806 846
807 if item_string then 847 if item_string then
808 local _, _, _, _, _, _, _, suffix_id, unique_id, _, _, upgrade_id = (":"):split(item_string) 848 local _, _, _, _, _, _, _, suffix_id, unique_id, _, _, upgrade_id = (":"):split(item_string)
809 suffix_id = tonumber(suffix_id) 849 suffix_id = tonumber(suffix_id)
850 upgrade_id = tonumber(upgrade_id)
810 851
811 if suffix_id and suffix_id ~= 0 then 852 if suffix_id and suffix_id ~= 0 then
853 item = DBEntry("items", item_id)
812 item.suffix_id = suffix_id 854 item.suffix_id = suffix_id
813 item.unique_id = bit.band(unique_id, 0xFFFF) 855 item.unique_id = bit.band(unique_id, 0xFFFF)
814 end 856 end
815 857
816 if upgrade_id then 858 if upgrade_id and upgrade_id ~= 0 then
817 item.upgrade_id = upgrade_id 859 ScrapeItemUpgradeStats(item_id, item_link, upgrade_id)
818 end 860 end
819 end 861 end
820 862
821 if durability and durability > 0 then 863 if durability and durability > 0 then
864 item = item or DBEntry("items", item_id)
822 item.durability = durability 865 item.durability = durability
823 end 866 end
824 end 867 end
825 868
826 869