-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.h
78 lines (77 loc) · 1.98 KB
/
message.h
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
#pragma once
#include "include.h"
void ini_game(char game[3][3]){
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
game[i][j]=' ';
}
}
}
void print_message(int *input, int *plays, char game[3][3],char _turn, int *pos, char turn ,int xyz[5][2][3],char **grid,chtype __grid[GRID_LENTH][GRID_WIDTH],int _pos[5],int key,wins *win){
if(key==0){
mvprintw(LINES-2,0,"Player '%c' wins!!",_turn);
mvprintw(LINES-1,0,"Press 'c' to play again or 'q' to quit: ");
if(_turn=='X'){
win->X+=1;
}
else if(_turn=='O'){
win->O+=1;
}
refresh();
while(1){
move(LINES-1,40);
char a=getch();
move(LINES-1,40);
if(a=='q'){
*input=0;
*plays=0;
move(xyz[1][0][1],xyz[1][1][1]);
break;
}
if(a=='c'){
*plays=0;
mvprintw(LINES-1,0," ");
mvprintw(LINES-2,0," ");
ini_game(game);
*pos+=1;
if(*pos==5){
clear();
print_grid(grid,__grid,xyz,turn,win,0);
*pos=0;
move(xyz[_pos[*pos]][0][1],xyz[_pos[*pos]][1][1]);
}
move(xyz[_pos[*pos]][0][1],xyz[_pos[*pos]][1][1]);
break;
}
}
}
else if(key==1){
mvprintw(LINES-2,0,"Match Tied.");
mvprintw(LINES-1,0,"Press 'c' to continue or 'q' to quit: ");
while(1){
move(LINES-1,38);
char a=getch();
move(LINES-1,38);
if(a=='q'){
*input=0;
break;
}
if(a=='c'){
*plays=0;
mvprintw(LINES-2,0," ");
mvprintw(LINES-1,0," ");
ini_game(game);
*pos+=1;
if(*pos==5){
clear();
print_grid(grid,__grid,xyz,turn,win,0);
*pos=0;
move(xyz[_pos[*pos]][0][1],xyz[_pos[*pos]][1][1]);
}
move(xyz[_pos[*pos]][0][1],xyz[_pos[*pos]][1][1]);
break;
}
}
}
print_table(1,win);
}