/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   so_long.h                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: yantoine <yantoine@student.42.fr>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/02/20 18:44:27 by yantoine          #+#    #+#             */
/*   Updated: 2024/02/23 21:46:22 by yantoine         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef SO_LONG_H
# define SO_LONG_H

# define ITEM_FILE "path_tile"
# define PLAYER_SPRITE_PATH "TUILE/tuile/knight_f_idle_anim_f0_sol.xpm"
# include "minilibx-linux/mlx.h"
# include "minilibx-linux/mlx_int.h"
# include "ft_printf/header/ft_printf.h"
# include <unistd.h>
# include <fcntl.h>
# include "get_next_line/get_next_line.h"
# include "libft/libft.h"
# include <X11/X.h>
# include <X11/keysym.h>
# include <stdio.h>
# include <stdlib.h>

typedef struct s_tile
{
	void	**tab_item;
	char	**tab_item_path;
	char	*item_ref_file;
	int		number_height_tile;
	int		number_width_tile;
}	t_tile;

typedef struct s_position
{
	int	x;
	int	y;
}	t_position;

typedef struct s_player
{
	char		*sprite_path;
	void		*sprite;
	t_position	position;
}	t_player;

typedef struct Element
{
	struct Element		*suivant;
	t_position			crdn;
}	t_Element;

typedef struct Liste
{
	t_Element	*premier;
}	t_Liste;

typedef struct s_data
{
	t_position	depart;
	t_position	arrive;
	t_player	player;
	void		*mlx;
	void		*win;
	char		**map;
	int			height;
	int			widht;
	int			height_screen;
	int			health;
	int			move;
	int			nb_c;
	int			nb_e;
	int			nb_p;
	int			width_screen;
	int			coin;
	int			max_coin;
	t_Liste		*path_finder_memory;
	t_tile		tile;
}		t_data;

int		init_player(t_data *data);
int		check_map_valid(char **map, t_data *data);
int		check_args(char **argv, int argc);
int		check_map_g(char **map, t_data *data);
int		init_tile(t_tile *tile, char **tab_item_path);
int		check_xpm_file(char	*chemin);
int		init_xpm(t_data *data, int *img_width, int *img_height);
int		count_number_line_f(char *file_path);
int		pathfinder(t_data *data);
int		is_framed(char **map, t_data *data);
int		ft_exit(t_data *data);

void	free_tab_void(void **tab, t_data *data);
void	ft_move_img(t_data *data, int keycode);
void	print_player(t_data *data);
void	refresh_window(t_data *data);
void	init_count_item(t_data *data);
void	ft_print_sprite(t_data *data, char c, int y, int x);
void	define_size(t_data *data);
void	**init_tab_item(t_data *data);
void	insertion(t_Liste *liste, t_position nV_position);
void	check_char(t_data *data, int i, int j);
void	free_tab(char **tab);
void	freelist(t_Liste *liste);

char	**ft_read_map(char *file);
char	**init_tab_item_path(char *file_path);
char	*anti_bn(char *line);

t_Liste	*initialise_liste(void);
#endif
