Fixed accidentally building the board from player2 perspective.

This commit is contained in:
2021-04-06 19:52:02 -05:00
parent 2d5c6b20b9
commit 05a9c71499
45 changed files with 441 additions and 276 deletions

View File

@@ -12,16 +12,13 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
// It can be an API route and still tell socket connections about the new session.
public class CreateGameHandler : IActionHandler
{
private readonly ILogger<CreateGameHandler> logger;
private readonly IGameboardRepository repository;
private readonly ISocketCommunicationManager communicationManager;
public CreateGameHandler(
ILogger<CreateGameHandler> logger,
ISocketCommunicationManager communicationManager,
IGameboardRepository repository)
{
this.logger = logger;
this.repository = repository;
this.communicationManager = communicationManager;
}
@@ -29,7 +26,7 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
public async Task Handle(string json, string userName)
{
var request = JsonConvert.DeserializeObject<CreateGameRequest>(json);
var postSessionResponse = await repository.PostSession(new PostSession
var sessionName = await repository.PostSession(new PostSession
{
SessionName = request.GameName,
PlayerName = userName,
@@ -41,12 +38,12 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
PlayerName = userName,
Game = new Game
{
GameName = postSessionResponse.SessionName,
GameName = sessionName,
Players = new[] { userName }
}
};
if (string.IsNullOrWhiteSpace(postSessionResponse.SessionName))
if (string.IsNullOrWhiteSpace(sessionName))
{
response.Error = "Game already exists.";
}