Esempio n. 1
0
void	ft_prompt(t_env *var)
{
	(void)var;
	ft_putcolor("[", YELLOW);
	ft_pwdfolder(var);
	ft_putcolor("]", YELLOW);
	ft_putstr("$> ");
}
Esempio n. 2
0
void		ft_display_players(int turn)
{
	if (turn)
	{
		ft_putcolor("green");
		ft_putstr("\nPlayer :\n");
	}
	else
	{
		ft_putcolor("red");
		ft_putstr("\nIA :\n");
	}
}
Esempio n. 3
0
void	ft_logname(t_env *var)
{
	int		hoo;

	if ((hoo = ft_search_var(var, "LOGNAME")) < 0)
	{
		ft_putcolor("42", GREEN);
		return ;
	}
	while (hoo--)
		var = var->next;
	ft_putcolor(var->content, YELLOW);
	return ;
}
Esempio n. 4
0
void	ft_option(t_push *p, char *str)
{
	if (p->blop && !p->option)
		ft_putchar(' ');
	if (!p->option)
		ft_putstr(str);
	p->blop++;
	if (!p->option)
		return ;
	ft_putcolor(str, "\033[4;35m");
	ft_putcolor(" :\n", "\033[4;35m");
	ft_afftab(p->l1, p->nbl1, 1);
	ft_afftab(p->l2, p->nbl2, 2);
}
Esempio n. 5
0
void	error_message(char *message, int terminate)
{
	ft_putcolor("ERROR: ", "red");
	perror(message);
	if (terminate)
		exit(0);
}
Esempio n. 6
0
void					ft_afftab(int *tab, int size, int pile)
{
	int					i;

	i = 0;
	if (pile == 1)
		ft_putcolor("a: ", RED);
	else
		ft_putcolor("b: ", BLUE);
	while (i != size)
	{
		ft_putnbr(tab[i++]);
		ft_putchar(' ');
	}
	ft_putchar('\n');
	return ;
}
Esempio n. 7
0
void			parsing_error(t_env *data, char *line)
{
	if (data->rooms)
		clear_rooms(data->rooms);
	if (data->start)
		ft_strdel(&(data->start));
	if (data->end)
		ft_strdel(&(data->end));
	ft_memdel((void**)&data);
	if (line)
	{
		ft_putcolor(line, "red");
		ft_putchar('\n');
		ft_strdel(&line);
	}
	ft_putcolor("\nERROR\n", "red");
	exit(EXIT_FAILURE);
}
Esempio n. 8
0
static int		take_turns(t_map *map)
{
	int		nb_of_matches;

	if (map->current_player == 0)
	{
		nb_of_matches = ft_botplays(map);
		ft_putcolor("The bot played and took ", "red");
		ft_putnbr(nb_of_matches);
		ft_putcolor(" matches.\n", "red");
		map->current_player += 1;
	}
	else
	{
		if (!(nb_of_matches = get_players_entry(map)))
			return (0);
		map->current_player -= 1;
	}
	return (nb_of_matches);
}
Esempio n. 9
0
static int	choose_stuff(char *path, int fd)
{
	char			*line;

	ft_putcolor("Existing file : ", 1);
	ft_putendl("Overwrite");
	get_next_line(0, &line);
	close(fd);
	fd = open(path, O_TRUNC | O_WRONLY);
	return (fd);
}
Esempio n. 10
0
void	ft_pwdfolder(t_env *var)
{
	char	**files;
	int		hoo;

	if ((hoo = ft_search_var(var, "PWD")) < 0)
	{
		ft_logname(var);
		return ;
	}
	while (hoo--)
		var = var->next;
	hoo = 0;
	if (ft_strcmp(var->content, "/") == 0)
	{
		ft_putcolor("/", YELLOW);
		return ;
	}
	files = ft_strsplit(var->content, '/');
	while (files[hoo + 1])
		hoo++;
	ft_putcolor(files[hoo], YELLOW);
	return ;
}
Esempio n. 11
0
char					*ft_gcmd(char *cmd)
{
	char				*next;

	next = NULL;
	ft_putcolor((cmd) ? "> " : "$> ", GREEN);
	if (get_next_line(0, &next) == 0)
		exit(EXIT_FAILURE);
	if (next[ft_strlen(next) - 1] == '\\')
	{
		next[ft_strlen(next) - 1] = 0;
		return (ft_gcmd(ft_strjoin(cmd, next)));
	}
	return ((cmd) ? ft_strjoin(cmd, next) : next);
}
Esempio n. 12
0
int		ft_check_m(char **m)
{
	int i;

	i = 0;
	while (m[i])
	{
		if (ft_atoi(m[i]) < 1 || ft_atoi(m[i]) > 10000)
		{
			ft_putcolor("red");
			ft_putstr("ERROR\n");
			return (0);
		}
		i++;
	}
	return (1);
}
Esempio n. 13
0
int		ft_check(char *tmp)
{
	int i;

	i = 0;
	while (tmp[i])
	{
		if (!ft_isdigit(tmp[i]) && tmp[i] != '\n')
		{
			ft_putcolor("red");
			ft_putstr("ERROR\n");
			free(tmp);
			return (0);
		}
		i++;
	}
	return (1);
}
Esempio n. 14
0
int			ft_game(char **m)
{
	t_alcu v;

	v.turn = 1;
	v.nbm = 0;
	v.winner = 2;
	while (v.winner == 2)
	{
		ft_putcolor("cyan");
		ft_display_matches(m);
		v.nbm = ft_nbmatches(m);
		ft_display_players(v.turn);
		if (v.turn)
			m = ft_player(m, v.nbm, &v.turn);
		else
			m = ft_ia(m, v.nbm, &v.turn);
		v.nbm = ft_nbmatches(m);
		if (v.nbm == 0)
			v.winner = v.turn;
	}
	free(m);
	return (v.winner);
}
Esempio n. 15
0
void	*ft_failure(char *str, void *ret_value)
{
	ft_putcolor(str, RED);
	ft_putchar('\n');
	return (ret_value);
}
Esempio n. 16
0
int	ft_printincolor(const char *str, char *color)
{
	return (ft_putstr(ft_putcolor(str, color)));
}