Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
evil-morfar committed Aug 21, 2019
2 parents 6673756 + 3fb4ad3 commit 4c505f9
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 6 deletions.
4 changes: 2 additions & 2 deletions RCLootCouncil.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Author: Potdisc
## Interface: 80200
## Notes: Interface for running a Loot Council v2.13.0
## Notes: Interface for running a Loot Council v2.13.1
## Title: RCLootCouncil
## Version: 2.13.0
## Version: 2.13.1
## SavedVariables: RCLootCouncilDB, RCLootCouncilLootDB
## OptionalDeps: LibStub, CallbackHandler-1.0, Ace3, lib-st, LibWindow-1.1, LibDialog-1.0

Expand Down
9 changes: 7 additions & 2 deletions Utils/BackwardsCompat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ addon.Compat = Compat
-- Each compat can only be run once per login, so feel free to call it again.
function Compat:Run()
for k,v in ipairs(self.list) do
if v.version == "always" or addon:VersionCompare(addon.db.global.version, v.version) and not v.executed then
if v.version == "always"
or (addon:VersionCompare(addon.db.global.version, v.version) or not addon.db.global.version)
and not v.executed then
addon:Debug("<Compat>", "Executing:", k, v.name or "no_name")
v.func(addon, addon.version, addon.db.global.version, addon.db.global.oldVersion)
local check = pcall(v.func, addon, addon.version, addon.db.global.version, addon.db.global.oldVersion)
v.executed = true
if not check then
addon:Debug("<Compat>", "<ERROR>", "Failed to execute:", v.name)
end
end
end

Expand Down
164 changes: 163 additions & 1 deletion __tests/wow_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ function GetTime()
return _time
end

function _G.StaticPopup_OnHide(args)
-- body...
end

function IsAddOnLoaded() return nil end

SlashCmdList = {}
Expand Down Expand Up @@ -150,6 +154,10 @@ function GetLocale()
return "enUS"
end

function GetCurrentRegion()
return 3 -- EU
end

function GetAddOnInfo()
return
end
Expand All @@ -158,6 +166,36 @@ function GetNumAddOns()
return 0
end

function IsPartyLFG ()
return _G.IsPartyLFGVal
end

function IsInRaid()
return _G.IsInRaidVal
end

function UnitInRaid()
return _G.IsInRaidVal
end

function UnitInParty()
return _G.IsInGroupVal
end

function IsInGroup ()
return _G.IsInGroupVal
end

function IsInInstance ()
local type = "none"
if _G.IsInGroupVal then
type = "party"
elseif _G.IsInRaidVal then
type = "raid"
end
return (IsInGroup() or IsInRaid()), type
end

function getglobal(k)
return _G[k]
end
Expand Down Expand Up @@ -276,7 +314,9 @@ function WoWAPI_FireUpdate(forceNow)
end
end


function GetServerTime ()
return os.time()
end


-- utility function for "dumping" a number of arguments (return a string representation of them)
Expand All @@ -294,3 +334,125 @@ function dump(...)
end
return "<"..table.concat(t, "> <")..">"
end

function tDeleteItem(tbl, item)
local index = 1;
while tbl[index] do
if ( item == tbl[index] ) then
tremove(tbl, index);
else
index = index + 1;
end
end
end

function tIndexOf(tbl, item)
for i, v in ipairs(tbl) do
if item == v then
return i;
end
end
end

function tContains(tbl, item)
return tIndexOf(tbl, item) ~= nil;
end

function tInvert(tbl)
local inverted = {};
for k, v in pairs(tbl) do
inverted[v] = k;
end
return inverted;
end

function tFilter(tbl, pred, isIndexTable)
local out = {};

if (isIndexTable) then
local currentIndex = 1;
for i, v in ipairs(tbl) do
if (pred(v)) then
out[currentIndex] = v;
currentIndex = currentIndex + 1;
end
end
else
for k, v in pairs(tbl) do
if (pred(v)) then
out[k] = v;
end
end
end

return out;
end

