Skip to content

Commit

Permalink
Merge branch 'release/3.10.2'
Browse files Browse the repository at this point in the history
evil-morfar committed Dec 1, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
acaloiaro Adriano Caloiaro
2 parents 13fe086 + c60784a commit ec00e50
Showing 11 changed files with 275 additions and 110 deletions.
14 changes: 7 additions & 7 deletions .specs/Classes/Utils/GroupLoot.spec.lua
Original file line number Diff line number Diff line change
@@ -120,14 +120,14 @@ describe("#GroupLoot", function()
assert.spy(s).was_not_called()
end)
end)
end)

function _G.GetLootRollItemLink(rollID)
if GroupLoot.IgnoreList[rollID] then
return "item:"..rollID..":"
function _G.GetLootRollItemLink(rollID)
if GroupLoot.IgnoreList[rollID] then
return "item:" .. rollID .. ":"
end
return _G.Items_Array[math.random(#_G.Items_Array)]
end
return _G.Items_Array[math.random(#_G.Items_Array)]
end
end)

function _G.GetNumGroupMembers()
return 10
@@ -144,7 +144,7 @@ function _G.GetLootThreshold()
end

function _G.GetLootRollItemInfo(rollID)

end

function SetupML()
238 changes: 146 additions & 92 deletions .specs/Classes/Utils/Utils.spec.lua
Original file line number Diff line number Diff line change
@@ -1,102 +1,156 @@
require "busted.runner"()
require "busted.runner" ()

dofile(".specs/AddonLoader.lua").LoadToc("RCLootCouncil.toc")

local Utils

describe("#Utils :CheckOutdatedVersion", function()

before_each(function()
Utils = RCLootCouncil.Utils
end)

it("should exist", function()
assert.is.Function(Utils.CheckOutdatedVersion)
end)

it("should not crash", function()
assert.has_no.errors(function() Utils:CheckOutdatedVersion("","") end)
end)

it("should report equal version", function()
local res = Utils:CheckOutdatedVersion("2.15.0","2.15.0")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("2.15.1","2.15.1")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("3.0.0","3.0.0")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("999.999.999","999.999.999")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should default to addon version", function()
RCLootCouncil.version = "2.14.0"
assert.are.equal(Utils:CheckOutdatedVersion(nil, "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should report not-outdated versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.14.1", "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.1", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should report outdated versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.14.3"), RCLootCouncil.VER_CHECK_CODES[2])
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.15.1"), RCLootCouncil.VER_CHECK_CODES[2])
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "3.0.0"), RCLootCouncil.VER_CHECK_CODES[2])
end)

it("should handle test versions", function()
assert.has_no.errors(function() Utils:CheckOutdatedVersion("2.0.0", "2.1.0", "Alpha.1", "Alpha.1") end)
end)

it("should handles outdated test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.2"), RCLootCouncil.VER_CHECK_CODES[3])
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Beta.1"), RCLootCouncil.VER_CHECK_CODES[3])
end)

it("should handle non-outdated test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.2", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Beta.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should handle equal test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.1", "Alpha.1"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.10", "Alpha.10"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should not treat test versions as newer despite of main version", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.19.3", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should handle releases of former test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", "Beta.1", nil), RCLootCouncil.VER_CHECK_CODES[2])
end)

it("should handle newer test versions", function()
assert.are.equal(RCLootCouncil.VER_CHECK_CODES[1], Utils:CheckOutdatedVersion("3.0.1", "3.0.0", "Alpha.1", nil))
end)
before_each(function()
Utils = RCLootCouncil.Utils
end)

it("should exist", function()
assert.is.Function(Utils.CheckOutdatedVersion)
end)

it("should not crash", function()
assert.has_no.errors(function() Utils:CheckOutdatedVersion("", "") end)
end)

it("should report equal version", function()
local res = Utils:CheckOutdatedVersion("2.15.0", "2.15.0")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("2.15.1", "2.15.1")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("3.0.0", "3.0.0")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
res = Utils:CheckOutdatedVersion("999.999.999", "999.999.999")
assert.are.equal(res, RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should default to addon version", function()
RCLootCouncil.version = "2.14.0"
assert.are.equal(Utils:CheckOutdatedVersion(nil, "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should report not-outdated versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.14.1", "2.14.0"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.1", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "2.14.20"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should report outdated versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.14.3"), RCLootCouncil.VER_CHECK_CODES[2])
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "2.15.1"), RCLootCouncil.VER_CHECK_CODES[2])
assert.are.equal(Utils:CheckOutdatedVersion("2.14.2", "3.0.0"), RCLootCouncil.VER_CHECK_CODES[2])
end)

it("should handle test versions", function()
assert.has_no.errors(function() Utils:CheckOutdatedVersion("2.0.0", "2.1.0", "Alpha.1", "Alpha.1") end)
end)

it("should handles outdated test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.2"),
RCLootCouncil.VER_CHECK_CODES[3])
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Beta.1"),
RCLootCouncil.VER_CHECK_CODES[3])
end)

