- Inform the human which turn position he's in during the Mulligan Input

This commit is contained in:
Sol
2013-03-04 03:33:01 +00:00
parent 3fcb3a9d1c
commit eaf3429cea
2 changed files with 28 additions and 4 deletions

View File

@@ -62,10 +62,19 @@ public class InputMulligan extends Input {
ButtonUtil.setButtonText("No", "Yes");
ButtonUtil.enableAllFocusOk();
final String str =
(Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn().equals(Singletons.getControl().getPlayer())
? "You're going first. " : "The computer is going first. ");
CMatchUI.SINGLETON_INSTANCE.showMessage(str + "Do you want to Mulligan?");
GameState game = Singletons.getModel().getGame();
Player startingPlayer = game.getPhaseHandler().getPlayerTurn();
Player localPlayer = Singletons.getControl().getPlayer();
StringBuilder sb = new StringBuilder();
sb.append(startingPlayer.getName()).append(" is going first. ");
if (!startingPlayer.equals(localPlayer)) {
sb.append("You are going ").append(game.getOrdinalPosition(localPlayer, startingPlayer)).append(". ");
}
sb.append("Do you want to Mulligan?");
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
}
/** {@inheritDoc} */

View File

@@ -478,6 +478,21 @@ public class GameState {
return roIngamePlayers.get(iPlayer);
}
public String getOrdinalPosition(Player player, Player startingPlayer) {
int startPosition = roIngamePlayers.indexOf(startingPlayer);
int position = roIngamePlayers.indexOf(player) + startPosition + 1;
String[] sufixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
switch (position % 100) {
case 11:
case 12:
case 13:
return position + "th";
default:
return position + sufixes[position % 10];
}
}
/**
* Only game knows how to get suitable players out of just connected clients.