Adoranda/src/capacite.c

42 lines
1.2 KiB
C
Raw Normal View History

2022-01-24 15:15:12 +01:00
#include <gint/display.h>
#include <gint/keyboard.h>
2022-01-24 21:27:51 +01:00
#include <string.h>
2022-02-13 21:46:52 +01:00
#include <math.h>
2022-01-24 15:15:12 +01:00
#include "capacite.h"
2022-01-24 21:27:51 +01:00
extern struct Capacities capacities;
2022-01-24 15:15:12 +01:00
struct Move default_move() {
2022-01-24 21:27:51 +01:00
return *capacities.moves[0];
2022-01-24 15:15:12 +01:00
}
struct Move get_move_id(int id) {
2022-01-24 21:27:51 +01:00
return *capacities.moves[id];
}
void draw_move(int x, int y, int x2, int y2, struct Move move) {
const int font_size = 8;
drect(x, y, x2, y2, C_WHITE);
dprint(x+5, y+5, C_BLACK, "PP : %d", move.pp);
dprint(x+5, y2-15, C_BLACK, "ATK : %d", move.atk);
dprint((int)((x+x2)/2)-(int)(strlen(move.name)/2*font_size),
(int)((y+y2)/2)-font_size/2,
C_BLACK, "%s", move.name);
}
void draw_classic_move(int x, int y, struct Move move) {
draw_move(x, y, x+125, y+60, move);
2022-01-25 22:20:10 +01:00
}
2022-02-11 19:00:44 +01:00
void execute_move(struct Stats *player_stats, struct Stats *monster_stats, struct Move move, int ismonster) {
if(ismonster) {
2022-02-13 21:46:52 +01:00
player_stats->pv-=calc_damage(monster_stats, player_stats, move);
2022-02-11 19:00:44 +01:00
} else {
2022-02-13 21:46:52 +01:00
monster_stats->pv-=calc_damage(player_stats, monster_stats, move);
2022-02-11 19:00:44 +01:00
}
2022-02-13 21:46:52 +01:00
}
int calc_damage(struct Stats *attacker, struct Stats *target, struct Move move) {
return(floor(((2*attacker->level / 5 + 2) * attacker->atk * move.atk / target->def) / 50) + 2);
2022-01-24 15:15:12 +01:00
}