summaryrefslogtreecommitdiff
path: root/magies.c
diff options
context:
space:
mode:
Diffstat (limited to 'magies.c')
-rw-r--r--magies.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/magies.c b/magies.c
index ef68677..72de556 100644
--- a/magies.c
+++ b/magies.c
@@ -5,7 +5,7 @@
#include "constantes.h"
#include "prototypes.h"
-enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[], int Vtourallie,ENNEMIS ennemis[],int Vnbennemis, int element)
+enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, int Vtourallie,ENNEMIS ennemis[],int Vnbennemis, int element)
{
enum action_state_t ret = ACTION_CANCELED;
int max;
@@ -46,7 +46,7 @@ enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSO
case SDLK_RETURN:
case SDLK_f:
continuer=0;
- max=Fcalculerdegats(persos, Vtourallie,&min,ennemis,selection,clan,TYPE_MAGIE);
+ max=Fcalculerdegats(ally, Vtourallie,&min,ennemis,selection,clan,TYPE_MAGIE);
degats=(rand()%(max-min+1))+min;
if(degats<0)
degats=0;
@@ -81,26 +81,28 @@ enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSO
}
else
{
+ struct character_t *chr = &ally->chrs[selection];
+
if(Bdegats==DEGATS)
- persos[selection].pv-=degats;
+ chr->hp-=degats;
else
- persos[selection].pv+=degats;
- if(persos[selection].pv<=0)
+ chr->hp+=degats;
+ if(chr->hp<=0)
{
- persos[selection].pv=0;
- persos[selection].etat=MORT;
+ chr->hp=0;
+ chr->alive = false;
positions->Vpositionmort.x=positions->Vpositionpersos[selection].x+surfaces->Tperso[selection]->w/2-surfaces->Pmort->w/2;
positions->Vpositionmort.y=positions->Vpositionpersos[selection].y+surfaces->Tperso[selection]->h/2-surfaces->Pmort->h/2;
SDL_BlitSurface(surfaces->Pmort,NULL,surfaces->Pecran,&positions->Vpositionmort);
}
- else if(persos[selection].pv>persos[selection].pvinitiaux)
- persos[selection].pv=persos[selection].pvinitiaux;
+ else if(chr->hp>chr->max_hp)
+ chr->hp=chr->max_hp;
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);
}
if(Bdegats==DEGATS)
- Fafficherdegats (surfaces,positions,degats,clan,selection,persos);
+ Fafficherdegats (surfaces,positions,degats,clan,selection, ally);
else
- Faffichersoins (surfaces,positions,degats,clan,selection,persos);
+ Faffichersoins (surfaces,positions,degats,clan,selection, ally);
if(clan==ENNEMI)
{
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
@@ -122,7 +124,7 @@ enum action_state_t Fmagieelement (SURFACES *surfaces,POSITIONS *positions,PERSO
return ret;
}
-enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAGES persos[], int Vtourallie,ENNEMIS ennemis[],int Vnbennemis)
+enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions, struct team_t *ally, int Vtourallie,ENNEMIS ennemis[],int Vnbennemis)
{
enum action_state_t ret = ACTION_CANCELED;
unsigned int continuer=1;
@@ -135,9 +137,9 @@ enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAG
int selection=0;
int Bdegats=SOINS;
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadreactions,surfaces->Pecran,&positions->Vpositioncadreactions);
- while(persos[selection].etat==MORT)
+ while(!ally->chrs[selection].alive)
selection++;
- Fchangercurseurpersos (surfaces,positions,selection,persos);
+ Fchangercurseurpersos (surfaces,positions,selection);
while(continuer)
{
SDL_WaitEvent(&event);
@@ -161,7 +163,7 @@ enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAG
SELECTION_CIBLE()
case SDLK_RETURN:
case SDLK_f:
- max=Fcalculersoins(persos, Vtourallie,&min,ennemis,selection);
+ max=Fcalculersoins(ally, Vtourallie,&min,ennemis,selection);
soins=(rand()%(max-min+1))+min;
if(soins<0)
soins=0;
@@ -186,25 +188,25 @@ enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAG
else
{
if(Bdegats==DEGATS)
- persos[selection].pv-=soins;
+ ally->chrs[selection].hp-=soins;
else
- persos[selection].pv+=soins;
- if(persos[selection].pv<=0)
+ ally->chrs[selection].hp+=soins;
+ if(ally->chrs[selection].hp<=0)
{
- persos[selection].pv=0;
- persos[selection].etat=MORT;
+ ally->chrs[selection].hp=0;
+ ally->chrs[selection].alive = false;
positions->Vpositionmort.x=positions->Vpositionpersos[selection].x+surfaces->Tperso[selection]->w/2-surfaces->Pmort->w/2;
positions->Vpositionmort.y=positions->Vpositionpersos[selection].y+surfaces->Tperso[selection]->h/2-surfaces->Pmort->h/2;
SDL_BlitSurface(surfaces->Pmort,NULL,surfaces->Pecran,&positions->Vpositionmort);
}
- else if(persos[selection].pv>persos[selection].pvinitiaux)
- persos[selection].pv=persos[selection].pvinitiaux;
+ else if(ally->chrs[selection].hp>ally->chrs[selection].max_hp)
+ ally->chrs[selection].hp=ally->chrs[selection].max_hp;
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncurseurallies,surfaces->Pecran,&positions->Vpositioncurseurallies);
}
if(Bdegats==DEGATS)
- Fafficherdegats (surfaces,positions,soins,clan,selection,persos);
+ Fafficherdegats (surfaces,positions,soins,clan,selection, ally);
else
- Faffichersoins (surfaces,positions,soins,clan,selection,persos);
+ Faffichersoins (surfaces,positions,soins,clan,selection, ally);
if(clan==ENNEMI)
{
SDL_BlitSurface (surfaces->Pfondjeu,&positions->Vpositioncadrecible,surfaces->Pecran,&positions->Vpositioncadrecible);
@@ -226,7 +228,7 @@ enum action_state_t Fmagiesoin(SURFACES *surfaces,POSITIONS *positions,PERSONNAG
return ret;
}
-int Fcalculersoins(PERSONNAGES persos[], int Vtourallie,int *min,ENNEMIS ennemis[],int selection)
+int Fcalculersoins(struct team_t *ally, int Vtourallie,int *min,ENNEMIS ennemis[],int selection)
{
unsigned int soins;
int max;
@@ -236,7 +238,7 @@ int Fcalculersoins(PERSONNAGES persos[], int Vtourallie,int *min,ENNEMIS ennemis
(void) ennemis;
(void) selection;
- soins=persos[Vtourallie].magie*20;
+ soins=ally->chrs[Vtourallie].magic*20;
taux=soins/4;
max=soins+taux;
*min=soins-taux;