public void CheckPlayerProperties()
 {
     var firstPlayer = new Player("Pesho", ChessColor.White);
     var moqedplayers = new Mock<IPlayer>();
     moqedplayers.Setup(p => p.AddFigure(It.IsAny<IFigure>())).Verifiable();
     moqedplayers.Setup(p => p.Name).Returns(firstPlayer.Name);
     moqedplayers.Setup(p => p.Color).Returns(firstPlayer.Color);
 }
        public IList<IPlayer> GetPlayers(int numberOfPlayers)
        {
            var players = new List<IPlayer>();
            for (int i = 1; i <= numberOfPlayers; i++)
            {
                Console.Clear();
                ConsoleHelpers.SetCursorAtCenter(PlayerNameText.Length);
                Console.Write(this.formatter.Format(string.Format(PlayerNameText, i)));
                string name = Console.ReadLine();
                var player = new Player(name, (ChessColor)i - 1);
                players.Add(player);
            }

            return players;
        }
        public void GameEngine(string gameId, string userId, string moveFrom, string moveTo)
        {
            var game = this.GetGame(gameId);
            var playerID = userId;
            var players = this.GetPlayers();
            var firstPlayer = players
                .FirstOrDefault(x => x.Id == game.FirstPlayerId);
            var secondPlayer = players
                .FirstOrDefault(x => x.Id == game.SecondPlayerId);
            var oldFen = game.Board;

            // if game doesn't exist
            if (game == null)
            {
                return;
            }

            if (firstPlayer == null || secondPlayer == null)
            {
                return;
            }

            // nothing to move
            if (moveFrom == moveTo)
            {
                return;
            }

            // check If player is 1 or 2
            if (playerID != game.FirstPlayerId && playerID != game.SecondPlayerId)
            {
                // return you are not part of this game
                this.Clients.Group(gameId).move(oldFen);
                return;
            }

            if (playerID == game.FirstPlayerId && game.State != KingSurvivalGameState.TurnKing)
            {
                // this is not your turn
                this.Clients.Group(gameId).move(oldFen);
                return;
            }

            if (playerID == game.SecondPlayerId && game.State != KingSurvivalGameState.TurnPown)
            {
                // this is not your turn
                this.Clients.Group(gameId).move(oldFen);
                return;
            }

            var renderer = new WebRenderer(this.Clients, game, this.data);
            var furstPlayer = new Player(firstPlayer.UserName, ChessColor.White);
            var scondPlayer = new Player(secondPlayer.UserName, Chess.Common.ChessColor.White);
            var kingSurvivalInitilizeStrategy = new KingSurvivalGameWebInitializationStrategy(oldFen, furstPlayer, scondPlayer);
            var from = new Position(moveFrom[1] - '0', moveFrom[0]);
            var to = new Position(moveTo[1] - '0', moveTo[0]);
            var move = new Move(from, to);
            var inputProvider = new WebInputProvider(move);
            var movementStrategy = new KingSurvivalMovementStrategy();

            var gameEngine = new KingSurvivalEngineWeb(renderer, inputProvider, movementStrategy);

            gameEngine.Initialize(kingSurvivalInitilizeStrategy);
            gameEngine.Play();
        }