From 6586f3f4a92fd7ee358ecb2212130527409e6b9a Mon Sep 17 00:00:00 2001 From: TheDevilofme <26227481+TheDevilofme@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:25:29 +0100 Subject: [PATCH 1/5] add constants for ReserveResult - FailedGuild - FailedGuildRank and their translation to a chat message --- Constants.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Constants.lua b/Constants.lua index 875da68..b4b4a8a 100644 --- a/Constants.lua +++ b/Constants.lua @@ -25,6 +25,8 @@ LootReserve.Constants.ReserveResult = { FailedLimit = 15, FailedLimitPartial = 16, FailedUsable = 17, + FailedGuild = 18, + FailedGuildRank = 19, }; LootReserve.Constants.CancelReserveResult = { OK = 0, @@ -389,6 +391,8 @@ LootReserve.Constants.ReserveResultText = [result.FailedLimit] = "That item has reached the limit of reserves", [result.FailedLimitPartial] = "Not all of your reserves were accepted because the item reached the limit of reserves", [result.FailedUsable] = "You may not reserve unusable items", + [result.FailedGuild] = "That item is not reservable if you're not member of the hosts guild", + [result.FailedGuildRank] = "This item is not reservable on your guildrank", }; local result = LootReserve.Constants.CancelReserveResult; From d9ad5c2472a63507824c8c03ea9085fcf351e0f6 Mon Sep 17 00:00:00 2001 From: TheDevilofme <26227481+TheDevilofme@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:26:31 +0100 Subject: [PATCH 2/5] add function for number guild ranks --- LootReserve.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LootReserve.lua b/LootReserve.lua index f2e295f..c73eb70 100644 --- a/LootReserve.lua +++ b/LootReserve.lua @@ -1,4 +1,4 @@ -local addon, ns = ...; +local addon, ns = ...; LootReserve = LibStub("AceAddon-3.0"):NewAddon("LootReserve", "AceComm-3.0"); LootReserve.Version = GetAddOnMetadata(addon, "Version"); @@ -348,6 +348,10 @@ function LootReserve:GetNumClasses() return 11; end +function LootReserve:GetNumGuildRanks() + return GuildControlGetNumRanks() +end + function LootReserve:GetClassInfo(classID) local info = C_CreatureInfo.GetClassInfo(classID); if info then From 57d0ceec9aa3693573fe772181732ef5ca9b846e Mon Sep 17 00:00:00 2001 From: TheDevilofme <26227481+TheDevilofme@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:28:36 +0100 Subject: [PATCH 3/5] check for item conditions for guild & guild rank - on pack check for G and R following G - Test on client and server side - add to default object --- ItemConditions.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/ItemConditions.lua b/ItemConditions.lua index d0ec879..2b26d15 100644 --- a/ItemConditions.lua +++ b/ItemConditions.lua @@ -8,6 +8,9 @@ local DefaultConditions = Faction = nil, ClassMask = nil, Limit = nil, + OnlyGuild = nil, + Guild = nil, + MinimumGuildRank = nil }; function LootReserve.ItemConditions:Get(itemID, server) @@ -61,6 +64,14 @@ function LootReserve.ItemConditions:Save(itemID, server) if conditions.Limit and conditions.Limit <= 0 then conditions.Limit = nil; end + if conditions.OnlyGuild == false then + conditions.OnlyGuild = nil; + conditions.Guild = nil; + conditions.MinimumGuildRank = nil; + end + if conditions.MinimumGuildRank and conditions.MinimumGuildRank >= 10 then + conditions.MinimumGuildRank = nil; + end end -- If conditions are no different from the default - delete the table @@ -299,6 +310,20 @@ function LootReserve.ItemConditions:TestFaction(faction) return faction and UnitFactionGroup("player") == faction; end +function LootReserve.ItemConditions:TestGuild(onlyGuild, server, player) + -- if server then check if player variable same as guild otherwise check if server is in my guild + if server then + return onlyGuild and UnitIsInMyGuild(player) + end + return onlyGuild and UnitIsInMyGuild(LootReserve.Client.SessionServer); +end + +function LootReserve.ItemConditions:TestGuildRank(minimumGuildRank, player) + -- C_GuildInfo.GetGuildRankOrder(UnitGUID(player)) usable on infinite range + local guildRankTesterino = C_GuildInfo.GetGuildRankOrder(UnitGUID(player)); + return minimumGuildRank and tonumber(guildRankTesterino) <= tonumber(minimumGuildRank); +end + function LootReserve.ItemConditions:TestLimit(limit, itemID, player, server) if limit <= 0 then -- Has no limiton the number of reserves @@ -355,6 +380,15 @@ function LootReserve.ItemConditions:TestPlayer(player, itemID, server) if conditions and conditions.Limit and not self:TestLimit(conditions.Limit, itemID, player, server) then return false, LootReserve.Constants.ReserveResult.FailedLimit; end + if conditions and conditions.OnlyGuild then + if self:TestGuild(conditions.OnlyGuild, server, player) then + if conditions.MinimumGuildRank and not self:TestGuildRank(conditions.MinimumGuildRank, player) then + return false, LootReserve.Constants.ReserveResult.FailedGuildRank; + end + else + return false, LootReserve.Constants.ReserveResult.FailedGuild; + end + end return true; end @@ -408,6 +442,12 @@ function LootReserve.ItemConditions:Pack(conditions) if conditions.Limit and conditions.Limit ~= 0 then text = text .. "L" .. conditions.Limit; end + if conditions.OnlyGuild == true then + text = text .. "G"; + if conditions.MinimumGuildRank and conditions.MinimumGuildRank < 10 then + text = text.. "R" .. conditions.MinimumGuildRank; + end + end return text; end @@ -442,6 +482,18 @@ function LootReserve.ItemConditions:Unpack(text) break; end end + elseif char == "G" then + conditions.OnlyGuild = true; + if text:sub(i+1, i+1) == "R" then + for len = 1, 10 do + local rank = text:sub(i + 2, i + 1 + len); + if tonumber(rank) then + conditions.MinimumGuildRank = rank; + else + break; + end + end + end end end return conditions; From 25a608209b844b3fcae2c4df3bf45b919449a110 Mon Sep 17 00:00:00 2001 From: TheDevilofme <26227481+TheDevilofme@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:29:31 +0100 Subject: [PATCH 4/5] edit UI - add dropdown for guild rank - add the option to add limit by guild rank on edit items --- Windows/ServerLootEditWindow.lua | 1 + Windows/ServerLootEditWindow.xml | 95 ++++++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/Windows/ServerLootEditWindow.lua b/Windows/ServerLootEditWindow.lua index d7ce11c..3e0a328 100644 --- a/Windows/ServerLootEditWindow.lua +++ b/Windows/ServerLootEditWindow.lua @@ -83,6 +83,7 @@ function LootReserve.Server.LootEdit:UpdateLootList() frame.ConditionsFrame.ClassMask:Update(); frame.ConditionsFrame.State:Update(); frame.ConditionsFrame.Limit:Update(); + frame.ConditionsFrame.OnlyGuild:Update(); frame.ConditionsFrame.LimitNoHover:Update(); frame.hovered = nil; end diff --git a/Windows/ServerLootEditWindow.xml b/Windows/ServerLootEditWindow.xml index 8d27571..6446ca4 100644 --- a/Windows/ServerLootEditWindow.xml +++ b/Windows/ServerLootEditWindow.xml @@ -6,14 +6,14 @@ - + - + @@ -21,7 +21,7 @@ + + + + + + @@ -339,6 +421,7 @@ local hovered = self:IsMouseOver() and self:GetParent():GetParent():IsMouseOver() and not UIDROPDOWNMENU_OPEN_MENU and not LootReserve.Server.LootEdit.FocusedEditBox or UIDROPDOWNMENU_OPEN_MENU == self.ConditionsFrame.ClassMaskMenu + or UIDROPDOWNMENU_OPEN_MENU == self.ConditionsFrame.GuildRankMenu or self.ConditionsFrame.Limit.EditBox:HasFocus(); if self.hovered ~= hovered then self.hovered = hovered; @@ -349,6 +432,8 @@ self.ConditionsFrame.State:SetEnabled(hovered and not self.ConditionsFrame.State.disabled); self.ConditionsFrame.State:SetShown(hovered or self.ConditionsFrame.State.shown); self.ConditionsFrame.Limit:SetShown(hovered and self.ConditionsFrame.Limit.shown and not self.ConditionsFrame.State.disabled); + self.ConditionsFrame.OnlyGuild:SetEnabled(hovered); + self.ConditionsFrame.OnlyGuild:SetShown(hovered or not self.ConditionsFrame.OnlyGuild.any); self.ConditionsFrame.LimitNoHover:SetShown(not hovered and self.ConditionsFrame.LimitNoHover.shown and not self.ConditionsFrame.State.disabled); self.ConditionsFrame:Update(); for _, part in ipairs(self.ConditionBackgrounds) do @@ -741,4 +826,4 @@ - \ No newline at end of file + From bcf514f86029bcb928098e106fc2ed5b2de7e951 Mon Sep 17 00:00:00 2001 From: TheDevilofme <26227481+TheDevilofme@users.noreply.github.com> Date: Wed, 21 Dec 2022 15:31:39 +0100 Subject: [PATCH 5/5] correct guild rank, maximum is 10 so 11 is any or invalid --- ItemConditions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ItemConditions.lua b/ItemConditions.lua index 2b26d15..d2d84d3 100644 --- a/ItemConditions.lua +++ b/ItemConditions.lua @@ -69,7 +69,7 @@ function LootReserve.ItemConditions:Save(itemID, server) conditions.Guild = nil; conditions.MinimumGuildRank = nil; end - if conditions.MinimumGuildRank and conditions.MinimumGuildRank >= 10 then + if conditions.MinimumGuildRank and conditions.MinimumGuildRank >= 11 then conditions.MinimumGuildRank = nil; end end @@ -444,7 +444,7 @@ function LootReserve.ItemConditions:Pack(conditions) end if conditions.OnlyGuild == true then text = text .. "G"; - if conditions.MinimumGuildRank and conditions.MinimumGuildRank < 10 then + if conditions.MinimumGuildRank and conditions.MinimumGuildRank < 11 then text = text.. "R" .. conditions.MinimumGuildRank; end end