1
0
mirror of synced 2024-12-11 06:16:01 +01:00
TaikoLocalServer/TaikoWebUI/Pages/DaniDojo.razor.cs

182 lines
6.9 KiB
C#
Raw Normal View History

namespace TaikoWebUI.Pages;
2022-09-11 18:33:58 +02:00
public partial class DaniDojo
{
[Parameter]
public int Baid { get; set; }
private DanBestDataResponse? response;
private Dictionary<uint, DanBestData> bestDataMap = new();
private readonly List<BreadcrumbItem> breadcrumbs = new()
{
new BreadcrumbItem("Cards", href: "/Cards"),
};
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<DanBestDataResponse>($"api/DanBestData/{Baid}");
response.ThrowIfNull();
2022-09-12 16:17:15 +02:00
response.DanBestDataList.ForEach(data => data.DanBestStageDataList
.Sort((stageData, otherStageData) => stageData.SongNumber.CompareTo(otherStageData.SongNumber)));
2022-09-11 18:33:58 +02:00
bestDataMap = response.DanBestDataList.ToDictionary(data => data.DanId);
breadcrumbs.Add(new BreadcrumbItem($"Card: {Baid}", href: null, disabled: true));
breadcrumbs.Add(new BreadcrumbItem("Dani Dojo", href: $"/Cards/{Baid}/DaniDojo", disabled: false));
}
2022-09-12 23:15:27 +02:00
private static string GetDanClearStateString(DanClearState danClearState)
{
return danClearState switch
{
DanClearState.NotClear => "Not Cleared",
DanClearState.RedNormalClear => "Red Clear",
DanClearState.RedFullComboClear => "Red Full Combo",
DanClearState.RedPerfectClear => "Red Donderful Combo",
DanClearState.GoldNormalClear => "Gold Clear",
DanClearState.GoldFullComboClear => "Gold Full Combo",
DanClearState.GoldPerfectClear => "Gold Donderful Combo",
_ => ""
};
}
2022-09-12 17:49:28 +02:00
private static string GetDanRequirementString(DanConditionType danConditionType)
{
return danConditionType switch
{
DanConditionType.TotalHitCount => "Total Hits",
2022-09-12 19:33:13 +02:00
DanConditionType.GoodCount => "Good Hits",
DanConditionType.OkCount => "OK Hits",
DanConditionType.BadCount => "Bad Hits",
2022-09-12 17:49:28 +02:00
DanConditionType.SoulGauge => "Soul Gauge",
DanConditionType.DrumrollCount => "Drumroll Hits",
DanConditionType.Score => "Score",
DanConditionType.ComboCount => "MAX Combo",
_ => ""
};
}
2022-09-12 16:17:15 +02:00
private static string GetDanRequirementTitle(DanData.OdaiBorder data)
2022-09-11 18:33:58 +02:00
{
var danConditionType = (DanConditionType)data.OdaiType;
2022-09-12 17:49:28 +02:00
return GetDanRequirementString(danConditionType);
2022-09-12 16:17:15 +02:00
}
private static long GetAllBestFromData(DanConditionType type, DanBestData data)
2022-09-12 16:17:15 +02:00
{
return type switch
{
DanConditionType.SoulGauge => throw new ArgumentException("Soul gauge should not be here"),
DanConditionType.GoodCount => data.DanBestStageDataList.Sum(stageData => stageData.GoodCount),
DanConditionType.OkCount => data.DanBestStageDataList.Sum(stageData => stageData.OkCount),
DanConditionType.BadCount => data.DanBestStageDataList.Sum(stageData => stageData.BadCount),
DanConditionType.ComboCount => data.ComboCountTotal,
DanConditionType.DrumrollCount => data.DanBestStageDataList.Sum(stageData => stageData.DrumrollCount),
DanConditionType.Score => data.DanBestStageDataList.Sum(stageData => stageData.PlayScore),
DanConditionType.TotalHitCount => data.DanBestStageDataList.Sum(stageData => stageData.TotalHitCount),
2022-09-12 16:17:15 +02:00
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
};
}
2022-09-13 02:50:33 +02:00
private static uint GetSongBestFromData(DanConditionType type, DanBestData data, int songNumber)
2022-09-12 16:17:15 +02:00
{
songNumber.Throw().IfOutOfRange(0, 2);
return type switch
{
DanConditionType.SoulGauge => throw new ArgumentException("Soul gauge should not be here"),
2022-09-13 02:50:33 +02:00
DanConditionType.GoodCount => data.DanBestStageDataList[songNumber].GoodCount,
DanConditionType.OkCount => data.DanBestStageDataList[songNumber].OkCount,
DanConditionType.BadCount => data.DanBestStageDataList[songNumber].BadCount,
DanConditionType.ComboCount => data.DanBestStageDataList[songNumber].ComboCount,
DanConditionType.DrumrollCount => data.DanBestStageDataList[songNumber].DrumrollCount,
DanConditionType.Score => data.DanBestStageDataList[songNumber].PlayScore,
DanConditionType.TotalHitCount => data.DanBestStageDataList[songNumber].TotalHitCount,
2022-09-12 16:17:15 +02:00
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
2022-09-11 18:33:58 +02:00
};
}
2022-09-11 23:32:24 +02:00
2022-09-13 03:12:40 +02:00
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
};
}
return songNumber switch
2022-09-13 03:12:40 +02:00
{
0 => data.GoldBorder1,
1 => data.GoldBorder2,
2 => data.GoldBorder3,
_ => 0
};
2022-09-13 03:12:40 +02:00
}
2022-09-11 23:32:24 +02:00
private static string GetDanTitle(string title)
{
return title switch
{
"5kyuu" => "Fifth Kyuu",
"4kyuu" => "Fourth Kyuu",
"3kyuu" => "Third Kyuu",
"2kyuu" => "Second Kyuu",
"1kyuu" => "First Kyuu",
"1dan" => "First Dan",
"2dan" => "Second Dan",
"3dan" => "Third Dan",
"4dan" => "Fourth Dan",
"5dan" => "Fifth Dan",
"6dan" => "Sixth Dan",
"7dan" => "Seventh Dan",
"8dan" => "Eighth Dan",
"9dan" => "Ninth Dan",
"10dan" => "Tenth Dan",
"11dan" => "Kuroto",
"12dan" => "Meijin",
"13dan" => "Chojin",
"14dan" => "Tatsujin",
"15dan" => "Gaiden",
_ => ""
};
}
2022-09-12 04:15:03 +02:00
private string GetDanResultIcon(uint danId)
{
string icon;
const string notClearIcon = "<image href='/images/dani_NotClear.png' width='24' height='24' style='filter: contrast(0.65)'/>";
2022-09-12 04:15:03 +02:00
2022-09-12 16:17:15 +02:00
if (!bestDataMap.ContainsKey(danId))
2022-09-12 04:15:03 +02:00
{
2022-09-13 03:55:57 +02:00
return notClearIcon;
2022-09-12 16:17:15 +02:00
}
var state = bestDataMap[danId].ClearState;
2022-09-12 04:15:03 +02:00
icon = state is DanClearState.NotClear ? notClearIcon : $"<image href='/images/dani_{state}.png' width='24' height='24' />";
2022-09-12 04:15:03 +02:00
return icon;
}
2022-09-12 16:17:15 +02:00
2022-09-12 23:15:27 +02:00
private DanClearState GetDanResultState(uint danId)
{
return bestDataMap.ContainsKey(danId) ? bestDataMap[danId].ClearState : DanClearState.NotClear;
2022-09-12 23:15:27 +02:00
}
2022-09-12 17:49:28 +02:00
private static uint GetSoulGauge(DanData data, bool isGold)
2022-09-12 16:17:15 +02:00
{
var borders = data.OdaiBorderList;
var soulBorder =
borders.FirstOrDefault(border => (DanConditionType)border.BorderType == DanConditionType.SoulGauge,
new DanData.OdaiBorder());
return isGold ? soulBorder.GoldBorderTotal : soulBorder.RedBorderTotal;
2022-09-12 16:17:15 +02:00
}
2022-09-11 18:33:58 +02:00
}