comparison Main.lua @ 68:95b8bf6b6fdb

Record required faction/reputation for items.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 02 Aug 2012 21:18:32 -0500
parents 8cbb3d7b8522
children 27549237b4d8
comparison
equal deleted inserted replaced
67:8cbb3d7b8522 68:95b8bf6b6fdb
889 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary 889 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary
890 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")), 890 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")),
891 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")), 891 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")),
892 } 892 }
893 893
894 local ITEM_REQ_REPUTATION_MATCH = "Requires (.-) %- (.*)"
895
894 function WDP:UpdateMerchantItems(event) 896 function WDP:UpdateMerchantItems(event)
895 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) 897 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
896 898
897 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then 899 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
898 return 900 return
912 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) 914 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
913 915
914 if item_id and item_id > 0 then 916 if item_id and item_id > 0 then
915 local price_string = ActualCopperCost(copper_price, merchant_standing) 917 local price_string = ActualCopperCost(copper_price, merchant_standing)
916 918
919 DatamineTT:ClearLines()
920 DatamineTT:SetMerchantItem(item_index)
921
922 local num_lines = DatamineTT:NumLines()
923
924 for line_index = 1, num_lines do
925 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
926
927 if not current_line then
928 break
929 end
930 local faction, reputation = current_line:GetText():match(ITEM_REQ_REPUTATION_MATCH)
931
932 if faction or reputation then
933 DBEntry("items", item_id).req_reputation = ("%s:%s"):format(faction:gsub("-", ""), reputation:upper())
934 break
935 end
936 end
937
917 if extended_cost then 938 if extended_cost then
918 local battleground_rating = 0 939 local battleground_rating = 0
919 local personal_rating = 0 940 local personal_rating = 0
920 local required_season_amount 941 local required_season_amount
921 942
922 DatamineTT:ClearLines() 943 for line_index = 1, num_lines do
923 DatamineTT:SetMerchantItem(item_index)
924
925 for line_index = 1, DatamineTT:NumLines() do
926 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] 944 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
927 945
928 if not current_line then 946 if not current_line then
929 break 947 break
930 end 948 end
931 local breakout
932 required_season_amount = current_line:GetText():match("Requires earning a total of (%d+)\n(.-) for the season.") 949 required_season_amount = current_line:GetText():match("Requires earning a total of (%d+)\n(.-) for the season.")
933 950
934 for match_index = 1, #POINT_MATCH_PATTERNS do 951 for match_index = 1, #POINT_MATCH_PATTERNS do
935 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index]) 952 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index])
936 personal_rating = personal_rating + (match1 or 0) 953 personal_rating = personal_rating + (match1 or 0)