Some minor formatting.

This commit is contained in:
LevelX2 2014-02-03 17:47:12 +01:00
parent 9c5d5208b9
commit bf4ccf185c
10 changed files with 79 additions and 61 deletions

View file

@ -44,6 +44,7 @@ import mage.target.Targets;
/**
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements ManaCosts<T> {

View file

@ -12,6 +12,7 @@ import mage.players.Player;
import java.util.List;
import java.util.UUID;
import mage.util.CardUtil;
/**
* Action for drawing cards.
@ -22,7 +23,7 @@ public class MageDrawAction extends MageAction {
private final Player player;
private final int amount;
private ArrayList<UUID> appliedEffects;
private final ArrayList<UUID> appliedEffects;
private List<Card> drawnCards;
private static final int NEGATIVE_VALUE = -1000000;
@ -37,6 +38,7 @@ public class MageDrawAction extends MageAction {
* Draw and set action score.
*
* @param game Game context.
* @return
*/
@Override
public int doAction(Game game) {
@ -51,7 +53,7 @@ public class MageDrawAction extends MageAction {
score += value;
}
if (numDrawn > 0) {
game.fireInformEvent(player.getName() + " draws " + Integer.toString(numDrawn) + " card" + (numDrawn > 1 ? "s" : ""));
game.fireInformEvent(player.getName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : ""));
}
if (player.isEmptyDraw()) {
game.doAction(new MageLoseGameAction(player, MageLoseGameAction.DRAW_REASON));

View file

@ -351,8 +351,25 @@ public class CardUtil {
* Converts an integer number to string
* Numbers > 20 will be returned as digits
*
* @param number
* @return
*/
public static String numberToText(int number) {
return numberToText(number, "one");
}
/**
* Converts an integer number to string like "one", "two", "three", ...
* Numbers > 20 will be returned as digits
*
* @param number number to convert to text
* @param forOne if the number is 1, this string will be returnedinstead of "one".
* @return
*/
public static String numberToText(int number, String forOne) {
if (number == 1 && forOne != null) {
return forOne;
}
if (number >= 0 && number < 21) {
return numberStrings[number];
}
@ -368,11 +385,7 @@ public class CardUtil {
public static String numberToText(String number, String forOne) {
if (checkNumeric(number)) {
int intNumber = Integer.parseInt(number);
if (forOne != null && intNumber == 1) {
return forOne;
}
return numberToText(intNumber);
return numberToText(Integer.parseInt(number));
}
return number;
}