From ffb7677a4792a158e05831f9b3afd9b2e6a8f2a5 Mon Sep 17 00:00:00 2001 From: Viridis Date: Mon, 31 Jan 2022 01:25:21 +0100 Subject: [PATCH 1/4] Update options.lua --- addons/config/options.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/config/options.lua b/addons/config/options.lua index ed9a143..c222e26 100644 --- a/addons/config/options.lua +++ b/addons/config/options.lua @@ -63,6 +63,7 @@ function Options:OnMain() self:AddCheck('Switcher') self:AddCheck('AlertUpgrades') self:AddCheck('Forfeit') + self:AddCheck('ForfeitNoRareUpgrades') end function Options:OnFAQ() From 36322f2a712b5666c5c13a200f5abe9f290fb58d Mon Sep 17 00:00:00 2001 From: Viridis Date: Mon, 31 Jan 2022 01:28:44 +0100 Subject: [PATCH 2/4] Update en.lua --- addons/main/localization/en.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/main/localization/en.lua b/addons/main/localization/en.lua index c684327..37dd6a2 100644 --- a/addons/main/localization/en.lua +++ b/addons/main/localization/en.lua @@ -45,6 +45,8 @@ L.AlertUpgradesTip = 'If disabled, an upgrades alert box will not be shown in co L.FAQDescription = 'These are the most frequently asked questions. To see the tutorials again, reset the addon settings using the "Defaults" button at the lower left corner.' L.Forfeit = 'Prompt for Forfeit' L.ForfeitTip = 'If enabled, will ask whether to forfeit a wild battle when no upgrades are available.' +L.ForfeitNoRareUpgrades = 'Prompt Forfeit No Rare' +L.ForfeitNoRareUpgradesTip = 'If enabled, will ask whether to forfeit a wild battle when no rare upgrades are available.' L.OptionsDescription = 'These options allow you to toggle PetTracker general features on and off. Gotta catch them all!' L.RivalPortraits = 'Rival Portraits' L.RivalPortraitsTip = 'If enabled, rivals will be marked by their portraits when shown in the world and battle map.' From 14b2e26b51929ea664ced2f46c342abd52559bef Mon Sep 17 00:00:00 2001 From: Viridis Date: Mon, 31 Jan 2022 01:35:39 +0100 Subject: [PATCH 3/4] Update alerts.lua --- addons/battle/alerts.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/addons/battle/alerts.lua b/addons/battle/alerts.lua index 07de1ad..e8b235b 100644 --- a/addons/battle/alerts.lua +++ b/addons/battle/alerts.lua @@ -32,19 +32,31 @@ function Alerts:OnEnable() end function Alerts:Verify() + local rareUpgrades = Addon.Battle:AnyRareUpgrade() + if not rareUpgrades and Addon.Battle:IsWildBattle() and not self.popped and Addon.sets.forfeitNoRareUpgrades then + self.popped = true + + LibStub('Sushi-3.1').Popup { + id = ADDON .. 'Alerts', + text = L.AskForfeit, button1 = "Quit, No Rare Upgrades", button2 = "Stay", + OnAccept = C_PetBattles.ForfeitGame, + hideOnEscape = 1, + } + end + local upgrades = Addon.Battle:AnyUpgrade() if not upgrades and Addon.Battle:IsWildBattle() and not self.popped and Addon.sets.forfeit then self.popped = true LibStub('Sushi-3.1').Popup { - id = ADDON .. 'Alerts', - text = L.AskForfeit, button1 = QUIT, button2 = NO, - OnAccept = C_PetBattles.ForfeitGame, - hideOnEscape = 1, - } + id = ADDON .. 'Alerts', + text = L.AskForfeit, button1 = "Quit, No Upgrades", button2 = "Stay", + OnAccept = C_PetBattles.ForfeitGame, + hideOnEscape = 1, + } end - self:SetShown(upgrades and not self.shown and Addon.sets.alertUpgrades) + self:SetShown(upgrades and not self.shown and Addon.sets.alertUpgrades) end function Alerts:Reset() From 3980de50575003527ad72bf6864ddc14c4a963fb Mon Sep 17 00:00:00 2001 From: Viridis Date: Mon, 31 Jan 2022 01:38:33 +0100 Subject: [PATCH 4/4] Update battle.lua --- addons/battle/battle.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/addons/battle/battle.lua b/addons/battle/battle.lua index b40b56d..58f13a5 100644 --- a/addons/battle/battle.lua +++ b/addons/battle/battle.lua @@ -31,6 +31,15 @@ function Battle:AnyUpgrade() end end +function Battle:AnyRareUpgrade() + for i = 1, self:NumPets(Enum.BattlePetOwner.Enemy) do + local pet = self(Enum.BattlePetOwner.Enemy, i) + if pet:IsUpgradeAndRare() then + return true + end + end +end + function Battle:GetRival() if self:IsPvE() then local specie1 = self(Enum.BattlePetOwner.Enemy, 1):GetSpecie() @@ -84,6 +93,24 @@ function Battle:IsUpgrade() return false end +function Battle:IsUpgradeAndRare() + if self:IsWildBattle() and not self:IsAlly() then + if self:GetSpecie() and self:GetSource() == 5 then + local _, quality = self:GetBestOwned() + + if quality > 3 then -- Player's best pet is rare, so it can never be an upgrade + return false + end + + if self:GetQuality() > 3 then -- The wild pet is rare (and ours is not), so it is an upgrade + return true + end + end + end + + return false +end + function Battle:CanSwap() return self:IsAlly() and C_PetBattles.CanPetSwapIn(self.index) end