Solving conflicting types issue
This commit is contained in:
komiko44240BB
2024-10-03 16:54:48 +02:00
parent b67e1cfa21
commit 90682d658c
13 changed files with 68 additions and 69 deletions

View File

@@ -3,17 +3,13 @@ project(BattleBay_tool C)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
add_executable(BattleBay_tool main.c add_executable(BattleBay_tool
objects.h main.c
ships.h
readobjects.h
readtraining.h
perks.h
menu.h
objects.c
ships.c
readobjects.c
readtraining.c
perks.c
menu.c menu.c
objects.c
perks.c
readobjects.c
ships.c
readtraining.c
clear_input.c
) )

7
clear_input.c Normal file
View File

@@ -0,0 +1,7 @@
#include "clear_input.h"
#include<stdio.h>
void clearInputBuffer() {
int c;
while ((c = getchar()) != '\n' && c != EOF);
}

6
clear_input.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef CLEAR_INPUT_H
#define CLEAR_INPUT_H
void clearInputBuffer();
#endif

12
main.c
View File

@@ -1,17 +1,9 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include <unistd.h>
#include "menu.h" #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 ) // 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}}; 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); struct Ship* s = initialiseShip("defender",1.2,0.9,0.5,1596,5);
setUpShip(s,gear); setUpShip(s,gear);

20
menu.c
View File

