#include "philo.h"

int	create_philos(t_rules *rules)
{
	int		i;
	t_philo *philo;

	i = 0;
	rules->philos = malloc(rules->n_philos * sizeof(t_philo));
	if (!rules->philos)
		return(FAILURE);
	while (i < rules->n_philos)
	{
		philo = &rules->philos[i];
		philo->id = i + 1;
		philo->l_fork = &rules->forks[i];
		philo->r_fork = &rules->forks[i + 1 % rules->n_philos];
		philo->death = 0;
		philo->pid = 0;
		philo->rules = rules;
		philo->last_meal = get_time();
		i++;
	}
	return (SUCCESS);
}