diff --git a/.gitignore b/.gitignore index 9ccbbfc..dec1509 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ __pycache__/ *.sublime-project *.sublime-workspace .vscode +.idea +cmake-build-debug diff --git a/assets-cg/capacites/Soin.json b/assets-cg/capacites/Soin.json index a78271c..d3fe53d 100644 --- a/assets-cg/capacites/Soin.json +++ b/assets-cg/capacites/Soin.json @@ -5,6 +5,8 @@ "type":"Rédacteur", "pp":100, "boost_atk":15, - "boost_hp":15, - "boost_def":15 + "boost_spe_atk":0, + "boost_spe_def":0, + "boost_def":15, + "boost_hp":15 } diff --git a/assets-cg/converters.py b/assets-cg/converters.py index 1174c64..8e095b7 100644 --- a/assets-cg/converters.py +++ b/assets-cg/converters.py @@ -296,6 +296,8 @@ def convert_capa(input, output, params, target): move += fxconv.u32(0) + fxconv.u32(100) move += fxconv.u32(data["boost_atk"]) move += fxconv.u32(data["boost_def"]) + move += fxconv.u32(data["boost_spe_atk"]) + move += fxconv.u32(data["boost_spe_def"]) move += fxconv.u32(data["boost_hp"]) except KeyError: raise Exception(f"convert_capa() : La capacité {data['name']} est mal configurée") diff --git a/assets-cg/monsters/test.json b/assets-cg/monsters/test.json index 4a067db..ac3dd1b 100644 --- a/assets-cg/monsters/test.json +++ b/assets-cg/monsters/test.json @@ -19,4 +19,4 @@ 1, 2 ] -} +} \ No newline at end of file diff --git a/assets-cg/uf8x9/U+0020.png b/assets-cg/uf8x9/U+0020.png index ba41f2b..a4a10e4 100644 Binary files a/assets-cg/uf8x9/U+0020.png and b/assets-cg/uf8x9/U+0020.png differ diff --git a/assets-cg/uf8x9/U+00A0.png b/assets-cg/uf8x9/U+00A0.png index a0e645c..4b1d3db 100644 Binary files a/assets-cg/uf8x9/U+00A0.png and b/assets-cg/uf8x9/U+00A0.png differ diff --git a/include/battle.h b/include/battle.h index b710a7f..668646b 100644 --- a/include/battle.h +++ b/include/battle.h @@ -15,4 +15,4 @@ void draw_battle(struct Player *player, struct Monster *monster); void draw_executed_move(struct Move *move, struct Monster *monster, int is_monster); void draw_status(char *name, char *message); void finish_battle(int status, struct Game *game, struct Monster *monster); -void check_move_status(int status, struct Player *player, struct Monster *monster, int is_monster); \ No newline at end of file +void check_move_status(int status, struct Player *player, struct Monster *monster, struct Move *move, int is_monster); \ No newline at end of file diff --git a/include/capacite.h b/include/capacite.h index f193098..ebd8ed4 100644 --- a/include/capacite.h +++ b/include/capacite.h @@ -14,6 +14,8 @@ struct Move { //self effect (%) int boost_atk; int boost_def; + int boost_spe_atk; + int boost_spe_def; int boost_hp; }; @@ -25,10 +27,7 @@ struct Capacities { enum status { MISS, SUCCESS, - HEAL, - ATK, - DEF, - MULTIPLE, + EFFECT, SUPER_EFFECTIVE, LESS_EFFECTIVE, NOT_EFFECTIVE @@ -51,6 +50,6 @@ struct Move *get_move_id_pointer(int id); float crit(struct Stats *attacker); int is_crit(); int is_miss(struct Move *move); -int self_effect(struct Stats *stats, struct Move *move); +void self_effect(struct Stats *stats, struct Move *move); float stab(char *type, char *move); void draw_special_move(int x, int y, struct Move *move, int selected); \ No newline at end of file diff --git a/src/battle.c b/src/battle.c index 728eab0..f87fee7 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include "engine.h" #include "battle.h" @@ -41,7 +43,7 @@ int battle(struct Player *player, struct Monster *monster) { dupdate(); wait_for_input(KEY_SHIFT); status = execute_move(&player->stats, monster->stats, player->moves[selection], 0); - check_move_status(status, player, monster, 0); + check_move_status(status, player, monster, player->moves[selection], 0); draw_battle(player, monster); @@ -57,7 +59,7 @@ int battle(struct Player *player, struct Monster *monster) { dupdate(); wait_for_input(KEY_SHIFT); status = execute_move(&player->stats, monster->stats, monster_move, 1); - check_move_status(status, player, monster, 1); + check_move_status(status, player, monster, monster_move, 1); if(player->stats.pv <= 0) { return LOSE; @@ -70,37 +72,49 @@ int battle(struct Player *player, struct Monster *monster) { return LOSE; } -void check_move_status(int status, struct Player *player, struct Monster *monster, int is_monster) { +void check_move_status(int status, struct Player *player, struct Monster *monster, struct Move *move, int is_monster) { char *name = is_monster ? monster->name : "Player"; if(status != SUCCESS) { draw_battle(player, monster); - switch(status){ - case MISS: - draw_status(name, "rate son attaque !"); - break; - case HEAL: - draw_status(name, "regagne des PVs !"); - break; - case ATK: - draw_status(name, "améliore son attaque !"); - break; - case DEF: - draw_status(name, "améliore sa défense !"); - break; - case MULTIPLE: - draw_status(name, "améliore ses statistiques !"); - break; - case SUPER_EFFECTIVE: - draw_status(name, "utilise une attaque super efficace !"); - break; - case LESS_EFFECTIVE: - draw_status(name, "utilise une attaque peu efficace"); - break; - case NOT_EFFECTIVE: - draw_status(name, "utilise une attaque non efficace..."); - break; - } + if(status == EFFECT) { + char *boost_strings[5] = {"", "", "", "", ""}; + int boost_count = 0; + + if(move->boost_spe_atk > 0) boost_strings[boost_count++] = "son attaque spéciale"; + if(move->boost_spe_def > 0) boost_strings[boost_count++] = "sa défense spéciale"; + if(move->boost_atk > 0) boost_strings[boost_count++] = "son attaque"; + if(move->boost_def > 0) boost_strings[boost_count++] = "sa défense"; + if(move->boost_hp > 0) boost_strings[boost_count++] = "ses points de vie"; + + if(boost_count > 0) { + char boost_message[128] = "augmente "; + for(int i = 0; i < boost_count; i++) { + if(i > 0) sprintf(boost_message + strlen(boost_message), (i == boost_count - 1) ? " et " : ", "); + sprintf(boost_message + strlen(boost_message), "%s", boost_strings[i]); + } + sprintf(boost_message + strlen(boost_message), " !"); + draw_status(name, boost_message); + + if(is_monster) self_effect(monster->stats, move); + else self_effect(&player->stats, move); + } + } else { + switch (status) { + case MISS: + draw_status(name, "rate son attaque !"); + break; + case SUPER_EFFECTIVE: + draw_status(name, "utilise une attaque super efficace !"); + break; + case LESS_EFFECTIVE: + draw_status(name, "utilise une attaque peu efficace"); + break; + case NOT_EFFECTIVE: + draw_status(name, "utilise une attaque inefficace sur le type adverse !"); + break; + } + } dupdate(); wait_for_input(KEY_SHIFT); diff --git a/src/capacite.c b/src/capacite.c index dcf3eff..8761570 100644 --- a/src/capacite.c +++ b/src/capacite.c @@ -44,6 +44,8 @@ struct Move *copy_move(struct Move move) { copyMove->precision = move.precision; copyMove->boost_atk = move.boost_atk; copyMove->boost_def = move.boost_def; + copyMove->boost_spe_atk = move.boost_spe_atk; + copyMove->boost_spe_def = move.boost_spe_def; copyMove->boost_hp = move.boost_hp; return copyMove; @@ -91,27 +93,29 @@ int execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct return MISS; } - float typeEffect; + float typeEffect = ismonster ? + getTypeEffect(getTypeFromName(move->type), getTypeFromName(player_stats->type)) : + getTypeEffect(getTypeFromName(move->type), getTypeFromName(monster_stats->type)); + if(ismonster) { player_stats->pv-=calc_damage(monster_stats, player_stats, move); - typeEffect = getTypeEffect(getTypeFromName(move->type), getTypeFromName(player_stats->type)); } else { move->pp--; monster_stats->pv-=calc_damage(player_stats, monster_stats, move); - typeEffect = getTypeEffect(getTypeFromName(move->type), getTypeFromName(monster_stats->type)); } if(typeEffect == 2) return SUPER_EFFECTIVE; if(typeEffect == 0.5) return LESS_EFFECTIVE; if(typeEffect == 0) return NOT_EFFECTIVE; } else { - if(ismonster) { + return EFFECT; + /*if(ismonster) { return self_effect(monster_stats, move); } else { move->pp--; return self_effect(player_stats, move); } - return HEAL; + return HEAL;*/ } return SUCCESS; } @@ -159,15 +163,12 @@ int is_miss(struct Move *move) { return rand_range(0, 101) > move->precision; } -int self_effect(struct Stats *stats, struct Move *move) { +void self_effect(struct Stats *stats, struct Move *move) { stats->pv += stats->max_pv * move->boost_hp/100; stats->atk *= (float)(100+move->boost_atk)/100; stats->def *= (float)(100+move->boost_def)/100; + stats->spe_atk *= (float)(100+move->boost_spe_atk)/100; + stats->spe_def *= (float)(100+move->boost_spe_def)/100; if(stats->pv > stats->max_pv) stats->pv = stats->max_pv; - - if((move->boost_hp > 0 && move->boost_atk > 0) || - (move->boost_hp > 0 && move->boost_def > 0) || - (move->boost_atk > 0 && move->boost_def > 0)) return MULTIPLE; - return move->boost_hp > 0 ? HEAL : move->boost_atk > 0 ? ATK : DEF; } \ No newline at end of file diff --git a/src/engine.c b/src/engine.c index cae64cd..a04e876 100644 --- a/src/engine.c +++ b/src/engine.c @@ -58,8 +58,8 @@ void engine_draw_map(struct Game const *game) { unsigned int tile_x = TILE_SIZE * (tile_id % tileset_size); unsigned int tile_y = TILE_SIZE * (tile_id / tileset_size); - dsubimage(x * TILE_SIZE - x_offset%TILE_SIZE, - y * TILE_SIZE - y_offset%TILE_SIZE, game->map->tileset, + dsubimage(x * TILE_SIZE - x_offset%TILE_SIZE, + y * TILE_SIZE - y_offset%TILE_SIZE, game->map->tileset, tile_x, tile_y, TILE_SIZE, TILE_SIZE, DIMAGE_NONE); } } diff --git a/src/player.c b/src/player.c index eb63095..50e20d8 100644 --- a/src/player.c +++ b/src/player.c @@ -54,7 +54,7 @@ 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(0)); + player.moves[0] = copy_move(get_move_id(1)); player.moves[1] = copy_move(get_move_id(4)); set_stats_level_from(&player.base_stats, &player.stats);