From 90682d658c6cb7b8be466764e48ebfbaf87b947f Mon Sep 17 00:00:00 2001 From: komiko44240BB Date: Thu, 3 Oct 2024 16:54:48 +0200 Subject: [PATCH] V0.7 Solving conflicting types issue --- CMakeLists.txt | 20 ++++++++------------ clear_input.c | 7 +++++++ clear_input.h | 6 ++++++ main.c | 12 ++---------- menu.c | 20 +++++++++----------- menu.h | 1 - objects.c | 4 ++-- perks.c | 47 ++++++++++++++++++++++++++--------------------- perks.h | 7 ++----- readobjects.c | 4 ++-- readtraining.c | 2 +- ships.c | 4 ++-- ships.h | 3 +-- 13 files changed, 68 insertions(+), 69 deletions(-) create mode 100644 clear_input.c create mode 100644 clear_input.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e5ec70..ea53611 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,17 +3,13 @@ project(BattleBay_tool C) set(CMAKE_C_STANDARD 11) -add_executable(BattleBay_tool main.c - objects.h - ships.h - readobjects.h - readtraining.h - perks.h - menu.h - objects.c - ships.c - readobjects.c - readtraining.c - perks.c +add_executable(BattleBay_tool + main.c menu.c + objects.c + perks.c + readobjects.c + ships.c + readtraining.c + clear_input.c ) diff --git a/clear_input.c b/clear_input.c new file mode 100644 index 0000000..09129d5 --- /dev/null +++ b/clear_input.c @@ -0,0 +1,7 @@ +#include "clear_input.h" +#include + +void clearInputBuffer() { + int c; + while ((c = getchar()) != '\n' && c != EOF); +} \ No newline at end of file diff --git a/clear_input.h b/clear_input.h new file mode 100644 index 0000000..931cad9 --- /dev/null +++ b/clear_input.h @@ -0,0 +1,6 @@ +#ifndef CLEAR_INPUT_H +#define CLEAR_INPUT_H + +void clearInputBuffer(); + +#endif diff --git a/main.c b/main.c index c535bec..a7268db 100644 --- a/main.c +++ b/main.c @@ -1,17 +1,9 @@ -#include -#include -#include -#include -#include #include "menu.h" -#include "readobjects.h" -#include "ships.h" -#include "objects.h" -#include "readtraining.h" // Formula to calculate stat and combo stat : ( base stat + flat train stat + flat perk stat ) * ( 1 + % perk stat + % train stat ) * ( 1 + % combo train stat + % combo perk stat ) -int main() {/* +int main() { + /* int gear[5][2] = {{5,8},{3,4},{0,0},{0,0},{0,0}}; struct Ship* s = initialiseShip("defender",1.2,0.9,0.5,1596,5); setUpShip(s,gear); diff --git a/menu.c b/menu.c index 77b8235..9d6e967 100644 --- a/menu.c +++ b/menu.c @@ -1,13 +1,15 @@ -#include -#include -#include -#include +#include +#include +#include #include #include "ships.h" -#include "menu.h" #include "readobjects.h" #include "readtraining.h" #include "perks.h" +#include "clear_input.h" +#include "menu.h" + + #define FILENAME_SIZE 40 @@ -38,10 +40,7 @@ void start(){ startMenu(); } -void clearInputBuffer() { - int c; - while ((c = getchar()) != '\n' && c != EOF); -} + void startMenu() { bool valid1 = true; @@ -397,8 +396,7 @@ void addObjects(struct Ship* s) { } if(read_file){ struct Object* o = readObjectFile(object_type,object_name,rarity); - bool isAdded = addOject(s,o); - if(!isAdded){ + if(!addOject(s,o)){ printf("Could not add object, not enought slot points or slots\n"); i--; }else{ diff --git a/menu.h b/menu.h index 58c7ef8..a0e96e7 100644 --- a/menu.h +++ b/menu.h @@ -2,7 +2,6 @@ #define MENU_H void start(); -void clearInputBuffer(); void startMenu(); void creatingShip(); void editingShip(); diff --git a/objects.c b/objects.c index e850737..7ee933d 100644 --- a/objects.c +++ b/objects.c @@ -1,8 +1,8 @@ -#include "objects.h" #include #include #include -#include +#include "objects.h" + struct Object* createObject(char* rarity, char* name, unsigned int level, float base_stat, float cool_down, float range, float projectile_speed, float critical_hit_chance, float critcal_hit_multiplier, float radius, float spread, unsigned int amount_of_projectiles, float duration, unsigned int slot_points, float combo_dmg_boost) { struct Object* o = malloc(sizeof(struct Object)); diff --git a/perks.c b/perks.c index 1e433b8..ae2cc5b 100644 --- a/perks.c +++ b/perks.c @@ -1,6 +1,9 @@ -#include "perks.h" -#include "menu.h" +#include +#include +#include #include "objects.h" +#include "perks.h" +#include "clear_input.h" #define MAX_LINE_SIZE 1024 struct Perk* createPerk(char* first_boost_type,char* second_boost_type, int first_boost_value,int second_boost_value) { @@ -15,38 +18,42 @@ struct Perk* createPerk(char* first_boost_type,char* second_boost_type, int firs int numberOfPerks(struct Object* o) { if(strcmp(o->rarity, "common") == 0){ - if(o->level>20){ + if(o->level > 20){ return 1; } return 0; } if(strcmp(o->rarity, "uncommon") == 0){ - switch (o->level){ - case o->level > 30: return 2; - case o->level > 10: return 1; - default: return 0; + if(o->level > 30){ + return 2; + } if(o->level > 10){ + return 1; } + return 0; } if(strcmp(o->rarity, "rare") == 0){ - switch (o->level){ - case o->level > 20: return 3; - case o->level > 10: return 2; - default: return 1; + if(o->level > 20){ + return 3; + } if(o->level > 10){ + return 2; } + return 1; } if(strcmp(o->rarity, "epic") == 0){ - switch (o->level){ - case o->level > 30: return 4; - case o->level > 10: return 3; - default: return 2; + if(o->level > 30){ + return 4; + } if(o->level > 10){ + return 3; } + return 2; } if(strcmp(o->rarity, "legendary") == 0){ - if(o->level>20){ + if(o->level > 20){ return 4; } return 3; } + printf("Error handeling your item, please report it to @komiko\n"); return 0; } @@ -85,12 +92,12 @@ void addPerks(struct Object* o) { } } char** perk_list = perkLists(o); - o->perk_list[i] = displayAndChoseAvailablePerks(perk_list, is_event); + o->perk_list[i] = displayAndChooseAvailablePerks(perk_list, is_event); } return; } -struct Perk* displayAndChoseAvailablePerks(char** perk_list, bool is_event) { +struct Perk* displayAndChooseAvailablePerks(char** perk_list, bool is_event) { if(perk_list == NULL){ return NULL; } @@ -331,9 +338,7 @@ void updateEvent(struct Perk* p,bool is_event) { p->is_event = is_event; } - - -char** perkLists(const struct Object* o) { +char** perkLists(struct Object* o) { char** files_names = malloc(sizeof(char*) * 2); if (files_names == NULL) { return NULL; diff --git a/perks.h b/perks.h index 2bc6331..5070d73 100644 --- a/perks.h +++ b/perks.h @@ -1,9 +1,6 @@ -#include -#include -#include -#include #ifndef PERKS_H #define PERKS_H +#include struct Perk { @@ -19,7 +16,7 @@ struct Perk* createPerk(char* first_boost_type,char* second_boost_type, int firs int numberOfPerks(struct Object* o); void addPerks(struct Object* o); char** perkLists(struct Object* o); -struct Perk* displayAndChoseAvailablePerks(char** perk_list, bool is_event); +struct Perk* displayAndChooseAvailablePerks(char** perk_list, bool is_event); void updateEvent(struct Perk* p,bool is_event); diff --git a/readobjects.c b/readobjects.c index ecb8faf..ccc35c3 100644 --- a/readobjects.c +++ b/readobjects.c @@ -3,9 +3,9 @@ #include #include #include -#include "readobjects.h" -#include "menu.h" #include "objects.h" +#include "readobjects.h" +#include "clear_input.h" #define MAX_LINE_SIZE 1024 /** diff --git a/readtraining.c b/readtraining.c index ce8ce4e..d7b6611 100644 --- a/readtraining.c +++ b/readtraining.c @@ -3,9 +3,9 @@ #include #include #include -#include "menu.h" #include "objects.h" #include "readtraining.h" +#include "clear_input.h" #define MAX_LINE_SIZE 1024 /** diff --git a/ships.c b/ships.c index 5fff06b..7f06ea1 100644 --- a/ships.c +++ b/ships.c @@ -1,8 +1,8 @@ -#include "ships.h" -#include "objects.h" #include #include #include +#include "objects.h" +#include "ships.h" #define OBJECT_TYPES "rbygt" /** diff --git a/ships.h b/ships.h index 6ac2208..d3fce00 100644 --- a/ships.h +++ b/ships.h @@ -1,8 +1,7 @@ #ifndef SHIPS_H #define SHIPS_H - #include -#include "objects.h" + struct Ship{ struct Slots* loadout [5];