function CopyTable(settings)
local copy = {};
for k, v in pairs(settings) do
if ( type(v) == "table" ) then
copy[k] = CopyTable(v);
else
copy[k] = v;
end
end
return copy;
end

function FindInTableIf(tbl, pred)
for k, v in pairs(tbl) do
if (pred(v)) then
return k, v;
end
end

return nil;
end

function Ambiguate(name, method)
if method == "short" then
name = gsub(name, "%-.+", "")
end
return name
end

function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end

function UnitGUID (name)
return "Player-FFF-ABCDF012"
end

-- Enable some globals
_G.gsub = string.gsub
_G.strfind = string.find
_G.strsplit = string.split
_G.strsub = string.sub
_G.tremove = table.remove
_G.strrep = string.rep
_G.tinsert = table.insert

-- Not part of the WoWAPI, but added to emulate the ingame /dump cmd
printtable = function( data, level )
if not data then return end
level = level or 0
local ident=strrep(' ', level)
if level>6 then return end
if type(data)~='table' then print(tostring(data)) end;
for index,value in pairs(data) do repeat
if type(value)~='table' then
print( ident .. '['..tostring(index)..'] = ' .. tostring(value) .. ' (' .. type(value) .. ')' );
break;
end
print( ident .. '['..tostring(index)..'] = {')
printtable(value, level+1)
print( ident .. '}' );
until true end
end

C_Timer = {After = function() end}
147 changes: 147 additions & 0 deletions __tests/wow_item_api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
-- Simulation of Blizzard Item functions.
-- Note: Only select return types are available, with the rest just being a string

local _G = getfenv(0)
_G.Items = {}

function GetItemInfo (item)
local i = assert(_G.Items[item], "item "..item .." isn't registered for GetItemInfo")
return i.itemName, i.itemLink, i.itemRarity, i.itemLevel, i.itemMinLevel, "itemType", "itemSubType", "itemStackCount",
i.itemEquipLoc, "itemIcon", "itemSellPrice", i.itemClassID, i.itemSubClassID, "bindType", "expacID", "itemSetID",
i.isCraftingReagent
end

function GetItemInfoInstant (item)
local i = assert(_G.Items[item], "item "..item .." isn't registered for GetItemInfoInstant")
return i.itemID, "itemType", "itemSubType", i.itemEquipLoc, "icon", i.itemClassID, i.itemSubClassID
end

