Skip to content

Commit efbaa73

Browse files
Merge pull request #172 from CodebreakerApp/162-backendmodels-gamesummaryupdates
162 GameSummary
2 parents b905265 + 097e2b4 commit efbaa73

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/Codebreaker.GameAPIs.Models.Tests/Codebreaker.GameAPIs.Models.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>
19-
<PackageReference Include="coverlet.collector" Version="6.0.1">
19+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
<PrivateAssets>all</PrivateAssets>
2222
</PackageReference>
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
namespace Codebreaker.GameAPIs.Extensions;
1+
using System.Runtime.CompilerServices;
2+
3+
namespace Codebreaker.GameAPIs.Extensions;
24

35
public static class GameExtensions
46
{
57
[Obsolete("Use HasEnded instead")]
68
public static bool Ended(this Game game) => HasEnded(game);
79
public static bool HasEnded(this Game game) => game.EndTime != null;
10+
11+
public static GameSummary ToGameSummary(this Game game) =>
12+
new(
13+
game.Id,
14+
game.GameType,
15+
game.PlayerName,
16+
game.HasEnded(),
17+
game.IsVictory,
18+
game.LastMoveNumber,
19+
game.StartTime,
20+
game.Duration ?? TimeSpan.MaxValue);
821
}

src/services/gameapi/Codebreaker.GameAPIs.Models/GameSummary.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public record class GameSummary(
66
string PlayerName,
77
bool IsCompleted,
88
bool IsVictory,
9+
int NumberMoves,
910
DateTime StartTime,
1011
TimeSpan Duration)
1112
{

0 commit comments

Comments
 (0)