summaryrefslogtreecommitdiff
path: root/jouer.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-08 02:39:16 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-08 02:44:56 +0100
commitc68227406beb7bc74a4179fb1b1b70bbeb6ad4a2 (patch)
treeb390ed5f463c28e7d80f5b446eddac6a6eeaf6e9 /jouer.c
parent6d8a9ac6c08e414e8ebb57a6a2ef9b4779d599a7 (diff)
use the new enemy team instead of the old array of ENEMIES
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'jouer.c')
-rw-r--r--jouer.c92
1 files changed, 9 insertions, 83 deletions
diff --git a/jouer.c b/jouer.c
index 4f66ee3..4514524 100644
--- a/jouer.c
+++ b/jouer.c
@@ -19,28 +19,6 @@ static inline void unhighlight_prev_character(struct team_t *team)
chr->surf = chr->def_surf;
}
-static void generate_enemy_types(struct team_t *ally_team, ENNEMIS ennemis[], int Vnbennemis)
-{
- int avg = 0;
-
- for (int i = 0; i < ally_team->chr_cnt; i++) {
- avg += ally_team->chrs[i].ally.nv;
- }
-
- avg /= ally_team->chr_cnt;
-
- if (avg < 5)
- {
- /* easy */
- for (int i=0; i <= Vnbennemis; i++) {
- ennemis[i].classe=GUERRIER_GOBELIN;
- }
- } else {
- /* XXX should not happen for now since we do not change the levels */
- abort();
- }
-}
-
static int find_next_ally(const struct team_t *ally)
{
for (int i = ally->chr_cur + 1; i < ally->chr_cnt; ++i) {
@@ -83,7 +61,7 @@ static void update_current_character(struct team_t *ally, bool *ally_turn)
}
}
-int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMIS ennemis[])
+int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally, struct team_t *enemy)
{
unsigned int continuer=1;
int selection=0;
@@ -103,9 +81,6 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
}
Fblitterfond(surfaces); // on blit le fond du jeu
Fremplirobjets(&ally->objects); // on monte les variables potions ether, etc
- Vnbennemis=Fcalculernbennemis(); // on tire aléatoirement le nombre d'ennemis présents dans le combat
- generate_enemy_types(ally, ennemis,Vnbennemis); // on choisit la classe des ennemis comme guerrier gobelin etc
- Fremplirennemis(surfaces,Vnbennemis,ennemis);
/* compute whether the allies or the enemies should begin */
Vtour = rand() % 2;
@@ -116,9 +91,8 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
highlight_current_character(ally);
}
-
- Fblitterennemis(surfaces,positions,ennemis,Vnbennemis); // idem pour les ennemis
blit_team(surfaces, ally);
+ blit_team(surfaces, enemy);
while (continuer)
{
@@ -166,7 +140,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
case SDLK_RETURN:
case SDLK_f:
{
- enum action_state_t (*actionp)(SURFACES *, POSITIONS *, struct team_t *ally, ENNEMIS[], int) = NULL;
+ enum action_state_t (*actionp)(SURFACES *, POSITIONS *, struct team_t *ally, struct team_t *enemy) = NULL;
switch (selection) {
case ATTAQUE: actionp = Fattaquer; break;
@@ -177,7 +151,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
default: abort(); break;
}
- if (actionp && (*actionp)(surfaces,positions, ally, ennemis,Vnbennemis) == ACTION_PERFORMED) {
+ if (actionp && (*actionp)(surfaces,positions, ally, enemy) == ACTION_PERFORMED) {
update_current_character(ally, (bool *)&Vtour);
blit_team(surfaces, ally);
}
@@ -191,7 +165,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
}
else if(Vtour==ENNEMI) // sinon si c'est le cpu qui joue
{
- while (ennemis[Vtourennemi].etat == MORT) {
+ while (!enemy->chrs[Vtourennemi].alive) {
if (Vtourennemi < Vnbennemis) {
Vtourennemi++;
} else if (Vtourennemi == Vnbennemis) {
@@ -201,6 +175,8 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
/* TODO reactivate */
#if 0
Factionennemi(&Vtourennemi,surfaces,positions,ennemis,persos,Vnbennemis,&Vtour,Vtourallie);
+#else
+ Vtour = ALLIE;
#endif
} // les actions sont faites
@@ -208,9 +184,8 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
// on vérifie à présent si on a gagné ou si on a perdu !
gagne=1;
perdu=1;
- for(i=0;i<=Vnbennemis;i++)
- {
- if(ennemis[i].etat==VIE)
+ for(i = 0; i <= enemy->chr_cnt; i++) {
+ if (enemy->chrs[i].alive)
gagne=0;
}
for (i = 0; i < ally->chr_cnt; i++) {
@@ -233,55 +208,6 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI
return 0;
}
-void Finitialiserpositionsennemis(SURFACES *surfaces,POSITIONS *positions,int Vnbennemis)
-{
- if (Vnbennemis==0)
- {
- positions->Vpositionennemis[0].x=XWIN-20-surfaces->Tennemi[0]->w;
- positions->Vpositionennemis[0].y=YWIN/2-surfaces->Tennemi[0]->h/2;
- }
- if (Vnbennemis==1)
- {
- positions->Vpositionennemis[0].x = XWIN - 20 - surfaces->Tennemi[0]->w;
- positions->Vpositionennemis[0].y = YWIN/3 - surfaces->Tennemi[0]->h/2;
- positions->Vpositionennemis[1].x = XWIN - 20 - surfaces->Tennemi[2]->w;
- positions->Vpositionennemis[1].y = YWIN/3*2 - surfaces->Tennemi[1]->h/2;
- }
- else if (Vnbennemis==2)
- {
- positions->Vpositionennemis[1].x = XWIN - 20 - surfaces->Tennemi[1]->w;
- positions->Vpositionennemis[1].y = YWIN/2 - surfaces->Tennemi[1]->h/2;
- positions->Vpositionennemis[0].x = XWIN - 20 - surfaces->Tennemi[0]->w;
- positions->Vpositionennemis[0].y = YWIN/4 - surfaces->Tennemi[1]->h/2;
- positions->Vpositionennemis[2].x = XWIN - 20 - surfaces->Tennemi[2]->w;
- positions->Vpositionennemis[2].y = YWIN/4*3 - surfaces->Tennemi[2]->h/2;
- }
- else if (Vnbennemis==3)
- {
- positions->Vpositionennemis[1].x = XWIN - 20 - surfaces->Tennemi[1]->w;
- positions->Vpositionennemis[1].y = YWIN/5*2 - surfaces->Tennemi[1]->h/2;
- positions->Vpositionennemis[2].x = XWIN - 20 - surfaces->Tennemi[2]->w;
- positions->Vpositionennemis[2].y = YWIN/5*3 - surfaces->Tennemi[2]->h/2;
- positions->Vpositionennemis[0].x = XWIN - surfaces->Tennemi[1]->w - surfaces->Tennemi[0]->w/2;
- positions->Vpositionennemis[0].y = YWIN/5 -surfaces->Tennemi[0]->h/2;
- positions->Vpositionennemis[3].x = XWIN - surfaces->Tennemi[2]->w - surfaces->Tennemi[3]->w/2;
- positions->Vpositionennemis[3].y = YWIN/5*4 - surfaces->Tennemi[3]->h/2;
- }
- else if (Vnbennemis==4)
- {
- positions->Vpositionennemis[2].x = XWIN - 20 - surfaces->Tennemi[2]->w;
- positions->Vpositionennemis[2].y = YWIN/2 - surfaces->Tennemi[2]->h/2;
- positions->Vpositionennemis[1].x = XWIN - surfaces->Tennemi[2]->w - surfaces->Tennemi[1]->w/2;
- positions->Vpositionennemis[1].y = YWIN/6*2 - surfaces->Tennemi[1]->h/2;
- positions->Vpositionennemis[3].x = XWIN - surfaces->Tennemi[2]->w - surfaces->Tennemi[3]->w/2;
- positions->Vpositionennemis[3].y = YWIN/6*4 - surfaces->Tennemi[3]->h/2;
- positions->Vpositionennemis[0].x = XWIN - surfaces->Tennemi[2]->w - surfaces->Tennemi[1]->w - surfaces->Tennemi[0]->w/2;
- positions->Vpositionennemis[0].y = YWIN/6 - surfaces->Tennemi[0]->h/2;
- positions->Vpositionennemis[4].x = XWIN - surfaces->Tennemi[2]->w - surfaces->Tennemi[3]->w - surfaces->Tennemi[4]->w/2;
- positions->Vpositionennemis[4].y = YWIN/6*5 - surfaces->Tennemi[4]->h/2;
- }
-}
-
void Fremplirobjets(OBJET *objets)
{
objets->potions=10;