Program.cs
4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.Collections.Generic;
using ConsoleUserInt.ConsoleUI;
using Engine;
using MenuSystem;
using static System.Console;
namespace IDoMinesweeper
{
class Program
{
static void Main(string[] args)
{
Clear();
WriteLine("Welcome to Minesweeper");
var gameMenu = new Menu(1)
{
Title = "New Game",
MenuItemsDictionary = new Dictionary<string, MenuItem>()
{
{
"1", new MenuItem()
{
Title = "Level 1",
CommandToExecute = null
}
},
{
"2", new MenuItem()
{
Title = "Level 2",
CommandToExecute = null
}
},
{
"3", new MenuItem()
{
Title = "Customize Your Board size",
CommandToExecute = TestGame
}
},
}
};
var menu0 = new Menu(0) //main menu
{
Title = "Main Menu",
MenuItemsDictionary = new Dictionary<string, MenuItem>()
{
{
"S", new MenuItem()
{
Title = "Start game",
CommandToExecute = gameMenu.Run
}
},
{
"D", new MenuItem()
{
Title = "Donate",
CommandToExecute = null
}
}
}
};
menu0.Run();
static string TestGame()
{
// do do-while and if it's correct it'll be done. Otherwise, it's gonna keep asking for input''''
WriteLine("Board height (Min. 8): ");
WriteLine(">");
int height = Convert.ToInt32(ReadLine());
WriteLine("Board width (Min. 8): ");
WriteLine(">");
var width = Convert.ToInt32(ReadLine());
var doIt = false;
do
{
if (height < 8 || width < 8)
{
Console.WriteLine("Too small");
return "";
break;
}
else
{
doIt = true;
}
} while (doIt = false);
var game = new BoardDim(height, width);
//previously game
var done = false;
do{
Clear();
GameUI.PrintBoard(game);
game.MinesLocator(height, width);
Console.WriteLine("Check the tile");
Console.WriteLine("Y location:");
int playerMoveY = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("X location:");
int playerMoveX = Convert.ToInt32(Console.ReadLine());
game.checkTile(playerMoveY, playerMoveX);
//done = userYint == 0 && userXint == 0;
//done when it gets one mine at least. it'll turn the value from -1 to 0
done = true;
} while (!done);
return "GAME OVER!!";
}
}
}
}