Skip to content
Snippets Groups Projects
Commit 7a3bb0b5 authored by ColinDrieu's avatar ColinDrieu
Browse files

Ajout d'une fonction au controleur pour obtenir le nom des attaques des Personnages.

parent ac7d3311
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -86,5 +86,9 @@ char * getNomClasse(Classe * c){ ...@@ -86,5 +86,9 @@ char * getNomClasse(Classe * c){
return c->nom; return c->nom;
} }
char * getNomAttaques(Classe * c, int i){
return c->attaques[i].nom;
}
...@@ -26,4 +26,6 @@ int getManaMax(Classe * c); ...@@ -26,4 +26,6 @@ int getManaMax(Classe * c);
int getPDMax(Classe * c); int getPDMax(Classe * c);
char * getNomAttaques(Classe * c, int i);
#endif // CLASSE_H_INCLUDED #endif // CLASSE_H_INCLUDED
...@@ -770,22 +770,33 @@ int obtenirPDMaxPersonnage(int numero){ ...@@ -770,22 +770,33 @@ int obtenirPDMaxPersonnage(int numero){
* *
* \return un tableau de chaine de charactères (char**). * \return un tableau de chaine de charactères (char**).
*/ */
/*char ** obtenirNomsAttaquesPersonnage(int numero){ char ** obtenirNomsAttaquesPersonnage(int numero){
//allocation en memoire du tableau de resultats.
int i; int i;
Joueur * actuel = getCurrentJoueur(getListJoueur(partieGlobale));
char ** tabNomsAttPerso = malloc(NB_ATTAQUES_MAX * sizeof(char *)); char ** tabNomsAttPerso = malloc(NB_ATTAQUES_MAX * sizeof(char *));
for(i=0;i<NB_ATTAQUES_MAX;i++){ for(i=0;i<NB_ATTAQUES_MAX;i++){
tabNomsAttPerso[i]= malloc(TAILLE_NOMS*sizeof(char)); tabNomsAttPerso[i]= malloc(TAILLE_NOMS*sizeof(char));
} }
//Recherche du nom des attaques du Personnage
if((numero>0) && (numero<=3)){ if((numero>0) && (numero<=3)){
for(i=0;i<NB_ATTAQUES_MAX;i++){ setOnFirstJoueur(getListJoueur(partieGlobale));
strncpy(tabNomsAttPerso[i],packGlobal.Classes_Package->attaques->nom, TAILLE_NOMS); for(i=0;i<NB_ATTAQUES_MAX;i++){
} strncpy(tabNomsAttPerso[i], getNomAttaques(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-1)),i),TAILLE_NOMS);
}
setOnJoueur(getListJoueur(partieGlobale),actuel);
} }
else if ((numero>3)&&(numero>6)){ else if ((numero>3)&&(numero<=6)){
strncpy(tabNomsAttPerso[i],packGlobal.Classes_Package->attaques->nom, TAILLE_NOMS); setOnFirstJoueur(getListJoueur(partieGlobale));
nextJoueur(getListJoueur(partieGlobale));
for(i=0;i<NB_ATTAQUES_MAX;i++){
strncpy(tabNomsAttPerso[i], getNomAttaques(getClasse(getPersonnage(getCurrentJoueur(getListJoueur(partieGlobale)),numero-4)),i),TAILLE_NOMS);
}
setOnJoueur(getListJoueur(partieGlobale),actuel);
} }
return tabNomsAttPerso; return tabNomsAttPerso;
}*/ }
/*! /*!
* \fn void debutDuTour() * \fn void debutDuTour()
...@@ -828,7 +839,7 @@ char * joueurVictorieux(){ ...@@ -828,7 +839,7 @@ char * joueurVictorieux(){
// Je met ici mes tests réalisés dans le main pour éviter de les réécrire si jamais il y a un problème. // Je met ici mes tests réalisés dans le main pour éviter de les réécrire si jamais il y a un problème.
// Si vous voulez tester aussi, à recopier dans le main avant l'appel à initJeu(). // Si vous voulez tester aussi, à recopier dans le main avant l'appel à initJeu().
void testControlleurConsole(){ void testControlleurConsole(){
int i,j,n,x,y; int i,j,n,k,x,y;
EtatsJeu state = SAISIE_JOUEURS; EtatsJeu state = SAISIE_JOUEURS;
extern Partie * partieGlobale; extern Partie * partieGlobale;
extern Game_Package packGlobal; extern Game_Package packGlobal;
...@@ -884,6 +895,10 @@ void testControlleurConsole(){ ...@@ -884,6 +895,10 @@ void testControlleurConsole(){
printf("%d\n", obtenirManaMaxPersonnage(n)); printf("%d\n", obtenirManaMaxPersonnage(n));
printf("%d\n", obtenirPDPersonnage(n)); printf("%d\n", obtenirPDPersonnage(n));
printf("%d\n", obtenirPDMaxPersonnage(n)); printf("%d\n", obtenirPDMaxPersonnage(n));
char ** tabNomAtt = obtenirNomsAttaquesPersonnage(n);
for(k=0;k<NB_ATTAQUES_MAX;k++){
printf("%s\n",tabNomAtt[k]);
}
} }
} }
} }
......
...@@ -135,7 +135,7 @@ typedef struct Attaque{ ...@@ -135,7 +135,7 @@ typedef struct Attaque{
*/ */
typedef struct Classe{ typedef struct Classe{
char nom[25]; /*!< Nom de la classe de taille TAILLE_NOMS*/ char nom[25]; /*!< Nom de la classe de taille TAILLE_NOMS*/
Attaque attaques[5]; /*!< Les attaques disponibles pour la classe*/ Attaque attaques[NB_ATTAQUES_MAX]; /*!< Les attaques disponibles pour la classe*/
unsigned short int points_deplacement_max; /*!< Les PD maximums accordés a la classe*/ unsigned short int points_deplacement_max; /*!< Les PD maximums accordés a la classe*/
unsigned short int PV_max; /*!< Les PV maximums accordés a la classe*/ unsigned short int PV_max; /*!< Les PV maximums accordés a la classe*/
unsigned short int mana_max; /*!< Le mana maximum accordé a la classe*/ unsigned short int mana_max; /*!< Le mana maximum accordé a la classe*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment