在我的二十一点计划中,我有:
Card c = dealCard(deck); //deals the card
updatePoints(players[i], c); // calls updatePoints below.
updatePoints 函数如下所示:
public static void updatePoints(Player player, Card c){
int point = c.getValue();
if(player.getPoints() + point >21 && (player.ace1 == 11 || player.ace2 == 11 || player.ace3 == 11 || player.ace4 == 11)){
player.points -= 10;
player.setPoints(point);
if (player.ace1 == 11){
player.ace1 = 1;
}else if(player.ace2 == 11){
player.ace2 = 1;
}else if(player.ace3 == 11){
player.ace3 = 1;
}else if (player.ace4 == 11){
player.ace4 = 1;
}
}
if (point == 1){
//default value for player.ace1 .. player.ace4 is 0
if(player.ace1 == 0){
player.ace1 = 11;
player.setPoints(11);
}else if (player.ace2 == 0){
player.ace2 = 11;
player.setPoints(11);
}else if (player.ace3 == 0){
player.ace3 = 11;
player.setPoints(11);
}else if(player.ace4 == 0){
player.ace4 = 11;
player.setPoints(11);
}
}else{
player.setPoints(point);
}
return;
}
由于某种原因,当点数超过 21 时,这不会改变 ace 值,也不会调整 ace。任何帮助将不胜感激。谢谢