#ifndef FILES_H
#define FILES_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ncurses.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <getopt.h>
static struct option long_options[] = {
{"help", no_argument, 0, 123 },
{"level", required_argument, 0, 'L' },
{"key-left", required_argument, 0, 'l' },
{"key-right", required_argument, 0, 'r' },
{"key-turn", required_argument, 0, 't' },
{"key-drop", required_argument, 0, 'd' },
{"key-quit", required_argument, 0, 'q' },
{"key-pause", required_argument, 0, 'p' },
{"map-size", required_argument, 0, 4269 },
{"without_next", no_argument, 0, 'w' },
{"debug", no_argument, 0, 'D' },
{0, 0, 0, 0 }
};
typedef struct s_tetriomino {
int width;
int height;
int color_code;
char **piece;
char *onlinepiece;
clock_t begin;
int max;
int next;
int level;
int error;
char *name;
char **rotate;
} tetriomino_t;
typedef struct screen {
WINDOW *main;
WINDOW *score;
WINDOW *game;
WINDOW *next;
} screen_t;
typedef struct scoreboard {
int highscore;
int score;
int line;
int level;
} scoreboard_t;
typedef struct arguments {
char help;
int level;
int key_left;
int key_right;
int key_turn;
int key_drop;
int key_quit;
int key_pause;
int map_x;
int map_y;
char without_next;
char debug_mode;
} arguments_t;
typedef struct game {
struct s_tetriomino **s_tetriomino;
struct screen *screen;
struct scoreboard *scoreboard;
struct arguments *arguments;
int **map;
int status;
} game_t;
//autocomplete:start
char *reduce(char *file_name);
void clean_space(char **str, int len, int max);
void clean_rotate(char **actual, tetriomino_t *piece);
int dodge(char *str, int i);
char *is_stared(char *str);
void end_of_display(screen_t *screen);
WINDOW *create_score_window(void);
WINDOW *create_game_window(int map_x, int map_y);
WINDOW *create_next_window(int map_x);
int window_assets(WINDOW *screen);
screen_t *init_display(char without_next, int map_x, int map_y);
void print_case(int x, int y, int color, WINDOW *game);
void switch_color(int *color, int place, WINDOW *game);
void print_map(int **map, WINDOW *game_window, int map_x);
void put_next_tetriomino(WINDOW *next, tetriomino_t *tetriomino);
int put_tetriomino(int **map, tetriomino_t *tetriomino, int x, int y);
int delete_tetriomino(int **map, tetriomino_t *tetriomino, int x, int y);
void display_scoreboard(WINDOW *win, scoreboard_t *scoreboard);
int reset(int *x, int *y, tetriomino_t **tetriomino, int map_x);
int my_strdoublen(char **str);
int is_collapsing(int x, int y, game_t *game, int piece_nb);
int give_piece(int piece);
char *map_get(char *path);
void pars(tetriomino_t *piece, game_t *game);
void set_mapsize(arguments_t *argument);
int parsopt(int val);
void my_puthelp(char *str, char **av);
int switch1(int opt, arguments_t *argument, char **av);
int switch2(int opt, arguments_t *argument);
void parsarg(int ac, char **av, arguments_t *argument);
arguments_t *create_arguments(int ac, char **av);
int **create_map(int x, int y);
void print_line(char *name, int nb);
void debug_keyboard(game_t *game);
void debug_tetriminos(game_t *game);
void free_array(char **str);
void free_tetriminos(game_t *game, tetriomino_t **tetriminos);
void start_debug(game_t *game);
void free_map(int **map);
scoreboard_t *create_scoreboard(void);
void write_new_highscore(int score);
void free_scoreboard(scoreboard_t *scoreboard);
void clean_loop(tetriomino_t *piece, char **newpiece, int i, int j);
char **clean_malloc(tetriomino_t *piece);
void init_struct(tetriomino_t *piece, char *file_name, int i, char *inside);
tetriomino_t *filler(tetriomino_t *piece, struct dirent *diren);
tetriomino_t **fill_struct(game_t *game);
int ending(int x, int y, game_t *game);
int my_structlen(tetriomino_t **tetriomino);
void falling(int *x, int *y, game_t *game);
void keyboard_event(game_t *game, int *x, int *y, int current);
void move_right(int *x, int *y, game_t *game, int current);
void move_left(int *x, int *y, game_t *game, int current);
void move_drop(int *x, int *y, game_t *game, int current);
char **create_new_piece(char **piece, int *x, int *y);
char **rotate_array(char **piece, int *x, int *y);
char **cancel_rotate_array(char **piece, int *x, int *y);
int verify_position(game_t *game, tetriomino_t *tetriomino, int x, int y);
void rotate_piece(tetriomino_t *tetriomino, int *pos_x, int *pos_y, \
game_t *game);
char *give_malloc_str(char *str);
void my_put_nbr(int nb);
void my_putstr2(char **str);
void my_putchar(char c);
void my_putstr(char *str);
int my_itoa_len(int nb);
char *my_itoa(int nb);
int my_strlen(char const *str);
void lining(game_t *game);
int main(int argc, char **argv);
int ft_nb_word(char *str);
int ft_word_len(char *str, int i);
char **my_str_to_word_array(char *str, char *charset);
int main_loop(game_t *game);
game_t *create_game(int ac, char **av);
int start(int ac, char **av);
int init_tetriomino(void);
int my_atoi(char *str);
char *my_strdup(char *src);
char *my_strcat(char *dest, char *src);
int size_dir(void);
void check(tetriomino_t **piece);
void redirect_all_std(void);
//autocomplete:end
#endif