Add score token to spectator state

This commit is contained in:
Dan Balasescu
2022-12-09 16:05:36 +09:00
parent e42bd7b31a
commit 4a65f5c864
5 changed files with 10 additions and 6 deletions

View File

@ -261,7 +261,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestFinalFramesPurgedBeforeEndingPlay() public void TestFinalFramesPurgedBeforeEndingPlay()
{ {
AddStep("begin playing", () => spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), new Score())); AddStep("begin playing", () => spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), new Score(), 0));
AddStep("send frames and finish play", () => AddStep("send frames and finish play", () =>
{ {

View File

@ -147,7 +147,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
}; };
spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), recordingScore); spectatorClient.BeginPlaying(TestGameplayState.Create(new OsuRuleset()), recordingScore, 0);
spectatorClient.OnNewFrames += onNewFrames; spectatorClient.OnNewFrames += onNewFrames;
}); });
} }

View File

@ -159,7 +159,7 @@ namespace osu.Game.Online.Spectator
return Task.CompletedTask; return Task.CompletedTask;
} }
public void BeginPlaying(GameplayState state, Score score) public void BeginPlaying(GameplayState state, Score score, long? token)
{ {
// This schedule is only here to match the one below in `EndPlaying`. // This schedule is only here to match the one below in `EndPlaying`.
Schedule(() => Schedule(() =>
@ -175,6 +175,7 @@ namespace osu.Game.Online.Spectator
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray(); currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
currentState.State = SpectatedUserState.Playing; currentState.State = SpectatedUserState.Playing;
currentState.MaximumScoringValues = state.ScoreProcessor.MaximumScoringValues; currentState.MaximumScoringValues = state.ScoreProcessor.MaximumScoringValues;
currentState.ScoreToken = token;
currentBeatmap = state.Beatmap; currentBeatmap = state.Beatmap;
currentScore = score; currentScore = score;

View File

@ -33,14 +33,17 @@ namespace osu.Game.Online.Spectator
[Key(4)] [Key(4)]
public ScoringValues MaximumScoringValues { get; set; } public ScoringValues MaximumScoringValues { get; set; }
[Key(5)]
public long? ScoreToken { get; set; }
public bool Equals(SpectatorState other) public bool Equals(SpectatorState other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID && State == other.State; return BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID && State == other.State && ScoreToken == other.ScoreToken;
} }
public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID} State:{State}"; public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID} State:{State} Token:{ScoreToken}";
} }
} }

View File

@ -148,7 +148,7 @@ namespace osu.Game.Screens.Play
realmBeatmap.LastPlayed = DateTimeOffset.Now; realmBeatmap.LastPlayed = DateTimeOffset.Now;
}); });
spectatorClient.BeginPlaying(GameplayState, Score); spectatorClient.BeginPlaying(GameplayState, Score, token);
} }
public override bool OnExiting(ScreenExitEvent e) public override bool OnExiting(ScreenExitEvent e)