-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_filler.c
52 lines (47 loc) · 1.71 KB
/
main_filler.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main_filler.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rvan-der <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/19 19:40:08 by rvan-der #+# #+# */
/* Updated: 2017/02/27 16:35:47 by rvan-der ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
t_info *init_global(char c)
{
t_info *ret;
ret = (t_info*)malloc(sizeof(t_info));
ret->pl = (c == '1' ? 'O' : 'X');
ret->pmap = NULL;
return (ret);
}
int main(void)
{
char *buff;
static t_info *global = NULL;
t_plateau plateau;
t_ennemi ennemi;
t_coord ret;
while (get_next_line(0, &buff))
{
if (!ft_strncmp(buff, "$$$ exec p", 10))
global = init_global(*(buff + 10));
else if (!ft_strncmp(buff, "Plateau ", 8))
{
plateau = get_plt(buff, global->pl);
ennemi = get_ennemi(plateau, global->pmap);
ret = play(plateau, ennemi);
delete_map(global->pmap, (plateau.size).y);
global->pmap = (ret.x == -3 && ret.y == -3 ? NULL : plateau.map);
delete_all(plateau, ennemi);
ft_printf("%d %d\n", ret.y, ret.x);
}
free(buff);
}
if (global->pmap == NULL)
free(global);
return (0);
}