diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 16:08:51 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 16:08:51 +0100 |
commit | 6d8f84b21c4423afa52a3d3c4ff88110dbe1d1be (patch) | |
tree | d0785e845175a9d60b50950971a2ef15f9e40f1e | |
parent | 491851043156d5fc74a388b3cb5b7b95322b8e3e (diff) |
add callback functions associated to a leaf action
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r-- | actions.c | 73 |
1 files changed, 73 insertions, 0 deletions
@@ -5,6 +5,79 @@ #include <stdio.h> #include <stdlib.h> +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; |