Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions fluXis.Tests/Multiplayer/TestMultiResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,49 @@ private void load(MapStore store)
{
new()
{
Accuracy = 99f,
Combo = 100,
MaxCombo = 100,
Mods = new List<string>(),
Rank = ScoreRank.SS,
Score = 1000000,
Flawless = 100,
Perfect = 100,
Great = 0,
Alright = 0,
Okay = 0,
Miss = 0,
PlayerID = 1,
MapID = map.OnlineID
MapID = map.OnlineID,
Players = new List<PlayerScore>
{
new PlayerScore
{
Accuracy = 99f,
Combo = 100,
MaxCombo = 100,
Rank = ScoreRank.SS,
Score = 1000000,
Flawless = 100,
Perfect = 100,
Great = 0,
Alright = 0,
Okay = 0,
Miss = 0,
PlayerID = 1,
}
}
},
new()
{
Accuracy = 100f,
Combo = 100,
MaxCombo = 100,
Mods = new List<string>(),
Rank = ScoreRank.X,
Score = 1100000,
Flawless = 100,
Perfect = 100,
Great = 0,
Alright = 0,
Okay = 0,
Miss = 0,
PlayerID = 2,
MapID = map.OnlineID
MapID = map.OnlineID,
Players = new List<PlayerScore>
{
new PlayerScore
{
Accuracy = 100f,
Combo = 100,
MaxCombo = 100,
Rank = ScoreRank.X,
Score = 1100000,
Flawless = 100,
Perfect = 100,
Great = 0,
Alright = 0,
Okay = 0,
Miss = 0,
PlayerID = 2,
}
}
}
};

Expand Down
38 changes: 22 additions & 16 deletions fluXis.Tests/Screens/TestResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using fluXis.Mods;
using fluXis.Online.API;
using fluXis.Online.API.Models.Scores;
using fluXis.Online.API.Models.Users;
using fluXis.Online.API.Requests.Scores;
using fluXis.Online.API.Responses.Scores;
using fluXis.Replays;
Expand Down Expand Up @@ -57,31 +56,38 @@ private RealmMap getMap()

private ScoreInfo getScore() => new()
{
Accuracy = 98.661736f,
Rank = ScoreRank.S,
PerformanceRating = 8,
Score = 1139289,
MaxCombo = 1218,
Flawless = 898,
Perfect = 290,
Great = 30,
Alright = 0,
Okay = 0,
Miss = 0,
Mods = new List<string> { "1.5x" }
Mods = new List<string> { "1.5x" },
Players = new List<PlayerScore>
{
new PlayerScore
{
PlayerID = -1,
Accuracy = 98.661736f,
Rank = ScoreRank.S,
PerformanceRating = 8,
Score = 1139289,
MaxCombo = 1218,
Flawless = 898,
Perfect = 290,
Great = 30,
Alright = 0,
Okay = 0,
Miss = 0,
}
}
};

[Test]
public void Normal()
{
AddStep("Push", () => stack.Push(new Results(getMap(), getScore(), APIUser.Dummy)));
AddStep("Push", () => stack.Push(new Results(getMap(), getScore())));
}

[Test]
public void WithRequestFromGameplay()
{
var score = getScore();
AddStep("Push With Request", () => stack.Push(new SoloResults(getMap(), score, APIUser.Dummy)
AddStep("Push With Request", () => stack.Push(new SoloResults(getMap(), score)
{
SubmitRequest = new SimulatedScoreRequest(score, new List<IMod>(), new Replay(), "", "", "")
}));
Expand All @@ -90,7 +96,7 @@ public void WithRequestFromGameplay()
[Test]
public void WithRestart()
{
AddStep("Push With Restart", () => stack.Push(new Results(getMap(), getScore(), APIUser.Dummy) { OnRestart = () => Logger.Log("Restart pressed.") }));
AddStep("Push With Restart", () => stack.Push(new Results(getMap(), getScore()) { OnRestart = () => Logger.Log("Restart pressed.") }));
}

private class SimulatedScoreRequest : ScoreSubmitRequest
Expand Down
26 changes: 16 additions & 10 deletions fluXis.Tests/Select/TestScoreEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ public TestScoreEntry()
DeleteAction = () => Logger.Log("Delete requested"),
ScoreInfo = new ScoreInfo
{
Score = 1000000,
MaxCombo = 100,
Accuracy = 100,
Mods = new List<string> { "1.4x", "HD", "NF" },
Rank = ScoreRank.X,
Flawless = 100,
Perfect = 100,
Great = 100,
Alright = 100,
Okay = 100,
Miss = 0,
Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds(),
Players = new List<PlayerScore>
{
new PlayerScore
{
Score = 1000000,
MaxCombo = 100,
Accuracy = 100,
Rank = ScoreRank.X,
Flawless = 100,
Perfect = 100,
Great = 100,
Alright = 100,
Okay = 100,
Miss = 0,
}
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion fluXis/Database/FluXisRealm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
using osu.Framework.Logging;
using osu.Framework.Platform;
using Realms;
using Realms.Dynamic;

//using Realms.Dynamic;

namespace fluXis.Database;

Expand Down Expand Up @@ -123,6 +124,8 @@ private void migrateTo(Migration migration, ulong targetSchemaVersion)

break;

//TODO: make this work again
/*
case 8:
var newScores2 = migration.NewRealm.All<RealmScore>().ToList();

Expand Down Expand Up @@ -152,6 +155,7 @@ private void migrateTo(Migration migration, ulong targetSchemaVersion)
}

break;
*/

case 10:
var mapsets = migration.OldRealm.DynamicApi.All("RealmMapSet").ToList();
Expand Down Expand Up @@ -286,6 +290,8 @@ private void migrateTo(Migration migration, ulong targetSchemaVersion)
maps.ForEach(x => x.Settings = new RealmMapUserSettings());
break;
}

//TODO: dual score migration
}
}

Expand Down
5 changes: 4 additions & 1 deletion fluXis/Database/RealmObjectUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public static class RealmObjectUtils
c.ShouldMapField = _ => false;
c.ShouldMapProperty = pi => pi.SetMethod?.IsPublic == true;

c.CreateMap<RealmScore, RealmScore>();
c.CreateMap<RealmScore, RealmScore>()
.ForMember(s => s.Players, cc => cc.Ignore());
c.CreateMap<RealmPlayerScore, RealmPlayerScore>()
.ForMember(s => s.RealmScore, cc => cc.Ignore());
c.CreateMap<RealmMapMetadata, RealmMapMetadata>();
c.CreateMap<RealmMapUserSettings, RealmMapUserSettings>();
c.CreateMap<RealmMapFilters, RealmMapFilters>();
Expand Down
66 changes: 66 additions & 0 deletions fluXis/Database/Score/RealmPlayerScore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using fluXis.Scoring;
using fluXis.Scoring.Enums;
using Realms;

namespace fluXis.Database.Score;

public class RealmPlayerScore : EmbeddedObject
{
public RealmScore RealmScore { get; set; } = null!;

public float Accuracy { get; set; }
public double PerformanceRating { get; set; }
public string Grade { get; set; }
public int Score { get; set; }
public int MaxCombo { get; set; }
public int Flawless { get; set; }
public int Perfect { get; set; }
public int Great { get; set; }
public int Alright { get; set; }
public int Okay { get; set; }
public int Miss { get; set; }
public long PlayerID { get; set; }
public float ScrollSpeed { get; set; }

[Ignored]
public ScoreRank Rank
{
get => Enum.Parse<ScoreRank>(Grade);
set => Grade = value.ToString();
}

public static RealmPlayerScore FromPlayerScore(PlayerScore playerScore) => new()
{
Accuracy = playerScore.Accuracy,
PerformanceRating = playerScore.PerformanceRating,
Rank = playerScore.Rank,
Score = playerScore.Score,
MaxCombo = playerScore.MaxCombo,
Flawless = playerScore.Flawless,
Perfect = playerScore.Perfect,
Great = playerScore.Great,
Alright = playerScore.Alright,
Okay = playerScore.Okay,
Miss = playerScore.Miss,
PlayerID = playerScore.PlayerID,
ScrollSpeed = playerScore.ScrollSpeed
};

public PlayerScore ToPlayerScore() => new()
{
Accuracy = Accuracy,
PerformanceRating = PerformanceRating,
Rank = Rank,
Score = Score,
MaxCombo = MaxCombo,
Flawless = Flawless,
Perfect = Perfect,
Great = Great,
Alright = Alright,
Okay = Okay,
Miss = Miss,
PlayerID = PlayerID,
ScrollSpeed = ScrollSpeed
};
}
Loading