/// <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;
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
 public static string GetGameUrl(Guid gameId, Guid playerId, EnumPlayerType playerType) => $"/game/{gameId}/{playerId}?init={playerType}";
예제 #6
0
 public static EnumPlayerType OponentType(EnumPlayerType playerType) => (EnumPlayerType)((int)playerType * (-1));