-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
41 lines (34 loc) · 1 KB
/
Form1.cs
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
namespace Projet2;
public partial class Form1 : Form
{
private Game game;
public Form1()
{
InitializeComponent();
game = new Game();
}
public void restartGame(){
for(int i=0; i<9;i++){
tabCases[i].Text="";
}
game= new Game();
}
public void onCaseClick(object sender, System.EventArgs e){
Case caseSelected = (Case) sender;
if(caseSelected.Text.Equals("")){
caseSelected.Text = game.CurrentPlayer+"";
int x = caseSelected.getCoord()[0];
int y = caseSelected.getCoord()[1];
game.grid[y,x] = game.CurrentPlayer;
if(game.isWin()){
MessageBox.Show($"{game.CurrentPlayer} a gagné!");
restartGame();
}else if(game.isNull()){
MessageBox.Show("Match null!!!");
restartGame();
}else{
game.changeCurrentPlayer();
}
}
}
}