Skip to content

Commit

Permalink
Add time difference to local record announcement (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdankert committed Sep 30, 2024
1 parent 48b1567 commit 6aed7ff
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Modules/LocalRecordsModule/Services/LocalRecordsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,24 @@ await server.InfoMessageAsync(new TextFormatter()

if (record.Score < oldRecord.Record.Score)
{
var timeDifference = RaceTime.FromMilliseconds(oldRecord.Record.Score - record.Score);
var timeDifferenceStr = timeDifference.ToString();

if (timeDifferenceStr == null)
{
throw new InvalidOperationException($"Failed to convert {timeDifference} to race time difference");
}

await server.InfoMessageAsync(new TextFormatter()
.AddText(record.Player.NickName)
.AddText(" improved the ")
.AddText($"{localRecord.Position}.", s => s.WithColor(themeManager.Theme.Info))
.AddText(" local record ")
.AddText(" local record to ")
.AddText(localRaceTime, s => s.WithColor(themeManager.Theme.Info))
.AddText(" (")
.AddText(" (-")
.AddText(timeDifferenceStr, s => s.WithColor(themeManager.Theme.Info))
.AddText(") from ")
.AddText($"{oldRecord.Position}.", s => s.WithColor(themeManager.Theme.Info))
.AddText(" - ")
.AddText($"{localRecord.Position}.", s => s.WithColor(themeManager.Theme.Info))
.AddText(" )")
.ToString());
await ShowWidgetToAllAsync();
}
Expand Down

0 comments on commit 6aed7ff

Please sign in to comment.