diff --git a/apply_training_and_perks.c b/apply_training_and_perks.c index 14f1e27..5895cca 100644 --- a/apply_training_and_perks.c +++ b/apply_training_and_perks.c @@ -42,9 +42,9 @@ void applytrainingAndPerks(struct Object* o,const struct Training* t) { } else if (strcasecmp(t->type[i], "PROJECTILE_SPEED") == 0) { percent_projectile_speed += t->value[i]; } else if (strcasecmp(t->type[i], "CRITICAL_HIT_CHANCE") == 0) { - percent_critical_hit_chance += t->value[i]; + flat_critical_hit_chance += t->value[i]; } else if (strcasecmp(t->type[i], "CRITICAL_HIT_MULTIPLIER") == 0) { - percent_critical_hit_multiplier += t->value[i]; + flat_critical_hit_multiplier += t->value[i]; } else if (strcasecmp(t->type[i], "DURATION") == 0) { percent_duration += t->value[i]; } else if (strcasecmp(t->type[i], "FROST_DAMAGE") == 0 || strcasecmp(t->type[i], "FIRE_DAMAGE")) { @@ -85,9 +85,9 @@ void applytrainingAndPerks(struct Object* o,const struct Training* t) { } else if (strcasecmp(p->first_boost_type, "PROJECTILE_SPEED") == 0) { percent_projectile_speed += p->first_boost_value; } else if (strcasecmp(p->first_boost_type, "CRITICAL_HIT_CHANCE") == 0) { - percent_critical_hit_chance += p->first_boost_value; + flat_critical_hit_chance += p->first_boost_value; } else if (strcasecmp(p->first_boost_type, "CRITICAL_HIT_MULTIPLIER") == 0) { - percent_critical_hit_multiplier += p->first_boost_value; + flat_critical_hit_multiplier += p->first_boost_value; } else if (strcasecmp(p->first_boost_type, "DURATION") == 0) { percent_duration += p->first_boost_value; } else if (strcasecmp(p->first_boost_type, "FROST_DAMAGE") == 0 || strcasecmp(p->first_boost_type, "FIRE_DAMAGE")) { @@ -122,9 +122,9 @@ void applytrainingAndPerks(struct Object* o,const struct Training* t) { } else if (strcasecmp(p->second_boost_type, "PROJECTILE_SPEED") == 0) { percent_projectile_speed += p->second_boost_value; } else if (strcasecmp(p->second_boost_type, "CRITICAL_HIT_CHANCE") == 0) { - percent_critical_hit_chance += p->second_boost_value; + flat_critical_hit_chance += p->second_boost_value; } else if (strcasecmp(p->second_boost_type, "CRITICAL_HIT_MULTIPLIER") == 0) { - percent_critical_hit_multiplier += p->second_boost_value; + flat_critical_hit_multiplier += p->second_boost_value; } else if (strcasecmp(p->second_boost_type, "DURATION") == 0) { percent_duration += p->second_boost_value; } else if (strcasecmp(p->second_boost_type, "FROST_DAMAGE") == 0 || strcasecmp(t->type[i], "FIRE_DAMAGE")) { @@ -152,6 +152,24 @@ void applytrainingAndPerks(struct Object* o,const struct Training* t) { } } + /*printf("%d\n",flat_base_stat); + printf("%d\n", flat_cool_down); + printf("%d\n", flat_range); + printf("%d\n", flat_projectile_speed); + printf("%d\n", flat_critical_hit_chance); + printf("%d\n", flat_critical_hit_multiplier); + printf("%d\n", flat_duration); + printf("%d\n", flat_combo_dmg_boost); + + printf("%f\n", percent_base_stat); + printf("%f\n", percent_cool_down); + printf("%f\n", percent_range); + printf("%f\n", percent_projectile_speed); + printf("%f\n", percent_critical_hit_chance); + printf("%f\n", percent_critical_hit_multiplier); + printf("%f\n", percent_duration); + printf("%f\n", percent_combo_dmg_boost);*/ + o->base_stat = (flat_base_stat + o->base_stat) * (percent_base_stat); o->cool_down = (flat_cool_down + o->cool_down) * (percent_cool_down); o->range = (flat_range + o->range) * (percent_range); diff --git a/menu.c b/menu.c index fd56659..9cc6df4 100644 --- a/menu.c +++ b/menu.c @@ -9,10 +9,8 @@ #include "apply_training_and_perks.h" #include "clear_input.h" #include "menu.h" - #include "objects.h" - #define FILENAME_SIZE 40 diff --git a/perks.c b/perks.c index dbbc810..544ef25 100644 --- a/perks.c +++ b/perks.c @@ -157,7 +157,9 @@ struct Perk* displayAndChooseAvailablePerks(char** perk_list, bool is_event, str printf("1.Uncommon\n"); printf("2.Rare\n"); printf("3.Epic\n"); - printf("4.Legendary\n"); + if(is_event){ + printf("4.Legendary\n"); + } printf("------------------------\n"); printf("Your choice: "); int choice = 0; @@ -309,33 +311,48 @@ struct Perk* displayAndChooseAvailablePerks(char** perk_list, bool is_event, str } char* copiedline = strdup(line); struct Perk* p = NULL; - - // Parse perk values and types from the selected line - char* token = strtok(copiedline, ","); - float first_boost_value = atof(token); - token = strtok(NULL, ","); - char* first_boost_type = strdup(token); - token = strtok(NULL, ","); - float second_boost_value = atof(token); - token = strtok(NULL, "\r"); - char* second_boost_type = strdup(token); - + float first_boost_value = 0; + float second_boost_value = 0; + char* first_boost_type = NULL; + char* second_boost_type = NULL; + if(is_event) { + // Parse perk values and types from the selected line + char* token = strtok(copiedline, ","); + first_boost_value = atof(token); + token = strtok(NULL, ","); + first_boost_type = strdup(token); + token = strtok(NULL, ","); + second_boost_value = atof(token); + token = strtok(NULL, "\r"); + second_boost_type = strdup(token); + } else { + // Parse perk values and types from the selected line + char* token = strtok(copiedline, ","); + first_boost_value = atof(token); + token = strtok(NULL, "\r"); + first_boost_type = strdup(token); + } free(copiedline); // Free copied line memory fclose(file); // Close file after reading - char* selected_perk = malloc((strlen(first_boost_type) + strlen(second_boost_type)) * sizeof(char)); - snprintf(selected_perk, strlen(first_boost_type) + strlen(second_boost_type), "%s,%s", first_boost_type, second_boost_type); - - // Check if selected perk is already applied; if not, create and update it - if (perk_already_fited(is_event, o, selected_perk) == false) { - p = createPerk(first_boost_type, second_boost_type, first_boost_value, second_boost_value); - updateEvent(p, is_event); + if(is_event) { + char* selected_perk = malloc((strlen(first_boost_type) + strlen(second_boost_type)) * sizeof(char)); + snprintf(selected_perk, strlen(first_boost_type) + strlen(second_boost_type), "%s,%s", first_boost_type, second_boost_type); + // Check if selected perk is already applied; if not, create and update it + if (perk_already_fited(is_event, o, selected_perk) == false) { + p = createPerk(first_boost_type, second_boost_type, first_boost_value, second_boost_value); + updateEvent(p, is_event); + } else { + printf("You can't have multiple of the same event perks on an object"); + p = displayAndChooseAvailablePerks(perk_list, is_event, o); + } + free(selected_perk); } else { - printf("You can't have multiple of the same event perks on an object"); - p = displayAndChooseAvailablePerks(perk_list, is_event, o); + p = createPerk(first_boost_type, "NA", first_boost_value, second_boost_value); + updateEvent(p, is_event); } - free(selected_perk); - + free(first_boost_type); + free(second_boost_type); // Free memory allocated for perk_rarity and perks_full_path free(perk_rarity); for (int i = 0; i < num_files; i++) {