Marking/unmarking multiple cells
in one move
This commit is contained in:
parent
ebd536897c
commit
2c477ef637
11
Game.cs
11
Game.cs
@ -25,7 +25,7 @@
|
|||||||
command = Console.ReadLine().ToUpper().Split();
|
command = Console.ReadLine().ToUpper().Split();
|
||||||
if (command.Length == 1)
|
if (command.Length == 1)
|
||||||
{
|
{
|
||||||
int x = Convert.ToInt16(command[0].Substring(1)) - 1;
|
int x = Convert.ToInt16(command[0][1..]) - 1;
|
||||||
int y = command[0].First() - 'A';
|
int y = command[0].First() - 'A';
|
||||||
if (field.Open(y, x))
|
if (field.Open(y, x))
|
||||||
{
|
{
|
||||||
@ -33,18 +33,21 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (command.Length == 2)
|
else if (command.Length > 1)
|
||||||
{
|
{
|
||||||
if (command[0] != "M" && command[0] != "U")
|
if (command[0] != "M" && command[0] != "U")
|
||||||
throw new Exception("Invalid command.");
|
throw new Exception("Invalid command.");
|
||||||
int x = Convert.ToInt16(command[1].Substring(1)) - 1;
|
for (int i = 1; i < command.Length; i++)
|
||||||
int y = command[1].First() - 'A';
|
{
|
||||||
|
int x = Convert.ToInt16(command[i][1..]) - 1;
|
||||||
|
int y = command[i].First() - 'A';
|
||||||
if (command[0] == "M")
|
if (command[0] == "M")
|
||||||
field.Mark(y, x);
|
field.Mark(y, x);
|
||||||
else
|
else
|
||||||
field.Unmark(y, x);
|
field.Unmark(y, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message + "\nTry again.");
|
Console.WriteLine(ex.Message + "\nTry again.");
|
||||||
|
|||||||
Reference in New Issue
Block a user