mirror of https://github.com/bgiraudr/Adoranda.git
Multiple self effects are now displayed correctly
This commit is contained in:
parent
181fffcb96
commit
a77544120a
|
@ -14,3 +14,5 @@ __pycache__/
|
|||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.vscode
|
||||
.idea
|
||||
cmake-build-debug
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -19,4 +19,4 @@
|
|||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 954 B After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1000 B After Width: | Height: | Size: 2.4 KiB |
|
@ -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);
|
||||
void check_move_status(int status, struct Player *player, struct Monster *monster, struct Move *move, int is_monster);
|
|
@ -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);
|
72
src/battle.c
72
src/battle.c
|
@ -2,6 +2,8 @@
|
|||
#include <gint/keyboard.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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);
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue