Skip to content

Commit

Permalink
Merge pull request #147 from CodebreakerApp/146-models-jsondeserializ…
Browse files Browse the repository at this point in the history
…ation

Game JSON deserialization of Moves
  • Loading branch information
christiannagel authored Feb 1, 2024
2 parents 340fa39 + c28f9e1 commit f0d8e6f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/Codebreaker.Backend.Models.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.GameAPIs.Models", "services\gameapi\Codebreaker.GameAPIs.Models\Codebreaker.GameAPIs.Models.csproj", "{CFC6E983-72EF-49AB-A0B1-9BFD7620517D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Codebreaker.GameAPIs.Models.Tests", "Codebreaker.GameAPIs.Models.Tests\Codebreaker.GameAPIs.Models.Tests.csproj", "{7CE99649-7DE1-4DA2-8E74-500595387669}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,8 +17,15 @@ Global
{CFC6E983-72EF-49AB-A0B1-9BFD7620517D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFC6E983-72EF-49AB-A0B1-9BFD7620517D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFC6E983-72EF-49AB-A0B1-9BFD7620517D}.Release|Any CPU.Build.0 = Release|Any CPU
{7CE99649-7DE1-4DA2-8E74-500595387669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CE99649-7DE1-4DA2-8E74-500595387669}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CE99649-7DE1-4DA2-8E74-500595387669}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CE99649-7DE1-4DA2-8E74-500595387669}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F57641F5-33AD-474C-9AEF-FD6992AC8EB9}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\services\gameapi\Codebreaker.GameAPIs.Models\Codebreaker.GameAPIs.Models.csproj" />
</ItemGroup>

</Project>
6 changes: 5 additions & 1 deletion src/services/gameapi/Codebreaker.GameAPIs.Models/Game.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Codebreaker.GameAPIs.Contracts;
using System.Text.Json.Serialization;

namespace Codebreaker.GameAPIs.Models;

Expand All @@ -25,7 +26,10 @@ public class Game(
public required IDictionary<string, IEnumerable<string>> FieldValues { get; init; }

public required string[] Codes { get; init; }
public ICollection<Move> Moves { get; } = new List<Move>();

[JsonInclude]
private List<Move> _moves = [];
public ICollection<Move> Moves => _moves;

public override string ToString() => $"{Id}:{GameType} - {StartTime}";
}
2 changes: 1 addition & 1 deletion src/services/gameapi/Codebreaker.GameAPIs.Models/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Move(Guid id, int moveNumber)
/// </summary>
public required string[] GuessPegs { get; init; }
/// <summary>
/// The result from the analyer for this move based on the associated game that contains the move.
/// The result from the analyzer for this move based on the associated game that contains the move.
/// </summary>
public required string[] KeyPegs { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ See [Codebreakerlight](https://github.com/codebreakerapp/codebreakerlight) for a
| Type | Description |
| --- | --- |
| CodebreakerException | Exceptions thrown within the backend. |
| CodebreakerExceptionCodes | Contants of exception codes. |
| CodebreakerExceptionCodes | Constants of exception codes. |
| GameExtensions | Extension methods for the Game type. |

0 comments on commit f0d8e6f

Please sign in to comment.