@@ -1,13 +1,15 @@
#include<stdio.h> #include <stdio.h>
#include<stdlib.h> #include <string.h>
#include<string.h> #include <stdbool.h>
#include<stdbool.h>
#include <unistd.h> #include <unistd.h>
#include "ships.h" #include "ships.h"
#include "menu.h"
#include "readobjects.h" #include "readobjects.h"
#include "readtraining.h" #include "readtraining.h"
#include "perks.h" #include "perks.h"
#include "clear_input.h"
#include "menu.h"
#define FILENAME_SIZE 40 #define FILENAME_SIZE 40
@@ -38,10 +40,7 @@ void start(){
startMenu(); startMenu();
} }
void clearInputBuffer() {
int c;
while ((c = getchar()) != '\n' && c != EOF);
}
void startMenu() { void startMenu() {
bool valid1 = true; bool valid1 = true;
@@ -397,8 +396,7 @@ void addObjects(struct Ship* s) {
} }
if(read_file){ if(read_file){
struct Object* o = readObjectFile(object_type,object_name,rarity); struct Object* o = readObjectFile(object_type,object_name,rarity);
bool isAdded = addOject(s,o); if(!addOject(s,o)){
if(!isAdded){
printf("Could not add object, not enought slot points or slots\n"); printf("Could not add object, not enought slot points or slots\n");
i--; i--;
}else{ }else{

1
menu.h
View File

@@ -2,7 +2,6 @@
#define MENU_H #define MENU_H
void start(); void start();
void clearInputBuffer();
void startMenu(); void startMenu();
void creatingShip(); void creatingShip();
void editingShip(); void editingShip();

View File

@@ -1,8 +1,8 @@
#include "objects.h"
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include<string.h> #include<string.h>
#include<stdbool.h> #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* 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)); struct Object* o = malloc(sizeof(struct Object));

47
perks.c
View File

@@ -1,6 +1,9 @@
#include "perks.h" #include<stdio.h>
#include "menu.h" #include<stdlib.h>
#include<string.h>
#include "objects.h" #include "objects.h"
#include "perks.h"
#include "clear_input.h"
#define MAX_LINE_SIZE 1024 #define MAX_LINE_SIZE 1024
struct Perk* createPerk(char* first_boost_type,char* second_boost_type, int first_boost_value,int second_boost_value) { 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) { int numberOfPerks(struct Object* o) {
if(strcmp(o->rarity, "common") == 0){ if(strcmp(o->rarity, "common") == 0){
if(o->level>20){ if(o->level > 20){
return 1; return 1;
} }
return 0; return 0;
} }
if(strcmp(o->rarity, "uncommon") == 0){ if(strcmp(o->rarity, "uncommon") == 0){
switch (o->level){ if(o->level > 30){
case o->level > 30: return 2; return 2;
case o->level > 10: return 1; } if(o->level > 10){
default: return 0; return 1;
} }
return 0;
} }
if(strcmp(o->rarity, "rare") == 0){ if(strcmp(o->rarity, "rare") == 0){
switch (o->level){ if(o->level > 20){
case o->level > 20: return 3; return 3;
case o->level > 10: return 2; } if(o->level > 10){
default: return 1; return 2;
} }
return 1;
} }
if(strcmp(o->rarity, "epic") == 0){ if(strcmp(o->rarity, "epic") == 0){
switch (o->level){ if(o->level > 30){
case o->level > 30: return 4; return 4;
case o->level > 10: return 3; } if(o->level > 10){
default: return 2; return 3;
} }
return 2;
} }
if(strcmp(o->rarity, "legendary") == 0){ if(strcmp(o->rarity, "legendary") == 0){
if(o->level>20){ if(o->level > 20){
return 4; return 4;
} }
return 3; return 3;
} }
printf("Error handeling your item, please report it to @komiko\n");
return 0; return 0;
} }
@@ -85,12 +92,12 @@ void addPerks(struct Object* o) {
} }
} }
char** perk_list = perkLists(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; return;
} }
struct Perk* displayAndChoseAvailablePerks(char** perk_list, bool is_event) { struct Perk* displayAndChooseAvailablePerks(char** perk_list, bool is_event) {
if(perk_list == NULL){ if(perk_list == NULL){
return NULL; return NULL;
} }
@@ -331,9 +338,7 @@ void updateEvent(struct Perk* p,bool is_event) {
p->is_event = is_event; p->is_event = is_event;
} }
char** perkLists(struct Object* o) {
char** perkLists(const struct Object* o) {
char** files_names = malloc(sizeof(char*) * 2); char** files_names = malloc(sizeof(char*) * 2);
if (files_names == NULL) { if (files_names == NULL) {
return NULL; return NULL;

View File

@@ -1,9 +1,6 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#ifndef PERKS_H #ifndef PERKS_H
#define PERKS_H #define PERKS_H
#include<stdbool.h>
struct Perk { struct Perk {
@@ -19,7 +16,7 @@ struct Perk* createPerk(char* first_boost_type,char* second_boost_type, int firs
int numberOfPerks(struct Object* o); int numberOfPerks(struct Object* o);
void addPerks(struct Object* o); void addPerks(struct Object* o);
char** perkLists(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); void updateEvent(struct Perk* p,bool is_event);

View File

@@ -3,9 +3,9 @@
#include<string.h> #include<string.h>
#include<stdbool.h> #include<stdbool.h>
#include <unistd.h> #include <unistd.h>
#include "readobjects.h"
#include "menu.h"
#include "objects.h" #include "objects.h"
#include "readobjects.h"
#include "clear_input.h"
#define MAX_LINE_SIZE 1024 #define MAX_LINE_SIZE 1024
/** /**

View File

@@ -3,9 +3,9 @@
#include<string.h> #include<string.h>
#include<stdbool.h> #include<stdbool.h>
#include <unistd.h> #include <unistd.h>
#include "menu.h"
#include "objects.h" #include "objects.h"
#include "readtraining.h" #include "readtraining.h"
#include "clear_input.h"
#define MAX_LINE_SIZE 1024 #define MAX_LINE_SIZE 1024
/** /**

View File

@@ -1,8 +1,8 @@
#include "ships.h"
#include "objects.h"
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include<string.h> #include<string.h>
#include "objects.h"
#include "ships.h"
#define OBJECT_TYPES "rbygt" #define OBJECT_TYPES "rbygt"
/** /**

View File

@@ -1,8 +1,7 @@
#ifndef SHIPS_H #ifndef SHIPS_H
#define SHIPS_H #define SHIPS_H
#include<stdbool.h> #include<stdbool.h>
#include "objects.h"
struct Ship{ struct Ship{
struct Slots* loadout [5]; struct Slots* loadout [5];