1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Joueur joueur1=new Joueur(nomDuJoueur1,"",2,mainDuJoueur1);
Joueur joueur2=new Joueur(nomDuJoueur2,"",2,mainDuJoueur2);
Joueur joueurCourant=new Joueur("","",0,initialisation);
System.out.println("les joueurs "+nomDuJoueur1+" et "+ nomDuJoueur2+" vont s'affronter!!");
int pileOuFace =(int)(Math.random()*2);
if (pileOuFace==0){
joueurCourant=joueur1;
}
else{
joueurCourant=joueur2;
}
System.out.println(joueurCourant.getNom()+" va choisir son personnage!");
System.out.println("l'ordinateur va retirer l'une des cartes de personnage.");
listeDePersonnage.remove((int)(Math.random()*8));
while(listeDePersonnage.size()>=4){
if((joueurCourant.getNom()=="ordi2")||(joueurCourant.getNom()=="ordi1")){
System.out.println("l'ordinateur va choisir son personnage.");
int numero=(int)(Math.random()*listeDePersonnage.size());
joueurCourant.personnage=CartePersonnage.getPersonnageDuNumero(numero);
listeDePersonnage.remove(numero);
System.out.println("L'ordinateur a choisi son personnage.");
joueurCourant=Joueur.changementDeJoueur(joueurCourant,joueur1, joueur2);
}
else{
System.out.println("Choisissez votre personnage en rentrant son numero");
for(int i=0;i<listeDePersonnage.size();i++){
System.out.println(listeDePersonnage.get(i));
}
int numeroDuPersonnage=Clavier.lireInt();
joueurCourant.personnage=CartePersonnage.getPersonnageDuNumero(numeroDuPersonnage);
System.out.println("Vous avez choisi "+joueurCourant.personnage);
listeDePersonnage.remove(numeroDuPersonnage);
joueurCourant=Joueur.changementDeJoueur(joueurCourant,joueur1, joueur2);
}
} |
Partager