summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--constantes.h15
-rw-r--r--entry.h4
-rw-r--r--jouer.c2
-rw-r--r--priv_entries.h140
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
diff --git a/entry.h b/entry.h
index 9ba9677..7258569 100644
--- a/entry.h
+++ b/entry.h
@@ -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;
};
};
diff --git a/jouer.c b/jouer.c
index 5050a29..95ee0f4 100644
--- a/jouer.c
+++ b/jouer.c
@@ -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,