Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

162 GameSummary #172

Merged
merged 2 commits into from
Apr 2, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
namespace Codebreaker.GameAPIs.Extensions;
using System.Runtime.CompilerServices;

namespace Codebreaker.GameAPIs.Extensions;

public static class GameExtensions
{
[Obsolete("Use HasEnded instead")]
public static bool Ended(this Game game) => HasEnded(game);
public static bool HasEnded(this Game game) => game.EndTime != null;

public static GameSummary ToGameSummary(this Game game) =>
new(
game.Id,
game.GameType,
game.PlayerName,
game.HasEnded(),
game.IsVictory,
game.LastMoveNumber,
game.StartTime,
game.Duration ?? TimeSpan.MaxValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public record class GameSummary(
string PlayerName,
bool IsCompleted,
bool IsVictory,
int NumberMoves,
DateTime StartTime,
TimeSpan Duration)
{
Expand Down