CNinnovation.Codebreaker.GamesClient
3.6.0-beta.24
See the version list below for details.
dotnet add package CNinnovation.Codebreaker.GamesClient --version 3.6.0-beta.24
NuGet\Install-Package CNinnovation.Codebreaker.GamesClient -Version 3.6.0-beta.24
<PackageReference Include="CNinnovation.Codebreaker.GamesClient" Version="3.6.0-beta.24" />
paket add CNinnovation.Codebreaker.GamesClient --version 3.6.0-beta.24
#r "nuget: CNinnovation.Codebreaker.GamesClient, 3.6.0-beta.24"
// Install CNinnovation.Codebreaker.GamesClient as a Cake Addin #addin nuget:?package=CNinnovation.Codebreaker.GamesClient&version=3.6.0-beta.24&prerelease // Install CNinnovation.Codebreaker.GamesClient as a Cake Tool #tool nuget:?package=CNinnovation.Codebreaker.GamesClient&version=3.6.0-beta.24&prerelease
CNinnovation.Codebreaker.GamesClient
This library contains the GamesClient
class to communicate with the Codebreaker service, and model types that are used for the communication.
See https://github.com/codebreakerapp for more information on the complete solution.
See Codebreakerlight for a simple version of the Codebreaker solution with a Wiki to create your own Codebreaker service.
The GamesClient class and IGamesClient interface
The IGamesClient
class is the main contract to be used for communication to play the game. It contains the following methods:
Method | Description |
---|---|
StartGameAsync |
Start a new game |
SetMoveAsync |
Set guesses for a game move |
GetGameAsync |
Get a game by id with all details and moves |
GetGamesAsync |
Get a list of games with all details and moves (use the GamesQuery class to define the filter) |
The GamesClient
class implements the IGamesClient
interface. In the constructor, inject the HttpClient
class. You can use Microsoft.Extensions.Http
to configure the HttpClient
class.
Model types
The following model types are used to return information about the game.
Model type | Description |
---|---|
GameType |
Enum value to list different game types |
GamesQuery |
Use this class to query for game info lists using GetGamesAsync |
GameInfo |
Contains the game id, the game status, the game moves and the game result |
MoveInfo |
Contains the move number, the guess and the result of the guess. Contained within a GameInfo |
How to use
The following code snippet shows how to use the GamesClient
class to play the game.
Configure the DI container with the GamesClient class (use the NuGet package Microsoft.Extensions.Http
to configure the HttpClient
class):
services.AddHttpClient<IGamesClient, GamesClient>(client =>
{
client.BaseAddress = new Uri("https://localhost:5001");
});
Start a game:
(Guid id, int numberCodes, int maxMoves, IDictionary<string, string[]> fieldValues) = await gamesClient.StartGameAsync("Game6x4", "player1");
Set a move:
(string[] result, bool ended, bool isVictory) = await gameClient.SetMoveAsync(id, "Game6x4", [ "Red", "Green", "Blue", "Yellow" ]);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CNinnovation.Codebreaker.GamesClient:
Package | Downloads |
---|---|
CNInnovation.Codebreaker.ViewModels
This library contains shared view-model types for the Codebreaker app. See https://github.com/codebreakerapp for more information on the complete solution. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.7.0 | 105 | 5/27/2024 |
3.6.0-beta.24 | 105 | 3/28/2024 |
3.6.0-beta.23 | 131 | 2/12/2024 |
3.6.0-beta.21 | 131 | 1/12/2024 |