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

@@ -9,6 +9,7 @@ namespace Gameboard.ShogiUI.Sockets.Repositories.RepositoryManagers
Task<string> CreateGuestUser();
Task<bool> IsPlayer1(string sessionName, string playerName);
bool IsGuest(string playerName);
Task<bool> PlayerExists(string playerName);
}
public class GameboardRepositoryManager : IGameboardRepositoryManager
@@ -33,8 +34,8 @@ namespace Gameboard.ShogiUI.Sockets.Repositories.RepositoryManagers
{
PlayerName = clientId
};
var response = await repository.PostPlayer(request);
if (response.IsSuccessStatusCode)
var isCreated = await repository.PostPlayer(request);
if (isCreated)
{
return clientId;
}
@@ -45,19 +46,21 @@ namespace Gameboard.ShogiUI.Sockets.Repositories.RepositoryManagers
public async Task<bool> IsPlayer1(string sessionName, string playerName)
{
var session = await repository.GetGame(sessionName);
return session?.Session.Player1 == playerName;
return session?.Player1 == playerName;
}
public async Task<string> CreateJoinCode(string sessionName, string playerName)
{
var getGameResponse = await repository.GetGame(sessionName);
if (playerName == getGameResponse?.Session.Player1)
var session = await repository.GetGame(sessionName);
if (playerName == session?.Player1)
{
return (await repository.PostJoinCode(sessionName, playerName)).JoinCode;
return await repository.PostJoinCode(sessionName, playerName);
}
return null;
}
public bool IsGuest(string playerName) => playerName.StartsWith(GuestPrefix);
public async Task<bool> PlayerExists(string playerName) => await repository.GetPlayer(playerName) != null;
}
}