Exemplo n.º 1
0
        public void InitializeBoardTest()
        {
            MonopolyBoard board = new MonopolyBoard(11, 11, 1, CellsData);
            int           expectedNumberOfCell       = 40;
            int           expextedNumberOfLandCell   = 28;
            int           expextedNumberOfActionCell = 6;
            int           expectedNumberOfTaxCell    = 2;

            // cek jumlah MonopolyCell
            Assert.AreEqual(board.ListOfMonopolyCell.Count, expectedNumberOfCell);

            // cek jumlah LandCell
            List <MonopolyCell> cells = board.ListOfMonopolyCell.FindAll(FindLandCell);

            Assert.AreEqual(cells.Count, expextedNumberOfLandCell);

            // cek jumlah ActionCell
            cells = board.ListOfMonopolyCell.FindAll(FindActionCell);
            Assert.AreEqual(cells.Count, expextedNumberOfActionCell);

            // cek jumlah TaxCell
            cells = board.ListOfMonopolyCell.FindAll(FindTaxCell);
            Assert.AreEqual(cells.Count, expectedNumberOfTaxCell);

            // cek StartCell exist
            StartCell start = board.ListOfMonopolyCell[0] as StartCell;

            Assert.AreNotEqual(start, null);

            // cek JailCell exist
            JailCell jail = board.ListOfMonopolyCell[10] as JailCell;

            Assert.AreNotEqual(jail, null);

            // cek FreeParkingCell exist
            FreeParkingCell free = board.ListOfMonopolyCell[20] as FreeParkingCell;

            Assert.AreNotEqual(free, null);

            // cek GotoJailCell exist
            GotoJailCell gotojail = board.ListOfMonopolyCell[30] as GotoJailCell;

            Assert.AreNotEqual(gotojail, null);
        }
Exemplo n.º 2
0
        public Maze GetMaze()
        {
            maze              = new Maze(Width, Height);
            Hero.GetHero.X    = 1;
            Hero.GetHero.Y    = 1;
            startCell         = maze[1, 1];
            startCell.Visited = true;

            do
            {
                var neighbours = GetNeighbours(maze, startCell, 2);

                if (neighbours.Any())
                {
                    neighbourCell = neighbours[random.Next(0, neighbours.Count)];
                    stackCells.Push(startCell);
                    RemoveWall(startCell, neighbourCell, maze);
                    startCell             = neighbourCell;
                    neighbourCell.Visited = true;
                }
                else if (stackCells.Any())
                {
                    startCell = stackCells.Pop();
                }
                else
                {
                    List <AnyCell> unvisitedCells = maze.Cells.Where(cell
                                                                     => (cell is Ground) && (!cell.Visited)).ToList <AnyCell>();
                    startCell = unvisitedCells[random.Next(0, unvisitedCells.Count)];
                }
            }while (stackCells.Count != 0);

            DropCoin(maze);

            maze[1, 1] = new StartCell();

            PlaceFinishCell(maze);

            return(maze);
        }
Exemplo n.º 3
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="name">Nome del giocatore</param>
 public Player(string name)
 {
     this.Name = name;
     Cell      = new StartCell();
 }