diff --git a/CoopSweeper/GameTypes/Game.cs b/CoopSweeper/GameTypes/Game.cs index c6259c2..7bed2ec 100644 --- a/CoopSweeper/GameTypes/Game.cs +++ b/CoopSweeper/GameTypes/Game.cs @@ -108,26 +108,36 @@ namespace CoopSweeper.GameTypes return true; } - - - public void Reveal(int x, int y) + private void InternalReveal(int x, int y) { - CheckMap(); var field = Map[x, y]; - //if (field.CheckID < _checkID) - // return; + if (field.CheckID == _checkID) + return; + + field.CheckID = _checkID; if (field.State != FieldState.REVEALED) { field.State = FieldState.REVEALED; if (field.ContainsBomb) GameFinished?.Invoke(false); + + if (field.SurroundingBombs == 0) + foreach (var surField in GetSorroundedFields(x, y)) + { + InternalReveal(surField.X, surField.Y); + } } if (CheckGameFinished()) GameFinished?.Invoke(true); + } - //_checkID + public void Reveal(int x, int y) + { + CheckMap(); + _checkID++; + InternalReveal(x, y); } public void ToggleMark(int x, int y)