Auto marking unmarked mines when win
This commit is contained in:
parent
2445155e93
commit
b3e3b50d64
8
Field.cs
8
Field.cs
@ -151,7 +151,7 @@
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void OpenAll()
|
||||
public void OpenAll(bool automark)
|
||||
{
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
@ -159,7 +159,13 @@
|
||||
opened.Add(cells[i]);
|
||||
if (cells[i].IsMarked && !cells[i].IsMine)
|
||||
cells[i].SetWrong();
|
||||
if (automark && cells[i].IsMine)
|
||||
{
|
||||
cells[i].Mark();
|
||||
nmines = 0;
|
||||
}
|
||||
}
|
||||
this.Draw();
|
||||
}
|
||||
public void Mark(int y, int x)
|
||||
{
|
||||
|
||||
12
Game.cs
12
Game.cs
@ -14,11 +14,12 @@
|
||||
while (true)
|
||||
{
|
||||
Console.Clear();
|
||||
field.Draw();
|
||||
if (field.Check())
|
||||
{
|
||||
field.OpenAll(true);
|
||||
return true;
|
||||
}
|
||||
field.Draw();
|
||||
Console.Write("Enter your command: ");
|
||||
try
|
||||
{
|
||||
@ -29,7 +30,8 @@
|
||||
int y = command[0].First() - 'A';
|
||||
if (field.Open(y, x))
|
||||
{
|
||||
this.Finish();
|
||||
Console.Clear();
|
||||
field.OpenAll(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -55,11 +57,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Finish()
|
||||
{
|
||||
field.OpenAll();
|
||||
Console.Clear();
|
||||
field.Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user