----------------------------------------------------------------
-- List of predefined items the functions can handle
----------------------------------------------------------------
_G.Items = {
["item:166418::::::::120:104::5:4:4799:1808:1522:4786:::"] = {
itemName = "Crest of Pa'ku",
itemID = 166418,
itemLink = "|cffa335ee|Hitem:166418::::::::120:104::5:4:4799:1808:1522:4786:::|h[Crest of Pa'ku]|h|r",
itemString = "item:166418::::::::120:104::5:4:4799:1808:1522:4786:::",
itemRarity = 4,
itemLevel = 400,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_TRINKET",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 0, --LE_ITEM_ARMOR_GENERIC
isCraftingReagent = false
},
["item:160651::::::::120:104::6:3:4800:1512:4783:::"] = {
itemName = "Vigilant's Bloodshaper",
itemID = 160651,
itemLink = "|cffa335ee|Hitem:160651::::::::120:104::6:3:4800:1512:4783:::|h[Vigilant's Bloodshaper]|h|r",
itemString = "item:160651::::::::120:104::6:3:4800:1512:4783:::",
itemRarity = 4,
itemLevel = 400,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_TRINKET",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 0, --LE_ITEM_ARMOR_GENERIC
isCraftingReagent = false
},
["item:165818::::::::120:104::5:4:4823:1522:4786:5417:::"] = {
itemName = "Crown of the Seducer",
itemID = 165818,
itemLink = "|cffa335ee|Hitem:165818::::::::120:104::5:4:4823:1522:4786:5417:::|h[Crown of the Seducer]|h|r",
itemString = "item:165818::::::::120:104::5:4:4823:1522:4786:5417:::",
itemRarity = 4,
itemLevel = 385,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_HEAD",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH
isCraftingReagent = false
},
["item:165501::::::::120:104::5:3:4799:1522:4786:::"] = {
itemName = "Bracers of Zealous Calling",
itemID = 165501,
itemLink = "|cffa335ee|Hitem:165501::::::::120:104::5:3:4799:1522:4786:::|h[Bracers of Zealous Calling]|h|r",
itemString = "item:165501::::::::120:104::5:3:4799:1522:4786:::",
itemRarity = 4,
itemLevel = 385,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_WRIST",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH
isCraftingReagent = false
},
["item:168363::::::::120:256::3:4:4822:1487:4786:6263:::"] = {
itemName = "Dark Passenger's Breastplate",
itemID = 168363,
itemLink = "|cffa335ee|Hitem:168363::::::::120:256::3:4:4822:1487:4786:6263:::|h[Dark Passenger's Breastplate]|h|r",
itemString = "item:168363::::::::120:256::3:4:4822:1487:4786:6263:::",
itemRarity = 4,
itemLevel = 415,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_CHEST",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 4, --LE_ITEM_ARMOR_PLATE
isCraftingReagent = false
},
["item:168337::::::::120:104::3:4:4822:1487:4786:6263:::"] = {
itemName = "Vestments of Creeping Terror",
itemID = 168337,
itemLink = "|cffa335ee|Hitem:168337::::::::120:104::3:4:4822:1487:4786:6263:::|h[Vestments of Creeping Terror]|h|r",
itemString = "item:168337::::::::120:104::3:4:4822:1487:4786:6263:::",
itemRarity = 4,
itemLevel = 415,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_ROBE",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH
isCraftingReagent = false
},
["item:168882::::::::120:256::3:3:4798:1487:4786:::"] = {
itemName = "Shackles of Dissonance",
itemID = 168882,
itemLink = "|cffa335ee|Hitem:168882::::::::120:256::3:3:4798:1487:4786:::|h[Shackles of Dissonance]|h|r",
itemString = "item:168882::::::::120:256::3:3:4798:1487:4786:::",
itemRarity = 4,
itemLevel = 415,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_WRIST",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 3, --LE_ITEM_ARMOR_MAIL
isCraftingReagent = false
},
--|cffa335ee|Hitem:168884::::::::120:256::3:3:4798:1487:4786:::|h[Bindings of the Herald]|h|r
["item:168884::::::::120:256::3:3:4798:1487:4786:::"] = {
itemName = "Bindings of the Herald",
itemID = 168884,
itemLink = "|cffa335ee|Hitem:168884::::::::120:256::3:3:4798:1487:4786:::|h[Bindings of the Herald]|h|r",
itemString = "item:168884::::::::120:256::3:3:4798:1487:4786:::",
itemRarity = 4,
itemLevel = 415,
itemMinLevel = 120,
itemEquipLoc = "INVTYPE_WRIST",
itemClassID = 4, --LE_ITEM_CLASS_ARMOR
itemSubClassID = 1, --LE_ITEM_ARMOR_CLOTH
isCraftingReagent = false
},
}

_G.Items_Array = {}

-- Create itemID indexes:
do
local add = {}
local add2 = {}
for itemstring, item in pairs(_G.Items) do
add[item.itemID] = item
add2[item.itemLink] = item
tinsert(_G.Items_Array, itemstring)
end
for a,b in pairs(add) do
_G.Items[a] = b
end
for a,b in pairs(add2) do
_G.Items[a] = b
end
end
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v2.13.1
---
###### Bugfixes
* *Fixed issues when upgrading from a pre 2.7 version to 2.13 (#391-394).*

### v2.13.0
---
* **Loot History**
Expand Down
3 changes: 2 additions & 1 deletion core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,8 @@ end
function RCLootCouncil:ClearOldVerTestCandidates()
local oneWeekAgo = time() - 604800
for name, data in pairs(self.db.global.verTestCandidates) do
if data[3] < oneWeekAgo then
if not data[3] -- Doesn't exist for ooold versions
or data[3] < oneWeekAgo then
self.db.global.verTestCandidates[name] = nil
end
end
Expand Down

0 comments on commit 4c505f9

Please sign in to comment.