Auto-upgrade legacy Reveal phase players to Vote
This commit is contained in:
@@ -20,8 +20,17 @@ internal static class EndpointHelpers
|
|||||||
|
|
||||||
public static async Task<Phase> GetPhase(AppDbContext db, Guid playerId)
|
public static async Task<Phase> GetPhase(AppDbContext db, Guid playerId)
|
||||||
{
|
{
|
||||||
var player = await db.Players.AsNoTracking().FirstOrDefaultAsync(p => p.Id == playerId);
|
var player = await db.Players.FirstOrDefaultAsync(p => p.Id == playerId);
|
||||||
return player?.CurrentPhase ?? Phase.Suggest;
|
if (player is null) return Phase.Suggest;
|
||||||
|
|
||||||
|
// Auto-upgrade any legacy Reveal phase to Vote to avoid blank screens
|
||||||
|
if (player.CurrentPhase == Phase.Reveal)
|
||||||
|
{
|
||||||
|
player.CurrentPhase = Phase.Vote;
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
return player.CurrentPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IResult PhaseMismatch(Phase required, Phase current) =>
|
public static IResult PhaseMismatch(Phase required, Phase current) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user