mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Refactor some "String.format" to use StringBuilder
This commit is contained in:
@@ -183,4 +183,30 @@ public class TextUtil {
|
|||||||
return s.substring(0, 1).toUpperCase()
|
return s.substring(0, 1).toUpperCase()
|
||||||
+ s.substring(1);
|
+ s.substring(1);
|
||||||
}
|
}
|
||||||
|
//concatenate with spaces
|
||||||
|
public static String concatWithSpace(String s1, String s2) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).toString();
|
||||||
|
}
|
||||||
|
public static String concatWithSpace(String s1, String s2, String s3) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).append(" ").append(s3).toString();
|
||||||
|
}
|
||||||
|
public static String concatWithSpace(String s1, String s2, String s3, String s4) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).append(" ").append(s3).append(" ").append(s4).toString();
|
||||||
|
}
|
||||||
|
public static String concatWithSpace(String s1, String s2, String s3, String s4, String s5) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).append(" ").append(s3).append(" ").append(s4).append(" ").append(s5).toString();
|
||||||
|
}
|
||||||
|
public static String concatWithSpace(String s1, String s2, String s3, String s4, String s5, String s6) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).append(" ").append(s3).append(" ").append(s4).append(" ").append(s5).append(" ").append(s6).toString();
|
||||||
|
}
|
||||||
|
public static String concatWithSpace(String s1, String s2, String s3, String s4, String s5, String s6, String s7) {
|
||||||
|
return new StringBuilder().append(s1).append(" ").append(s2).append(" ").append(s3).append(" ").append(s4).append(" ").append(s5).append(" ").append(s6).append(" ").append(s7).toString();
|
||||||
|
}
|
||||||
|
//concatenate no spaces
|
||||||
|
public static String concatNoSpace(String s1, String s2, String s3) {
|
||||||
|
return new StringBuilder().append(s1).append(s2).append(s3).toString();
|
||||||
|
}
|
||||||
|
public static String concatNoSpace(String s1, String s2, String s3, String s4, String s5) {
|
||||||
|
return new StringBuilder().append(s1).append(s2).append(s3).append(s4).append(s5).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ public final class GameActionUtil {
|
|||||||
newSA.setBasicSpell(false);
|
newSA.setBasicSpell(false);
|
||||||
final Cost cost1 = new Cost(sCosts[0], false);
|
final Cost cost1 = new Cost(sCosts[0], false);
|
||||||
final Cost cost2 = new Cost(sCosts[1], false);
|
final Cost cost2 = new Cost(sCosts[1], false);
|
||||||
newSA.setDescription(newSA.getDescription() + String.format(" (Both kickers: %s and %s)", cost1.toSimpleString(), cost2.toSimpleString()));
|
newSA.setDescription(newSA.getDescription() + TextUtil.concatWithSpace(" (Both kickers:", cost1.toSimpleString(),"and",cost2.toSimpleString()+")"));
|
||||||
newSA.setPayCosts(cost2.add(cost1.add(newSA.getPayCosts())));
|
newSA.setPayCosts(cost2.add(cost1.add(newSA.getPayCosts())));
|
||||||
newSA.addOptionalCost(OptionalCost.Kicker1);
|
newSA.addOptionalCost(OptionalCost.Kicker1);
|
||||||
newSA.addOptionalCost(OptionalCost.Kicker2);
|
newSA.addOptionalCost(OptionalCost.Kicker2);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.TargetChoices;
|
import forge.game.spellability.TargetChoices;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
|
|
||||||
public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||||
@@ -42,7 +43,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventGameOutcome ev) {
|
public GameLogEntry visit(GameEventGameOutcome ev) {
|
||||||
for (Player p : ev.result.getPlayers()) {
|
for (Player p : ev.result.getPlayers()) {
|
||||||
String outcome = String.format("%s has %s", p.getName(), p.getOutcome().toString());
|
String outcome = TextUtil.concatWithSpace(p.getName(),"has", p.getOutcome().toString());
|
||||||
log.add(GameLogEntryType.GAME_OUTCOME, outcome);
|
log.add(GameLogEntryType.GAME_OUTCOME, outcome);
|
||||||
}
|
}
|
||||||
return generateSummary(ev.history);
|
return generateSummary(ev.history);
|
||||||
@@ -51,15 +52,15 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventScry ev) {
|
public GameLogEntry visit(GameEventScry ev) {
|
||||||
String scryOutcome = "";
|
String scryOutcome = "";
|
||||||
String toTop = String.format("%s to the top of the library", Lang.nounWithAmount(ev.toTop, "card"));
|
String toTop = TextUtil.concatWithSpace(Lang.nounWithAmount(ev.toTop, "card"),"to the top of the library");
|
||||||
String toBottom = String.format("%s to the bottom of the library", Lang.nounWithAmount(ev.toBottom, "card"));
|
String toBottom = TextUtil.concatWithSpace(Lang.nounWithAmount(ev.toBottom, "card"),"to the bottom of the library");
|
||||||
|
|
||||||
if (ev.toTop > 0 && ev.toBottom > 0) {
|
if (ev.toTop > 0 && ev.toBottom > 0) {
|
||||||
scryOutcome = String.format("%s scried %s and %s.", ev.player, toTop, toBottom);
|
scryOutcome = TextUtil.concatWithSpace(ev.player.toString(),"scried", toTop, "and", toBottom);
|
||||||
} else if (ev.toBottom == 0) {
|
} else if (ev.toBottom == 0) {
|
||||||
scryOutcome = String.format("%s scried %s.", ev.player, toTop);
|
scryOutcome = TextUtil.concatWithSpace(ev.player.toString(),"scried", toTop);
|
||||||
} else {
|
} else {
|
||||||
scryOutcome = String.format("%s scried %s.", ev.player, toBottom);
|
scryOutcome = TextUtil.concatWithSpace(ev.player.toString(),"scried", toBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, scryOutcome);
|
return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, scryOutcome);
|
||||||
@@ -104,7 +105,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String modeChoiceOutcome = String.format("%s has chosen %s for %s.", ev.player, ev.mode, ev.cardName);
|
String modeChoiceOutcome = TextUtil.concatWithSpace(ev.player.toString(), "has chosen", ev.mode, "for", ev.cardName+".");
|
||||||
return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, modeChoiceOutcome);
|
return new GameLogEntry(GameLogEntryType.STACK_RESOLVE, modeChoiceOutcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
if (newLobbyPlayer == null) {
|
if (newLobbyPlayer == null) {
|
||||||
message = p.getName() + " has restored control over themself";
|
message = p.getName() + " has restored control over themself";
|
||||||
} else {
|
} else {
|
||||||
message = String.format("%s is controlled by %s", p.getName(), newLobbyPlayer.getName());
|
message = TextUtil.concatWithSpace(p.getName(), "is controlled by", newLobbyPlayer.getName());
|
||||||
}
|
}
|
||||||
return new GameLogEntry(GameLogEntryType.PLAYER_CONROL, message);
|
return new GameLogEntry(GameLogEntryType.PLAYER_CONROL, message);
|
||||||
}
|
}
|
||||||
@@ -166,7 +167,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
if (event.type == DamageType.LoyaltyLoss) {
|
if (event.type == DamageType.LoyaltyLoss) {
|
||||||
additionalLog = "(Removing " + Lang.nounWithAmount(event.amount, "loyalty counter") + ")";
|
additionalLog = "(Removing " + Lang.nounWithAmount(event.amount, "loyalty counter") + ")";
|
||||||
}
|
}
|
||||||
String message = String.format("%s deals %d damage %s to %s.", event.source, event.amount, additionalLog, event.card);
|
String message = TextUtil.concatWithSpace(event.source.toString(),"deals", String.valueOf(event.amount),"damage", additionalLog,"to", event.card.toString()+".");
|
||||||
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,26 +176,27 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventLandPlayed ev) {
|
public GameLogEntry visit(GameEventLandPlayed ev) {
|
||||||
String message = String.format("%s played %s", ev.player, ev.land);
|
String message = TextUtil.concatWithSpace(ev.player.toString(),"played", ev.land.toString());
|
||||||
return new GameLogEntry(GameLogEntryType.LAND, message);
|
return new GameLogEntry(GameLogEntryType.LAND, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventTurnBegan event) {
|
public GameLogEntry visit(GameEventTurnBegan event) {
|
||||||
String message = String.format("Turn %d (%s)", event.turnNumber, event.turnOwner);
|
String message = TextUtil.concatWithSpace("Turn", String.valueOf(event.turnNumber), "("+event.turnOwner.toString()+")");
|
||||||
return new GameLogEntry(GameLogEntryType.TURN, message);
|
return new GameLogEntry(GameLogEntryType.TURN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventPlayerDamaged ev) {
|
public GameLogEntry visit(GameEventPlayerDamaged ev) {
|
||||||
String extra = ev.infect ? " (as poison counters)" : "";
|
String extra = ev.infect ? " (as poison counters)" : "";
|
||||||
String message = String.format("%s deals %d %s damage to %s%s.", ev.source, ev.amount, ev.combat ? "combat" : "non-combat", ev.target, extra);
|
String damageType = ev.combat ? "combat" : "non-combat";
|
||||||
|
String message = TextUtil.concatWithSpace(ev.source.toString(),"deals", String.valueOf(ev.amount), damageType, "damage to", ev.target.toString()+extra+".");
|
||||||
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventPlayerPoisoned ev) {
|
public GameLogEntry visit(GameEventPlayerPoisoned ev) {
|
||||||
String message = String.format("%s receives %s from %s", ev.receiver, Lang.nounWithAmount(ev.amount, "posion counter"), ev.source);
|
String message = TextUtil.concatWithSpace(ev.receiver.toString(),"receives", Lang.nounWithAmount(ev.amount, "posion counter"),"from", ev.source.toString());
|
||||||
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
return new GameLogEntry(GameLogEntryType.DAMAGE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +266,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameLogEntry visit(GameEventMulligan ev) {
|
public GameLogEntry visit(GameEventMulligan ev) {
|
||||||
String message = String.format("%s has mulliganed down to %d cards.", ev.player, ev.player.getZone(ZoneType.Hand).size());
|
String message = TextUtil.concatWithSpace(ev.player.toString(),"has mulliganed down to", String.valueOf(ev.player.getZone(ZoneType.Hand).size()),"cards.");
|
||||||
return new GameLogEntry(GameLogEntryType.MULLIGAN, message);
|
return new GameLogEntry(GameLogEntryType.MULLIGAN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package forge.game.ability;
|
package forge.game.ability;
|
||||||
|
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class IllegalAbilityException extends RuntimeException {
|
public class IllegalAbilityException extends RuntimeException {
|
||||||
private static final long serialVersionUID = -8638474348184716635L;
|
private static final long serialVersionUID = -8638474348184716635L;
|
||||||
@@ -10,7 +11,7 @@ public class IllegalAbilityException extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IllegalAbilityException(final SpellAbility sa, final SpellAbilityEffect effect) {
|
public IllegalAbilityException(final SpellAbility sa, final SpellAbilityEffect effect) {
|
||||||
this(String.format("%s (effect %s)", sa, effect.getClass().getName()));
|
this(TextUtil.concatWithSpace(sa.toString(), "(effect "+effect.getClass().getName()+")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IllegalAbilityException(final String message) {
|
private IllegalAbilityException(final String message) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -105,12 +106,12 @@ public abstract class SpellAbilityEffect {
|
|||||||
if (sa.hasParam("Announce")) {
|
if (sa.hasParam("Announce")) {
|
||||||
String svar = sa.getParam("Announce");
|
String svar = sa.getParam("Announce");
|
||||||
int amount = CardFactoryUtil.xCount(sa.getHostCard(), sa.getSVar(svar));
|
int amount = CardFactoryUtil.xCount(sa.getHostCard(), sa.getSVar(svar));
|
||||||
sb.append(String.format(" (%s=%d)", svar, amount));
|
sb.append(TextUtil.concatNoSpace(" (", svar,"="+amount+")"));
|
||||||
} else{
|
} else{
|
||||||
if (sa.getPayCosts() != null && sa.getPayCosts().getCostMana() != null &&
|
if (sa.getPayCosts() != null && sa.getPayCosts().getCostMana() != null &&
|
||||||
sa.getPayCosts().getCostMana().getAmountOfX() > 0) {
|
sa.getPayCosts().getCostMana().getAmountOfX() > 0) {
|
||||||
int amount = sa.getHostCard().getXManaCostPaid();
|
int amount = sa.getHostCard().getXManaCostPaid();
|
||||||
sb.append(String.format(" (%s=%d)", "X", amount));
|
sb.append(TextUtil.concatNoSpace(" (","X","="+amount+")"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import forge.game.trigger.TriggerType;
|
|||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.collect.*;
|
import forge.util.collect.*;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.MessageUtil;
|
import forge.util.MessageUtil;
|
||||||
@@ -427,7 +428,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
hostCard.addRemembered(CardUtil.getLKICopy(tgtC));
|
hostCard.addRemembered(CardUtil.getLKICopy(tgtC));
|
||||||
}
|
}
|
||||||
|
|
||||||
final String prompt = String.format("Do you want to move %s from %s to %s?", tgtC, origin, destination);
|
final String prompt = TextUtil.concatWithSpace("Do you want to move", tgtC.toString(), "from", origin.toString(), "to",destination.toString()+"?");
|
||||||
if (optional && !player.getController().confirmAction(sa, null, prompt) )
|
if (optional && !player.getController().confirmAction(sa, null, prompt) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import forge.game.ability.SpellAbilityEffect;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public class ControlPlayerEffect extends SpellAbilityEffect {
|
|||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(SpellAbility sa) {
|
||||||
|
|
||||||
List<Player> tgtPlayers = getTargetPlayers(sa);
|
List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||||
return String.format("%s controls %s during their next turn", sa.getActivatingPlayer(), Lang.joinHomogenous(tgtPlayers));
|
return TextUtil.concatWithSpace(sa.getActivatingPlayer().toString(),"controls", Lang.joinHomogenous(tgtPlayers),"during their next turn");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class CountersMoveEffect extends SpellAbilityEffect {
|
public class CountersMoveEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ public class CountersMoveEffect extends SpellAbilityEffect {
|
|||||||
try{
|
try{
|
||||||
sb.append(tgtCards.get(0));
|
sb.append(tgtCards.get(0));
|
||||||
} catch(final IndexOutOfBoundsException exception) {
|
} catch(final IndexOutOfBoundsException exception) {
|
||||||
System.out.println(String.format("Somehow this is missing targets? %s", source.toString()));
|
System.out.println(TextUtil.concatWithSpace("Somehow this is missing targets?", source.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ public class MillEffect extends SpellAbilityEffect {
|
|||||||
for (final Player p : getTargetPlayers(sa)) {
|
for (final Player p : getTargetPlayers(sa)) {
|
||||||
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
if ((tgt == null) || p.canBeTargetedBy(sa)) {
|
||||||
if (sa.hasParam("Optional")) {
|
if (sa.hasParam("Optional")) {
|
||||||
final String prompt = String.format("Do you want to put card(s) from library to %s?", destination);
|
final String prompt = TextUtil.concatWithSpace("Do you want to put card(s) from library to", destination.toString()+"?");
|
||||||
if (!p.getController().confirmAction(sa, null, prompt)) {
|
if (!p.getController().confirmAction(sa, null, prompt)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.game.ability.effects;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -150,7 +151,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
game.getAction().revealTo(tgtCard, activator);
|
game.getAction().revealTo(tgtCard, activator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optional && !controller.getController().confirmAction(sa, null, String.format("Do you want to play %s?", tgtCard))) {
|
if (optional && !controller.getController().confirmAction(sa, null, TextUtil.concatWithSpace("Do you want to play", tgtCard.toString()+"?"))) {
|
||||||
if (wasFaceDown) {
|
if (wasFaceDown) {
|
||||||
tgtCard.setState(CardStateName.FaceDown, false);
|
tgtCard.setState(CardStateName.FaceDown, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3046,7 +3046,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("c:%d tb:%d spb:%d bfc:%d", currentValue, tempBoost, semiPermanentBoost, bonusFromCounters);
|
return TextUtil.concatWithSpace("c:"+String.valueOf(currentValue),"tb:"+String.valueOf(tempBoost), "spb:"+String.valueOf(semiPermanentBoost),"bfc:"+String.valueOf(bonusFromCounters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5229,7 +5229,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
requestedCMC += xPaid;
|
requestedCMC += xPaid;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println(String.format("Illegal Split Card CMC mode %s passed to getCMC!", mode.toString()));
|
System.out.println(TextUtil.concatWithSpace("Illegal Split Card CMC mode", mode.toString(),"passed to getCMC!"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (currentStateName == CardStateName.Transformed) {
|
} else if (currentStateName == CardStateName.Transformed) {
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public class CardFactoryUtil {
|
|||||||
int counters = AbilityUtils.calculateAmount(c, timeCounters, this);
|
int counters = AbilityUtils.calculateAmount(c, timeCounters, this);
|
||||||
c.addCounter(CounterType.TIME, counters, c, true);
|
c.addCounter(CounterType.TIME, counters, c, true);
|
||||||
|
|
||||||
String sb = String.format("%s has suspended %s with %d time counters on it.", this.getActivatingPlayer(), c.getName(), counters);
|
String sb = TextUtil.concatWithSpace(this.getActivatingPlayer().toString(),"has suspended", c.getName(), "with", String.valueOf(counters),"time counters on it.");
|
||||||
game.getGameLog().add(GameLogEntryType.STACK_RESOLVE, sb);
|
game.getGameLog().add(GameLogEntryType.STACK_RESOLVE, sb);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -4249,7 +4249,7 @@ public class CardFactoryUtil {
|
|||||||
altCostSA.setRestrictions(restriction);
|
altCostSA.setRestrictions(restriction);
|
||||||
|
|
||||||
final String costDescription = params.containsKey("Description") ? params.get("Description")
|
final String costDescription = params.containsKey("Description") ? params.get("Description")
|
||||||
: String.format("You may %s rather than pay %s's mana cost.", abCost.toStringAlt(), card.getName());
|
: TextUtil.concatWithSpace("You may", abCost.toStringAlt(),"rather than pay", card.getName()+"'s mana cost.");
|
||||||
|
|
||||||
altCostSA.setDescription(costDescription);
|
altCostSA.setDescription(costDescription);
|
||||||
if (params.containsKey("References")) {
|
if (params.containsKey("References")) {
|
||||||
|
|||||||
@@ -693,13 +693,13 @@ public class CombatUtil {
|
|||||||
for (Card cardToBeBlocked : blocker.getMustBlockCards()) {
|
for (Card cardToBeBlocked : blocker.getMustBlockCards()) {
|
||||||
if (!blockedSoFar.contains(cardToBeBlocked) && CombatUtil.canBlockMoreCreatures(blocker, blockedSoFar)
|
if (!blockedSoFar.contains(cardToBeBlocked) && CombatUtil.canBlockMoreCreatures(blocker, blockedSoFar)
|
||||||
&& combat.isAttacking(cardToBeBlocked) && CombatUtil.canBlock(cardToBeBlocked, blocker)) {
|
&& combat.isAttacking(cardToBeBlocked) && CombatUtil.canBlock(cardToBeBlocked, blocker)) {
|
||||||
return String.format("%s must still block %s.", blocker, cardToBeBlocked);
|
return TextUtil.concatWithSpace(blocker.toString(),"must still block", cardToBeBlocked.toString()+".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lure effects
|
// lure effects
|
||||||
if (!blockers.contains(blocker) && CombatUtil.mustBlockAnAttacker(blocker, combat)) {
|
if (!blockers.contains(blocker) && CombatUtil.mustBlockAnAttacker(blocker, combat)) {
|
||||||
return String.format("%s must block an attacker, but has not been assigned to block any.", blocker);
|
return TextUtil.concatWithSpace(blocker.toString(),"must block an attacker, but has not been assigned to block any.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// "CARDNAME blocks each turn if able."
|
// "CARDNAME blocks each turn if able."
|
||||||
@@ -715,7 +715,7 @@ public class CombatUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (must) {
|
if (must) {
|
||||||
return String.format("%s must block each turn, but was not assigned to block any attacker now.", blocker);
|
return TextUtil.concatWithSpace(blocker.toString(),"must block each turn, but was not assigned to block any attacker now.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -725,9 +725,9 @@ public class CombatUtil {
|
|||||||
// Creatures that aren't allowed to block unless certain restrictions are met.
|
// Creatures that aren't allowed to block unless certain restrictions are met.
|
||||||
for (final Card blocker : blockers) {
|
for (final Card blocker : blockers) {
|
||||||
if (blockers.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) {
|
if (blockers.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) {
|
||||||
return String.format("%s can't block alone.", blocker);
|
return TextUtil.concatWithSpace(blocker.toString(),"can't block alone.");
|
||||||
} else if (blockers.size() < 3 && blocker.hasKeyword("CARDNAME can't block unless at least two other creatures block.")) {
|
} else if (blockers.size() < 3 && blocker.hasKeyword("CARDNAME can't block unless at least two other creatures block.")) {
|
||||||
return String.format("%s can't block unless at least two other creatures block.", blocker);
|
return TextUtil.concatWithSpace(blocker.toString(),"can't block unless at least two other creatures block.");
|
||||||
} else if (blocker.hasKeyword("CARDNAME can't block unless a creature with greater power also blocks.")) {
|
} else if (blocker.hasKeyword("CARDNAME can't block unless a creature with greater power also blocks.")) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
int power = blocker.getNetPower();
|
int power = blocker.getNetPower();
|
||||||
@@ -739,7 +739,7 @@ public class CombatUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
return String.format("%s can't block unless a creature with greater power also blocks.", blocker);
|
return TextUtil.concatWithSpace(blocker.toString(),"can't block unless a creature with greater power also blocks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -748,7 +748,7 @@ public class CombatUtil {
|
|||||||
int cntBlockers = combat.getBlockers(attacker).size();
|
int cntBlockers = combat.getBlockers(attacker).size();
|
||||||
// don't accept blocker amount for attackers with keyword defining valid blockers amount
|
// don't accept blocker amount for attackers with keyword defining valid blockers amount
|
||||||
if (cntBlockers > 0 && !canAttackerBeBlockedWithAmount(attacker, cntBlockers, combat))
|
if (cntBlockers > 0 && !canAttackerBeBlockedWithAmount(attacker, cntBlockers, combat))
|
||||||
return String.format("%s cannot be blocked with %d creatures you've assigned", attacker, cntBlockers);
|
return TextUtil.concatWithSpace(attacker.toString(),"cannot be blocked with", String.valueOf(cntBlockers), "creatures you've assigned");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import forge.game.card.Card;
|
|||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ public class CostUnattach extends CostPartWithList {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return String.format("Unattach %s", this.getTypeDescription());
|
return TextUtil.concatWithSpace("Unattach", this.getTypeDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import forge.game.card.CounterType;
|
|||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class PaymentDecision {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Payment Decision: %d, %s", c, cards);
|
return TextUtil.concatWithSpace("Payment Decision:", String.valueOf(c)+",", cards.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaymentDecision type(String choice) {
|
public static PaymentDecision type(String choice) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import forge.game.GameEntity;
|
|||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -42,6 +43,6 @@ public class GameEventBlockersDeclared extends GameEvent {
|
|||||||
blockerCards.addAll(cc);
|
blockerCards.addAll(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return String.format("%s declared %d blockers: %s", defendingPlayer.getName(), blockerCards.size(), Lang.joinHomogenous(blockerCards) );
|
return TextUtil.concatWithSpace(defendingPlayer.getName(),"declared", String.valueOf(blockerCards.size()),"blockers:", Lang.joinHomogenous(blockerCards) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.event;
|
|||||||
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class GameEventCardChangeZone extends GameEvent {
|
public class GameEventCardChangeZone extends GameEvent {
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ public class GameEventCardChangeZone extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s : [%s] -> [%s]", card, from, to);
|
return TextUtil.concatWithSpace(card.toString(),":", "["+from.toString()+"]","->", "["+to.toString()+"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.event;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -36,9 +37,9 @@ public class GameEventCardStatsChanged extends GameEvent {
|
|||||||
if ( null == card )
|
if ( null == card )
|
||||||
return "Card state changes: (empty list)";
|
return "Card state changes: (empty list)";
|
||||||
if( cards.size() == 1)
|
if( cards.size() == 1)
|
||||||
return String.format("Card state changes: %s (%s) %d/%d", card.getName(), StringUtils.join(card.getType(), ' '), card.getNetPower(), card.getNetToughness() );
|
return TextUtil.concatWithSpace("Card state changes:", card.getName(), "("+StringUtils.join(card.getType(), ' ')+")", card.getNetPower()+"/"+card.getNetToughness() );
|
||||||
else
|
else
|
||||||
return String.format("Card state changes: %s (%s) %d/%d and %d more", card.getName(), StringUtils.join(card.getType(), ' '), card.getNetPower(), card.getNetToughness(), cards.size() - 1 );
|
return TextUtil.concatWithSpace("Card state changes: %s (%s)", card.getName(), "("+StringUtils.join(card.getType(), ' ')+")", card.getNetPower()+"/"+card.getNetToughness(),"and", cards.size() - 1 +" more");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.game.event;
|
|||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -32,7 +33,7 @@ public class GameEventGameStarted extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s game between %s started. %s goes first ", gameType, Lang.joinHomogenous(players), firstTurn) ;
|
return TextUtil.concatWithSpace(gameType.toString(),"game between", Lang.joinHomogenous(players), "started.", firstTurn.toString(), "goes first ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.game.event;
|
|||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -29,6 +30,6 @@ public class GameEventManaPool extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s mana pool %s - %s ", Lang.getPossesive(player.getName()), mode, mana);
|
return TextUtil.concatWithSpace(Lang.getPossesive(player.getName()),"mana pool", mode.toString(), "-", mana.toString()+" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.event;
|
|||||||
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class GameEventPlayerLivesChanged extends GameEvent {
|
public class GameEventPlayerLivesChanged extends GameEvent {
|
||||||
public final Player player;
|
public final Player player;
|
||||||
@@ -21,6 +22,6 @@ public class GameEventPlayerLivesChanged extends GameEvent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s lives changed: %d -> %d", Lang.getPossesive(player.getName()), oldLives, newLives);
|
return TextUtil.concatWithSpace(Lang.getPossesive(player.getName()),"lives changed:", String.valueOf(oldLives),"->", String.valueOf(newLives));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.event;
|
|||||||
|
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -30,6 +31,6 @@ public class GameEventPlayerPriority extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Priority - %s", priority.getName());
|
return TextUtil.concatWithSpace("Priority -", priority.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.google.common.collect.Iterables;
|
|||||||
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This means card's characteristics have changed on server, clients must re-request them
|
* This means card's characteristics have changed on server, clients must re-request them
|
||||||
@@ -36,7 +37,7 @@ public class GameEventPlayerStatsChanged extends GameEvent {
|
|||||||
if (null == players || Iterables.isEmpty(players)) {
|
if (null == players || Iterables.isEmpty(players)) {
|
||||||
return "Player state changes: (empty list)";
|
return "Player state changes: (empty list)";
|
||||||
}
|
}
|
||||||
return String.format("Player state changes: %s", Lang.joinHomogenous(players));
|
return TextUtil.concatWithSpace("Player state changes:", Lang.joinHomogenous(players));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.game.event;
|
|||||||
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class GameEventShuffle extends GameEvent {
|
public class GameEventShuffle extends GameEvent {
|
||||||
|
|
||||||
@@ -21,6 +22,6 @@ public class GameEventShuffle extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s %s his/her/its library", player, Lang.joinVerb(player.getName(), "shuffle"));
|
return TextUtil.concatWithSpace(player.toString(), Lang.joinVerb(player.getName(), "shuffle"),"his/her/its library");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package forge.game.event;
|
package forge.game.event;
|
||||||
|
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public class GameEventTurnBegan extends GameEvent {
|
public class GameEventTurnBegan extends GameEvent {
|
||||||
|
|
||||||
@@ -23,6 +24,6 @@ public class GameEventTurnBegan extends GameEvent {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Turn %d (%s)", turnNumber, turnOwner);
|
return TextUtil.concatWithSpace("Turn", String.valueOf(turnNumber), "("+turnOwner.toString()+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package forge.game.event;
|
|||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -27,6 +28,6 @@ public class GameEventTurnPhase extends GameEvent {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String playerName = Lang.getPossesive(playerTurn.getName());
|
String playerName = Lang.getPossesive(playerTurn.getName());
|
||||||
return String.format("%s turn, %s%s phase", playerName, phaseDesc, phase.nameForUi );
|
return TextUtil.concatWithSpace(playerName,"turn,", phaseDesc+phase.nameForUi, "phase");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import forge.game.card.Card;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
@@ -35,9 +36,10 @@ public class GameEventZone extends GameEvent {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String owners = player == null ? "Game" : Lang.getPossesive(player.getName());
|
String owners = player == null ? "Game" : Lang.getPossesive(player.getName());
|
||||||
String zts = zoneType.toString();
|
return card == null
|
||||||
String ms = mode.toString();
|
? TextUtil.concatWithSpace(owners, zoneType.toString(), ":", mode.toString())
|
||||||
return String.format(card == null ? "%s %s : %s" : "%s %s : %s %s", owners, zts, ms, card);
|
: TextUtil.concatWithSpace(owners, zoneType.toString(), ":", mode.toString(), card.toString()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import forge.StaticData;
|
|||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.util.EnumUtil;
|
import forge.util.EnumUtil;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
public enum Keyword {
|
public enum Keyword {
|
||||||
UNDEFINED(SimpleKeyword.class, false, ""),
|
UNDEFINED(SimpleKeyword.class, false, ""),
|
||||||
@@ -217,7 +218,7 @@ public enum Keyword {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return String.format("%s (%s)", displayName, reminderText);
|
return TextUtil.concatWithSpace(displayName," ("+reminderText+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Keyword> getAllKeywords() {
|
public static List<Keyword> getAllKeywords() {
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ public class Kicker extends KeywordWithCost {
|
|||||||
return super.formatReminderText(reminderText);
|
return super.formatReminderText(reminderText);
|
||||||
}
|
}
|
||||||
//handle special case of double kicker
|
//handle special case of double kicker
|
||||||
return String.format("You may pay an additional %s and/or %s as you cast this spell.",
|
return TextUtil.concatWithSpace("You may pay an additional", cost.toSimpleString(),"and/or", cost2.toSimpleString(),"as you cast this spell.");
|
||||||
cost.toSimpleString(),
|
|
||||||
cost2.toSimpleString()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import forge.game.trigger.Trigger;
|
|||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.CollectionSuppliers;
|
import forge.util.CollectionSuppliers;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
import forge.util.maps.HashMapOfLists;
|
import forge.util.maps.HashMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -985,7 +986,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
if (game.isGameOver() || nextPlayer == null) { return; } // conceded?
|
if (game.isGameOver() || nextPlayer == null) { return; } // conceded?
|
||||||
|
|
||||||
if (DEBUG_PHASES) {
|
if (DEBUG_PHASES) {
|
||||||
System.out.println(String.format("%s %s: %s is active, previous was %s", playerTurn, phase, pPlayerPriority, nextPlayer));
|
System.out.println(TextUtil.concatWithSpace(playerTurn.toString(),phase.toString()+":", pPlayerPriority.toString(),"is active, previous was", nextPlayer.toString()));
|
||||||
}
|
}
|
||||||
if (pFirstPriority == nextPlayer) {
|
if (pFirstPriority == nextPlayer) {
|
||||||
if (game.getStack().isEmpty()) {
|
if (game.getStack().isEmpty()) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import forge.card.CardType;
|
|||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.game.card.CounterType;
|
import forge.game.card.CounterType;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@@ -109,8 +110,8 @@ public class PlayerView extends GameEntityView {
|
|||||||
for (final PlayerView p : Iterables.concat(Collections.singleton(this), opponents)) {
|
for (final PlayerView p : Iterables.concat(Collections.singleton(this), opponents)) {
|
||||||
final int damage = p.getCommanderDamage(v);
|
final int damage = p.getCommanderDamage(v);
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
final String text = String.format("Commander damage to %s from %s:", p, v.getName());
|
final String text = TextUtil.concatWithSpace("Commander damage to", p.toString(),"from", v.getName()+":");
|
||||||
sb.append(String.format(text + " %d\r\n", damage));
|
sb.append(TextUtil.concatWithSpace(text, String.valueOf(damage)+"\r\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -124,18 +125,18 @@ public class PlayerView extends GameEntityView {
|
|||||||
|
|
||||||
final FCollectionView<PlayerView> opponents = getOpponents();
|
final FCollectionView<PlayerView> opponents = getOpponents();
|
||||||
final List<String> info = Lists.newArrayListWithExpectedSize(opponents.size());
|
final List<String> info = Lists.newArrayListWithExpectedSize(opponents.size());
|
||||||
info.add(String.format("Commanders: %s", Lang.joinHomogenous(commanders)));
|
info.add(TextUtil.concatWithSpace("Commanders:", Lang.joinHomogenous(commanders)));
|
||||||
for (final PlayerView p : Iterables.concat(Collections.singleton(this), opponents)) {
|
for (final PlayerView p : Iterables.concat(Collections.singleton(this), opponents)) {
|
||||||
for (final CardView v : p.getCommanders()) {
|
for (final CardView v : p.getCommanders()) {
|
||||||
final int damage = this.getCommanderDamage(v);
|
final int damage = this.getCommanderDamage(v);
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
final String text;
|
final String text;
|
||||||
if (p.equals(this)) {
|
if (p.equals(this)) {
|
||||||
text = String.format("Commander damage from own commander %s:", v);
|
text = TextUtil.concatWithSpace("Commander damage from own commander", v.toString()+":");
|
||||||
} else {
|
} else {
|
||||||
text = String.format("Commander damage from %s's %s:", p, v);
|
text = TextUtil.concatWithSpace("Commander damage from", p.toString()+"'s", v.toString()+":");
|
||||||
}
|
}
|
||||||
info.add(String.format(text + " %d\r\n", damage));
|
info.add(TextUtil.concatWithSpace(text,String.valueOf(damage)+"\r\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,27 +384,27 @@ public class PlayerView extends GameEntityView {
|
|||||||
|
|
||||||
private List<String> getDetailsList() {
|
private List<String> getDetailsList() {
|
||||||
final List<String> details = Lists.newArrayListWithCapacity(8);
|
final List<String> details = Lists.newArrayListWithCapacity(8);
|
||||||
details.add(String.format("Life: %d", getLife()));
|
details.add(TextUtil.concatWithSpace("Life:", String.valueOf(getLife())));
|
||||||
|
|
||||||
Map<CounterType, Integer> counters = getCounters();
|
Map<CounterType, Integer> counters = getCounters();
|
||||||
if (counters != null) {
|
if (counters != null) {
|
||||||
for (Entry<CounterType, Integer> p : counters.entrySet()) {
|
for (Entry<CounterType, Integer> p : counters.entrySet()) {
|
||||||
if (p.getValue() > 0) {
|
if (p.getValue() > 0) {
|
||||||
details.add(String.format("%s counters: %d", p.getKey().getName(), p.getValue()));
|
details.add(TextUtil.concatWithSpace(p.getKey().getName(), "counters:", String.valueOf(p.getValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
details.add(String.format("Cards in hand: %d/%s", getHandSize(), getMaxHandString()));
|
details.add(TextUtil.concatNoSpace("Cards in hand: ", String.valueOf(getHandSize())+"/", getMaxHandString()));
|
||||||
details.add(String.format("Cards drawn this turn: %d", getNumDrawnThisTurn()));
|
details.add(TextUtil.concatWithSpace("Cards drawn this turn:", String.valueOf(getNumDrawnThisTurn())));
|
||||||
details.add(String.format("Damage prevention: %d", getPreventNextDamage()));
|
details.add(TextUtil.concatWithSpace("Damage prevention:", String.valueOf(getPreventNextDamage())));
|
||||||
final String keywords = Lang.joinHomogenous(getDisplayableKeywords());
|
final String keywords = Lang.joinHomogenous(getDisplayableKeywords());
|
||||||
if (!keywords.isEmpty()) {
|
if (!keywords.isEmpty()) {
|
||||||
details.add(keywords);
|
details.add(keywords);
|
||||||
}
|
}
|
||||||
final FCollectionView<CardView> ante = getAnte();
|
final FCollectionView<CardView> ante = getAnte();
|
||||||
if (ante != null && !ante.isEmpty()) {
|
if (ante != null && !ante.isEmpty()) {
|
||||||
details.add(String.format("Ante'd: %s", Lang.joinHomogenous(ante)));
|
details.add(TextUtil.concatWithSpace("Ante'd:", Lang.joinHomogenous(ante)));
|
||||||
}
|
}
|
||||||
details.addAll(getPlayerCommanderInfo());
|
details.addAll(getPlayerCommanderInfo());
|
||||||
return details;
|
return details;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.Visitor;
|
import forge.util.Visitor;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -241,8 +242,8 @@ public class ReplacementHandler {
|
|||||||
Card cardForUi = host.getCardForUi();
|
Card cardForUi = host.getCardForUi();
|
||||||
String effectDesc = replacementEffect.toString().replace("CARDNAME", cardForUi.getName());
|
String effectDesc = replacementEffect.toString().replace("CARDNAME", cardForUi.getName());
|
||||||
final String question = replacementEffect instanceof ReplaceDiscard
|
final String question = replacementEffect instanceof ReplaceDiscard
|
||||||
? String.format("Apply replacement effect of %s to %s?\r\n(%s)", cardForUi, runParams.get("Card").toString(), effectDesc)
|
? TextUtil.concatWithSpace("Apply replacement effect of", cardForUi.toString(), "to", runParams.get("Card").toString()+"?", "\r\n(", effectDesc+")")
|
||||||
: String.format("Apply replacement effect of %s?\r\n(%s)", cardForUi, effectDesc);
|
: TextUtil.concatWithSpace("Apply replacement effect of", cardForUi.toString()+"?", "\r\n(", effectDesc+")");
|
||||||
boolean confirmed = optDecider.getController().confirmReplacementEffect(replacementEffect, effectSA, question);
|
boolean confirmed = optDecider.getController().confirmReplacementEffect(replacementEffect, effectSA, question);
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return ReplacementResult.NotReplaced;
|
return ReplacementResult.NotReplaced;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import forge.game.trigger.Trigger;
|
|||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.trigger.WrappedAbility;
|
import forge.game.trigger.WrappedAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -414,7 +415,7 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s->%s", getSourceCard(), getStackDescription());
|
return TextUtil.concatNoSpace(getSourceCard().toString(), "->", getStackDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackItemView getView() {
|
public StackItemView getView() {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package forge.game.trigger;
|
package forge.game.trigger;
|
||||||
|
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -35,6 +37,6 @@ public class TriggerWaiting {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Waiting trigger: %s with %s", mode, params);
|
return TextUtil.concatWithSpace("Waiting trigger:", mode.toString(),"with", params.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import forge.game.spellability.TargetChoices;
|
|||||||
import forge.game.trigger.Trigger;
|
import forge.game.trigger.Trigger;
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.trigger.WrappedAbility;
|
import forge.game.trigger.WrappedAbility;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -284,7 +285,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
boolean hasPaid = false;
|
boolean hasPaid = false;
|
||||||
do {
|
do {
|
||||||
int mkMagnitude = source.getPseudoKickerMagnitude();
|
int mkMagnitude = source.getPseudoKickerMagnitude();
|
||||||
String prompt = String.format("Additional Cost for %s\r\nTimes Kicked: %d\r\n", source, mkMagnitude );
|
String prompt = TextUtil.concatWithSpace("Additional Cost for",source.toString(),"\r\nTimes Kicked:", String.valueOf(mkMagnitude),"\r\n");
|
||||||
hasPaid = activator.getController().payManaOptional(source, costPseudoKicker, sp, prompt, ManaPaymentPurpose.Multikicker);
|
hasPaid = activator.getController().payManaOptional(source, costPseudoKicker, sp, prompt, ManaPaymentPurpose.Multikicker);
|
||||||
if (hasPaid) {
|
if (hasPaid) {
|
||||||
source.addPseudoMultiKickerMagnitude(1);
|
source.addPseudoMultiKickerMagnitude(1);
|
||||||
@@ -324,7 +325,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
boolean hasPaid = false;
|
boolean hasPaid = false;
|
||||||
int replicateCMC = source.getManaCost().getCMC();
|
int replicateCMC = source.getManaCost().getCMC();
|
||||||
do {
|
do {
|
||||||
String prompt = String.format("Replicate for %s\r\nTimes Replicated: %d\r\n", source, magnitude);
|
String prompt = TextUtil.concatWithSpace("Replicate for", source.toString(),"\r\nTimes Replicated:", magnitude.toString(),"\r\n");
|
||||||
hasPaid = activator.getController().payManaOptional(source, costReplicate, sp, prompt, ManaPaymentPurpose.Replicate);
|
hasPaid = activator.getController().payManaOptional(source, costReplicate, sp, prompt, ManaPaymentPurpose.Replicate);
|
||||||
if (hasPaid) {
|
if (hasPaid) {
|
||||||
magnitude++;
|
magnitude++;
|
||||||
@@ -334,7 +335,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replicate Trigger
|
// Replicate Trigger
|
||||||
String effect = String.format("DB$ CopySpellAbility | Cost$ 0 | Defined$ Parent | Amount$ %d", magnitude);
|
String effect = TextUtil.concatWithSpace("DB$ CopySpellAbility | Cost$ 0 | Defined$ Parent | Amount$", magnitude.toString());
|
||||||
AbilitySub sa = (AbilitySub) AbilityFactory.getAbility(effect, source);
|
AbilitySub sa = (AbilitySub) AbilityFactory.getAbility(effect, source);
|
||||||
sa.setParent(sp);
|
sa.setParent(sp);
|
||||||
sa.setDescription("Replicate - " + source);
|
sa.setDescription("Replicate - " + source);
|
||||||
@@ -917,6 +918,6 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s==%s==%s", simultaneousStackEntryList, frozenStack.toString(), stack.toString());
|
return TextUtil.concatNoSpace(simultaneousStackEntryList.toString(),"==", frozenStack.toString(), "==", stack.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import forge.game.card.CardLists;
|
|||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -101,7 +102,7 @@ public class PlayerZone extends Zone {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return String.format("%s %s", Lang.getPossesive(player.toString()), zoneType);
|
return TextUtil.concatWithSpace(Lang.getPossesive(player.toString()), zoneType.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardCollectionView getCardsPlayerCanActivate(Player who) {
|
public CardCollectionView getCardsPlayerCanActivate(Player who) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.player.PlayerView;
|
import forge.game.player.PlayerView;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
|
|
||||||
public class MessageUtil {
|
public class MessageUtil {
|
||||||
private MessageUtil() { };
|
private MessageUtil() { };
|
||||||
|
|
||||||
@@ -39,26 +40,27 @@ public class MessageUtil {
|
|||||||
if (sa.hasParam("SecretlyChoose")) {
|
if (sa.hasParam("SecretlyChoose")) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
final boolean random = sa.hasParam("Random");
|
return sa.hasParam("Random")
|
||||||
return String.format(random ? "Randomly chosen number for %s is %s" : "%s chooses number: %s", mayBeYou(player, target), value);
|
? TextUtil.concatWithSpace("Randomly chosen number for", mayBeYou(player, target),"is", value)
|
||||||
|
: TextUtil.concatWithSpace( mayBeYou(player, target),"chooses number:", value);
|
||||||
case ChooseType:
|
case ChooseType:
|
||||||
return String.format("%s %s %s for effect of %s", choser, Lang.joinVerb(choser, "choose"), value, sa.getHostCard().getName());
|
return TextUtil.concatWithSpace(choser, Lang.joinVerb(choser, "choose"), value, "for effect of", sa.getHostCard().getName());
|
||||||
case FlipACoin:
|
case FlipACoin:
|
||||||
String flipper = StringUtils.capitalize(mayBeYou(player, target));
|
String flipper = StringUtils.capitalize(mayBeYou(player, target));
|
||||||
return sa.hasParam("NoCall")
|
return sa.hasParam("NoCall")
|
||||||
? String.format("%s flip comes up %s", Lang.getPossesive(flipper), value)
|
? TextUtil.concatWithSpace(Lang.getPossesive(flipper),"flip comes up", value)
|
||||||
: String.format("%s %s the flip", flipper, Lang.joinVerb(flipper, value));
|
: TextUtil.concatWithSpace(flipper, Lang.joinVerb(flipper, value), "the flip");
|
||||||
case Protection:
|
case Protection:
|
||||||
return String.format("%s %s protection from %s", choser, Lang.joinVerb(choser, "choose"), value);
|
return TextUtil.concatWithSpace(choser, Lang.joinVerb(choser, "choose"), value);
|
||||||
case Vote:
|
case Vote:
|
||||||
String chooser = StringUtils.capitalize(mayBeYou(player, target));
|
String chooser = StringUtils.capitalize(mayBeYou(player, target));
|
||||||
return String.format("%s %s %s", chooser, Lang.joinVerb(chooser, "vote"), value);
|
return TextUtil.concatWithSpace(chooser, Lang.joinVerb(chooser,"vote"), value);
|
||||||
default:
|
default:
|
||||||
String tgt = mayBeYou(player, target);
|
String tgt = mayBeYou(player, target);
|
||||||
if (tgt.equals("(null)")) {
|
if (tgt.equals("(null)")) {
|
||||||
return String.format("%s effect's value is %s", sa.getHostCard().getName(), value);
|
return TextUtil.concatWithSpace(sa.getHostCard().getName(),"effect's value is", value);
|
||||||
} else {
|
} else {
|
||||||
return String.format("%s effect's value for %s is %s", sa.getHostCard().getName(), tgt, value);
|
return TextUtil.concatWithSpace(sa.getHostCard().getName(),"effect's value for", tgt,"is", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user