/// <summary> /// Method that reveals cells onto the game field. /// </summary> /// <param name="mineField">The game field</param> /// <param name="currentCell">The cell to reveal</param> private static void ExecuteRevealBlockCommand(MineField mineField, Cell currentCell) { int row = currentCell.Row; int col = currentCell.Col; if (mineField.IsInsideTheField(row, col) && !mineField.IsAlreadyShown(row, col)) { if (mineField.IsMine(row, col)) { mineField.RevealAllMines(); Console.Clear(); GameMessages.EndGame(mineField.RevealedCellsCounter); GameMessages.DrawGameField(mineField.ToString()); bool isInTop5 = (mineField.RevealedCellsCounter > scoreBoard.MinimalScoreInTop5()); if (scoreBoard.Count() < 5 || isInTop5) { scoreBoard.AddScore(mineField.RevealedCellsCounter); } scoreBoard.ShowScore(); Main(); } else { mineField.RevealBlock(row, col); } } else { GameMessages.IlligalMove(); shouldDisplayBoard = false; } }
/// <summary> /// Method that executes flag command on a cell of the gamefield /// </summary> /// <param name="mineField">The game field</param> /// <param name="currentCell">The cell to flag.</param> private static void ExecuteFlagCommand(MineField mineField, Cell currentCell) { int row = currentCell.Row; int col = currentCell.Col; if (mineField.IsInsideTheField(row, col) && !mineField.IsAlreadyShown(row, col)) { mineField.AddRemoveFlag(row, col); } else { GameMessages.IlligalMove(); shouldDisplayBoard = false; } }