Fix automatic reveal on restart
This commit is contained in:
@@ -43,7 +43,7 @@ namespace CoopSweeper.GameTypes
|
||||
for (int j = 0; j < Map.GetLength(1); j++)
|
||||
{
|
||||
int bombCounter = 0;
|
||||
foreach (var point in GetSorroundedFields(i, j))
|
||||
foreach (var point in GetSurroundedFields(i, j))
|
||||
{
|
||||
if (Map[point.X, point.Y].ContainsBomb)
|
||||
bombCounter++;
|
||||
@@ -54,7 +54,7 @@ namespace CoopSweeper.GameTypes
|
||||
}
|
||||
}
|
||||
|
||||
private List<Point> GetSorroundedFields(int x, int y)
|
||||
private List<Point> GetSurroundedFields(int x, int y)
|
||||
{
|
||||
var points = new List<Point>();
|
||||
points.Add(new Point(x - 1, y - 1));
|
||||
@@ -123,10 +123,13 @@ namespace CoopSweeper.GameTypes
|
||||
|
||||
field.State = FieldState.REVEALED;
|
||||
if (field.ContainsBomb)
|
||||
{
|
||||
FinishGame(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (field.SurroundingBombs == 0)
|
||||
foreach (var surField in GetSorroundedFields(x, y))
|
||||
foreach (var surField in GetSurroundedFields(x, y))
|
||||
{
|
||||
InternalReveal(surField.X, surField.Y, false);
|
||||
}
|
||||
@@ -138,7 +141,10 @@ namespace CoopSweeper.GameTypes
|
||||
}
|
||||
|
||||
if (CheckGameFinished())
|
||||
{
|
||||
FinishGame(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void RevealSurroindings(int x, int y)
|
||||
@@ -146,14 +152,14 @@ namespace CoopSweeper.GameTypes
|
||||
int bombs = Map[x, y].SurroundingBombs;
|
||||
int bombsFlagged = 0;
|
||||
|
||||
foreach (var point in GetSorroundedFields(x, y))
|
||||
foreach (var point in GetSurroundedFields(x, y))
|
||||
{
|
||||
if (Map[point.X, point.Y].ContainsBomb && Map[point.X, point.Y].State == FieldState.FLAG)
|
||||
if (Map[point.X, point.Y].State == FieldState.FLAG)
|
||||
bombsFlagged++;
|
||||
}
|
||||
|
||||
if (bombsFlagged == bombs)
|
||||
foreach (var point in GetSorroundedFields(x, y))
|
||||
foreach (var point in GetSurroundedFields(x, y))
|
||||
{
|
||||
if (Map[point.X, point.Y].State != FieldState.FLAG)
|
||||
InternalReveal(point.X, point.Y, false);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace CoopSweeper
|
||||
StartNewGame(game, cursorPosX, cursorPosY);
|
||||
};
|
||||
ConsoleKey key = (ConsoleKey)(-1);
|
||||
do
|
||||
while ((key = Console.ReadKey().Key) != ConsoleKey.Escape)
|
||||
{
|
||||
var oldCursorPosX = cursorPosX;
|
||||
var oldCursorPosY = cursorPosY;
|
||||
@@ -70,7 +70,7 @@ namespace CoopSweeper
|
||||
}
|
||||
Console.SetCursorPosition(0, 0);
|
||||
Console.CursorVisible = false;
|
||||
} while ((key = Console.ReadKey().Key) != ConsoleKey.Escape);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawChar(IField f, bool isCursor)
|
||||
|
||||
Reference in New Issue
Block a user