summaryrefslogtreecommitdiff
path: root/magies.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-07 16:56:21 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-07 16:56:21 +0100
commitb3295086c84b09353d5e89c6f7c743167b486a49 (patch)
treefc9dcc035c486d028bf4460c1b2d9e988efed9d4 /magies.c
parent461a28bb608e117267431eac78b08d3d8a089c0c (diff)
clean the code and fix bugs
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'magies.c')
-rw-r--r--magies.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/magies.c b/magies.c
index a52e8b4..ef68677 100644
--- a/magies.c
+++ b/magies.c
@@ -5,8 +5,9 @@
#include "constantes.h"
#include "prototypes.h"
-int Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int *Vtourallie,ENNEMIS ennemis[],int Vnbennemis, int element,int *Vtour)
+enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[], int Vtourallie,ENNEMIS ennemis[],int Vnbennemis, int element)
{
+ enum action_state_t ret = ACTION_CANCELED;
int max;
int min;
unsigned int continuer = 1;
@@ -45,7 +46,7 @@ int Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],
case SDLK_RETURN:
case SDLK_f:
continuer=0;
- max=Fcalculerdegats(persos, *Vtourallie,&min,ennemis,selection,clan,TYPE_MAGIE);
+ max=Fcalculerdegats(persos, Vtourallie,&min,ennemis,selection,clan,TYPE_MAGIE);
degats=(rand()%(max-min+1))+min;
if(degats<0)
degats=0;
@@ -105,17 +106,7 @@ int Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
SDL_Flip (surfaces->Pecran);
}
- if (*Vtourallie==2)
- {
- inverse_boolean(*Vtour);
- *Vtourallie=0;
- }
- else
- {
- (*Vtourallie)++;
- Fblitterpersos(surfaces,positions,persos);
- Fblitcoloredselection(surfaces,positions,*Vtourallie,persos);
- }
+ ret = ACTION_PERFORMED;
break;
default:
break;
@@ -127,12 +118,13 @@ int Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],
SDL_Delay(1000);
SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats);
SDL_Flip(surfaces->Pecran);
- return continuer;
- return 0;
+
+ return ret;
}
-int Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int *Vtourallie,ENNEMIS ennemis[],int Vnbennemis,int *Vtour)
+enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[], int Vtourallie,ENNEMIS ennemis[],int Vnbennemis)
{
+ enum action_state_t ret = ACTION_CANCELED;
unsigned int continuer=1;
SDL_Event event;
int max;
@@ -169,7 +161,7 @@ int Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int
SELECTION_CIBLE()
case SDLK_RETURN:
case SDLK_f:
- max=Fcalculersoins(persos,Vtourallie,&min,ennemis,selection);
+ max=Fcalculersoins(persos, Vtourallie,&min,ennemis,selection);
soins=(rand()%(max-min+1))+min;
if(soins<0)
soins=0;
@@ -218,17 +210,7 @@ int Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
SDL_Flip (surfaces->Pecran);
}
- if (*Vtourallie==2)
- {
- *Vtourallie=0;
- inverse_boolean(*Vtour);
- }
- else
- {
- (*Vtourallie)++;
- Fblitterpersos(surfaces,positions,persos);
- Fblitcoloredselection(surfaces,positions,*Vtourallie,persos);
- }
+ ret = ACTION_PERFORMED;
continuer=0;
break;
default:
@@ -241,10 +223,10 @@ int Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[],int
SDL_Delay(1000);
SDL_BlitSurface(surfaces->Pfondjeu,&positions->Vpositiondegats,surfaces->Pecran,&positions->Vpositiondegats);
SDL_Flip(surfaces->Pecran);
- return continuer;
+ return ret;
}
-int Fcalculersoins(PERSONNAGES persos[],int *Vtourallie,int *min,ENNEMIS ennemis[],int selection)
+int Fcalculersoins(PERSONNAGES persos[], int Vtourallie,int *min,ENNEMIS ennemis[],int selection)
{
unsigned int soins;
int max;
@@ -254,14 +236,10 @@ int Fcalculersoins(PERSONNAGES persos[],int *Vtourallie,int *min,ENNEMIS ennemis
(void) ennemis;
(void) selection;
- soins=persos[*Vtourallie].magie*20;
+ soins=persos[Vtourallie].magie*20;
taux=soins/4;
max=soins+taux;
*min=soins-taux;
return max;
}
-
-
-
-