diff --git a/MudAdmin/MudAdmin.csproj b/MudAdmin/MudAdmin.csproj
index 5f53783..4a0e5b7 100644
--- a/MudAdmin/MudAdmin.csproj
+++ b/MudAdmin/MudAdmin.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/MudAdmin/Pages/User.razor b/MudAdmin/Pages/User.razor
index 5984b7c..ec62111 100644
--- a/MudAdmin/Pages/User.razor
+++ b/MudAdmin/Pages/User.razor
@@ -2,7 +2,6 @@
@using SharedProject.models
@using MudAdmin.Utils
@using SharedProject.enums
-@using GenFu
User
@@ -42,6 +41,19 @@ else
@item.GetHelpText()
}
+
+
+ @if (isSavingOptions)
+ {
+
+ Saving...
+ }
+ else
+ {
+
+ Save
+ }
+
@@ -52,15 +64,27 @@ else
+ OnClick="@(() => OnShowDetailsClick(context.Item))">
@(context.Item.ShowDetails ? "Hide" : "Show") Song Play Details
+
+
+
+
+
-
-
+
+
+
+ @CalculateTotalPlayCount(context.Item)
+
+
+
@if (context.ShowDetails)
@@ -77,16 +101,20 @@ else
Difficulty
- Score
Clear State
Play Count
+ Rating
+ Score
Max Chain
@SongPlayDetail.Difficulty
- @SongPlayDetail.Score
- @SongPlayDetail.ClearState
+
+ @(SongPlayDetail.Score != 1000000 ? SongPlayDetail.ClearState : ClearState.Perfect)
+
@SongPlayDetail.PlayCount
+ @CalculateRating(SongPlayDetail.Score)
+ @SongPlayDetail.Score
@SongPlayDetail.MaxChain
@@ -117,6 +145,20 @@ else
private List songPlayDataList = null!;
+ private bool isSavingOptions = false;
+
+ private static readonly ScoreGradeMap[] GRADES =
+ {
+ new(0, "E"),
+ new(300000, "D"),
+ new(500000, "C"),
+ new(700000, "B"),
+ new(800000, "A"),
+ new(900000, "S"),
+ new(950000, "S+"),
+ new(990000, "S++"),
+ };
+
protected override void OnInitialized()
{
var details = MockDataRepo.GetMockDataRepo().UserDetails;
@@ -129,9 +171,40 @@ else
songPlayDataList = MockDataRepo.GetMockDataRepo().SongPlayDataList;
}
- private void OnClick(SongPlayData data)
+ private void OnShowDetailsClick(SongPlayData data)
{
data.ShowDetails = !data.ShowDetails;
}
+ private async Task SaveOptions()
+ {
+ isSavingOptions = true;
+ await Task.Delay(2000);
+ isSavingOptions = false;
+ }
+
+ public record ScoreGradeMap(int Score, string Grade)
+ {
+ public override string ToString()
+ {
+ return $"{{ Score = {Score}, Grade = {Grade} }}";
+ }
+ }
+
+ private static string CalculateRating(int score)
+ {
+ var grade = GRADES.Where(g => g.Score <= score).Select(g => g.Grade).Last();
+ return grade;
+ }
+
+ private void OnFavoriteToggled(SongPlayData data)
+ {
+ data.IsFavorite = !data.IsFavorite;
+ }
+
+ private static int CalculateTotalPlayCount(SongPlayData data)
+ {
+ return data.SongPlaySubDataList
+ .Sum(detailData => detailData.PlayCount);
+ }
}
\ No newline at end of file
diff --git a/MudAdmin/Utils/MockDataRepo.cs b/MudAdmin/Utils/MockDataRepo.cs
index 89f0827..a51d694 100644
--- a/MudAdmin/Utils/MockDataRepo.cs
+++ b/MudAdmin/Utils/MockDataRepo.cs
@@ -33,12 +33,19 @@ public class MockDataRepo
foreach (var difficulty in Enum.GetValues())
{
- if (random.Next() > int.MaxValue / 2)
+ if (random.Next() <= int.MaxValue / 2)
{
- var subData = GenFu.GenFu.New();
- subData.Difficulty = difficulty;
- subDataList.Add(subData);
+ continue;
}
+
+ var subData = GenFu.GenFu.New();
+ subData.Difficulty = difficulty;
+
+ if (subData.ClearState == ClearState.Perfect)
+ {
+ subData.ClearState = ClearState.FullChain;
+ }
+ subDataList.Add(subData);
}
songPlayData.SongPlaySubDataList = subDataList;
@@ -92,7 +99,6 @@ public class MockDataRepo
GenFu.GenFu.Configure()
.Fill(data => data.Score).WithinRange(0, 1000001);
GenFu.GenFu.Configure()
- .Fill(data => data.LastPlayTime).AsPastDate()
.Fill(data => data.ShowDetails, false);
}
diff --git a/SharedProject/models/SongPlayData.cs b/SharedProject/models/SongPlayData.cs
index 03ebc93..18fec40 100644
--- a/SharedProject/models/SongPlayData.cs
+++ b/SharedProject/models/SongPlayData.cs
@@ -7,10 +7,8 @@ public class SongPlayData
public string Artist { get; set; } = string.Empty;
public List SongPlaySubDataList { get; set; } = new List(4);
-
- public DateTime LastPlayTime { get; set; }
-
- public int TotalPlayCount { get; set; }
+
+ public bool IsFavorite { get; set; }
public bool ShowDetails { get; set; }
}
\ No newline at end of file