public MineField(int width, int height, int totalMines, bool isResolvable, MinePutterDifficulty minePutterDifficulty) { Width = width; Height = height; IsResolvable = isResolvable; TotalMines = totalMines; // Seed = (int) GetCurrentUnixTimestampSeconds(); Random = new Random(); _minePutter = new MinePutterFactory().Generate(minePutterDifficulty); if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(Width), "Width cannot be less or equal to zero"); } if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(Height), "Height cannot be less or equal to zero"); } if (totalMines <= 0) { throw new ArgumentOutOfRangeException(nameof(TotalMines), "Total mines cannot be less or equal to zero"); } if (totalMines >= TotalCells) { throw new ArgumentOutOfRangeException(nameof(TotalCells), "Total mines cannot be greater or equal to total cells"); } Cells = new FieldCell[height, width]; }
public IMinePutter Generate(MinePutterDifficulty difficulty) { switch (difficulty) { case MinePutterDifficulty.Random: return(new MinePutterRandom()); case MinePutterDifficulty.Hard: return(new MinePutterHard()); case MinePutterDifficulty.Easy: return(new MinePutterEasy()); case MinePutterDifficulty.Cheat: return(new MinePutterCheat()); default: throw new ArgumentOutOfRangeException(nameof(difficulty), difficulty, null); } }
public MineFieldSnapshot( FieldCell[,] cells, int minesLeft, int freeCellsLeft, int totalOpenCells, int width, int height, int totalMines, bool isResolvable, MinePutterDifficulty minePutterDifficulty ) { Cells = cells; MinesLeft = minesLeft; FreeCellsLeft = freeCellsLeft; TotalOpenCells = totalOpenCells; Width = width; Height = height; TotalMines = totalMines; IsResolvable = isResolvable; MinePutterDifficulty = minePutterDifficulty; }