diff options
Diffstat (limited to 'magies.c')
-rw-r--r-- | magies.c | 101 |
1 files changed, 39 insertions, 62 deletions
@@ -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) |