/// <summary> /// Construct a Chess Player /// </summary> /// <param name="aType"></param> /// <param name="aName"></param> /// <param name="aColor"></param> public ChessPlayer(EnumPlayerType aType, string aName, EnumPieceColor aColor) { isTurn = false; playerType = aType; name = aName; pieceColor = aColor; isCheck = false; }
private Player CreatePlayer(EnumPlayerType playerType, Guid playerId, decimal timeLeft) { var player = new Player(playerId, playerType, timeLeft); if (IsPlayer) { player.OnTimeTick += Player_OnTimeTick; } return(player); }
public async Task CreateGame(Guid gameId, Guid playerId, EnumPlayerType playerType) { var oponentId = Guid.NewGuid(); var state = GameLogic.CreateGameState(playerId, playerType, oponentId); Context.Items.Add(gameId, state); await Clients.Caller.SendAsync(EnumGameEvent.GameCreated.ToString(), oponentId); }
public static GameState CreateGameState(Guid playerId, EnumPlayerType playerType, Guid oponentId) { var playerX = playerType == EnumPlayerType.X ? playerId : oponentId; var playerO = playerType == EnumPlayerType.O ? playerId : oponentId; var state = new GameState { PlayerX = playerX, PlayerO = playerO, TimeLeftX = PlayerTime, TimeLeftO = PlayerTime, ActivePlayer = playerId, FirstPlayer = playerType, }; state.AddLog($"Game created"); return(state); }
public static string GetGameUrl(Guid gameId, Guid playerId, EnumPlayerType playerType) => $"/game/{gameId}/{playerId}?init={playerType}";
public static EnumPlayerType OponentType(EnumPlayerType playerType) => (EnumPlayerType)((int)playerType * (-1));