Skip to content

Commit

Permalink
Fix maze bug for 1,1
Browse files Browse the repository at this point in the history
  • Loading branch information
dukeofsussex committed Apr 23, 2023
1 parent ca00a89 commit 7b4dc7b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Game/Modules/Maze.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ internal class Maze : BombModule
},
};

private Point squareLocation;
private Point? squareLocation;

private char[,] targetMaze;

private Point triangleLocation;
private Point? triangleLocation;

private bool solved;

Expand Down Expand Up @@ -185,20 +185,21 @@ public override string Process(string command, Bomb bomb)
return "Invalid circle coordinates.";
}

if (this.squareLocation.IsEmpty)
if (!this.squareLocation.HasValue)
{
this.squareLocation = new Point(x, y);
return "Triangle coordinates?";
}

this.triangleLocation = new Point(x, y);

if (this.triangleLocation.X == this.squareLocation.X && this.triangleLocation.Y == this.squareLocation.Y)
if (this.triangleLocation.Value.X == this.squareLocation.Value.X && this.triangleLocation.Value.Y == this.squareLocation.Value.Y)
{
this.squareLocation = new Point(0, 0);
return "Square and triangle must be in different places.";
}

List<string> directions = this.Solve(this.squareLocation.X, this.squareLocation.Y, new List<string>());
List<string> directions = this.Solve(this.squareLocation.Value.X, this.squareLocation.Value.Y, new List<string>());

if (directions.Count > 0)
{
Expand All @@ -210,7 +211,7 @@ public override string Process(string command, Bomb bomb)

private List<string> Solve(int x, int y, List<string> currentPath, string direction = null)
{
if (x == this.triangleLocation.X && y == this.triangleLocation.Y)
if (x == this.triangleLocation.Value.X && y == this.triangleLocation.Value.Y)
{
this.solved = true;
}
Expand Down

0 comments on commit 7b4dc7b

Please sign in to comment.