-
Notifications
You must be signed in to change notification settings - Fork 0
/
skin_tests.c
62 lines (56 loc) · 2.24 KB
/
skin_tests.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* skin_tests.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvan-der <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 04:16:41 by rvan-der #+# #+# */
/* Updated: 2017/02/27 16:44:48 by rvan-der ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
int is_ennemi(char c, char pl)
{
if (c == (pl == 'X' ? 'O' : 'X'))
return (1);
return (0);
}
int is_atwall(t_coord pos, t_plateau p)
{
if (!pos.x || !pos.y || pos.x == (p.size).x || pos.y == (p.size).y)
return (1);
return (0);
}
int is_corner(t_coord pos, t_plateau p)
{
if ((!pos.x && pos.y == (p.size).y) || (pos.x == (p.size).x && !pos.y) || \
(pos.x == (p.size).x && pos.y == (p.size).y) || (!pos.x && !pos.y))
return (1);
return (0);
}
int is_inhole(t_coord p, t_plateau plt)
{
int i;
i = -1;
if (p.x + 1 < (plt.size).x && is_ennemi((plt.map)[p.y][p.x + 1], plt.pl))
while (p.x - (++i) >= 0 && (plt.map)[p.y][p.x - i] != plt.pl)
if (is_ennemi((plt.map)[p.y][p.x - i], plt.pl))
return (1);
i = -1;
if (p.x > 0 && is_ennemi((plt.map)[p.y][p.x - 1], plt.pl))
while (p.x + (++i) < (plt.size).x && (plt.map)[p.y][p.x + i] != plt.pl)
if (is_ennemi((plt.map)[p.y][p.x + i], plt.pl))
return (1);
i = -1;
if (p.y + 1 < (plt.size).y && is_ennemi((plt.map)[p.y + 1][p.x], plt.pl))
while (p.y - (++i) >= 0 && (plt.map)[p.y - i][p.x] != plt.pl)
if (is_ennemi((plt.map)[p.y - i][p.x], plt.pl))
return (1);
i = -1;
if (p.y > 0 && is_ennemi((plt.map)[p.y - 1][p.x], plt.pl))
while (p.y + (++i) < (plt.size).y && (plt.map)[p.y + i][p.x] != plt.pl)
if (is_ennemi((plt.map)[p.y + i][p.x], plt.pl))
return (1);
return (0);
}