From 3a3a6613cd9783f421df0a152c8675a669910557 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 8 Sep 2024 15:14:44 -0700 Subject: add preliminary frontline losing streak bonus tracking --- Malmstone/Services/PVPService.cs | 148 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) (limited to 'Malmstone/Services') diff --git a/Malmstone/Services/PVPService.cs b/Malmstone/Services/PVPService.cs index cf08fea..ef16df9 100644 --- a/Malmstone/Services/PVPService.cs +++ b/Malmstone/Services/PVPService.cs @@ -4,6 +4,22 @@ namespace Malmstone.Services { public class PvPService { + public int CurrentFrontlineLosingBonus = -1; + + public enum FrontlinePlacement + { + FirstPlace = 1, SecondPlace = 2, ThirdPlace = 3, Unknown=4 + } + + public struct PVPProfileFrontlineResults + { + public uint FirstPlace; + public uint SecondPlace; + public uint ThirdPlace; + } + + public PVPProfileFrontlineResults CachedFrontlineResults; + public PvPSeriesInfo? GetPvPSeriesInfo() { unsafe @@ -21,6 +37,138 @@ namespace Malmstone.Services return null; } } + + public bool UpdateFrontlineResultCache() + { + unsafe + { + var pvpProfile = PvPProfile.Instance(); + if (pvpProfile != null && pvpProfile->IsLoaded != 0) + { + CachedFrontlineResults = new PVPProfileFrontlineResults + { + FirstPlace = pvpProfile->FrontlineTotalFirstPlace, + SecondPlace = pvpProfile->FrontlineTotalSecondPlace, + ThirdPlace = pvpProfile->FrontlineTotalThirdPlace + }; + return true; + } + return false; + } + } + + public int GenerateFrontlineBonus(FrontlinePlacement FrontlineResult, int EarnedSeriesEXP) + { + // Calculates the current Frontline Bonus + // 1000 (no bonus), 1100, 1200, 1300, 1400, 1500 3rd + // 1250 (no bonus), 1375, 1500, 1625, 1750, 1875 2nd + // 1500 (no bonus), 1650, 1800, 1950, 2100, 2250 1st + if (FrontlineResult == FrontlinePlacement.ThirdPlace) + { + switch (EarnedSeriesEXP) + { + case 1000: + CurrentFrontlineLosingBonus = 0; + return 0; + case 1100: + CurrentFrontlineLosingBonus = 10; + return 10; + case 1200: + CurrentFrontlineLosingBonus = 20; + return 20; + case 1300: + CurrentFrontlineLosingBonus = 30; + return 30; + case 1400: + CurrentFrontlineLosingBonus = 40; + return 40; + case 1500: + CurrentFrontlineLosingBonus = 50; + return 50; + default: + return -1; + } + } + else if (FrontlineResult == FrontlinePlacement.SecondPlace) + { + switch (EarnedSeriesEXP) + { + case 1250: + CurrentFrontlineLosingBonus = 0; + return 0; + case 1375: + CurrentFrontlineLosingBonus = 10; + return 10; + case 1500: + CurrentFrontlineLosingBonus = 20; + return 20; + case 1625: + CurrentFrontlineLosingBonus = 30; + return 30; + case 2100: + CurrentFrontlineLosingBonus = 40; + return 40; + case 2250: + CurrentFrontlineLosingBonus = 50; + return 50; + default: + return -1; + } + } + else if (FrontlineResult == FrontlinePlacement.FirstPlace) + { + switch (EarnedSeriesEXP) + { + case 1500: + CurrentFrontlineLosingBonus = 0; + return 0; + case 1650: + CurrentFrontlineLosingBonus = 10; + return 10; + case 1800: + CurrentFrontlineLosingBonus = 20; + return 20; + case 1950: + CurrentFrontlineLosingBonus = 30; + return 30; + case 1750: + CurrentFrontlineLosingBonus = 40; + return 40; + case 1875: + CurrentFrontlineLosingBonus = 50; + return 50; + default: + return -1; + } + } + return -1; + } + + public PVPProfileFrontlineResults GetPVPProfileFrontlineResults() + { + unsafe + { + var pvpProfile = PvPProfile.Instance(); + if (pvpProfile != null && pvpProfile->IsLoaded != 0) + { + return new PVPProfileFrontlineResults + { + FirstPlace = pvpProfile->FrontlineTotalFirstPlace, + SecondPlace = pvpProfile->FrontlineTotalSecondPlace, + ThirdPlace = pvpProfile->FrontlineTotalThirdPlace, + + }; + } + } + return new PVPProfileFrontlineResults + { + FirstPlace = 0, + SecondPlace = 0, + ThirdPlace = 0, + + }; + } + } public class PvPSeriesInfo -- cgit v1.2.3 From c434ed7e5b557ff82882d7ac74068169eb83de7c Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 8 Sep 2024 18:31:03 -0700 Subject: fix: logic with calculating start of losing streak bonus --- Malmstone/Services/PVPService.cs | 33 ++++++++------------------------- Malmstone/Windows/MainWindow.cs | 31 ++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 28 deletions(-) (limited to 'Malmstone/Services') diff --git a/Malmstone/Services/PVPService.cs b/Malmstone/Services/PVPService.cs index ef16df9..12b4c2a 100644 --- a/Malmstone/Services/PVPService.cs +++ b/Malmstone/Services/PVPService.cs @@ -5,6 +5,7 @@ namespace Malmstone.Services public class PvPService { public int CurrentFrontlineLosingBonus = -1; + public int ConsecutiveThirdPlaceFrontline = 0; public enum FrontlinePlacement { @@ -65,10 +66,11 @@ namespace Malmstone.Services // 1500 (no bonus), 1650, 1800, 1950, 2100, 2250 1st if (FrontlineResult == FrontlinePlacement.ThirdPlace) { + ConsecutiveThirdPlaceFrontline++; switch (EarnedSeriesEXP) - { + { // Next 3rd place will get +10% value case 1000: - CurrentFrontlineLosingBonus = 0; + CurrentFrontlineLosingBonus = 0; // Primed for buff return 0; case 1100: CurrentFrontlineLosingBonus = 10; @@ -117,29 +119,10 @@ namespace Malmstone.Services } else if (FrontlineResult == FrontlinePlacement.FirstPlace) { - switch (EarnedSeriesEXP) - { - case 1500: - CurrentFrontlineLosingBonus = 0; - return 0; - case 1650: - CurrentFrontlineLosingBonus = 10; - return 10; - case 1800: - CurrentFrontlineLosingBonus = 20; - return 20; - case 1950: - CurrentFrontlineLosingBonus = 30; - return 30; - case 1750: - CurrentFrontlineLosingBonus = 40; - return 40; - case 1875: - CurrentFrontlineLosingBonus = 50; - return 50; - default: - return -1; - } + // Buff is reset regardless + ConsecutiveThirdPlaceFrontline = 0; + CurrentFrontlineLosingBonus = 0; + return 0; } return -1; } diff --git a/Malmstone/Windows/MainWindow.cs b/Malmstone/Windows/MainWindow.cs index bd1ef5d..1617a00 100644 --- a/Malmstone/Windows/MainWindow.cs +++ b/Malmstone/Windows/MainWindow.cs @@ -26,7 +26,7 @@ namespace Malmstone.Windows { SizeConstraints = new WindowSizeConstraints { - MinimumSize = new Vector2(460, 530), + MinimumSize = new Vector2(460, 545), MaximumSize = new Vector2(float.MaxValue, float.MaxValue) }; @@ -120,18 +120,43 @@ namespace Malmstone.Windows { if(Plugin.PvPService.CurrentFrontlineLosingBonus == 0) { + if(Plugin.PvPService.ConsecutiveThirdPlaceFrontline == 1) + { + ImGui.TextColored(new Vector4(0.0f, 1.0f, 0.0f, 1.0f), "You'll receive 10%% reward bonus if you place 3rd"); + } + if (ImGui.IsItemHovered()) + { + ImGui.BeginTooltip(); + ImGui.Text("You're primed for a reward bonus! You will get a 10% reward bonus if you place 3rd again" + + "\nCounter resets if you rank 1st"); + ImGui.EndTooltip(); + } ImGui.Text("No Frontline Reward Bonus Currently Active"); } else { - ImGui.TextColored(new Vector4(0.0f, 1.0f, 0.0f, 1.0f), "You'll receive a " + Plugin.PvPService.CurrentFrontlineLosingBonus + "%% reward boost next Frontline match"); + if (Plugin.PvPService.CurrentFrontlineLosingBonus != 50) + ImGui.TextColored(new Vector4(0.0f, 1.0f, 0.0f, 1.0f), "You'll receive a " + Plugin.PvPService.CurrentFrontlineLosingBonus + "%% reward bonus placing 1st or 2nd"); + else + ImGui.TextColored(new Vector4(0.0f, 1.0f, 0.0f, 1.0f), "You'll receive a " + Plugin.PvPService.CurrentFrontlineLosingBonus + "%% reward bonus placing 1st, 2nd, or 3rd"); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); - ImGui.Text("You will earn a " + Plugin.PvPService.CurrentFrontlineLosingBonus + "%% bonus on PvP EXP, Series EXP, and Wolf Marks " + + ImGui.Text("You'll earn a percentage bonus on PvP EXP, Series EXP, and Wolf Marks " + "until attaining First Place" ); ImGui.EndTooltip(); } + if (Plugin.PvPService.CurrentFrontlineLosingBonus != 50) + { + ImGui.TextColored(new Vector4(0.0f, 1.0f, 0.0f, 1.0f), "Your reward bonus will increase to " + (Plugin.PvPService.CurrentFrontlineLosingBonus + 10) + "%% if place 3rd"); + if (ImGui.IsItemHovered()) + { + ImGui.BeginTooltip(); + ImGui.Text($"Finishing 3rd again will increase your bonus to {Plugin.PvPService.CurrentFrontlineLosingBonus + 10}%." + + "\nThis increased bonus will also apply to the match where this happens."); + ImGui.EndTooltip(); + } + } } if (Plugin.Configuration.OutdatedFrontlineRewardBonus) { -- cgit v1.2.3