/// <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;
 }
Ejemplo n.º 2
0
        private Player CreatePlayer(EnumPlayerType playerType, Guid playerId, decimal timeLeft)
        {
            var player = new Player(playerId, playerType, timeLeft);

            if (IsPlayer)
            {
                player.OnTimeTick += Player_OnTimeTick;
            }
            return(player);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 public static string GetGameUrl(Guid gameId, Guid playerId, EnumPlayerType playerType) => $"/game/{gameId}/{playerId}?init={playerType}";
Ejemplo n.º 6
0
 public static EnumPlayerType OponentType(EnumPlayerType playerType) => (EnumPlayerType)((int)playerType * (-1));