From 92dc9315b9bb8576373b1f2325a049dd5490a9f6 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 7 Jan 2015 23:06:43 +0100 Subject: generate the affinities during the creation of the characters do not differenciate between the players and the enemies as well Signed-off-by: Olivier Gayot --- competences.c | 68 ------------------------------------------------------- constantes.h | 11 +++++++++ jouer.c | 1 - menuchoixpersos.c | 4 ++++ players.h | 3 +++ prototypes.h | 1 - 6 files changed, 18 insertions(+), 70 deletions(-) delete mode 100644 competences.c diff --git a/competences.c b/competences.c deleted file mode 100644 index 7acd8b9..0000000 --- a/competences.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include "structures.h" -#include "constantes.h" -#include "prototypes.h" - -void Fremplircompetencesennemis (ENNEMIS ennemis[],int Vnbennemis) -{ - int i, y; - unsigned int sensibilite; - unsigned int max = 8, min = 0; - - for (i=0;i<=Vnbennemis;i++) - { - if(ennemis[i].classe==GUERRIER_GOBELIN) - { - ennemis[i].force = 15; - ennemis[i].magie = 0; - ennemis[i].defense = 10; - ennemis[i].defensemagique = 5; - ennemis[i].pv = 1000; - ennemis[i].pm = 0; - ennemis[i].pminitiaux = 0; - ennemis[i].pvinitiaux = 1000; - ennemis[i].etat = VIE; - for (y=0;y<4;y++) - { - sensibilite = (rand() % (max - min + 1)) + min; - if (sensibilite == SENSIBILITE) - { - ennemis[i].sensibilite[y] = ACTIVE; - ennemis[i].resistance[y] = DESACTIVE; - ennemis[i].invulnerabilite[y] = DESACTIVE; - ennemis[i].absorbtion[y] = DESACTIVE; - } - else if (sensibilite == RESISTANCE) - { - ennemis[i].resistance[y] = ACTIVE; - ennemis[i].sensibilite[y] = DESACTIVE; - ennemis[i].invulnerabilite[y] = DESACTIVE; - ennemis[i].absorbtion[y] = DESACTIVE; - } - else if (sensibilite == INVULNERABILITE) - { - ennemis[i].resistance[y] = DESACTIVE; - ennemis[i].sensibilite[y] = DESACTIVE; - ennemis[i].invulnerabilite[y] = ACTIVE; - ennemis[i].absorbtion[y] = DESACTIVE; - } - else if (sensibilite == ABSORBTION) - { - ennemis[i].sensibilite[y] = DESACTIVE; - ennemis[i].resistance[y] = DESACTIVE; - ennemis[i].invulnerabilite[y] = DESACTIVE; - ennemis[i].absorbtion[y] = ACTIVE; - } - else - { - ennemis[i].sensibilite[y] = DESACTIVE; - ennemis[i].resistance[y] = DESACTIVE; - ennemis[i].invulnerabilite[y] = DESACTIVE; - ennemis[i].absorbtion[y] = DESACTIVE; - } - } - } - } -} diff --git a/constantes.h b/constantes.h index 1178eca..7e3d7da 100644 --- a/constantes.h +++ b/constantes.h @@ -44,6 +44,15 @@ enum character_class_t { #define SOIN 0 //caractéristiques +enum affinity_t { + AFFINITY_ABSORPTION, + AFFINITY_INVULNERABILITY, + AFFINITY_RESISTANCE, + AFFINITY_NONE, + AFFINITY_SENSITIVE, + + AFFINITY_COUNT, +}; #define SENSIBILITE 1 #define RESISTANCE 2 #define INVULNERABILITE 3 @@ -205,6 +214,8 @@ else\ }\ break; +#define countof(_array) ((int)(sizeof((_array)) / sizeof((_array)[0]))) + #include #define inverse_boolean(_b) ((_b) = (((_b)) ? false : true)) diff --git a/jouer.c b/jouer.c index b792f4f..802642a 100644 --- a/jouer.c +++ b/jouer.c @@ -120,7 +120,6 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally,ENNEMI blit_ally_team(surfaces,positions, ally); // on blit les persos sur l'ecran Fblitterennemis(surfaces,positions,ennemis,Vnbennemis); // idem pour les ennemis - Fremplircompetencesennemis(ennemis,Vnbennemis); // on initialise les pv, pm, exp, etc DES ENNEMIS while (continuer) { diff --git a/menuchoixpersos.c b/menuchoixpersos.c index ef8b8a1..91e0c7d 100644 --- a/menuchoixpersos.c +++ b/menuchoixpersos.c @@ -60,6 +60,10 @@ struct team_t *new_ally_team(SURFACES *surfaces, chr->defense = base_stats_g[chr->class_].defense; chr->spirit = base_stats_g[chr->class_].spirit; + for (int j = 0; j < countof(chr->affinities); ++j) { + chr->affinities[j] = rand() % AFFINITY_COUNT; + } + /* set its position */ chr->pos.x = 20; chr->pos.y = (YWIN / (cnt + 1)) * (i + 1) - chr->def_surf->h / 2; diff --git a/players.h b/players.h index 7d7b42c..6097d2c 100644 --- a/players.h +++ b/players.h @@ -39,6 +39,9 @@ struct character_t { int strength; int defense; int spirit; + + /* one for each element */ + enum affinity_t affinities[AFFINITY_COUNT]; }; struct team_t { diff --git a/prototypes.h b/prototypes.h index 069438d..956e9b6 100644 --- a/prototypes.h +++ b/prototypes.h @@ -39,7 +39,6 @@ void Fchangercurseurpersos (SURFACES *surfaces, POSITIONS *positions,int selecti void Fafficherdegats (SURFACES *surfaces, POSITIONS *positions, int degats,int camp, int cible, struct team_t *ally); void Fblitteractivedesactive (SURFACES *surfaces,POSITIONS *positions,ENNEMIS ennemis[],int selection); void Fchangeractionselectionnee(SURFACES *surfaces, POSITIONS *positions,int selection,int page,int nbactions,int type,OBJET *objets); -void Fremplircompetencesennemis (ENNEMIS ennemis[],int Vnbennemis); void Fblitterpvcible (SURFACES *surfaces,POSITIONS *positions,ENNEMIS ennemis[],int selection); void Fblitterpmcible (SURFACES *surfaces,POSITIONS *positions,ENNEMIS ennemis[],int selection); void Fchangermagienoireselectionnee(SURFACES *surfaces,POSITIONS *positions,int selection,int page,int nbactions); -- cgit v1.2.3