Exemplo n.º 1
0
        public IGame CreateGame(GameRequest request)
        {
            request.Validate();

            IPlayer player1 = null;
            IPlayer player2 = null;

            if (request.IsPlayer1ComputerPlayer)
            {
                player1 = ServiceLocator.CreateComputerPlayer(request.Player1Name);
            }
            else
            {
                player1 = new HumanPlayer(request.Player1Name);
            }

            if (request.IsPlayer2ComputerPlayer)
            {
                player2 = ServiceLocator.CreateComputerPlayer(request.Player2Name);
            }
            else
            {
                player2 = new HumanPlayer(request.Player2Name);
            }

            var rules = Checkers.ServiceLocator.CreateRules();
            var game  = Game.ServiceLocator.CreateGame(rules, player1, player2, request.GameSize);

            return(game);
        }