summaryrefslogtreecommitdiff
path: root/magies.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-08 06:02:31 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-08 06:02:31 +0100
commit9a98118c3d9a062b33134e8354620be43ecf3786 (patch)
treeee04aa9b65a401a720e387439b8180578ee8cbfe /magies.c
parentc1e13470835e18ac0077bf77ce8f77db07144bcf (diff)
improve code and fix numerous bugs
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'magies.c')
-rw-r--r--magies.c101
1 files changed, 39 insertions, 62 deletions
diff --git a/magies.c b/magies.c
index 13c98eb..3740c84 100644
--- a/magies.c
+++ b/magies.c
@@ -8,20 +8,17 @@
enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, enum element_t element)
{
struct character_t *target;
- enum action_state_t ret = ACTION_CANCELED;
- unsigned int continuer = 1;
int degats;
int selection = 0;
- int delay=1;
int clan=ENNEMI;
SDL_Event event;
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions);
while (!enemy->chrs[selection].alive)
selection++;
- Fchangercurseurennemis (surfaces,positions, &enemy->chrs[selection]);
- while (continuer)
- {
- SDL_Flip (surfaces->Pecran);
+ update_selected_target(surfaces,positions, &enemy->chrs[selection]);
+ SDL_Flip(surfaces->Pecran);
+
+ for (;;) {
SDL_WaitEvent (&event);
switch (event.type)
{
@@ -30,21 +27,12 @@ enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions, stru
{
case SDLK_ESCAPE:
case SDLK_a:
- continuer = 0;
- if(clan==ENNEMI)
- {
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);
- }
- else
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);
- SDL_Flip (surfaces->Pecran);
- break;
+ update_selected_target(surfaces, positions, NULL);
+ SDL_Flip(surfaces->Pecran);
+ return ACTION_CANCELED;
SELECTION_CIBLE()
case SDLK_RETURN:
case SDLK_f:
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
-
if (clan == ENNEMI) {
target = &enemy->chrs[selection];
} else {
@@ -53,43 +41,40 @@ enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions, stru
degats = compute_damages(&ally->chrs[ally->chr_cur], target, DAMAGES_MAGICAL, element);
+ update_selected_target(surfaces, positions, NULL);
damage_target_hp(surfaces, positions, target, degats);
SDL_Flip(surfaces->Pecran);
- ret = ACTION_PERFORMED;
- continuer=0;
- break;
+ SDL_Delay(1000);
+
+ SDL_BlitSurface(surfaces->Pfondjeu, &positions->Vpositiondegats, surfaces->Pecran, &positions->Vpositiondegats);
+
+ SDL_Flip(surfaces->Pecran);
+
+ return ACTION_PERFORMED;
default:
break;
}
break;
}
}
- if (delay)
- SDL_Delay(1000);
- SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats);
- SDL_Flip(surfaces->Pecran);
-
- return ret;
}
enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy)
{
struct character_t *target;
- enum action_state_t ret = ACTION_CANCELED;
- unsigned int continuer=1;
SDL_Event event;
int soins;
int clan=ALLIE;
- int delay=1;
int selection=0;
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions);
while(!ally->chrs[selection].alive)
selection++;
- Fchangercurseurpersos (surfaces,positions,selection);
- while(continuer)
- {
+ update_selected_target(surfaces,positions, &ally->chrs[selection]);
+ SDL_Flip(surfaces->Pecran);
+
+ for (;;) {
SDL_WaitEvent(&event);
switch(event.type)
{
@@ -98,47 +83,39 @@ enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions, struct t
{
case SDLK_ESCAPE:
case SDLK_a:
- continuer = 0;
- if(clan==ENNEMI)
- {
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurennemis,surfaces->Pecran,&positions->Vpositioncurseurennemis);
- }
- else
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);
- SDL_Flip (surfaces->Pecran);
- break;
+ update_selected_target(surfaces, positions, NULL);
+ SDL_Flip (surfaces->Pecran);
+ return ACTION_CANCELED;
SELECTION_CIBLE()
case SDLK_RETURN:
case SDLK_f:
- SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
+ if (clan == ENNEMI) {
+ target = &enemy->chrs[selection];
+ } else {
+ target = &ally->chrs[selection];
+ }
- if (clan == ENNEMI) {
- target = &enemy->chrs[selection];
- } else {
- target = &ally->chrs[selection];
- }
+ soins = compute_cure(&ally->chrs[ally->chr_cur], target);
- soins = compute_cure(&ally->chrs[ally->chr_cur], target);
+ update_selected_target(surfaces, positions, NULL);
- cure_target_hp(surfaces, positions, target, soins);
+ cure_target_hp(surfaces, positions, target, soins);
+ SDL_Flip(surfaces->Pecran);
+
+ SDL_Delay(1000);
+
+ SDL_BlitSurface(surfaces->Pfondjeu, &positions->Vpositiondegats, surfaces->Pecran, &positions->Vpositiondegats);
- SDL_Flip (surfaces->Pecran);
- ret = ACTION_PERFORMED;
- continuer=0;
- break;
+ SDL_Flip (surfaces->Pecran);
+
+ return ACTION_PERFORMED;
default:
- break;
+ break;
}
break;
}
}
- if (delay)
- SDL_Delay(1000);
- SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats);
- SDL_Flip(surfaces->Pecran);
- return ret;
}
int compute_cure(const struct character_t *src, const struct character_t *dest)