Exemplo n.º 1
0
 public Game(int x, int y, int bombs, bool fromFile)
 {
     this.x = x;
     this.y = y;
     this.bombs = bombs;
     if (fromFile)
     {
         FileProvider i = new FileProvider();
         this.grid = i.readGrid();
     }
     else
     {
         TestDataProvider i = new TestDataProvider();
         this.grid = i.readGrid();
     }
 }
Exemplo n.º 2
0
        private void placeTheBombs()
        {
            TestDataProvider testDataProvider = new TestDataProvider();
            Cell[] array = testDataProvider.readGrid();
            Random rand = new Random();
            //Fisher–Yates shuffle.
            for (int z = 0; z < 10; z++)
            {
                int k;
                Cell temp;
                for (int i = 80; i >= 0; i--)
                {
                    k = rand.Next(0, i + 1);
                    temp = array[k];
                    array[k] = array[i];
                    array[i] = temp;
                }

                for (int i = 0; i < 10; i++)
                {
                    array[i].currentCellState = CellState.Bomb;
                    int num = array[i].X * 9 + array[i].Y;
                    database[z, i] = num;
                }
            }
        }