it("should handle non-outdated test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.2", "Alpha.1"),
RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Beta.1", "Alpha.1"),
RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should handle equal test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.0.0", "2.0.0", "Alpha.1", "Alpha.1"),
RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.1", "Alpha.1"),
RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("2.15.0", "2.15.0", "Alpha.10", "Alpha.10"),
RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should not treat test versions as newer despite of main version", function()
assert.are.equal(Utils:CheckOutdatedVersion("2.19.3", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1])
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", nil, "Beta.1"), RCLootCouncil.VER_CHECK_CODES[1])
end)

it("should handle releases of former test versions", function()
assert.are.equal(Utils:CheckOutdatedVersion("3.0.0", "3.0.0", "Beta.1", nil), RCLootCouncil.VER_CHECK_CODES[2])
end)

it("should handle newer test versions", function()
assert.are.equal(RCLootCouncil.VER_CHECK_CODES[1], Utils:CheckOutdatedVersion("3.0.1", "3.0.0", "Alpha.1", nil))
end)
end)

describe("#Utils functions", function()
describe("DiscardWeaponCorruption", function()
it("should remove correct bonusID", function()
local itemWith = "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:6513:::|h[Sk'shuul~`Vaz]|h|r"
local itemWithout = "|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:::|h[Sk'shuul~`Vaz]|h|r"
assert.are.equal(itemWithout, Utils:DiscardWeaponCorruption(itemWith))
end)

it("shouldn't touch others", function()
local item = "|cffa335ee|Hitem:174117::::::::120:256::5:5:4823:1502:4786:6509:4775:::|h[Spaulders of Miasmic Mycelia]|h|r"
assert.are.equal(item, Utils:DiscardWeaponCorruption(item))
end)

it("should handle nils", function()
assert.has_no.errors(function()
assert.is_nil(Utils:DiscardWeaponCorruption(nil))
end)
end)
end)
before_each(function()
Utils = RCLootCouncil.Utils
end)

describe("DiscardWeaponCorruption", function()
it("should remove correct bonusID", function()
local itemWith =
"|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:6513:::|h[Sk'shuul~`Vaz]|h|r"
local itemWithout =
"|cffa335ee|Hitem:172200::::::::120:104::5:7:4823:6572:6578:6579:1502:4786:::|h[Sk'shuul~`Vaz]|h|r"
assert.are.equal(itemWithout, Utils:DiscardWeaponCorruption(itemWith))
end)

it("shouldn't touch others", function()
local item =
"|cffa335ee|Hitem:174117::::::::120:256::5:5:4823:1502:4786:6509:4775:::|h[Spaulders of Miasmic Mycelia]|h|r"
assert.are.equal(item, Utils:DiscardWeaponCorruption(item))
end)

it("should handle nils", function()
assert.has_no.errors(function()
assert.is_nil(Utils:DiscardWeaponCorruption(nil))
end)
end)
end)

describe("UnitName", function()
local potdisc

setup(function()
potdisc = "Potdisc-Ravencrest"
end)

before_each(function()
RCLootCouncil.realmName = "Ravencrest"
Utils.unitNameLookup = {}
end)
it("should handle full name-realm", function()
assert.equals(potdisc, Utils:UnitName(potdisc))
end)

it("should handle missing realm", function()
assert.equals(potdisc, Utils:UnitName("Potdisc"))
assert.equals(potdisc, Utils:UnitName("Potdisc-"))
end)

it("should cache found player names", function()
Utils:UnitName("potdisc")
assert.are.same(potdisc, Utils.unitNameLookup["potdisc"])
Utils:UnitName(potdisc)
assert.are.same(potdisc, Utils.unitNameLookup[potdisc])
end)

it("should not cache names ending with '-'", function()
RCLootCouncil.realmName = ""
Utils:UnitName("potdisc")
Utils:UnitName("potdisc-")
assert.are.same({}, Utils.unitNameLookup)
end)

it("can handle missing param", function()
assert.has_no.errors(function ()
Utils:UnitName()
end)
end)
end)
end)
2 changes: 1 addition & 1 deletion Classes/Services/ErrorHandler.lua
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ function private:SanitizeLine (line)
end

