Commit ccf99b58 by adbaga

yes

parent 7cf525b9
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
<option value="$PROJECT_DIR$/Game/CellState.cs" /> <option value="$PROJECT_DIR$/Game/CellState.cs" />
<option value="$PROJECT_DIR$/MenuSystem/Menu.cs" /> <option value="$PROJECT_DIR$/MenuSystem/Menu.cs" />
<option value="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" /> <option value="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" />
<option value="$PROJECT_DIR$/Game/CheckCell.cs" />
<option value="$PROJECT_DIR$/IDoMinesweeper/Program.cs" /> <option value="$PROJECT_DIR$/IDoMinesweeper/Program.cs" />
<option value="$PROJECT_DIR$/Game/Engine.cs" /> <option value="$PROJECT_DIR$/Game/Engine.cs" />
</list> </list>
...@@ -118,7 +119,8 @@ ...@@ -118,7 +119,8 @@
<workItem from="1570969640551" duration="4588000" /> <workItem from="1570969640551" duration="4588000" />
<workItem from="1571052402368" duration="4070000" /> <workItem from="1571052402368" duration="4070000" />
<workItem from="1571651125428" duration="10380000" /> <workItem from="1571651125428" duration="10380000" />
<workItem from="1571827801729" duration="4988000" /> <workItem from="1571827801729" duration="8314000" />
<workItem from="1571984846202" duration="7667000" />
</task> </task>
<task id="LOCAL-00001" summary="yes"> <task id="LOCAL-00001" summary="yes">
<created>1570973690674</created> <created>1570973690674</created>
...@@ -148,7 +150,14 @@ ...@@ -148,7 +150,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1571657780059</updated> <updated>1571657780059</updated>
</task> </task>
<option name="localTasksCounter" value="5" /> <task id="LOCAL-00005" summary="mines">
<created>1571842780536</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1571842780536</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
...@@ -174,7 +183,8 @@ ...@@ -174,7 +183,8 @@
<MESSAGE value="Adding validation input: Doesn't accept non int and set maximum size of the board" /> <MESSAGE value="Adding validation input: Doesn't accept non int and set maximum size of the board" />
<MESSAGE value="commit 3" /> <MESSAGE value="commit 3" />
<MESSAGE value="yes" /> <MESSAGE value="yes" />
<option name="LAST_COMMIT_MESSAGE" value="yes" /> <MESSAGE value="mines" />
<option name="LAST_COMMIT_MESSAGE" value="mines" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
......
...@@ -9,7 +9,8 @@ namespace Engine ...@@ -9,7 +9,8 @@ namespace Engine
public int BoardWidth { get; } public int BoardWidth { get; }
public int BoardHeight { get; } public int BoardHeight { get; }
private bool _minesSet;
public BoardDim(int boardHeight, int boardWidth) public BoardDim(int boardHeight, int boardWidth)
{ {
...@@ -51,66 +52,60 @@ namespace Engine ...@@ -51,66 +52,60 @@ namespace Engine
//private static Random random = new Random();
public int[,] MinesSetter(int height, int width)
}
public class Mines
{
public int[,] MineLoc { get; set; }
public int minePosY { get; }
public int minePosX { get; }
private static Random random = new Random();
public static int[,] MinesSetter(int height, int width)
{ {
Random random = new Random();
int[,] mineLoc = new int[height,width];
int mineCount = 0; int mineCount = 0;
int numOfMines = height * width / 3; int numOfMines = height * width / 8;
Console.WriteLine($"There are {numOfMines} mines"); //int[,] mineLoc = new int[width, height];
Console.WriteLine($"The size is {height} x {width}");
var results = new int[width, height];
do var placed = 0;
int[,] mineLoc = new int[width, height];
{ {
int minePosX = random.Next(width); do
int minePosY = random.Next(height);
// Make sure we haven't already set this position
if (mineLoc[minePosX, minePosY] != 1)
{ {
mineLoc[minePosX, minePosY] = 1; int minePosY = random.Next(width);
mineCount++; int minePosX = random.Next(height);
}
} while (mineCount <= numOfMines);
var done = true;
do{
// Make sure we haven't already set this position
Console.WriteLine("Check the tile"); if (mineLoc[minePosY, minePosX] != 1)
Console.WriteLine("Y location:"); {
int playerMoveY = Convert.ToInt32(Console.ReadLine()); mineLoc[minePosY, minePosX] = 1;
Console.WriteLine("X location:"); mineCount++;
int playerMoveX = Convert.ToInt32(Console.ReadLine());
int[,] checkMines = new int[playerMoveY,playerMoveX];
if (checkMines == mineLoc)
{
done = false;
}
} } while (mineCount <= numOfMines);
}
} while (done = true); Console.WriteLine(mineLoc.Length);
/*foreach (var x in mineLoc)
{
Console.WriteLine(mineCount);
}
*/
return mineLoc; return mineLoc;
} }
}
...@@ -120,5 +115,5 @@ namespace Engine ...@@ -120,5 +115,5 @@ namespace Engine
}
...@@ -78,8 +78,7 @@ namespace IDoMinesweeper ...@@ -78,8 +78,7 @@ namespace IDoMinesweeper
static string TestGame() static string TestGame()
{ {
WriteLine("Board height (Min. 8): "); WriteLine("Board height (Min. 8): ");
WriteLine(">"); WriteLine(">");
var checkHeight = ReadLine(); var checkHeight = ReadLine();
...@@ -91,12 +90,9 @@ namespace IDoMinesweeper ...@@ -91,12 +90,9 @@ namespace IDoMinesweeper
else else
{ {
height = Convert.ToInt32(checkHeight); height = Convert.ToInt32(checkHeight);
} }
...@@ -147,53 +143,49 @@ namespace IDoMinesweeper ...@@ -147,53 +143,49 @@ namespace IDoMinesweeper
var game = new BoardDim(height, width); var game = new BoardDim(height, width);
GameUI.PrintBoard(game); GameUI.PrintBoard(game);
//var mine = new Mines(height, width);
game.MinesSetter(height, width); Mines.MinesSetter(height,width);
Console.WriteLine();
/*var done = false;
var done = true;
do{ do{
Clear();
Console.WriteLine("Check the tile"); Console.WriteLine("Check the tile");
Console.WriteLine("Y location:"); Console.WriteLine("Y location:");
int playerMoveY = Convert.ToInt32(Console.ReadLine()); int playerMoveY = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("X location:"); Console.WriteLine("X location:");
int playerMoveX = Convert.ToInt32(Console.ReadLine()); int playerMoveX = Convert.ToInt32(Console.ReadLine());
game.checkTile(playerMoveY, playerMoveX);
int[,] checkMines = new int[playerMoveY,playerMoveX];
GameUI.PrintBoard(game);
//done = userYint == 0 && userXint == 0;
//done when it gets one mine at least. it'll turn the value from -1 to 0
} while (true);
*/
Console.WriteLine("GameOver");
} while (done = true);
return ""; return "";
}
} }
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment