rendered paste bodyint ia_cmd_look_count_comas(char *str){ char *s; int ret; s = str; ret = 0; while (*s) { if (*s == ',') ret++; s++; } return (ret);}int ia_cmd_look_cb(t_ia *ia, int ac, char **av){ int i; int j; int c; int food_c; static int step; i = 0; c = 0; food_c = -1; ++step; printf("step : %d\n", step); /* take other ressources */ if (!strchr(av[1], ',')) { j = 0; while (!strchr(av[j + 2], ',')) { if (strstr(av[j + 2], "linemate") && step >= 30) { ia_net_send(ia, "incantation\nvoir\n"); printf("INCANTATION !\n"); step = 0; } else ia_net_send(ia, "prend %s\n", av[j + 2]); j++; } } /* searching for food */ while (i < ac) { if (strstr("nourriture", av[i])) { food_c = food_c >= 0 ? food_c : c; } if (strchr(av[i], ',')) c += ia_cmd_look_count_comas(av[i]); i++; } if (food_c == 0) ia_net_send(ia, "prend nourriture\nvoir\n"); else if (food_c == 1) ia_net_send(ia, "avance\ngauche\navance\nprend nourriture\nvoir\n"); else if (food_c == 2) ia_net_send(ia, "avance\nprend nourriture\nvoir\n"); else if (food_c == 3) ia_net_send(ia, "avance\ndroite\navance\nprend nourriture\nvoir\n"); else ia_net_send(ia, "avance\nvoir\n"); return (1);}