function private:DoesErrorExist (err)
for _, v in ipairs(self.log) do
for _, v in ipairs(self.log or {}) do
if v.msg == err then return v end
end
return false
34 changes: 33 additions & 1 deletion Classes/Utils/GroupLoot.lua
Original file line number Diff line number Diff line change
@@ -24,6 +24,9 @@ GroupLoot.IgnoreList = {
function GroupLoot:OnInitialize()
self.Log = addon.Require "Utils.Log":New "GroupLoot"
addon:RegisterEvent("START_LOOT_ROLL", self.OnStartLootRoll, self)
self.OnLootRoll:subscribe(function (_, rollID)
pcall(self.HideGroupLootFrameWithRollID, self, rollID) -- REVIEW: pcall because I haven't actually tested it in game.
end)
-- addon:RegisterEvent("LOOT_HISTORY_ROLL_CHANGED", self.OnLootHistoryRollChanged, self)
end

@@ -72,7 +75,7 @@ end
function GroupLoot:RollOnLoot(rollID, rollType)
-- Delay execution in case other addons have modified the loot frame
-- and haven't had a change to fully load.
addon:ScheduleTimer(RollOnLoot, 0, rollID, rollType)
addon:ScheduleTimer(RollOnLoot, 0.05, rollID, rollType)
--ConfirmLootRoll(rollID, rollType)
end

@@ -93,3 +96,32 @@ function GroupLoot:OnLootHistoryRollChanged(event, itemId, playerId)
self.Log:d("GetItem:", C_LootHistory.GetItem(itemId))
self.Log:d("GetPlayerInfo:", C_LootHistory.GetPlayerInfo(itemId, playerId))
end

local NUM_LOOT_FRAMES = 4
--- Hides any visible default group loot frames
function GroupLoot:HideGroupLootFrames()
local hidden = false
for i = 1, NUM_LOOT_FRAMES do
local frame = _G["GroupLootFrame" .. i]
if frame and frame:IsShown() then
frame:Hide()
hidden = true
end
end
if hidden then
self.Log:D("Hided default group loot frames")
end
end

---Hides a visiable default group loot frame with a particular rollID
---@param rollID integer RollID of the frame to hide.
function GroupLoot:HideGroupLootFrameWithRollID(rollID)
if not rollID then return end
for i = 1, NUM_LOOT_FRAMES do
local frame = _G["GroupLootFrame" .. i]
if frame and frame:IsShown() and frame.rollID == rollID then
frame:Hide()
self.Log:D("Hide group loot frame with rollID", i, rollID)
end
end
end
22 changes: 22 additions & 0 deletions Modules/History/lootHistory.lua
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ function LootHistory:OnInitialize()
{name = "", width = ROW_HEIGHT, }, -- Item icon
{name = L["Item"], width = 250, comparesort = self.ItemSort, defaultsort = 1, sortnext = 2}, -- Item string
{name = L["Reason"], width = 220, comparesort = self.ResponseSort, defaultsort = 1, sortnext = 2}, -- Response aka the text supplied to lootDB...response
{ name = L["Notes"], width = 40, },
{name = "", width = ROW_HEIGHT}, -- Delete button
}
filterMenu = _G.MSA_DropDownMenu_Create("RCLootCouncil_LootHistory_FilterMenu", UIParent)
@@ -229,6 +230,7 @@ function LootHistory:BuildData()
{DoCellUpdate = self.SetCellGear, args={i.lootWon}},
{value = i.lootWon},
{DoCellUpdate = self.SetCellResponse, args = {color = i.color, response = i.response, responseID = i.responseID or 0, isAwardReason = i.isAwardReason}},
{ DoCellUpdate = self.SetCellNote },
{DoCellUpdate = self.SetCellDelete},
}
}
@@ -492,6 +494,26 @@ function LootHistory.SetCellResponse(rowFrame, frame, data, cols, row, realrow,
end
end

function LootHistory.SetCellNote(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...)
if not data then return end
local row = data[realrow]
local note = lootDB[row.name][row.num].note
local f = frame.noteBtn or CreateFrame("Button", nil, frame)
f:SetSize(ROW_HEIGHT, ROW_HEIGHT)
f:SetPoint("CENTER", frame, "CENTER")
if note then
f:SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Up.png")
f:SetScript("OnEnter", function() addon:CreateTooltip(_G.LABEL_NOTE, note) end) -- _G.LABEL_NOTE == "Note" in English
f:SetScript("OnLeave", function() addon:HideTooltip() end)
data[realrow].cols[column].value = 1 -- Set value for sorting compability
else
f:SetScript("OnEnter", nil)
f:SetNormalTexture("Interface/BUTTONS/UI-GuildButton-PublicNote-Disabled.png")
data[realrow].cols[column].value = 0
end
frame.noteBtn = f
end

function LootHistory.SetCellDelete(rowFrame, frame, data, cols, row, realrow, column, fShow, table, ...)
if not frame.created then
frame:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up")
Loading

0 comments on commit ec00e50

Please sign in to comment.