@@ -46,8 +46,8 @@ public static void main(String[] args) {
4646 public static void jeu (int nbJoueurs ) {
4747
4848 Carte carte = new Carte ();
49- Ville ville = (Ville ) carte .getCase (12 , 12 );
50-
49+ Ville ville = (Ville ) carte .getCase (12 , 12 );
50+
5151 ArrayList <Joueur > listeJoueur = new ArrayList ();
5252
5353 for (int i = 0 ; i < nbJoueurs ; i ++) {
@@ -59,7 +59,6 @@ public static void jeu(int nbJoueurs) {
5959 listeJoueur .add (j );
6060 }
6161
62-
6362 boolean game = true ;
6463 Joueur joueur ;
6564 Scanner sc = new Scanner (System .in );
@@ -74,8 +73,8 @@ public static void jeu(int nbJoueurs) {
7473 while (tour ){
7574 System .out .println ("Que souhaitez-vous faire ?" );
7675 String action = sc .nextLine ();
77-
78- switch (action ){
76+
77+ switch (action ) {
7978 case "éteindre console" :
8079 game = false ;
8180 case "aller en haut" :
@@ -115,15 +114,15 @@ public static void jeu(int nbJoueurs) {
115114
116115 }
117116 }
118-
117+
119118 }
120119
121120 if (listeJoueur .size ()<=1 ){
122121 game = false ;
123122 }
124123 //retirer les joueurs morts de l'arraylist
125124 //les joueurs regagnent 4PA
126- //si y'a des addicts, avec le compteur à 0, ils perdent 5PV
125+ //si y'a des addicts, avec le compteur à 0, ils perdent 5PV - DONE
127126 //compteur de tour prend +1
128127
129128 if (carte .getTour ()==13 ){
@@ -169,25 +168,21 @@ public static void jeu(int nbJoueurs) {
169168
170169 }
171170
172- public static void addiction (boolean testAddiction , int compteur ) {
173- compteur = 3 ;
174- while (compteur != 0 ) {
175- if (testAddiction == true ) { // Si joueur addicte, commencer à décrémenter
176- compteur = compteur - 1 ;
177- }
178- }
179- while (testAddiction == false ) { // Si arrivé à 0, perte de PV jusque prise de boisson; Comment éviter boucle infinie ? Risque ici non ?
180- // rédiger perte de PV help
171+ public static void addiction (Joueur joueur ) {
172+ if (joueur .getAddiction ().getCompteurDeTour () == 0 ) {
173+ joueur .setPv (joueur .getPv () - 5 );
174+ } else if (joueur .getAddiction ().getTestAddiction ()) { // Implicite que == true
175+ joueur .getAddiction ().setCompteurDeTour (joueur .getAddiction ().getCompteurDeTour () - 1 );
181176 }
182177 }
183178 // Réccupérer objet addiction; true = commencer décompte + perte de -5 PV si 0 au décompte
184179
185180 public static void tuerJoueur (ArrayList <Joueur > listeJoueur ){
186181 int taille = listeJoueur .size ();
187- int moitie = (int ) taille / 2 ;
182+ int moitie = (int ) taille / 2 ;
188183 Random ra = new Random ();
189-
190- for (int i = 0 ; i < moitie ; i ++){
184+
185+ for (int i = 0 ; i < moitie ; i ++) {
191186 int indice = ra .nextInt (taille );
192187 listeJoueur .get (indice ).setPv (0 );
193188 }
0 commit comments