I'm designing a multiplayer game of poker. I have Human and Computer objects, both which implement a Player interface which contains methods necessary to a poker player. I have an ArrayList of the players in the game, and I need to go to each player and check whether they want to fold their hand or stand. If everyone has folded, then the last person to check their play automatically wins. For each hand, the starting player needs to rotate. For the first hand, the person in index 0 of the ArrayList will go first. The second hand, the person in index 1 will go first. Just looking to bounce ideas and hear peoples views on how they'd implement these features.
Initially I had the idea of doing something like this;
public void poker(ArrayList<Player> players){
int foldCounter = 0;
int starter = 0;
while (weWantToPlay){
for (int j = starter; j < players.size(); j++){
//get the players game plan
players.get(j).getStand
//the player is folding
if (!player.stand()){
foldCounter++;
//doStuff
else{
//doStuff
}
}
//do more stuff and play poker
//increment starter so the next hand, the second person starts
// this obviously will not work, cause we need go to the end of the list, then wrap around
starter++;
//check who's folded to see if we automatically have a winner
if (foldCounter == players.size()-1){
for (Player element:players){
if (element.stand()){
winner = element;
break;
}
}
}
}
}