diff --git a/src/controleur.c b/src/controleur.c index 0ba4a2e51333a44526522e6139320ab1d1e85b20..dd2c66a7ff7fd4506930d0740c97735b7511592a 100644 --- a/src/controleur.c +++ b/src/controleur.c @@ -59,36 +59,6 @@ Case * entrerCoordonnees(Partie * p){ return caseTemp; } - /*! - * \fn Personnage * coordonneesValidesPersonnage(Partie * p, Case * c) - * \brief La fonction teste pour tous les Joueurs de la Partie s'ils possedent un Personnage sur la Case en entree. - * Si c'est le cas, le Personnage sur la Case est retourne. - * - * \param La Partie p en cours, la Case a tester. - * \return Un pointeur vers le Personnage sur la Case, NULL s'il n'y a pas de Personnage sur la Case. - */ -Personnage * coordonneesValidesPersonnage(Partie * p, Case * c){ - int i; - Personnage * resP = NULL; - Joueur * tempJ = NULL; - tempJ = getCurrentJoueur(getListJoueur(p)); - setOnFirstJoueur(getListJoueur(p)); - while(outOfJoueurList(getListJoueur(p))){ - for(i=0;i<TAILLE_MAX_GROUPE;i++){ - if(estSurLaCase(getPersonnage(getCurrentJoueur(getListJoueur(p)),i),c)){ - resP = getPersonnage(getCurrentJoueur(getListJoueur(p)),i); - } - } - } - for(i=0;i<TAILLE_MAX_GROUPE;i++){ - if(estSurLaCase(getPersonnage(getCurrentJoueur(getListJoueur(p)),i),c)){ - resP = getPersonnage(getCurrentJoueur(getListJoueur(p)),i); - } - } - setOnJoueur(getListJoueur(p),tempJ); - return resP; -} - /*! * \fn void personnageSelectionne(Partie * p) * \brief La fonction fait l'interface entre le moteur du jeu et l'affichage pour l'affichage des caracteristiques d'un Personnage. diff --git a/src/mainPartieConsole.c b/src/mainPartieConsole.c index d391ed12cc82c97d0e75b507a635cc1bc95a545b..04a4044bf524b5b0c068e12fe89a2122fc69461d 100644 --- a/src/mainPartieConsole.c +++ b/src/mainPartieConsole.c @@ -1,5 +1,7 @@ -#include <stdio.h> #include <stdlib.h> +#include <stdio.h> +#include <string.h> + #include "structures.h" #include "controleur.h" #include "partie.h" @@ -8,10 +10,13 @@ #include "joueur.h" #include "affichageConsole2.h" + int mainPartieConsole(){ - Partie * partieEnCours=initPartie(); + //initialisation Case * caseSel = NULL; Personnage * persSel = NULL; + Partie * partieEnCours=initPartie(); + //Partie while(!victoire(partieEnCours)){ switch(choixPrincipal(partieEnCours)){ case 1:{ @@ -29,10 +34,11 @@ int mainPartieConsole(){ //Deplacement } case 3:{ - //Retour choix Principal + //retour au choix principal. } case 4:{ - //fin du tour + finTour(partieEnCours); + afficheFinTour(getNomJoueur(getCurrentJoueur(getListJoueur(partieEnCours)))); } default:{ afficherChoixImpossible(); diff --git a/src/partie.c b/src/partie.c index 242f75be2a8a7fb0702e0b36817300f119c8d479..fa9eb27c69d504b139a678abec11aecf00f6f925 100644 --- a/src/partie.c +++ b/src/partie.c @@ -9,6 +9,7 @@ #include "partie.h" #include "joueurList.h" #include "joueur.h" +#include "case.h" /*! * \fn Partie * initPartie() @@ -19,10 +20,9 @@ Partie * initPartie(){ Partie * p = malloc(sizeof(Partie)); ListJoueur * l = initJoueurList(); - Carte * carteJeu = NULL; + Carte * carteJeu = nouvelleCarte(); p->nbTours=0; p->participants=l; - init_carte(carteJeu,LARG_MAX_CARTE,HAUT_MAX_CARTE); p->c=carteJeu; return p; } @@ -35,6 +35,7 @@ */ void deletePartie(Partie * p){ deleteJoueurList(p->participants); + deleteCarte(p->c); free(p); } @@ -216,5 +217,35 @@ Joueur * appartientJoueur(Personnage * p, Partie * partieEnCours){ return resJ; } + /*! + * \fn Personnage * coordonneesValidesPersonnage(Partie * p, Case * c) + * \brief La fonction teste pour tous les Joueurs de la Partie s'ils possedent un Personnage sur la Case en entree. + * Si c'est le cas, le Personnage sur la Case est retourne. + * + * \param La Partie p en cours, la Case a tester. + * \return Un pointeur vers le Personnage sur la Case, NULL s'il n'y a pas de Personnage sur la Case. + */ +Personnage * coordonneesValidesPersonnage(Partie * p, Case * c){ + int i; + Personnage * resP = NULL; + Joueur * tempJ = NULL; + tempJ = getCurrentJoueur(getListJoueur(p)); + setOnFirstJoueur(getListJoueur(p)); + while(outOfJoueurList(getListJoueur(p))){ + for(i=0;i<TAILLE_MAX_GROUPE;i++){ + if(estSurLaCase(getPersonnage(getCurrentJoueur(getListJoueur(p)),i),c)){ + resP = getPersonnage(getCurrentJoueur(getListJoueur(p)),i); + } + } + } + for(i=0;i<TAILLE_MAX_GROUPE;i++){ + if(estSurLaCase(getPersonnage(getCurrentJoueur(getListJoueur(p)),i),c)){ + resP = getPersonnage(getCurrentJoueur(getListJoueur(p)),i); + } + } + setOnJoueur(getListJoueur(p),tempJ); + return resP; +} + diff --git a/src/partie.h b/src/partie.h index 4c151e1045626b6cd506ecc9500a8f03c7afc5d6..d4ceca18bb47f4e624a1ea337edd79f023c3080e 100644 --- a/src/partie.h +++ b/src/partie.h @@ -25,6 +25,7 @@ int finTour(Partie * p); int isTurn(Partie * p, Joueur * j); Personnage * jouerPersonnage(Partie * p, Joueur * j, Personnage * perso); Joueur * appartientJoueur(Personnage * p, Partie * partieEnCours); +Personnage * coordonneesValidesPersonnage(Partie * p, Case * c); int victoire(Partie * p); diff --git a/src/terrain.c b/src/terrain.c index dea7bed32f6d43311ea52626894e456f1635d5c0..a676c26bd76522919d1cd6ea8a21181ed2d35841 100644 --- a/src/terrain.c +++ b/src/terrain.c @@ -40,7 +40,7 @@ boolean terrain_franchissable(Terrain *t){ Terrain * init_terrain(Terrain * t, char * n, boolean f, unsigned short int PD){ t->franchissable=f; strncpy(n,t->nomTerrain,TAILLE_NOMS-1); - t->nomTerrain[0]='/0'; + t->nomTerrain[0]='\0'; t->PD_requis=PD; return t; }