diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 15:04:26 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 15:37:48 +0100 |
commit | 1f9c71b49eeef9cd05b542515c06200b4a25f693 (patch) | |
tree | 6a29ab8af1ae447236013cbd78e5089937b72b1f /actions.c | |
parent | adceeb1192fdd1d14e0f55219bbd1bcb14eacc05 (diff) |
use a generic way to navigate through entries
entries are actually any action or subaction that can be performed.
Attack, White Magic and so on are root actions.
Fire, Ice X are subactions of Black Magic.
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'actions.c')
-rw-r--r-- | actions.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> -enum action_state_t Fattaquer(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy) +enum action_state_t Fattaquer(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) { int degats; struct character_t *target; @@ -13,6 +13,9 @@ enum action_state_t Fattaquer(SURFACES *surfaces,POSITIONS *positions, struct te int selection = 0; SDL_Event event; SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions); + + (void) data; + while(!enemy->chrs[selection].alive) selection++; update_selected_target(surfaces, positions, &enemy->chrs[selection]); @@ -150,7 +153,7 @@ enum action_state_t Fselectionnermagienoire(SURFACES *surfaces,POSITIONS *positi case SDLK_RETURN: SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats); SDL_Flip(surfaces->Pecran); - ret = Fmagieelement(surfaces,positions, ally, enemy, selection); + ret = Fmagieelement(surfaces,positions, ally, enemy, (enum element_t []) {selection}); if (ret == ACTION_PERFORMED) { continuer = 0; @@ -211,7 +214,7 @@ enum action_state_t Fselectionnermagieblanche(SURFACES *surfaces,POSITIONS *posi SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats); SDL_Flip(surfaces->Pecran); if(selection==SOIN) - ret = Fmagiesoin(surfaces,positions, ally, enemy); + ret = Fmagiesoin(surfaces,positions, ally, enemy, NULL); if (ret == ACTION_PERFORMED) { continuer = 0; @@ -273,17 +276,17 @@ enum action_state_t Fselectionnerobjet(SURFACES *surfaces,POSITIONS *positions, if(page==0) { if(selection==POTION) - ret = Fpotion(surfaces,positions, ally, enemy, selection); + ret = Fpotion(surfaces,positions, ally, enemy, (int []) {selection}); else if(selection==ETHER) - ret = Fether(surfaces,positions, ally, enemy, selection); + ret = Fether(surfaces,positions, ally, enemy, (int []) {selection}); else if(selection==POTIONPLUS) - ret = Fpotion(surfaces,positions, ally, enemy, selection); + ret = Fpotion(surfaces,positions, ally, enemy, (int []) { selection}); } else if(page==1) { if(selection==ETHERPLUS) - ret = Fether(surfaces,positions, ally, enemy, selection); + ret = Fether(surfaces,positions, ally, enemy, (int []) { selection}); } if (ret == ACTION_PERFORMED) { @@ -300,7 +303,7 @@ enum action_state_t Fselectionnerobjet(SURFACES *surfaces,POSITIONS *positions, return ret; } -enum action_state_t Fpotion(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, int type) +enum action_state_t Fpotion(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) { struct character_t *target; SDL_Event event; @@ -308,6 +311,8 @@ enum action_state_t Fpotion(SURFACES *surfaces,POSITIONS *positions, struct team int soins=0; int clan=ALLIE; + int type = *((int *)data); + if (type == POTION && ally->objects.potions <= 0) return ACTION_ERROR; else if(type == POTIONPLUS && ally->objects.potionsplus <= 0) @@ -365,7 +370,7 @@ enum action_state_t Fpotion(SURFACES *surfaces,POSITIONS *positions, struct team } } -enum action_state_t Fether(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, int type) +enum action_state_t Fether(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) { struct character_t *target; SDL_Event event; @@ -373,6 +378,8 @@ enum action_state_t Fether(SURFACES *surfaces,POSITIONS *positions, struct team_ int soins=0; int clan=ALLIE; + int type = *((int *)data); + if (type == ETHER && ally->objects.ethers <= 0) return ACTION_ERROR; else if (type == ETHERPLUS && ally->objects.ethersplus <= 0) |