1+ #define _CRT_SECURE_NO_WARNINGS
12#include <stdio.h>
3+ #include <stdbool.h>
4+ #include "ai.h"
5+ #include "ansi_escapes.h"
6+ #include "Lig 4.h"
27
38
9+ extern void setupConsole (void );
10+ extern void restoreConsole (void );
11+
12+ Win winVerifyer (int grid [6 ][7 ])
13+ {
14+
15+ }
16+
17+ void supergridGenerator (char supergrid [37 ][98 ])
18+ {
19+ for (int i = 0 ; i < 37 ; i ++ )
20+ {
21+ for (int j = 0 ; j < 97 ; j ++ )
22+ {
23+ if (j != 0 && j != 13 && j != 14 && j != 27 && j != 28 && j != 41 && j != 42 && j != 55 && j != 56 && j != 69 && j != 70 && j != 83 && j != 84 && j != 97 )
24+ supergrid [i ][j ] = ' ' ;
25+ }
26+ supergrid [i ][0 ] = '|' ;
27+ supergrid [i ][13 ] = '|' ;
28+ supergrid [i ][14 ] = '|' ;
29+ supergrid [i ][27 ] = '|' ;
30+ supergrid [i ][28 ] = '|' ;
31+ supergrid [i ][41 ] = '|' ;
32+ supergrid [i ][42 ] = '|' ;
33+ supergrid [i ][55 ] = '|' ;
34+ supergrid [i ][56 ] = '|' ;
35+ supergrid [i ][69 ] = '|' ;
36+ supergrid [i ][70 ] = '|' ;
37+ supergrid [i ][83 ] = '|' ;
38+ supergrid [i ][84 ] = '|' ;
39+ supergrid [i ][97 ] = '|' ;
40+ if (i == 0 || i == 6 || i == 12 || i == 18 || i == 24 || i == 30 || i == 36 )
41+ {
42+ for (int j = 0 ; j < 98 ; j ++ )
43+ {
44+ if (supergrid [i ][j ] != '|' )
45+ supergrid [i ][j ] = ':' ;
46+ }
47+ }
48+ }
49+ }
50+
51+ void supergridPrinter (char supergrid [37 ][98 ], int grid [6 ][7 ])
52+ {
53+ for (int i = 0 , gridI = 0 ; i < 37 ; i ++ )
54+ {
55+ printf (" " );
56+ if (i > 5 )
57+ gridI = 1 ;
58+ if (i > 11 )
59+ gridI = 2 ;
60+ if (i > 17 )
61+ gridI = 3 ;
62+ if (i > 23 )
63+ gridI = 4 ;
64+ if (i > 29 )
65+ gridI = 5 ;
66+
67+ for (int j = 0 , gridJ = 0 ; j < 98 ; j ++ )
68+ {
69+ if (j > 12 )
70+ gridJ = 1 ;
71+ if (j > 26 )
72+ gridJ = 2 ;
73+ if (j > 40 )
74+ gridJ = 3 ;
75+ if (j > 54 )
76+ gridJ = 4 ;
77+ if (j > 68 )
78+ gridJ = 5 ;
79+ if (j > 82 )
80+ gridJ = 6 ;
81+
82+ if (supergrid [i ][j ] != ':' && supergrid [i ][j ] != '|' )
83+ {
84+ if (grid [gridI ][gridJ ] == 1 )
85+ {
86+ setTextColorBright (BLUE_TXT );
87+ printf ("%c" , supergrid [i ][j ]);
88+ setTextColor (WHITE_TXT );
89+ }
90+ if (grid [gridI ][gridJ ] == -1 )
91+ {
92+ setTextColorBright (RED_TXT );
93+ printf ("%c" , supergrid [i ][j ]);
94+ setTextColor (WHITE_TXT );
95+ }
96+ if (grid [gridI ][gridJ ] == 0 )
97+ printf ("%c" , supergrid [i ][j ]);
98+ }
99+ else
100+ printf ("%c" , supergrid [i ][j ]);
101+ }
102+ printf ("\n" );
103+ }
104+ }
105+
106+ void supergridModifyer (char supergrid [37 ][98 ], Move modification )
107+ {
108+ Move startCoordinate , copy_of_startCoordinate , circleCoordinates ;
109+ char circle [5 ][12 ] = { { ' ' , ' ' , ' ' , '.' , '-' , '\"' , '\"' , '-' , '.' , ' ' , ' ' , ' ' },
110+ { ' ' , ' ' , '/' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , '\\' , ' ' , ' ' },
111+ { ' ' , ';' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ';' , ' ' },
112+ { ' ' , ' ' , '\\' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , '/' , ' ' , ' ' },
113+ { ' ' , ' ' , ' ' , '\'' , '-' , '.' , '.' , '-' , '\'' , ' ' , ' ' , ' ' } };
114+
115+ if (modification .row == 0 )
116+ startCoordinate .row = 1 ;
117+ if (modification .row == 1 )
118+ startCoordinate .row = 7 ;
119+ if (modification .row == 2 )
120+ startCoordinate .row = 13 ;
121+ if (modification .row == 3 )
122+ startCoordinate .row = 19 ;
123+ if (modification .row == 4 )
124+ startCoordinate .row = 25 ;
125+ if (modification .row == 5 )
126+ startCoordinate .row = 31 ;
127+
128+ if (modification .col == 0 )
129+ startCoordinate .col = 1 ;
130+ if (modification .col == 1 )
131+ startCoordinate .col = 15 ;
132+ if (modification .col == 2 )
133+ startCoordinate .col = 29 ;
134+ if (modification .col == 3 )
135+ startCoordinate .col = 43 ;
136+ if (modification .col == 4 )
137+ startCoordinate .col = 57 ;
138+ if (modification .col == 5 )
139+ startCoordinate .col = 71 ;
140+ if (modification .col == 6 )
141+ startCoordinate .col = 85 ;
142+ copy_of_startCoordinate .col = startCoordinate .col ;
143+ copy_of_startCoordinate .row = startCoordinate .row ;
144+ for (startCoordinate .row = copy_of_startCoordinate .row , circleCoordinates .row = 0 ; startCoordinate .row < (copy_of_startCoordinate .row + 5 ); startCoordinate .row ++ , circleCoordinates .row ++ )
145+ {
146+ for (startCoordinate .col = copy_of_startCoordinate .col , circleCoordinates .col = 0 ; startCoordinate .col < (copy_of_startCoordinate .col + 12 ); startCoordinate .col ++ , circleCoordinates .col ++ )
147+ {
148+ supergrid [startCoordinate .row ][startCoordinate .col ] = circle [circleCoordinates .row ][circleCoordinates .col ];
149+ }
150+ }
151+
152+ }
153+
154+ void getTheRow (int grid [6 ][7 ], Move * move )
155+ {
156+ for (int i = 6 ; i >= 0 ; i -- )
157+ {
158+ if (grid [i ][move -> col ] == 0 )
159+ {
160+ move -> row = i ;
161+ break ;
162+ }
163+ if (i == 0 )
164+ {
165+ move -> row = -1 ;
166+ }
167+ }
168+ }
169+
4170int main (int argc , char * argv )
5171{
172+ int grid [6 ][7 ] = { 0 };
173+ char supergrid [37 ][98 ];
174+
175+ supergridGenerator (supergrid );
176+ printf ("\n" );
177+
178+
179+ for (int mainMenu = 0 ; mainMenu == 0 ;)
180+ {
181+ int player ;
182+ char playerNumber [3 ];
183+ Move playerMove ;
184+ char playerMovement [3 ];
185+ printf ("Gostaria de jogar o modo: 1- Singleplyer ou 2- Multiplayer\n" );
186+ if (scanf ("%i" , & player ) == 1 );
187+
188+ for (char keepPlaying = 's' ; keepPlaying == 's' || keepPlaying == 'S' ;)
189+ {
190+ player = 1 ;
191+ for (int win = 0 , tie = 0 ; win == 0 && tie == 0 ;)
192+ {
193+ if (player == 3 )
194+ player = 1 ;
195+ setupConsole ();
196+ supergridPrinter (supergrid , grid );
197+ restoreConsole ();
198+ printf ("Jogue jogador %i\n" , player );
199+ if (scanf (" %i" , & playerMove .col ) == 1 );
200+ playerMove .col -- ;
201+ getTheRow (grid , & playerMove );
202+ if (playerMove .row == -1 )
203+ {
204+ printf ("Você não pode jogar aí!\n" );
205+ getchar ();
206+ getchar ();
207+ continue ;
208+ }
209+ if (player == 1 )
210+ grid [playerMove .row ][playerMove .col ] = 1 ;
211+ if (player == 2 )
212+ grid [playerMove .row ][playerMove .col ] = -1 ;
213+ supergridModifyer (supergrid , playerMove );
214+ player ++ ;
215+ }
216+
217+ printf ("\nContinuar jogando? s-sim n-não\n" );
218+ if (scanf (" %c" , & keepPlaying ) == 1 );
219+ }
220+ }
221+
6222
223+ setBackgroundColor (MAGENTA_BKG );
224+ setTextColorBright (RED_TXT );
225+ puts ("Hello, World\n" );
226+ setTextColorBright (BLUE_TXT );
227+ puts ("Hello, World\n" );
228+ restoreConsole ();
229+
7230}
0 commit comments