From c6ccdfaee1dc4b078bd65adcb316756cb68573ac Mon Sep 17 00:00:00 2001 From: shiibe Date: Mon, 12 Sep 2022 21:12:40 -0400 Subject: [PATCH] Fix song requirements always showing 0 --- TaikoWebUI/Pages/DaniDojo.razor | 44 +++++++++++++++----- TaikoWebUI/Pages/DaniDojo.razor.cs | 65 +++++++++++------------------- 2 files changed, 59 insertions(+), 50 deletions(-) diff --git a/TaikoWebUI/Pages/DaniDojo.razor b/TaikoWebUI/Pages/DaniDojo.razor index 40ff653..00c87c9 100644 --- a/TaikoWebUI/Pages/DaniDojo.razor +++ b/TaikoWebUI/Pages/DaniDojo.razor @@ -228,7 +228,7 @@ } - @bestData + @(redRequirement - bestData) @resultText } @@ -289,8 +289,8 @@ @for (var k = 0; k < 3; k++) { var songNumber = k; - var redRequirement = border.RedBorderTotal; - var goldRequirement = border.GoldBorderTotal; + var redRequirement = GetSongBorderCondition(border, songNumber, false); + var goldRequirement = GetSongBorderCondition(border, songNumber, false); var barClass = "bar-default"; var resultText = "Failed"; @@ -322,7 +322,7 @@ } - @bestData + @(redRequirement - bestData) @resultText } @@ -340,12 +340,12 @@ resultText = "Gold"; } - @goldRequirement - - + @bestData - @resultText + + @resultText + } } @@ -354,8 +354,34 @@ 0 - N/A + + N/A + } + @{ + string conditionOperator = ">"; + if ((DanConditionType)border.OdaiType is DanConditionType.BadCount) + { + conditionOperator = "<"; + } + + if (redRequirement == 0) { + conditionOperator = ""; + } + } + + Conditions + + + Red + @conditionOperator @redRequirement + + + Gold + @conditionOperator @goldRequirement + + + diff --git a/TaikoWebUI/Pages/DaniDojo.razor.cs b/TaikoWebUI/Pages/DaniDojo.razor.cs index 152565d..5637ab8 100644 --- a/TaikoWebUI/Pages/DaniDojo.razor.cs +++ b/TaikoWebUI/Pages/DaniDojo.razor.cs @@ -67,47 +67,6 @@ public partial class DaniDojo return GetDanRequirementString(danConditionType); } - - private static string GetDanRequirementAll(DanData.OdaiBorder odaiBorder) - { - ((DanBorderType)odaiBorder.BorderType).Throw().IfNotEquals(DanBorderType.All); - var type = (DanConditionType)odaiBorder.OdaiType; - var template = - $"Pass when {{0}} {{1}} {odaiBorder.RedBorderTotal}, gold when {{1}} {odaiBorder.GoldBorderTotal}"; - return type switch - { - DanConditionType.SoulGauge => throw new ArgumentException("Soul gauge should not be here"), - DanConditionType.GoodCount => string.Format(template, "good count", "exceeds"), - DanConditionType.OkCount => string.Format(template, "ok count", "exceeds"), - DanConditionType.BadCount => string.Format(template, "bad count", "below"), - DanConditionType.ComboCount => string.Format(template, "combo count", "exceeds"), - DanConditionType.DrumrollCount => string.Format(template, "drum roll count", "exceeds"), - DanConditionType.Score => string.Format(template, "score", "exceeds"), - DanConditionType.TotalHitCount => string.Format(template, "hit count", "exceeds"), - _ => throw new ArgumentOutOfRangeException(nameof(odaiBorder)) - }; - } - - private static string GetDanRequirementPerSong(DanData.OdaiBorder odaiBorder, int songNumber) - { - songNumber.Throw().IfOutOfRange(0, 2); - ((DanBorderType)odaiBorder.BorderType).Throw().IfNotEquals(DanBorderType.PerSong); - var type = (DanConditionType)odaiBorder.OdaiType; - var template = - $"Pass when song{songNumber}'s {{0}} {{1}} {odaiBorder.RedBorderTotal}, gold when {{1}} {odaiBorder.GoldBorderTotal}"; - return type switch - { - DanConditionType.SoulGauge => throw new ArgumentException("Soul gauge should not be here"), - DanConditionType.GoodCount => string.Format(template, "good count", "exceeds"), - DanConditionType.OkCount => string.Format(template, "ok count", "exceeds"), - DanConditionType.BadCount => string.Format(template, "bad count", "below"), - DanConditionType.ComboCount => string.Format(template, "combo count", "exceeds"), - DanConditionType.DrumrollCount => string.Format(template, "drum roll count", "exceeds"), - DanConditionType.Score => string.Format(template, "score", "exceeds"), - DanConditionType.TotalHitCount => string.Format(template, "hit count", "exceeds"), - _ => throw new ArgumentOutOfRangeException(nameof(odaiBorder)) - }; - } private static long GetAllBestFromData(DanConditionType type, DanBestData data) { @@ -142,6 +101,30 @@ public partial class DaniDojo }; } + private static uint GetSongBorderCondition(DanData.OdaiBorder data, int songNumber, bool isGold) + { + if (!isGold) + { + return songNumber switch + { + 0 => data.RedBorder1, + 1 => data.RedBorder2, + 2 => data.RedBorder3, + _ => 0 + }; + } + else + { + return songNumber switch + { + 0 => data.GoldBorder1, + 1 => data.GoldBorder2, + 2 => data.GoldBorder3, + _ => 0 + }; + } + } + private static string GetDanTitle(string title) { return title switch