Browse Source

Added botWantsToPlay() to BlackJack

This method returns a boolean whether the bot wants to play or not specified by the points he has currently
remotes/origin/quiz
Friederike von Gruben 2 years ago
parent
commit
0b3ef70def
  1. 23
      src/main/java/org/bitbiome/classes/BlackJack.java

23
src/main/java/org/bitbiome/classes/BlackJack.java

@ -1,5 +1,7 @@
package org.bitbiome.classes;
import java.util.Random;
public class BlackJack {
public enum Entity {
@ -66,4 +68,25 @@ public class BlackJack {
if (entity == Entity.BOT) botPoints += points;
if (entity == Entity.PLAYER) playerPoints += points;
}
public boolean botWantsToPlay() {
if (botIn) {
if (botPoints <= 10) {
return true;
} else if (botPoints <= 17) {
int r = new Random().nextInt(1, 9);
if (r <= 3) {
botIn = false;
return false;
} else {
return true;
}
} else {
botIn = false;
return false;
}
} else {
return false;
}
}
}
Loading…
Cancel
Save