Exemple #1
0
        public void ItVisitsAnd_AddsHardScore()
        {
            // Prepare:
            var score         = new RealScore();
            var boardDirector = new BoardDirector(new MediumStrategy(), 0, score, new Position(0, 0), new List <Bullet>());
            var builder       = new BoardBuilder();

            boardDirector.Construct(builder);
            var board = builder.Build();

            board.VisitVisitor();

            var mscore         = new RealScore();
            var mboardDirector = new BoardDirector(new HardStrategy(), 0, mscore, new Position(0, 0), new List <Bullet>());
            var mbuilder       = new BoardBuilder();

            mboardDirector.Construct(mbuilder);
            var mboard = mbuilder.Build();

            mboard.VisitVisitor();

            // Assert:

            Assert.True(score.Number < mscore.Number);
        }
        public GameController(IEnumerable <IView> availableViews, IWindowFascade windowFascade, IBoardStrategy strategy)
            : base(availableViews, windowFascade)
        {
            Game game = Game.Instance;

            _strategy = strategy;

            if (strategy.ProfileName.Equals("Justtest"))
            {
                _score = new NullScore();
            }
            else
            {
                _score = new RealScore();
            }
            game.Score = _score;
            if (_spaceShipPosition == null)
            {
                _spaceShipPosition = game.Board?.GetPosition();
            }
            var bullets = game.Board?.GetBullets() != null?game.Board?.GetBullets() : new List <Bullet>();

            _boardDirector = new BoardDirector(_strategy, game.Level, game.Score, _spaceShipPosition, bullets);
            _builder       = new BoardBuilder();
            _boardDirector.Construct(_builder);
            game.Board = _builder.Build();
        }
Exemple #3
0
        public void ItBuilds_GameBoard()
        {
            // Prepare:
            var score         = new RealScore();
            var boardDirector = new BoardDirector(new EasyStrategy(), 0, score, new Position(0, 0), new List <Bullet>());
            var builder       = new BoardBuilder();

            // Act:

            boardDirector.Construct(builder);
            var board = builder.Build();

            // Assert:

            Assert.NotNull(board);
            Assert.IsType <GameBoard>(board);
        }
Exemple #4
0
        public void ItBuilds_DifferentTemplatesRetro()
        {
            // Prepare:
            var score         = new RealScore();
            var boardDirector = new BoardDirector(new MediumStrategy(), 0, score, new Position(0, 0), new List <Bullet>());
            var builder       = new BoardBuilder();

            // Act:

            boardDirector.Construct(builder);
            var board = builder.Build();

            var drawTemplate = board.GetDrawTemplate();

            // Assert:

            Assert.NotNull(drawTemplate);
            Assert.IsType <RetroGame>(drawTemplate);
        }
        private Game GetGame()
        {
            Game game = Game.Instance;

            if (_spaceShipPosition == null)
            {
                _spaceShipPosition = game.Board?.GetPosition();
            }
            var bullets = game.Board?.GetBullets() != null?game.Board?.GetBullets() : new List <Bullet>();

            _boardDirector = new BoardDirector(_strategy, game.Level, game.Score, _spaceShipPosition, bullets);
            _boardDirector.Construct(_builder);
            if (game.Board?.EnemiesCount == 0)
            {
                var state = new GameEndedState();
                state.DoAction(game);
            }
            return(game);
        }