Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.53 KB | None | 0 0
  1. package fr.hitsumo.ouno;
  2.  
  3. import plum.console.Clavier;
  4.  
  5. public class MainJoueur
  6. {
  7.     int[] indices = {1,2,3,4,5,6,7};
  8.     private boolean ounojoueur = false;
  9.     private boolean ounomachine = false;
  10.     private String[] tJoueur;
  11.     private String[] tCartePosee;
  12.     private String[] tMachine;
  13.     private String[] tPioche;
  14.     private boolean turnjoueur = true;
  15.     private boolean apioche;
  16.  
  17.     public void afficherMainJoueur(String[] tJoueur, String[] tCartePosee, String[] tMachine, String[] tPioche)
  18.     {
  19.         this.tJoueur = tJoueur;
  20.         this.tCartePosee = tCartePosee;
  21.         this.tMachine = tMachine;
  22.         this.tPioche = tPioche;
  23.  
  24.         String touche = "";
  25.         do
  26.         {
  27.            
  28.             Ouno.afficherJeuJoueur(tJoueur);
  29.             Ouno.afficherCarteARecouvrir(tCartePosee);
  30.             touche = Clavier.lireTexte("Action ( ! : ouno ; p : pioche; i : indice de la carte ; n : passer; q : quitter) ? ");
  31.             if (touche.equals("!")) faireouno();
  32.             else if (touche.equals("p")) piocher();
  33.             else if (touche.equals("n")) passer();
  34.             else if (touche.equals("q")) break;
  35.             else
  36.             {
  37.                 jouercarte(Integer.parseInt(touche));
  38.             }
  39.            
  40.  
  41.             turnjoueur=false;
  42.         } while (true);
  43.     }
  44.  
  45.     private void faireouno()
  46.     {
  47.         if (ounojoueur == true)
  48.         {
  49.             System.out.println("Vous avez déjà fait un uno.");
  50.             return;
  51.         }
  52.         else
  53.         {
  54.             if(tJoueur.length==1)
  55.             {
  56.                 ounojoueur=true;
  57.                 System.out.println("Le joueur a crié OUNO");
  58.             }
  59.             else
  60.             {
  61.                 System.out.println("Vous ne pouvez pas déclarer OUNO");
  62.             }
  63.         }
  64.     }
  65.  
  66.     private void piocher()
  67.     {
  68.         if(turnjoueur)
  69.         {
  70.             if (apioche==true) System.out.println("Vous avez déjà pioché");
  71.             else if (!Ouno.piocherUneCarte(tCartePosee, tJoueur)) System.out.println("Vous ne pouvez pas piocher car vous pouvez jouer une carte.");
  72.             else
  73.             {
  74.                 tJoueur = Ouno.ajouteUneCarteAuJeuDunJoueur(tJoueur,tPioche[0]);
  75.                 apioche = true;
  76.             }
  77.         }
  78.         else
  79.         {
  80.             tMachine = Ouno.ajouteUneCarteAuJeuDunJoueur(tJoueur,tPioche[0]);
  81.         }
  82.  
  83.         tPioche = Ouno.enleverCartePiochee(tPioche);
  84.     }
  85.  
  86.     private void jouercarte(int i)
  87.     {
  88.         //Système pour jouer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement