int checksend_incantation(t_env *e, t_fd *a) { int i; t_fd *other; int *ids; int number; int j; if (((number = check_playerlvls(e, a)) == FAILURE) || (check_stones(e, a) == FAILURE)) return (FAILURE); i = 0; j = 0; ids = malloc(sizeof(*ids) * number); while (i < e->maxfd) { other = &(e->fds[i]); if ((other->type == FD_CLIENT) && ((other->x == a->x) && (other->y == a->y) && (other->level == a->level))) j = result_from_if(ids, j, a, other); i++; } gfxsend_ik(e->gfx_fd, a, number, ids); return (SUCCESS); }
int incantation(t_env *e, t_fd *a) { char **split; if ((split = ft_strsplitwhite(a->act[0].action)) == NULL) return (FAILURE); if (ft_strcmp(split[0], "incantation") != SUCCESS) return (FAILURE); if ((check_playerlvls(e, a) == FAILURE) || (check_stones(e, a) == FAILURE)) { gfxsend_inc(e->gfx_fd, a, 1); return (FAILURE); } gfxsend_inc(e->gfx_fd, a, 0); do_levelup(e, a); ft_freechartab(&split); stone_explode(e, e->map[a->y][a->x], (a->level - 1)); gfxsend_content(e->gfx_fd, a->x, a->y, e->map[a->y][a->x]); return (SUCCESS); }
int incantation_valide(t_server *s, t_player *p) { t_player *tmp; int count; count = 0; tmp = s->game.map[p->x + p->y * s->x].players; while (tmp) { if (tmp->level != p->level) return (0); count++; tmp = tmp->next_t; } if ((p->level == 1 && count == 1 && check_stones(s, p, S_LEVEL1)) || (p->level == 2 && count == 2 && check_stones(s, p, S_LEVEL2)) || (p->level == 3 && count == 2 && check_stones(s, p, S_LEVEL3)) || (p->level == 4 && count == 4 && check_stones(s, p, S_LEVEL4)) || (p->level == 5 && count == 4 && check_stones(s, p, S_LEVEL5)) || (p->level == 6 && count == 6 && check_stones(s, p, S_LEVEL6)) || (p->level == 7 && count == 6 && check_stones(s, p, S_LEVEL7))) return (1); return (0); }