Fixed accidentally building the board from player2 perspective.
This commit is contained in:
@@ -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.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user