-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_case.c
47 lines (43 loc) · 1.15 KB
/
check_case.c
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
#include <gtk/gtk.h>
#include <stdio.h>
#include "base.h"
int check_for_black(t_terrain* terrain_tmp, t_terrain* button_p, int count)
{
while (terrain_tmp->next != 0)
{
count = check_vertical(terrain_tmp, button_p, count, 1);
count = check_horizontal(terrain_tmp, button_p, count, 1);
count = check_diagonal(terrain_tmp, button_p, count, 1);
terrain_tmp = terrain_tmp->next;
}
return (count);
}
int check_for_white(t_terrain* terrain_tmp, t_terrain* button_p, int count)
{
while (terrain_tmp->next != 0)
{
count = check_vertical(terrain_tmp, button_p, count, 2);
count = check_horizontal(terrain_tmp, button_p, count, 2);
count = check_diagonal(terrain_tmp, button_p, count, 2);
terrain_tmp = terrain_tmp->next;
}
return (count);
}
int check_case(t_terrain* terrain, t_terrain* button, int round)
{
t_terrain* button_p;
int count;
button_p = terrain;
while (button_p->i != button->i)
button_p = button_p->next;
if (button->color == 0)
{
if (round % 2 == 0)
count = check_global_black(terrain, button_p, 0);
else if (round % 2 == 1)
count = check_global_white(terrain, button_p, 0);
if (count > 0)
return (1);
}
return (0);
}