1
0
mirror of synced 2024-11-24 06:50:15 +01:00

Fix song requirements always showing 0

This commit is contained in:
shiibe 2022-09-12 21:12:40 -04:00
parent 7708e3a268
commit c6ccdfaee1
2 changed files with 59 additions and 50 deletions

View File

@ -228,7 +228,7 @@
} }
<MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@redRequirement" Value="@(redRequirement - bestData)"> <MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@redRequirement" Value="@(redRequirement - bestData)">
<MudText Typo="Typo.caption">@bestData</MudText> <MudText Typo="Typo.caption">@(redRequirement - bestData)</MudText>
</MudProgressLinear> </MudProgressLinear>
<MudText Typo="Typo.caption" Style="text-align: right">@resultText</MudText> <MudText Typo="Typo.caption" Style="text-align: right">@resultText</MudText>
} }
@ -289,8 +289,8 @@
@for (var k = 0; k < 3; k++) @for (var k = 0; k < 3; k++)
{ {
var songNumber = k; var songNumber = k;
var redRequirement = border.RedBorderTotal; var redRequirement = GetSongBorderCondition(border, songNumber, false);
var goldRequirement = border.GoldBorderTotal; var goldRequirement = GetSongBorderCondition(border, songNumber, false);
var barClass = "bar-default"; var barClass = "bar-default";
var resultText = "Failed"; var resultText = "Failed";
@ -322,7 +322,7 @@
} }
<MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@redRequirement" Value="@(redRequirement - bestData)"> <MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@redRequirement" Value="@(redRequirement - bestData)">
<MudText Typo="Typo.caption">@bestData</MudText> <MudText Typo="Typo.caption">@(redRequirement - bestData)</MudText>
</MudProgressLinear> </MudProgressLinear>
<MudText Typo="Typo.caption" Style="text-align: right">@resultText</MudText> <MudText Typo="Typo.caption" Style="text-align: right">@resultText</MudText>
} }
@ -340,12 +340,12 @@
resultText = "Gold"; resultText = "Gold";
} }
@goldRequirement <MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@(goldRequirement > 0 ? goldRequirement : 1)" Value="@(goldRequirement > 0 ? bestData : 1)">
<MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="@goldRequirement" Value="@bestData">
<MudText Typo="Typo.caption">@bestData</MudText> <MudText Typo="Typo.caption">@bestData</MudText>
</MudProgressLinear> </MudProgressLinear>
<MudText Typo="Typo.caption" Style="text-align: right">@resultText</MudText> <MudStack Class="mt-1" AlignItems="AlignItems.End">
<MudText Typo="Typo.caption">@resultText</MudText>
</MudStack>
} }
} }
@ -354,8 +354,34 @@
<MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="100" Value="0"> <MudProgressLinear Class="@barClass" Rounded="true" Size="Size.Large" Max="100" Value="0">
<MudText Typo="Typo.caption">0</MudText> <MudText Typo="Typo.caption">0</MudText>
</MudProgressLinear> </MudProgressLinear>
<MudText Typo="Typo.caption" Style="text-align: right">N/A</MudText> <MudStack Class="mt-1" AlignItems="AlignItems.End">
<MudText Typo="Typo.caption">N/A</MudText>
</MudStack>
} }
@{
string conditionOperator = ">";
if ((DanConditionType)border.OdaiType is DanConditionType.BadCount)
{
conditionOperator = "<";
}
if (redRequirement == 0) {
conditionOperator = "";
}
}
<MudStack Spacing="1" Class="mt-8">
<MudText Typo="Typo.subtitle2" Style="font-weight:bold">Conditions</MudText>
<MudStack Row="true" Spacing="16">
<MudStack Spacing="0">
<MudText Typo="Typo.caption">Red</MudText>
<MudText Typo="Typo.body1" Style="font-weight: bold">@conditionOperator @redRequirement</MudText>
</MudStack>
<MudStack Spacing="0">
<MudText Typo="Typo.caption">Gold</MudText>
<MudText Typo="Typo.body1" Style="font-weight: bold">@conditionOperator @goldRequirement</MudText>
</MudStack>
</MudStack>
</MudStack>
</MudCardContent> </MudCardContent>
</MudCard> </MudCard>
</MudItem> </MudItem>

View File

@ -68,47 +68,6 @@ public partial class DaniDojo
return GetDanRequirementString(danConditionType); 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) private static long GetAllBestFromData(DanConditionType type, DanBestData data)
{ {
return type switch return type switch
@ -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) private static string GetDanTitle(string title)
{ {
return title switch return title switch