private void CreateGameField(int size) { int minesNumber = GenerateNumberOfMines(size); Field field = new Field(size, minesNumber); field.FillTheField(); Console.WriteLine(field.PrintField()); this.Field = field; }
public void MakeATurn() { int minesNumber = GenerateNumberOfMines(); Field field = new Field(this.GameField, minesNumber); field.FillTheField(); field.PrintField(); int turns = 0; while (minesNumber > 0) { int explodedMines = SetNextMinePosition(field.MatrixForField); minesNumber -= explodedMines; field.PrintField(); //Console.WriteLine("Mines Blowed this round: {0}",explodedMines); turns++; } Console.WriteLine("Game over -> detonated mines: {0}", turns); }
public void PrintRegularTest() { Field field = new Field(5, 8); Random fixedRandomGen = new Random(8); Type type = typeof(Field); var fieldValue = type.GetField("randomGen", BindingFlags.Instance | BindingFlags.NonPublic); fieldValue.SetValue(field, fixedRandomGen); field.FillTheField(); string expected = " 0 1 2 3 4\r\n ---------\r\n0|- 5 - 3 - \r\n1|4 - - - 3 \r\n2|- - 5 - - \r\n3|- - - - - \r\n4|2 5 5 - - \r\n"; string actual = field.PrintField(); Assert.AreEqual(expected, actual); }