diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 18:31:29 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 18:39:01 +0100 |
commit | 2a76d0662f9494f8469283a7b0fc72c17f40ecf6 (patch) | |
tree | 8420a57e6029a5d62a31343a13b51acbeb3e7d60 | |
parent | dfe9604dc9e4292c9f0e420d3a926e8268178308 (diff) |
implement a way to define who is targetable by an action
we can specify who are the targets of an action by setting the field
entry->action.target
it can be a combination of one or more specifiers, such as:
one team
an eneny
self
everyone
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r-- | constantes.h | 15 | ||||
-rw-r--r-- | entry.h | 4 | ||||
-rw-r--r-- | jouer.c | 2 | ||||
-rw-r--r-- | priv_entries.h | 140 |
4 files changed, 119 insertions, 42 deletions
diff --git a/constantes.h b/constantes.h index 36fdf6d..e68946b 100644 --- a/constantes.h +++ b/constantes.h @@ -73,6 +73,21 @@ enum action_state_t { ACTION_COUNT, }; +enum target_t { + TARGET_SINGLE_ALLY = 0x1, + TARGET_SINGLE_ENEMY = TARGET_SINGLE_ALLY << 0x1, + + TARGET_TEAM_ALLY = TARGET_SINGLE_ENEMY << 0x1, + TARGET_TEAM_ENEMY = TARGET_TEAM_ALLY << 0x1, + + TARGET_SELF = TARGET_TEAM_ENEMY << 0x1, + + TARGET_ALL = TARGET_SELF << 0x1, + + TARGET_SINGLE = TARGET_SINGLE_ALLY | TARGET_SINGLE_ENEMY, + TARGET_TEAM = TARGET_TEAM_ALLY | TARGET_TEAM_ENEMY, +}; + //map #define SOL 0 #define MUR 1 @@ -15,7 +15,9 @@ struct entry_t { struct { void *data; void (*f)(SURFACES *, POSITIONS *, struct character_t *, struct character_t *, void *data); - }; + + enum target_t target; + } action; }; }; @@ -216,7 +216,7 @@ enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, st case SDLK_RETURN: target = &entries[selection]; if (!target->children_cnt) { - enum action_state_t state = select_target(params, target->data, target->f); + enum action_state_t state = select_target(params, target->action.data, target->action.f); if (state == ACTION_PERFORMED) return ACTION_PERFORMED; diff --git a/priv_entries.h b/priv_entries.h index 62fe5f2..dd6ff69 100644 --- a/priv_entries.h +++ b/priv_entries.h @@ -10,13 +10,19 @@ struct entry_t white_magic_entries[] = { { .name = "Cure", .children_cnt = 0, - .f = cast_cure, - .data = NULL, + .action = { + .f = cast_cure, + .data = NULL, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Cure +", .children_cnt = 0, - .f = cast_cure, - .data = NULL, + .action = { + .f = cast_cure, + .data = NULL, + .target = TARGET_SINGLE | TARGET_TEAM, + } }, }; @@ -24,68 +30,107 @@ struct entry_t black_magic_entries[] = { { .name = "Fire", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_FIRE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_FIRE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Fire +", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_FIRE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_FIRE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Fire x", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_FIRE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_FIRE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Ice -", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_ICE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_ICE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Ice +", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_ICE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_ICE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Ice x", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_ICE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_ICE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Thunder", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_THUNDER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_THUNDER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Thunder +", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_THUNDER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_THUNDER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Thunder x", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_THUNDER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_THUNDER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Water", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_WATER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_WATER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Water + ", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_WATER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_WATER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Water x", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_WATER }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_WATER }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, { .name = "Choc", .children_cnt = 0, - .f = cast_element, - .data = (enum element_t []) { ELEMENT_NONE }, + .action = { + .f = cast_element, + .data = (enum element_t []) { ELEMENT_NONE }, + .target = TARGET_SINGLE | TARGET_TEAM, + }, }, }; @@ -93,23 +138,35 @@ struct entry_t object_entries[] = { { .name = "Potion", .children_cnt = 0, - .f = use_potion, - .data = (int []) { POTION }, + .action = { + .f = use_potion, + .data = (int []) { POTION }, + .target = TARGET_SINGLE, + }, }, { .name = "Potion +", .children_cnt = 0, - .f = use_potion, - .data = (int []) { POTIONPLUS }, + .action = { + .f = use_potion, + .data = (int []) { POTIONPLUS }, + .target = TARGET_SINGLE, + }, }, { .name = "Ether", .children_cnt = 0, - .f = use_ether, - .data = (int []) { ETHER }, + .action = { + .f = use_ether, + .data = (int []) { ETHER }, + .target = TARGET_SINGLE, + }, }, { .name = "Ether + ", .children_cnt = 0, - .f = use_ether, - .data = (int []) { ETHERPLUS }, + .action = { + .f = use_ether, + .data = (int []) { ETHERPLUS }, + .target = TARGET_SINGLE, + }, }, }; @@ -117,8 +174,11 @@ struct entry_t action_entries_g[] = { { .name = "Attack", .children_cnt = 0, - .f = attack, - .data = NULL, + .action = { + .f = attack, + .data = NULL, + .target = TARGET_SINGLE, + }, }, { .name = "White Magic", .children = white_magic_entries, |