Skip to content
Snippets Groups Projects
Commit 6e98607d authored by ColinDrieu's avatar ColinDrieu
Browse files

Deplacement de fonctions du controleur vers Partie.c

Une fonctions qui me semble plus dépendre du moteur que du controleur a été déplacée.
Correction d'un warning dans terrain.c
parent 0aa41903
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
#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();
......
......@@ -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;
}
......@@ -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);
......
......@@ -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;
}
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