Пример #1
0
        public void TestMatrixAlwaysToCreateADiffrentMatrix()
        {
            var labyrinthOne = new LabyrinthMatrix().Matrix;

            Thread.Sleep(25);
            var labyrinthTwo = new LabyrinthMatrix().Matrix;
            var result       = CompareTwoMatrix(labyrinthOne, labyrinthTwo);

            Assert.IsTrue(result, "Does not create different matrisies");
        }
Пример #2
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer = objectBuilder.CreteRenderer();
            this.player = objectBuilder.CreatePlayer();
            this.scoreboard = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix = objectBuilder.CreateLabyrinthMatrix();

            return GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix);
        }
Пример #3
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer          = objectBuilder.CreteRenderer();
            this.player            = objectBuilder.CreatePlayer();
            this.scoreboard        = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix            = objectBuilder.CreateLabyrinthMatrix();

            return(GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix));
        }
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard      = new ScoreBoardHandler(localScoreBoard);
            this.renderer        = new ConsoleRenderer();
            this.player          = new Player("Goshou");
            this.matrix          = new LabyrinthMatrix();

            this.game    = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
        public void IntanceAlwaysReturnsTheSamePlayerNameAsFirstCreational()
        {
            var mockedPlayer             = new Mock <IPlayer>();
            var mockedRenderer           = new Mock <IRenderer>();
            var mockedScoreBoardObserver = new Mock <IScoreBoardObserver>();
            var labyrinthMatrix          = new LabyrinthMatrix();

            mockedPlayer.SetupProperty(x => x.Name, "Ivo");

            var initialGameIntance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);
            var context            = initialGameIntance.GetCurrentContext();

            Assert.AreNotEqual(mockedPlayer.Object.Name, context.Player.Name);
            Assert.AreEqual("Goshou", context.Player.Name);
        }
        public void IntanceAlwaysReturnsTheSameGameEngineIntance()
        {
            var mockedPlayer = new Mock<IPlayer>();
            var mockedRenderer = new Mock<IRenderer>();
            var mockedScoreBoardObserver = new Mock<IScoreBoardObserver>();
            var labyrinthMatrix = new LabyrinthMatrix();

            mockedPlayer.SetupProperty(x => x.Name, "Stamat");

            var initialGameIntance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);

            mockedPlayer = new Mock<IPlayer>();
            mockedPlayer.SetupProperty(x => x.Name, "Pesho");

            var secondGameInstance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);

            Assert.AreEqual(initialGameIntance, secondGameInstance);
        }
        public void IntanceAlwaysReturnsTheSameGameEngineIntance()
        {
            var mockedPlayer             = new Mock <IPlayer>();
            var mockedRenderer           = new Mock <IRenderer>();
            var mockedScoreBoardObserver = new Mock <IScoreBoardObserver>();
            var labyrinthMatrix          = new LabyrinthMatrix();

            mockedPlayer.SetupProperty(x => x.Name, "Stamat");

            var initialGameIntance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);

            mockedPlayer = new Mock <IPlayer>();
            mockedPlayer.SetupProperty(x => x.Name, "Pesho");

            var secondGameInstance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);

            Assert.AreEqual(initialGameIntance, secondGameInstance);
        }
        public ILabyrinthMatrix GetLabyrinthMatrixFromString(string matrix)
        {
            var lines = matrix.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            int maxX  = lines.Max(l => l.Length);
            int maxY  = lines.Length;


            var labirynthMatrix = new LabyrinthMatrix(maxX, maxY);

            for (int x = 0; x < maxX; x++)
            {
                for (int y = 0; y < maxY; y++)
                {
                    labirynthMatrix[x, y] = lines[y][x];
                }
            }

            return(labirynthMatrix);
        }
Пример #9
0
        public void ShowLabyrinth(LabyrinthMatrix labyrinth, IPlayer player)
        {
            Console.WriteLine();
            char[][] myMatrix = labyrinth.Matrix;
            for (int i = 0; i < myMatrix.Length; i++)
            {
                for (int j = 0; j < myMatrix[i].Length; j++)
                {
                    if (i == player.PositionRow && j == player.PositionCol)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("*");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write(myMatrix[j][i]);
                    }
                }

                Console.WriteLine();
            }
        }
Пример #10
0
        public void ShowLabyrinth(LabyrinthMatrix labyrinth, IPlayer player)
        {
            Console.WriteLine();
            char[][] myMatrix = labyrinth.Matrix;
            for (int i = 0; i < myMatrix.Length; i++)
            {
                for (int j = 0; j < myMatrix[i].Length; j++)
                {
                    if (i == player.PositionRow && j == player.PositionCol)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("*");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write(myMatrix[j][i]);
                    }
                }

                Console.WriteLine();
            }
        }
        public void IntanceAlwaysReturnsTheSamePlayerNameAsFirstCreational()
        {
            var mockedPlayer = new Mock<IPlayer>();
            var mockedRenderer = new Mock<IRenderer>();
            var mockedScoreBoardObserver = new Mock<IScoreBoardObserver>();
            var labyrinthMatrix = new LabyrinthMatrix();

            mockedPlayer.SetupProperty(x => x.Name, "Ivo");

            var initialGameIntance = GameEngine.Instance(mockedPlayer.Object, mockedRenderer.Object, mockedScoreBoardObserver.Object, labyrinthMatrix);
            var context = initialGameIntance.GetCurrentContext();

            Assert.AreNotEqual(mockedPlayer.Object.Name, context.Player.Name);
            Assert.AreEqual("Goshou", context.Player.Name);
        }
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard = new ScoreBoardHandler(localScoreBoard);
            this.renderer = new ConsoleRenderer();
            this.player = new Player("Goshou");
            this.matrix = new LabyrinthMatrix();

            this.game = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
Пример #13
0
 public void ShowLabyrinth(LabyrinthMatrix labyrinth, Users.IPlayer player)
 {
     this.Renderer.ShowLabyrinth(labyrinth, player);
 }
Пример #14
0
 /// <summary>
 /// Creates instance of the context object.
 /// </summary>
 /// <param name="player">Accepts any instance of IPlayer.</param>
 /// <param name="renderer">Accepts any instance of IRenderer.</param>
 /// <param name="scoreboard">Accepts any instance of IScoreBoardObserver.</param>
 /// <param name="matrix">Accepts instance of the class LabyrinthMatrix.</param>
 public Context(IScoreBoardObserver scoreboardHandler, IRenderer renderer, IPlayer player, LabyrinthMatrix matrix)
 {
     this.ScoreboardHandler = scoreboardHandler;
     this.Renderer          = renderer;
     this.Player            = player;
     this.Matrix            = matrix;
     this.Memory            = new StateMemory();
 }