diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e3e91b..62a715c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(SOURCES src/main.c src/core.c src/display_engine.c + src/mutation_engine.c # ... ) # Shared assets, fx-9860G-only assets and fx-CG-50-only assets @@ -35,6 +36,9 @@ set(ASSETS_fx assets-fx/mutations_table/transmissions_1.txt assets-fx/mutations_table/transmissions_2.txt assets-fx/mutations_table/transmissions_3.txt + assets-fx/mutations_data/abilities.txt + assets-fx/mutations_data/symptoms.txt + assets-fx/mutations_data/transmissions.txt # ... ) set(ASSETS_cg diff --git a/Plague.g1a b/Plague.g1a index 1175150..b180f0a 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/README.md b/README.md index c3a1686..c10a668 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ En mutant, votre maladie peut acquérir des capacités. Ces capacités lui perme |résistance au froid|+4|||10 |résistance au chand|+7|||15 |résistance à l'environnement|+10|||30 -|résistance aux médicaments||+2|+0,5|15 -|résistance génétique||+5|+1|25 +|résistance aux médicaments||+2|+2|15 +|résistance génétique||+5|+4|25 |mutation accélérée||+8|+2|30 ### Moyens de transmissions @@ -77,8 +77,7 @@ Votre maladie aura tout le loisir de changer ses moyens de transmission ! Plus o |air Nv 3|+8|20 |air et eau|+10|30 |eau Nv 1|+2|9 -|eau Nv 2|+3|12 -|eau Nv 3|+9|25 +|eau Nv 2|+4|12 |oiseau Nv 1|+3|12 |oiseau Nv 2|+5|18 |animaux Nv 1|+2|10 diff --git a/assets-fx/__pycache__/converters.cpython-39.pyc b/assets-fx/__pycache__/converters.cpython-39.pyc index b7ecc36..655234a 100644 Binary files a/assets-fx/__pycache__/converters.cpython-39.pyc and b/assets-fx/__pycache__/converters.cpython-39.pyc differ diff --git a/assets-fx/converters.py b/assets-fx/converters.py index 9984554..10a2b88 100644 --- a/assets-fx/converters.py +++ b/assets-fx/converters.py @@ -5,6 +5,9 @@ def convert(input_name, output, params, target): if params["custom-type"] == "mutation-table": convert_mt(input_name, output, params, target) return 0 + elif params["custom-type"] == "mutation-data": + convert_md(input_name, output, params, target) + return 0 else: return 1 @@ -22,3 +25,16 @@ def convert_mt(input_name, output, params, target): data += fxconv.u32(int(j)) fxconv.elf(data, output, "_" + params["name"], **target) + + +def convert_md(input_name, output, params, target): + with open(input_name, "r") as file: + # Extract informations + lines = file.read().splitlines() + + # Convert data into bytes-like object + data = bytes() + for i in lines: + data += bytes(i, encoding="utf-8") + + fxconv.elf(data, output, "_" + params["name"], **target) diff --git a/assets-fx/mutations_data/abilities.txt b/assets-fx/mutations_data/abilities.txt new file mode 100644 index 0000000..2a93ce9 --- /dev/null +++ b/assets-fx/mutations_data/abilities.txt @@ -0,0 +1,14 @@ +FROID,4,0,0,10,0 +CHAUD,7,0,0,15,0 +GENETIQUE,0,5,4,25, +MUTATION+,0,8,8,30,2 +ENVIRON,10,0,0,30,0 +MEDICAMENT,0,2,2,15,1 +NONE +NONE +NONE +NONE +NONE +NONE +NONE +NONE \ No newline at end of file diff --git a/assets-fx/mutations_data/fxconv-metadata.txt b/assets-fx/mutations_data/fxconv-metadata.txt new file mode 100644 index 0000000..0ad2668 --- /dev/null +++ b/assets-fx/mutations_data/fxconv-metadata.txt @@ -0,0 +1,3 @@ +*.txt: + custom-type: mutation-data + name_regex: (.*)\.txt md_\1 \ No newline at end of file diff --git a/assets-fx/mutations_data/space_splitter.py b/assets-fx/mutations_data/space_splitter.py new file mode 100644 index 0000000..e09ada1 --- /dev/null +++ b/assets-fx/mutations_data/space_splitter.py @@ -0,0 +1,8 @@ +for file_name in ("abilities.txt", "symptoms.txt", "transmissions.txt"): + file = open(file_name, "r") + content = file.read().replace(" ", "") + file.close() + + file = open(file_name, "w") + file.write(content) + file.close() \ No newline at end of file diff --git a/assets-fx/mutations_data/symptoms.txt b/assets-fx/mutations_data/symptoms.txt new file mode 100644 index 0000000..7ccbfa5 --- /dev/null +++ b/assets-fx/mutations_data/symptoms.txt @@ -0,0 +1,14 @@ +NAUSEE,1,1,0,2,0.5, +VOMISSEMENT,3,2,0,4,0.5 +TOUX,2,1,0,3,0.5 +PNEUMONIE,2,2,0,4,0.5 +TUMEUR,4,2,5,15,1 +PLAIES,2,1,0,3,0.5 +LESIONS,5,4,0,10,0.5 +HEMORRAGIE,5,15,15,20,0.5 +INFLAMMATION,2,2,2,5,0.5 +INFECTION,6,7,6,17,0.5 +IMMUNODEFICIENCE,2,6,4,12,1 +PARANOIA,0,4,0,5,1 +FOLIE,6,15,0,20,2 +ARRETTOTAL,0,20,25,30,2 \ No newline at end of file diff --git a/assets-fx/mutations_data/transmissions.txt b/assets-fx/mutations_data/transmissions.txt new file mode 100644 index 0000000..c4f008c --- /dev/null +++ b/assets-fx/mutations_data/transmissions.txt @@ -0,0 +1,14 @@ +AIR1,2,0,0,9,0 +AIR2,5,0,0,15,0 +AIR3,8,0,0,20,0 +AEROSOL,10,0,0,30,0 +EAU1,2,0,0,9,0 +EAU2,4,0,0,12,0 +OISEAU1,3,0,0,12,0 +OISEAU2,6,0,0,16,0 +ANIMAL1,2,0,0,10,0 +ANIMAL2,6,0,0,16,0 +SANG1,1,0,0,8,0 +SANG2,4,0,0,14,0 +SANG3,9,0,0,20,0 +NONE \ No newline at end of file diff --git a/src/core.c b/src/core.c index 063c56c..e57f55d 100644 --- a/src/core.c +++ b/src/core.c @@ -3,6 +3,7 @@ #include #include "core.h" +#include "mutation_engine.h" #include "display_engine.h" @@ -130,14 +131,19 @@ void manage_mutation(struct game *current_game, const int mutation_menu) tick = 0; c.display = (c.display + 1) % 2; - // Display the mutation menu - display_mutation(current_game, mutation_menu, c); + // Get and display the mutation menu + int table[4][8]; + get_mutation(current_game, mutation_menu, table); + char data[14]; + get_mutation_data(mutation_menu, data); + display_mutation(table, c, mutation_menu); // Get the key key = rtc_key(); + // Manage input if (key == KEY_EXIT) end = 1; - + // if (key == KEY_EXE) mutation_selected(c, mutation_menu, get_mutation_data(current_game, mutation_menu)); if (key == KEY_LEFT && c.x > 0) c.x--; if (key == KEY_RIGHT && c.x < 7) c.x++; diff --git a/src/display_engine.c b/src/display_engine.c index 3fae5b4..31caeeb 100644 --- a/src/display_engine.c +++ b/src/display_engine.c @@ -1,6 +1,6 @@ #include -#include "core.h" +#include "mutation_engine.h" #include "display_engine.h" @@ -79,48 +79,11 @@ void display_foreground(const int background, const struct game *current_game) } -void display_mutation(const struct game *current_game, const int mutation_menu, const struct cursor c) +void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu) { extern const bopti_image_t img_mutations; extern bopti_image_t img_cursor; - // Load symptoms - extern struct mutation_table mt_symptoms_1; - extern struct mutation_table mt_symptoms_2; - extern struct mutation_table mt_symptoms_3; - - // Load abilities - extern struct mutation_table mt_abilities_1; - extern struct mutation_table mt_abilities_2; - extern struct mutation_table mt_abilities_3; - - // Load transmissions - extern struct mutation_table mt_transmissions_1; - extern struct mutation_table mt_transmissions_2; - extern struct mutation_table mt_transmissions_3; - - int table[4][8]; - if (mutation_menu == 1) - { - if (current_game->symptoms < 4) init_mat(8, 4, table, mt_symptoms_1.data); - else if (current_game->symptoms < 8) init_mat(8, 4, table, mt_symptoms_2.data); - else init_mat(8, 4, table, mt_symptoms_3.data); - } - - if (mutation_menu == 2) - { - if (current_game->abilities < 2) init_mat(8, 4, table, mt_abilities_1.data); - else if (current_game->abilities < 4) init_mat(8, 4, table, mt_abilities_2.data); - else init_mat(8, 4, table, mt_abilities_3.data); - } - - if (mutation_menu == 3) - { - if (current_game->transmissions < 5) init_mat(8, 4, table, mt_transmissions_1.data); - else if (current_game->transmissions < 10) init_mat(8, 4, table, mt_transmissions_2.data); - else init_mat(8, 4, table, mt_transmissions_3.data); - } - dclear(C_WHITE); display_background(5); for (int i = 0 ; i < 4 ; i++) @@ -135,14 +98,3 @@ void display_mutation(const struct game *current_game, const int mutation_menu, } - -void init_mat(int x, int y, int dest[][x], int src[][x]) -{ - for (int i = 0 ; i < x ; i++) - { - for (int j = 0 ; j < y ; j++) - { - dest[j][i] = src[j][i]; - } - } -} diff --git a/src/display_engine.h b/src/display_engine.h index e9c7e9c..57fbeaa 100644 --- a/src/display_engine.h +++ b/src/display_engine.h @@ -1,6 +1,8 @@ #ifndef _PLAGUE_DISPLAY_ENGINE_H #define _PLAGUE_DISPLAY_ENGINE_H +#include "core.h" + // display_background : display the background void display_background(const int background); @@ -8,17 +10,6 @@ void display_background(const int background); void display_foreground(const int background, const struct game *current_game); // display_mutation : display the mutation selection screen -void display_mutation(const struct game *current_game, const int mutation_menu, const struct cursor c); - -// init_mat : copy src into dest -void init_mat(int x, int y, int dest[][x], int src[][x]); - -// mutation_table : contain the map of the mutation available -struct mutation_table -{ - // Data of the map - int data[4][8]; -}; - +void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu); #endif /* _PLAGUE_DISPLAY_ENGINE_H */ \ No newline at end of file diff --git a/src/mutation_engine.c b/src/mutation_engine.c new file mode 100644 index 0000000..a5b4c99 --- /dev/null +++ b/src/mutation_engine.c @@ -0,0 +1,84 @@ +#include "mutation_engine.h" + +void get_mutation(const struct game *current_game, const int mutation_menu, int table[4][8]) +{ + // Load symptoms + extern struct mutation_table mt_symptoms_1; + extern struct mutation_table mt_symptoms_2; + extern struct mutation_table mt_symptoms_3; + + // Load abilities + extern struct mutation_table mt_abilities_1; + extern struct mutation_table mt_abilities_2; + extern struct mutation_table mt_abilities_3; + + // Load transmissions + extern struct mutation_table mt_transmissions_1; + extern struct mutation_table mt_transmissions_2; + extern struct mutation_table mt_transmissions_3; + + if (mutation_menu == 1) + { + if (current_game->symptoms < 4) init_mat(8, 4, table, mt_symptoms_1.data); + else if (current_game->symptoms < 8) init_mat(8, 4, table, mt_symptoms_2.data); + else init_mat(8, 4, table, mt_symptoms_3.data); + } + + if (mutation_menu == 2) + { + if (current_game->abilities < 2) init_mat(8, 4, table, mt_abilities_1.data); + else if (current_game->abilities < 4) init_mat(8, 4, table, mt_abilities_2.data); + else init_mat(8, 4, table, mt_abilities_3.data); + } + + if (mutation_menu == 3) + { + if (current_game->transmissions < 5) init_mat(8, 4, table, mt_transmissions_1.data); + else if (current_game->transmissions < 10) init_mat(8, 4, table, mt_transmissions_2.data); + else init_mat(8, 4, table, mt_transmissions_3.data); + } +} + + +void get_mutation_data(const int mutation_menu, char data[14]) +{ + extern struct mutation_data md_abilities; + extern struct mutation_data md_symptoms; + extern struct mutation_data md_transmissions; + + switch (mutation_menu) + { + case 1: + char_init_mat(14, data, md_symptoms.data); + break; + + case 2: + char_init_mat(14, data, md_abilities.data); + break; + + case 3: + char_init_mat(14, data, md_transmissions.data); + break; + } +} + + +void init_mat(int x, int y, int dest[][x], int src[][x]) +{ + for (int i = 0; i < x; i++) + { + for (int j = 0; j < y; j++) + { + dest[j][i] = src[j][i]; + } + } +} + +void char_init_mat(int x, char dest[x], char src[x]) +{ + for (int i = 0; i < x; i++) + { + dest[i] = src[i]; + } +} + diff --git a/src/mutation_engine.h b/src/mutation_engine.h new file mode 100644 index 0000000..1b99a7a --- /dev/null +++ b/src/mutation_engine.h @@ -0,0 +1,32 @@ +#ifndef _MUTATION_ENGINE_H +#define _MUTATION_ENGINE_H + +#include "core.h" + +// mutation_table : contain the map of the mutation available +struct mutation_table +{ + // Data of the map + int data[4][8]; +}; + +// mutation_data : contain the mutations data +struct mutation_data +{ + // Data of the mutations + char data[14]; +}; + +// get_mutation : return the mutation table to display +void get_mutation(const struct game *current_game, const int mutation_menu, int table[4][8]); + +// get_mutation_data : return the mutation_data +void get_mutation_data(const int mutation_menu, char data[14]); + +// init_mat : copy src into dest (for int) +void init_mat(int x, int y, int dest[][x], int src[][x]); + +// char_init_mat : copy src into dest (for char) +void char_init_mat(int x, char dest[x], char srx[x]); + +#endif /* _MUTATION_ENGINE_H */ \ No newline at end of file