Example #1
0
void		ccmd_bcast(t_data *data, int cs, char **cmd, t_timeval **t)
{
	t_tlist		*team;
	t_plist		*plist;
	t_player	*player;

	player = &data->fds[cs].player;
	if (!(*t))
		timer_init(data, t);
	else
	{
		player->msg = split_join(cmd + 1);
		gui_broadcast(data, gui_pbc, player);
		team = data->teams;
		while (team)
		{
			plist = team->list;
			while (plist)
			{
				if (plist->player != player)
					bcast(data, player, plist->player);
				plist = plist->next;
			}
			team = team->next;
		}
		dprintf(cs, "ok\n");
	}
}
Example #2
0
void	win_check(t_data *data)
{
	t_tlist		*team;
	t_plist		*list;
	int			count;

	team = data->teams;
	while (team)
	{
		count = 0;
		list = team->list;
		while (list)
		{
			if (list->player->level == 8)
				count++;
			list = list->next;
		}
		if (count >= 6)
		{
			gui_broadcast(data, gui_seg, team);
			quit_game(data);
		}
		team = team->next;
	}
}
Example #3
0
void	ccmd_forward(t_data *data, int cs, char **cmd, t_timeval **t)
{
	t_player	*player;
	t_timeval	now;

	if (*t == NULL)
	{
		gettimeofday(&now, NULL);
		*t = (t_timeval*)malloc(sizeof(t_timeval));
		**t = time_add(data, &now, MOVE_T);
		return ;
	}
	(void)cmd;
	player = &data->fds[cs].player;
	if (player->o == N)
		player->y = mod(player->y - 1, data->y);
	else if (player->o == S)
		player->y = mod(player->y + 1, data->y);
	else if (player->o == W)
		player->x = mod(player->x - 1, data->x);
	else if (player->o == E)
		player->x = mod(player->x + 1, data->x);
	dprintf(cs, "ok\n");
	gui_broadcast(data, gui_ppo, player);
}
Example #4
0
static void		timer_init(t_data *data, t_timeval **timer, t_player *player)
{
	t_timeval	now;

	gettimeofday(&now, NULL);
	*timer = (t_timeval*)malloc(sizeof(t_timeval));
	**timer = time_add(data, &now, DROP_T);
	gui_broadcast(data, gui_pfk, player);
}
Example #5
0
void			disperse(t_data *data, t_spell *spell)
{
	srand(time(NULL));
	disperse_linemate(data, spell);
	disperse_deraumere(data, spell);
	disperse_sibur(data, spell);
	disperse_mendiane(data, spell);
	disperse_phiras(data, spell);
	disperse_thystame(data, spell);
	gui_broadcast(data, gui_bct, get_square(data, spell->x, spell->y));
}
Example #6
0
static void		disperse_thystame(t_data *data, t_spell *spell)
{
	int			i;
	t_square	*target;

	i = data->spell_tab[spell->level - 1][6];
	while (i--)
	{
		target = get_square(data, rand() % data->x, rand() % data->y);
		target->thystame += 1;
		gui_broadcast(data, gui_bct, target);
		data->map[spell->x][spell->y].thystame -= 1;
	}
}
Example #7
0
void	ccmd_right(t_data *data, int cs, char **cmd, t_timeval **t)
{
	t_player	*player;
	t_timeval	now;

	if (!(*t))
	{
		gettimeofday(&now, NULL);
		*t = (t_timeval*)malloc(sizeof(t_timeval));
		**t = time_add(data, &now, MOVE_T);
		return ;
	}
	(void)cmd;
	player = &data->fds[cs].player;
	player->o = (player->o % 4) + 1;
	dprintf(cs, "ok\n");
	gui_broadcast(data, gui_ppo, player);
}
Example #8
0
void			ccmd_fork(t_data *data, int cs, char **cmd, t_timeval **t)
{
	t_player	*player;
	t_egg		*egg;
	t_timeval	now;

	gettimeofday(&now, NULL);
	(void)cmd;
	player = &data->fds[cs].player;
	if (!(*t))
		timer_init(data, t, player);
	else
	{
		egg = init_egg(data, cs, player, now);
		data->eggs = egg;
		gui_broadcast(data, gui_enw, egg);
		dprintf(cs, "ok\n");
	}
}