我正在设计一款多人扑克游戏。我有 Human 和 Computer 对象,它们都实现了 Player 接口,其中包含扑克玩家所需的方法。我有一个游戏中玩家的 ArrayList,我需要去找每个玩家并检查他们是否想要弃牌或站立。如果每个人都弃牌,那么最后一个过牌的人自动获胜。对于每一手,起始玩家需要轮换。对于第一手,ArrayList 索引 0 中的人将先走。第二手,索引 1 中的人会先走。只是想反弹想法并听取人们对如何实现这些功能的看法。
最初我有做这样的事情的想法;
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;
}
}
}
}
}