From 6e98607db8b412c310fd381aa79df4a9d51df98b Mon Sep 17 00:00:00 2001
From: ColinDrieu <colin.drieu@insa-rennes.fr>
Date: Thu, 21 Apr 2016 13:54:25 +0200
Subject: [PATCH] Deplacement de fonctions du controleur vers Partie.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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
---
 src/controleur.c        | 30 ------------------------------
 src/mainPartieConsole.c | 14 ++++++++++----
 src/partie.c            | 35 +++++++++++++++++++++++++++++++++--
 src/partie.h            |  1 +
 src/terrain.c           |  2 +-
 5 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/src/controleur.c b/src/controleur.c
index 0ba4a2e..dd2c66a 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 d391ed1..04a4044 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 242f75b..fa9eb27 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 4c151e1..d4ceca1 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 dea7bed..a676c26 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;
 }
-- 
GitLab