From e8b35eae36f56492069d8f242c078ec5275d1a0b Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 8 Jan 2015 16:53:35 +0100 Subject: handle the selection of a target in a generic way. we do not split the code of the selection of a target anymore. Each action now does a very simple thing and as much efficiently as possible. every old function that are not used anymore have been removed. Signed-off-by: Olivier Gayot --- magies.c | 139 --------------------------------------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 magies.c (limited to 'magies.c') diff --git a/magies.c b/magies.c deleted file mode 100644 index 94183e7..0000000 --- a/magies.c +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include -#include -#include "structures.h" -#include "constantes.h" -#include "prototypes.h" - -enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) -{ - struct character_t *target; - int degats; - int selection = 0; - int clan=ENNEMI; - SDL_Event event; - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions); - - enum element_t element = *((enum element_t *)data); - - while (!enemy->chrs[selection].alive) - selection++; - update_selected_target(surfaces,positions, &enemy->chrs[selection]); - SDL_Flip(surfaces->Pecran); - - for (;;) { - SDL_WaitEvent (&event); - switch (event.type) - { - case SDL_KEYDOWN: - switch (event.key.keysym.sym) - { - case SDLK_ESCAPE: - case SDLK_a: - update_selected_target(surfaces, positions, NULL); - SDL_Flip(surfaces->Pecran); - return ACTION_CANCELED; - SELECTION_CIBLE() - case SDLK_RETURN: - case SDLK_f: - if (clan == ENNEMI) { - target = &enemy->chrs[selection]; - } else { - target = &ally->chrs[selection]; - } - - 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); - - SDL_Delay(1000); - - SDL_BlitSurface(surfaces->Pfondjeu, &positions->Vpositiondegats, surfaces->Pecran, &positions->Vpositiondegats); - - SDL_Flip(surfaces->Pecran); - - return ACTION_PERFORMED; - default: - break; - } - break; - } - } -} - -enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, struct team_t *enemy, void *data) -{ - struct character_t *target; - SDL_Event event; - int soins; - int clan=ALLIE; - int selection=0; - - (void) data; - - SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions); - while(!ally->chrs[selection].alive) - selection++; - update_selected_target(surfaces,positions, &ally->chrs[selection]); - SDL_Flip(surfaces->Pecran); - - for (;;) { - SDL_WaitEvent(&event); - switch(event.type) - { - case SDL_KEYDOWN: - switch(event.key.keysym.sym) - { - case SDLK_ESCAPE: - case SDLK_a: - update_selected_target(surfaces, positions, NULL); - SDL_Flip (surfaces->Pecran); - return ACTION_CANCELED; - SELECTION_CIBLE() - case SDLK_RETURN: - case SDLK_f: - if (clan == ENNEMI) { - target = &enemy->chrs[selection]; - } else { - target = &ally->chrs[selection]; - } - - soins = compute_cure(&ally->chrs[ally->chr_cur], target); - - update_selected_target(surfaces, positions, NULL); - - 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); - - return ACTION_PERFORMED; - default: - break; - } - break; - } - } -} - -int compute_cure(const struct character_t *src, const struct character_t *dest) -{ - int avg, max, min; - - /* TODO maybe we should use the dest to compute the cure ? */ - (void) dest; - - avg = src->magic * 20; - min = avg - avg / 4; - max = avg + avg / 4; - - return rand() % (max - min + 1) + min; -} -- cgit v1.2.3