diff --git a/Plague.g1a b/Plague.g1a index c155969..779e458 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/src/core.c b/src/core.c index e5c1133..3202c87 100644 --- a/src/core.c +++ b/src/core.c @@ -9,7 +9,7 @@ #include "display_engine.h" -void next_frame(struct game *current_game) +int next_frame(struct game *current_game) { for (int i = 0; current_game->planes[i]; i++) { @@ -60,7 +60,7 @@ void next_frame(struct game *current_game) current_game->time = 0; // Update the game - current_game->dna = current_game->dna + 1 + floor(current_game->severity / 25); + current_game->dna = current_game->dna + 1 + floor(current_game->severity / 10); if (current_game->dna > 30) current_game->dna = 30; current_game->research += current_game->priority; if (current_game->research > current_game->limit) current_game->research = current_game->limit; @@ -72,8 +72,10 @@ void next_frame(struct game *current_game) { if (current_game->humans[0]) message("VOUS AVEZ PERDU."); else message("VOUS AVEZ GAGNE !"); + return 0; } } + return 1; } @@ -87,7 +89,11 @@ int get_inputs(const int background, int *mutation_menu) *mutation_menu = 4; return 3; } - if (key == KEY_SQUARE) return 6; + if (key == KEY_SQUARE) + { + if (background == 1 || background == 2) return 6; + else if (background == 6) return 1; + } if (key == KEY_ALPHA) { diff --git a/src/core.h b/src/core.h index f756376..cb46e65 100644 --- a/src/core.h +++ b/src/core.h @@ -90,7 +90,7 @@ struct cursor int get_inputs(const int background, int *mutation_menu); // next_frame : compute the plane's positions -void next_frame(struct game *current_game); +int next_frame(struct game *current_game); // rtc_key : get the key with RTC system int rtc_key(void); diff --git a/src/data.c b/src/data.c index 1c92e66..ce19a94 100644 --- a/src/data.c +++ b/src/data.c @@ -5,7 +5,7 @@ const struct mutation symptoms_data[14] = { {10, 10, 0, 2, 0, "NAUSEE", "DONNE DES NAUSEES"}, - {15, 10, 0, 10, 0, "VOMISSEMENT", "PROVOQUE DES REJETS GESTRIQUES"}, + {15, 10, 0, 10, 0, "VOMISSEMENT", "PROVOQUE DES REJETS GASTRIQUES"}, {10, 5, 0, 3, 0, "TOUX", "LA PROJECTION DE PARTICULE AUGMENTE LA CONTAGION"}, {15, 20, 5, 10, 0, "PNEUMONIE", "AFFECTION PULMONAIRE PEU MORTELLE"}, { 0, 30, 20, 15, 10, "TUMEUR", "PEU CONTAGIEUX, MAIS MORTEL"}, @@ -25,8 +25,8 @@ const struct mutation abilities_data[6] = { {15, 0, 0, 10, 0, "FROID", "RESISTANCE AU FROID"}, {15, 0, 0, 15, 0, "CHAUD", "RESISTANCE AU CHAUD"}, - { 0, 10, 4, 25, 10, "GENETIQUE", "LE GENOME MUTE, RALENTISSANT LE SEQUENCAGE ADN"}, - {10, 40, 20, 30, 20, "MUTATION+", "LE VIRUS MUTE, BLOQUANT LES CHERCHEURS"}, + { 0, 10, 0, 25, 10, "GENETIQUE", "LE GENOME MUTE, RALENTISSANT LE SEQUENCAGE ADN"}, + {10, 10, 20, 30, 30, "MUTATION+", "LE VIRUS MUTE, BLOQUANT LES CHERCHEURS"}, {30, 10, 0, 30, 0, "ENVIRON", "LE VIRUS RESISTE AUX ENVIRONNEMENTS LES PLUS HOSTILES"}, { 0, 15, 30, 15, 20, "MEDICAMENT", "RESISTANCES AU MEDICAMENTS"}, }; @@ -38,15 +38,15 @@ const struct mutation transmissions_data[13] = {10, 10, 0, 15, 0, "AIR 2", "TRANSMISSION PAR L'AIR"}, {20, 10, 0, 20, 0, "AIR 3", "TRANSMISSION PAR L'AIR"}, {40, 15, 0, 30, 0, "AEROSOL", "TRANSMISSION PAR L'AIR ET PAR L'EAU"}, - {10, 0, 0, 9, 0, "EAU 1", "TRANSMISSION PAR L'EAU"}, - {20, 10, 0, 12, 0, "EAU 2", "TRANSMISSION PAR L'EAU"}, - {20, 0, 0, 10, 0, "ANIMAL 1", "LE VIRUS PEUT PASSER DE L'ANIMAL À L'HOMME"}, - {40, 10, 0, 16, 0, "ANIMAL 2", "CAPACITE DE TRANSMISSION HOMME-ANIMAL"}, - {20, 0, 0, 12, 0, "OISEAU 1", "CAPACITE DE TRANSMISSION ENTRE LES OISEAU"}, - {40, 10, 0, 16, 0, "OISEAU 2", "LES OISEAUX DEVIENNENT DES VECTEURS VIRALS"}, + {10, 0, 0, 15, 0, "EAU 1", "TRANSMISSION PAR L'EAU"}, + {20, 10, 0, 20, 0, "EAU 2", "TRANSMISSION PAR L'EAU"}, + {20, 0, 5, 12, 0, "ANIMAL 1", "LE VIRUS PEUT PASSER DE L'ANIMAL À L'HOMME"}, + {40, 10, 0, 25, 0, "ANIMAL 2", "CAPACITE DE TRANSMISSION HOMME-ANIMAL"}, + {20, 0, 0, 15, 0, "OISEAU 1", "LES OISEAUX TRANSMETTENT LE VIRUS"}, + {40, 10, 0, 25, 0, "OISEAU 2", "LES OISEAUX TRANSMETTENT LE VIRUS"}, {10, 0, 0, 8, 0, "SANG 1", "LE VIRUS SE TRANSMET PAR LE SANG"}, - {20, 10, 0, 14, 0, "SANG 2", "LE VIRUS SE TRANSMET PAR LE SANG"}, - {40, 15, 0, 20, 0, "SANG 3", "LE VIRUS SE TRANSMET PAR LE SANG"}, + {20, 10, 0, 15, 0, "SANG 2", "LE VIRUS SE TRANSMET PAR LE SANG"}, + {40, 15, 0, 25, 0, "SANG 3", "LE VIRUS SE TRANSMET PAR LE SANG"}, }; diff --git a/src/epidemic_engine.c b/src/epidemic_engine.c index f10108a..aa45cc8 100644 --- a/src/epidemic_engine.c +++ b/src/epidemic_engine.c @@ -41,7 +41,8 @@ void epidemic_simulation(struct game *current_game) uint8_t *current_grid = calloc(current_game->grid.width * current_game->grid.height, sizeof(uint8_t)); init_tab(current_game->grid.width * current_game->grid.height, current_grid, current_game->grid.data); - int healed_rate = ceil((100 * current_game->research / current_game->limit)); + int healed_rate = floor((100 * current_game->research / current_game->limit)); + if (!bernoulli(healed_rate)) healed_rate = 0; // Make the epidemic grid evolove for (int i = 0; i < current_game->grid.width; i ++) diff --git a/src/main.c b/src/main.c index e23b835..383ac60 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ /* Project name ......: Plague - Version ...........: 1.3 + Version ...........: 1.3.1 Last modification .: 4 June 2021 code and assets provided with licence : @@ -24,7 +24,7 @@ static void title_screen(void); // main_loop : display background, foreground and manage inputs -void main_loop(struct game *current_game); +int main_loop(struct game *current_game); int main(void) @@ -74,9 +74,10 @@ int main(void) read_save(¤t_game); - main_loop(¤t_game); + int to_save = main_loop(¤t_game); - write_save(¤t_game); + if (to_save) write_save(¤t_game); + else delete_save(); // Free memory free(current_game.grid.data); @@ -128,10 +129,10 @@ static void title_screen(void) } -void main_loop(struct game *current_game) +int main_loop(struct game *current_game) { int background = 1, mutation_menu = 4; - int end = 0; + int end = 0, to_save = 1; static volatile int tick = 1; int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick)); @@ -150,7 +151,7 @@ void main_loop(struct game *current_game) dupdate(); // Compute the motion of planes, DNA points and infectious model - next_frame(current_game); + to_save = next_frame(current_game); // Get inputs from the keyboard and manage it background = get_inputs(background, &mutation_menu); @@ -165,5 +166,6 @@ void main_loop(struct game *current_game) } if (t >= 0) timer_stop(t); + return to_save; } diff --git a/src/mutation_engine.c b/src/mutation_engine.c index 65a0f93..b4fac43 100644 --- a/src/mutation_engine.c +++ b/src/mutation_engine.c @@ -133,7 +133,7 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut // Update update_disease(current_game); - current_game->priority += ceil((mutation_data->severity + mutation_data->lethality)/8); + current_game->priority += ceil((mutation_data->severity + mutation_data->lethality) / 10); message("MUTATION ACHETEE"); } else message("ACHAT IMPOSSIBLE"); diff --git a/src/mutation_engine.h b/src/mutation_engine.h index 0a31ef0..8b2ec28 100644 --- a/src/mutation_engine.h +++ b/src/mutation_engine.h @@ -5,7 +5,7 @@ #include "display_engine.h" // Basic limit research -#define RESEARCH_LIMIT 200 +#define RESEARCH_LIMIT 300 // mutation_table : contain the map of the mutation available struct mutation_table diff --git a/src/save.c b/src/save.c index addae58..34b314c 100644 --- a/src/save.c +++ b/src/save.c @@ -90,4 +90,10 @@ void write_save(const struct game *current_game) // Close file BFile_Close(fd); +} + + +void delete_save(void) +{ + BFile_Remove(filename); } \ No newline at end of file diff --git a/src/save.h b/src/save.h index f4dd4bc..3a95910 100644 --- a/src/save.h +++ b/src/save.h @@ -9,4 +9,7 @@ void read_save(struct game *current_game); // write_save : write the savefile void write_save(const struct game *current_game); +// delete_save : delete the savefile +void delete_save(void); + #endif /* _SAVE_H */ \ No newline at end of file