From 6d8f84b21c4423afa52a3d3c4ff88110dbe1d1be Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 8 Jan 2015 16:08:51 +0100 Subject: add callback functions associated to a leaf action Signed-off-by: Olivier Gayot --- actions.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/actions.c b/actions.c index 1005ab7..dcbfc10 100644 --- a/actions.c +++ b/actions.c @@ -5,6 +5,79 @@ #include #include +void attack(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct character_t *dest, void *data) +{ + int damages; + + (void) data; + + damages = compute_damages(src, dest, DAMAGES_PHYSICAL, ELEMENT_NONE); + damage_target_hp(surfaces, positions, dest, damages); +} + +void cast_element(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct character_t *dest, void *data) +{ + int damages; + enum element_t elem = *((enum element_t *)data); + + /* TODO remove the MP */ + + damages = compute_damages(src, dest, DAMAGES_MAGICAL, elem); + damage_target_hp(surfaces, positions, dest, damages); +} + +void cast_cure(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct character_t *dest, void *data) +{ + int cure; + + (void) data; + + cure = compute_cure(src, dest); + cure_target_hp(surfaces, positions, dest, cure); +} + +void use_potion(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct character_t *dest, void *data) +{ + int type = *((int *)data); + int cure; + + switch (type) { + case POTION: + cure = 1000; + src->team->objects.potions--; + break; + case POTIONPLUS: + cure = 4000; + src->team->objects.potionsplus--; + break; + default: + abort(); + } + + cure_target_hp(surfaces, positions, dest, cure); +} + +void use_ether(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct character_t *dest, void *data) +{ + int type = *((int *)data); + int cure; + + switch (type) { + case ETHER: + cure = 10; + src->team->objects.ethers--; + break; + case ETHERPLUS: + cure = 40; + src->team->objects.ethersplus--; + break; + default: + abort(); + } + + cure_target_mp(surfaces, positions, dest, cure); +} + enum action_state_t Fattaquer(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) { int degats; -- cgit v1.2.3