Skip to content

Commit 09a5920

Browse files
committed
#47 Correction negative value + extension choix
1 parent 15a6541 commit 09a5920

File tree

3 files changed

+64
-13
lines changed

3 files changed

+64
-13
lines changed

src/main/java/bot/Choix.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public ArrayList<ArrayList<Integer>> permutation(int[] num) {
4141
private int rand9 = choix.nextInt(2);
4242

4343
public void addChoixList() {
44-
if (choix.nextInt(2)==0){
44+
int mem = choix.nextInt(4);
45+
if (mem == 0){
4546
this.choixList.add(0);
4647
this.choixList.add(0);
4748
this.choixList.add(0);
@@ -51,10 +52,30 @@ public void addChoixList() {
5152
this.choixList.add(0);
5253
this.choixList.add(0);
5354
this.choixList.add(0);}
54-
else {
55+
if (mem == 1){
56+
this.choixList.add(0);
57+
this.choixList.add(1);
58+
this.choixList.add(0);
59+
this.choixList.add(0);
60+
this.choixList.add(0);
61+
this.choixList.add(0);
62+
this.choixList.add(0);
63+
this.choixList.add(0);
64+
this.choixList.add(0);}
65+
if (mem == 2){
5566
this.choixList.add(0);
5667
this.choixList.add(0);
5768
this.choixList.add(0);
69+
this.choixList.add(1);
70+
this.choixList.add(0);
71+
this.choixList.add(0);
72+
this.choixList.add(0);
73+
this.choixList.add(0);
74+
this.choixList.add(0);}
75+
else {
76+
this.choixList.add(1);
77+
this.choixList.add(0);
78+
this.choixList.add(0);
5879
this.choixList.add(0);
5980
this.choixList.add(0);
6081
this.choixList.add(0);

src/main/java/bot/Inventaire.java

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,71 @@ public void setNbVictoire(int nbVictoire) {
7272

7373
public List<Exploit> getCartes() {return cartes;}
7474

75-
public void addCartes(Exploit c){cartes.add(c);}
75+
void addCartes(Exploit c){cartes.add(c);}
7676

7777
public void adderFace(Face FaceDe) {
7878
Choix Courant = new Choix();
7979
Courant.addChoixList();
8080
int rand = Courant.getChoixList(0);
8181
int rand2 = Courant.getChoixList(1);
82+
8283
if(FaceDe.getType() == NORMAL){
83-
if (FaceDe.getRes() == Ressource.OR) this.setNbOR(this.getNbOR() + FaceDe.getValeur());
84-
if (FaceDe.getRes() == Ressource.SOLAIRE) this.setNbSolaire(this.getNbSolaire() + FaceDe.getValeur());
85-
if (FaceDe.getRes() == Ressource.LUNAIRE) this.setNbLunaire(this.getNbLunaire() + FaceDe.getValeur());
86-
if (FaceDe.getRes() == Ressource.VICTOIRE) this.setNbVictoire(this.getNbVictoire() + FaceDe.getValeur());
84+
if (FaceDe.getRes() == Ressource.OR) {
85+
this.setNbOR(this.getNbOR() + FaceDe.getValeur());
86+
if (this.getNbOR() < 0) this.setNbOR(0);
87+
88+
}
89+
if (FaceDe.getRes() == Ressource.SOLAIRE){
90+
this.setNbSolaire(this.getNbSolaire() + FaceDe.getValeur());
91+
if (this.getNbLunaire() < 0) this.setNbLunaire(0);
92+
93+
}
94+
if (FaceDe.getRes() == Ressource.LUNAIRE){
95+
this.setNbLunaire(this.getNbLunaire() + FaceDe.getValeur());
96+
if (this.getNbSolaire() < 0) this.setNbSolaire(0);
97+
98+
}
99+
if (FaceDe.getRes() == Ressource.VICTOIRE){
100+
this.setNbVictoire(this.getNbVictoire() + FaceDe.getValeur());
101+
if (this.getNbVictoire() < 0) this.setNbVictoire(0);
102+
103+
}
104+
87105
}
88106
else if(FaceDe.getType() == PLUS){
89107
this.setNbSolaire(this.getNbSolaire() + FaceDe.getNbSOL());
90108
this.setNbLunaire(this.getNbLunaire() + FaceDe.getNbLUN());
91109
this.setNbVictoire(this.getNbVictoire() + FaceDe.getNbVICT());
92110
this.setNbOR(this.getNbOR() + FaceDe.getNbOR());
111+
if (this.getNbOR() < 0) this.setNbOR(0);
112+
if (this.getNbLunaire() < 0) this.setNbLunaire(0);
113+
if (this.getNbSolaire() < 0) this.setNbSolaire(0);
114+
if (this.getNbVictoire() < 0) this.setNbVictoire(0);
115+
93116
}
94117
else if(FaceDe.getType() == CHOIX && FaceDe.getNbSOL()>0){
95118
if (rand == 0){
96-
this.setNbOR(this.getNbOR() + FaceDe.getNbOR());}
119+
this.setNbOR(this.getNbOR() + FaceDe.getNbOR());
120+
if (this.getNbOR() < 0) this.setNbOR(0);
121+
}
97122
if (rand == 1){
98123
this.setNbSolaire(this.getNbSolaire() + FaceDe.getNbSOL());
124+
if (this.getNbLunaire() < 0) this.setNbLunaire(0);
99125
}
100126
if (rand == 2){
101127
this.setNbLunaire(this.getNbLunaire() + FaceDe.getNbLUN());
128+
if (this.getNbSolaire() < 0) this.setNbSolaire(0);
102129
}
103130
else if(FaceDe.getType() == CHOIX && FaceDe.getNbSOL()>0){
104131
if (rand2 == 0){
105-
this.setNbOR(this.getNbOR() + FaceDe.getNbOR());}
132+
this.setNbOR(this.getNbOR() + FaceDe.getNbOR());
133+
if (this.getNbOR() < 0) this.setNbOR(0);
134+
}
135+
}
136+
else{
137+
this.setNbVictoire(this.getNbVictoire() + FaceDe.getNbVICT());
138+
if (this.getNbVictoire() < 0) this.setNbVictoire(0);
106139
}
107-
else{ this.setNbVictoire(this.getNbVictoire() + FaceDe.getNbVICT());}
108140
}
109141

110142
}

src/main/java/iles/Exploit.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ public static void effetAncien(Joueur Joueur){
267267
int nbOr = Joueur.getInventaireJoueur().getNbOR();
268268
int nbVict = Joueur.getInventaireJoueur().getNbVictoire();
269269

270-
if (choix == 1) {
270+
if (choix == 1 && Joueur.getInventaireJoueur().getNbOR() >= 3 ) {
271271
Joueur.getInventaireJoueur().setNbOR(nbOr - 3);
272-
if (nbOr<=3)
273-
Joueur.getInventaireJoueur().setNbOR(0);
274272
Joueur.getInventaireJoueur().setNbVictoire(nbVict + 4);
275273
System.out.println("Il échange à l'ancien 3 Or contre 4 points Victoire");
276274

0 commit comments

Comments
 (0)