diff --git a/assets-cg/capacites/TestCapacite.json b/assets-cg/capacites/TestCapacite.json index 388b744..dbd1569 100644 --- a/assets-cg/capacites/TestCapacite.json +++ b/assets-cg/capacites/TestCapacite.json @@ -1,8 +1,8 @@ { "name":"Test capacité", "id":0, - "categorie":"PHYSICAL", + "categorie":"SPECIAL", "pp":5, "atk":20, - "precision":80 + "precision":100 } diff --git a/assets-cg/capacites/TestCapacite2.json b/assets-cg/capacites/TestCapacite2.json new file mode 100644 index 0000000..0528d96 --- /dev/null +++ b/assets-cg/capacites/TestCapacite2.json @@ -0,0 +1,8 @@ +{ + "name":"Test capacité2", + "id":4, + "categorie":"PHYSICAL", + "pp":5, + "atk":20, + "precision":100 +} diff --git a/assets-cg/categories.png b/assets-cg/categories.png index c74d226..7b5cfd1 100644 Binary files a/assets-cg/categories.png and b/assets-cg/categories.png differ diff --git a/assets-cg/converters.py b/assets-cg/converters.py index 7f66ea1..119e18d 100644 --- a/assets-cg/converters.py +++ b/assets-cg/converters.py @@ -223,14 +223,16 @@ def convert_capa(input, output, params, target): move = fxconv.Structure() try: + categorie = data["categorie"] + id_categorie = ["STATUT", "PHYSICAL", "SPECIAL"] + move += fxconv.string(data["name"]) move += fxconv.u32(data["id"]) - move += fxconv.u32(1 if data["categorie"]=="PHYSICAL" else 0) + move += fxconv.u32(id_categorie.index(categorie)) move += fxconv.u32(data["pp"]) move += fxconv.u32(data["pp"]) - categorie = data["categorie"] - if categorie=="PHYSICAL": + if categorie=="PHYSICAL" or categorie=="SPECIAL": move += fxconv.u32(data["atk"]) move += fxconv.u32(data["precision"]) move += fxconv.u32(0) + fxconv.u32(0) + fxconv.u32(0) @@ -256,11 +258,13 @@ def convert_monster(input, output, params, target): data = json.load(file) stats = fxconv.Structure() - if len(data["stats"]) != 4: raise Exception(f"convert_monster : Les statistiques de {data['name']} sont mauvaises") + if len(data["stats"]) != 6: raise Exception(f"convert_monster : Les statistiques de {data['name']} sont mauvaises") stats+=fxconv.u32(data["stats"]["atk"]) stats+=fxconv.u32(data["stats"]["def"]) stats+=fxconv.u32(data["stats"]["pv"]) - stats+=fxconv.u32(1) + stats+=fxconv.u32(data["stats"]["spe_atk"]) + stats+=fxconv.u32(data["stats"]["spe_def"]) + stats+=fxconv.u32(1) # level, will be calculated later stats+=fxconv.u32(data["stats"]["xp"]) stats+=fxconv.u32(data["stats"]["pv"]) diff --git a/assets-cg/monsters/test.json b/assets-cg/monsters/test.json index 87912f6..23521d1 100644 --- a/assets-cg/monsters/test.json +++ b/assets-cg/monsters/test.json @@ -5,6 +5,8 @@ "stats":{ "atk":10, "def":10, + "spe_atk":10, + "spe_def":10, "pv":20, "xp":300 }, diff --git a/assets-cg/monsters/test2.json b/assets-cg/monsters/test2.json index 167da9d..2573783 100644 --- a/assets-cg/monsters/test2.json +++ b/assets-cg/monsters/test2.json @@ -5,6 +5,8 @@ "stats":{ "atk":80, "def":5, + "spe_atk":10, + "spe_def":130, "pv":45, "xp":150 }, diff --git a/include/capacite.h b/include/capacite.h index 8b2b67b..2da5124 100644 --- a/include/capacite.h +++ b/include/capacite.h @@ -34,6 +34,7 @@ enum status { enum categorie { STATUT, PHYSICAL, + SPECIAL, }; struct Move default_move(); diff --git a/include/engine.h b/include/engine.h index a1d9480..6632045 100644 --- a/include/engine.h +++ b/include/engine.h @@ -16,7 +16,7 @@ void engine_tick(struct Game *game, int dt); /*set the background color*/ void engine_set_background(struct Game *game, int color); /*make an interaction with something*/ -void engine_action(struct Game const *game, int action); +void engine_action(struct Game *game, int action); /*check the current position of the player. To perform action depends of his location*/ void engine_check_position(struct Game *game); void engine_center_camera(struct Game *game); \ No newline at end of file diff --git a/include/stats.h b/include/stats.h index 56176bf..ee6438d 100644 --- a/include/stats.h +++ b/include/stats.h @@ -4,6 +4,8 @@ struct Stats { int atk; int def; int pv; + int spe_atk; + int spe_def; int level; int xp; int max_pv; diff --git a/src/battle.c b/src/battle.c index 05edd96..e6cea88 100644 --- a/src/battle.c +++ b/src/battle.c @@ -161,7 +161,7 @@ int select_move(struct Player *player, struct Monster *monster, int prec_selecte if(keydown(KEY_EXIT)) { break; } - while(keydown_any(KEY_RIGHT, KEY_LEFT, KEY_SHIFT, 0)) clearevents(); + while(keydown_any(KEY_RIGHT, KEY_LEFT, KEY_SHIFT, KEY_OPTN, 0)) clearevents(); } return selection; } diff --git a/src/capacite.c b/src/capacite.c index 1383c73..9a46dcb 100644 --- a/src/capacite.c +++ b/src/capacite.c @@ -59,13 +59,13 @@ void draw_move(int x, int y, int x2, int y2, struct Move *move) { (int)((y+y2)/2)-font_size/2, C_BLACK, "%s", move->name); - if(move->categorie == PHYSICAL) { - dprint(x+15, y2-17, C_BLACK, "ATK : %d", move->atk); - dprint(x+70, y2-17, C_BLACK, "PRE : %d", move->precision); - } else { + if(move->categorie == STATUT) { if(move->boost_atk > 0) dprint(x+10, y2-17, C_BLACK, "A+%d%%", move->boost_atk); if(move->boost_hp > 0) dprint(x+47, y2-17, C_BLACK, "H+%d%%", move->boost_hp); if(move->boost_def > 0) dprint(x+85, y2-17, C_BLACK, "D+%d%%", move->boost_def); + } else { + dprint(x+15, y2-17, C_BLACK, "ATK : %d", move->atk); + dprint(x+70, y2-17, C_BLACK, "PRE : %d", move->precision); } } @@ -75,7 +75,7 @@ void draw_classic_move(int x, int y, struct Move *move) { int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct Move *move, int ismonster) { srand(rtc_ticks()); - if(move->categorie == PHYSICAL) { + if(move->categorie == PHYSICAL || move->categorie == SPECIAL) { if(is_miss(move)) { move->pp--; return MISS; @@ -102,7 +102,11 @@ int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct } int calc_damage(struct Stats *attacker, struct Stats *target, struct Move *move) { - return floor((floor(((2*attacker->level / 5 + 2) * attacker->atk * move->atk / target->def) / 50) + 2)*crit(attacker)); + if(move->categorie == PHYSICAL) + return floor((floor(((2*attacker->level / 5 + 2) * attacker->atk * move->atk / target->def) / 50) + 2)*crit(attacker)); + if(move->categorie == SPECIAL) + return floor((floor(((2*attacker->level / 5 + 2) * attacker->spe_atk * move->atk / target->spe_def) / 50) + 2)*crit(attacker)); + return 0; } int is_crit() { diff --git a/src/engine.c b/src/engine.c index abdf9dc..28a6411 100644 --- a/src/engine.c +++ b/src/engine.c @@ -117,7 +117,7 @@ void engine_set_background(struct Game *game, int color) { } /*make an interaction with something*/ -void engine_action(struct Game const *game, int action) { +void engine_action(struct Game *game, int action) { if(action == ACTION_SHIFT) { if(player_facing(game) == TILE_TALKABLE) { draw_dialog(game); diff --git a/src/player.c b/src/player.c index 3e492e2..f4783fa 100644 --- a/src/player.c +++ b/src/player.c @@ -17,6 +17,8 @@ struct Player init_player(void) { struct Stats bstats = { .atk = 15, .def = 15, + .spe_atk = 15, + .spe_def = 15, .level = 1, .pv = 30, }; @@ -40,7 +42,8 @@ struct Player init_player(void) { .anim.dir = DIR_DOWN }; player.idle = !anim_player_idle(&player.anim, 1); - player.moves[0] = copy_move(get_move_id(1)); + player.moves[0] = copy_move(get_move_id(0)); + player.moves[1] = copy_move(get_move_id(4)); set_stats_level_from(&player.base_stats, &player.stats); return player; diff --git a/src/stats.c b/src/stats.c index f5be0b2..a0dcc71 100644 --- a/src/stats.c +++ b/src/stats.c @@ -12,19 +12,25 @@ void draw_stats(struct Stats stats) { dprint(300,60,C_BLACK,"XP : %d",stats.xp); dprint(300,80,C_BLACK,"ATK : %d",stats.atk); dprint(300,100,C_BLACK,"DEF : %d",stats.def); - dprint(300,120,C_BLACK,"LVLUP : %d",(int)(pow(stats.level+1, 3.03))-stats.xp); + dprint(300,120,C_BLACK,"ATKS : %d",stats.spe_atk); + dprint(300,140,C_BLACK,"DEFS : %d",stats.spe_def); + dprint(300,160,C_BLACK,"LVLUP : %d",(int)(pow(stats.level+1, 3.03))-stats.xp); } void set_stats_level_from(const struct Stats *from, struct Stats *to) { to->max_pv = calc_stats(from->pv, to->level); to->atk = calc_stats(from->atk, to->level); to->def = calc_stats(from->def, to->level); + to->spe_atk = calc_stats(from->spe_atk, to->level); + to->spe_def = calc_stats(from->spe_def, to->level); } void set_stats_level(struct Stats *stats) { stats->max_pv = calc_stats(stats->pv, stats->level); stats->atk = calc_stats(stats->atk, stats->level); stats->def = calc_stats(stats->def, stats->level); + stats->spe_atk = calc_stats(stats->spe_atk, stats->level); + stats->spe_def = calc_stats(stats->spe_def, stats->level); } int calc_stats(int base, int level) {