From 5385bf43eb96ef2b5e78263c366c6ab658f261f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Sat, 8 Jun 2024 13:36:05 +0200 Subject: [PATCH] Implement a very rough outline of the program --- Makefile | 51 +++++++++++++++++++++++++++++++++++++++++++ inc/railnation_calc.h | 33 ++++++++++++++++++++++++++++ src/main.c | 16 ++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 Makefile create mode 100644 inc/railnation_calc.h create mode 100644 src/main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..be8c4fa --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +CC := gcc +CFLAGS = -std=c99 -Wall -Wextra -Werror -Wpedantic + +RM := rm -f + +SUBPROJECTS := Libft + +INCDIR := inc +INCDIR += $(addsuffix /inc, $(SUBPROJECTS)); +INCLUDE := $(addprefix -I, $(INCDIR)) + +SRCDIR := src + +SOURCES := main.c \ + +SOURCES := $(addprefix $(SRCDIR)/, $(SOURCES)) + +OBJECTS := $(SOURCES:.c=.o) + +NAME := railnation_calc + +all : $(NAME) + +debug : CFLAGS += -g +debug : $(NAME) + +$(NAME) : $(OBJECTS) Libft/libft.a + $(CC) $(CFLAGS) -o $@ $^ + +Libft/libft.a : | Libft/Makefile +ifneq (,$(findstring debug, $(MAKECMDGOALS))) + $(MAKE) -C Libft debug +else + $(MAKE) -C Libft +endif + +%.o : %.c | Libft/Makefile + $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE) + +%/Makefile : + git submodule update --init $($@%/Makefile=%) + +clean : + $(RM) $(OBJECTS) + +fclean : clean + $(MAKE) -C Libft/ fclean + $(RM) $(NAME) + +re : fclean + $(MAKE) all diff --git a/inc/railnation_calc.h b/inc/railnation_calc.h new file mode 100644 index 0000000..36f4eaa --- /dev/null +++ b/inc/railnation_calc.h @@ -0,0 +1,33 @@ +#ifndef RAILNATION_CALC_H +# define RAILNATION_CALC_H + +# include "libft.h" + +# define ERA_COUNT 6 + +typedef struct s_train_characteristics +{ + unsigned short era; + unsigned short size; + unsigned short capacity; + unsigned short reliability; + unsigned short acceleration; + unsigned short top_speed; + unsigned short research_cost; + unsigned int price; +} t_train_characteristics; + +typedef struct s_upgrade +{ + char *name; + t_train_characteristics characteristics; +} t_upgrade; + +typedef struct s_train +{ + char *name; + t_train_characteristics base; + t_vec upgrades; +} t_train; + +#endif //RAILNATION_CALC_H diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..7320e2c --- /dev/null +++ b/src/main.c @@ -0,0 +1,16 @@ +#include "railnation_calc.h" +#include "libft.h" + +#define DATABASE_FILE_NAME "research.csv" + +int main(void) +{ + const t_vec catalog = load_catalog(DATABASE_FILE_NAME); + t_vec trains; + + ft_vec_init(&trains, sizeof(t_train)); + while (main_prompt(&catalog, &train)); + ft_vec_free(&trains, free_train); + free_catalog(&catalog); + return (0); +} -- 2.30.2