diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 16:53:35 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-08 16:53:35 +0100 |
commit | e8b35eae36f56492069d8f242c078ec5275d1a0b (patch) | |
tree | be50721ca7d46454d4be5ab311fdbee52578417a /magies.c | |
parent | 6d8f84b21c4423afa52a3d3c4ff88110dbe1d1be (diff) |
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 <duskcoder@gmail.com>
Diffstat (limited to 'magies.c')
-rw-r--r-- | magies.c | 139 |
1 files changed, 0 insertions, 139 deletions
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 <stdlib.h> -#include <stdio.h> -#include <SDL/SDL.h> -#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; -} |