Finalization for Refactoring

This commit is contained in:
Anthony Calosa
2019-09-06 12:55:40 +08:00
parent f5eb14afaa
commit e977420ffa
89 changed files with 312 additions and 393 deletions

View File

@@ -103,8 +103,7 @@ public class AiAttackController {
} // overloaded constructor to evaluate single specified attacker } // overloaded constructor to evaluate single specified attacker
public static List<Card> getOpponentCreatures(final Player defender) { public static List<Card> getOpponentCreatures(final Player defender) {
List<Card> defenders = new ArrayList<>(); List<Card> defenders = new ArrayList<>(defender.getCreaturesInPlay());
defenders.addAll(defender.getCreaturesInPlay());
Predicate<Card> canAnimate = new Predicate<Card>() { Predicate<Card> canAnimate = new Predicate<Card>() {
@Override @Override
public boolean apply(Card c) { public boolean apply(Card c) {

View File

@@ -148,9 +148,7 @@ public class AiBlockController {
final CardCollection attackers = combat.getAttackersOf(defender); final CardCollection attackers = combat.getAttackersOf(defender);
// Begin with the attackers that pose the biggest threat // Begin with the attackers that pose the biggest threat
CardLists.sortByPowerDesc(attackers); CardLists.sortByPowerDesc(attackers);
for (final Card c : attackers) { sortedAttackers.addAll(attackers);
sortedAttackers.add(c);
}
} else if (defender instanceof Player && defender.equals(ai)) { } else if (defender instanceof Player && defender.equals(ai)) {
firstAttacker = combat.getAttackersOf(defender); firstAttacker = combat.getAttackersOf(defender);
} }
@@ -163,9 +161,7 @@ public class AiBlockController {
} }
} else { } else {
// add creatures attacking the Player to the back of the list // add creatures attacking the Player to the back of the list
for (final Card c : firstAttacker) { sortedAttackers.addAll(firstAttacker);
sortedAttackers.add(c);
}
} }
return sortedAttackers; return sortedAttackers;
} }
@@ -481,8 +477,7 @@ public class AiBlockController {
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker) final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, secondBlocker, combat, false); + ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, secondBlocker, combat, false);
List<Card> usableBlockersAsThird = new ArrayList<>(); List<Card> usableBlockersAsThird = new ArrayList<>(usableBlockers);
usableBlockersAsThird.addAll(usableBlockers);
usableBlockersAsThird.remove(secondBlocker); usableBlockersAsThird.remove(secondBlocker);
// loop over the remaining blockers in search of a good third blocker candidate // loop over the remaining blockers in search of a good third blocker candidate

View File

@@ -2283,8 +2283,7 @@ public class ComputerUtil {
chosen = ComputerUtilCard.getMostProminentType(list, valid); chosen = ComputerUtilCard.getMostProminentType(list, valid);
} else if (logic.equals("MostNeededType")) { } else if (logic.equals("MostNeededType")) {
// Choose a type that is in the deck, but not in hand or on the battlefield // Choose a type that is in the deck, but not in hand or on the battlefield
final List<String> basics = new ArrayList<>(); final List<String> basics = new ArrayList<>(CardType.Constant.BASIC_TYPES);
basics.addAll(CardType.Constant.BASIC_TYPES);
CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand)); CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
CardCollectionView possibleCards = ai.getAllCards(); CardCollectionView possibleCards = ai.getAllCards();

View File

@@ -254,7 +254,7 @@ public abstract class GameState {
newText.append(";"); newText.append(";");
} }
if (c.isToken()) { if (c.isToken()) {
newText.append("t:" + new TokenInfo(c).toString()); newText.append("t:").append(new TokenInfo(c).toString());
} else { } else {
if (c.getPaperCard() == null) { if (c.getPaperCard() == null) {
return; return;
@@ -377,7 +377,7 @@ public abstract class GameState {
newText.append("|Attacking"); newText.append("|Attacking");
GameEntity def = c.getGame().getCombat().getDefenderByAttacker(c); GameEntity def = c.getGame().getCombat().getDefenderByAttacker(c);
if (def instanceof Card) { if (def instanceof Card) {
newText.append(":" + def.getId()); newText.append(":").append(def.getId());
} }
} }
} }
@@ -653,15 +653,15 @@ public abstract class GameState {
} }
private String processManaPool(ManaPool manaPool) { private String processManaPool(ManaPool manaPool) {
String mana = ""; StringBuilder mana = new StringBuilder();
for (final byte c : MagicColor.WUBRGC) { for (final byte c : MagicColor.WUBRGC) {
int amount = manaPool.getAmountOfColor(c); int amount = manaPool.getAmountOfColor(c);
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
mana += MagicColor.toShortString(c) + " "; mana.append(MagicColor.toShortString(c)).append(" ");
} }
} }
return mana.trim(); return mana.toString().trim();
} }
private void updateManaPool(Player p, String manaDef, boolean clearPool, boolean persistent) { private void updateManaPool(Player p, String manaDef, boolean clearPool, boolean persistent) {

View File

@@ -31,10 +31,7 @@ import forge.game.trigger.TriggerType;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.util.MyRandom; import forge.util.MyRandom;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class AttachAi extends SpellAbilityAi { public class AttachAi extends SpellAbilityAi {
@@ -875,15 +872,11 @@ public class AttachAi extends SpellAbilityAi {
String kws = stabMap.get("AddKeyword"); String kws = stabMap.get("AddKeyword");
if (kws != null) { if (kws != null) {
for (final String kw : kws.split(" & ")) { keywords.addAll(Arrays.asList(kws.split(" & ")));
keywords.add(kw);
}
} }
kws = stabMap.get("AddHiddenKeyword"); kws = stabMap.get("AddHiddenKeyword");
if (kws != null) { if (kws != null) {
for (final String kw : kws.split(" & ")) { keywords.addAll(Arrays.asList(kws.split(" & ")));
keywords.add(kw);
}
} }
} }
} }
@@ -1173,15 +1166,11 @@ public class AttachAi extends SpellAbilityAi {
String kws = stabMap.get("AddKeyword"); String kws = stabMap.get("AddKeyword");
if (kws != null) { if (kws != null) {
for (final String kw : kws.split(" & ")) { keywords.addAll(Arrays.asList(kws.split(" & ")));
keywords.add(kw);
}
} }
kws = stabMap.get("AddHiddenKeyword"); kws = stabMap.get("AddHiddenKeyword");
if (kws != null) { if (kws != null) {
for (final String kw : kws.split(" & ")) { keywords.addAll(Arrays.asList(kws.split(" & ")));
keywords.add(kw);
}
} }
} }
} }

View File

@@ -403,7 +403,7 @@ public class TokenAi extends SpellAbilityAi {
String tokenToughness = sa.getParam("TokenToughness"); String tokenToughness = sa.getParam("TokenToughness");
String tokenName = sa.getParam("TokenName"); String tokenName = sa.getParam("TokenName");
String[] tokenTypes = sa.getParam("TokenTypes").split(","); String[] tokenTypes = sa.getParam("TokenTypes").split(",");
String cost = ""; StringBuilder cost = new StringBuilder();
String[] tokenColors = sa.getParam("TokenColors").split(","); String[] tokenColors = sa.getParam("TokenColors").split(",");
String tokenImage = sa.hasParam("TokenImage") ? PaperToken.makeTokenFileName(sa.getParam("TokenImage")) : ""; String tokenImage = sa.hasParam("TokenImage") ? PaperToken.makeTokenFileName(sa.getParam("TokenImage")) : "";
String[] tokenAbilities = sa.hasParam("TokenAbilities") ? sa.getParam("TokenAbilities").split(",") : null; String[] tokenAbilities = sa.hasParam("TokenAbilities") ? sa.getParam("TokenAbilities").split(",") : null;
@@ -418,35 +418,35 @@ public class TokenAi extends SpellAbilityAi {
substitutedColors[i] = host.getChosenColor(); substitutedColors[i] = host.getChosenColor();
} }
} }
String colorDesc = ""; StringBuilder colorDesc = new StringBuilder();
for (final String col : substitutedColors) { for (final String col : substitutedColors) {
if (col.equalsIgnoreCase("White")) { if (col.equalsIgnoreCase("White")) {
colorDesc += "W "; colorDesc.append("W ");
} else if (col.equalsIgnoreCase("Blue")) { } else if (col.equalsIgnoreCase("Blue")) {
colorDesc += "U "; colorDesc.append("U ");
} else if (col.equalsIgnoreCase("Black")) { } else if (col.equalsIgnoreCase("Black")) {
colorDesc += "B "; colorDesc.append("B ");
} else if (col.equalsIgnoreCase("Red")) { } else if (col.equalsIgnoreCase("Red")) {
colorDesc += "R "; colorDesc.append("R ");
} else if (col.equalsIgnoreCase("Green")) { } else if (col.equalsIgnoreCase("Green")) {
colorDesc += "G "; colorDesc.append("G ");
} else if (col.equalsIgnoreCase("Colorless")) { } else if (col.equalsIgnoreCase("Colorless")) {
colorDesc = "C"; colorDesc = new StringBuilder("C");
} }
} }
final List<String> imageNames = new ArrayList<>(1); final List<String> imageNames = new ArrayList<>(1);
if (tokenImage.equals("")) { if (tokenImage.equals("")) {
imageNames.add(PaperToken.makeTokenFileName(TextUtil.fastReplace(colorDesc, " ", ""), tokenPower, tokenToughness, tokenName)); imageNames.add(PaperToken.makeTokenFileName(TextUtil.fastReplace(colorDesc.toString(), " ", ""), tokenPower, tokenToughness, tokenName));
} else { } else {
imageNames.add(0, tokenImage); imageNames.add(0, tokenImage);
} }
for (final char c : colorDesc.toCharArray()) { for (final char c : colorDesc.toString().toCharArray()) {
cost += c + ' '; cost.append(c + ' ');
} }
cost = colorDesc.replace('C', '1').trim(); cost = new StringBuilder(colorDesc.toString().replace('C', '1').trim());
final int finalPower = AbilityUtils.calculateAmount(host, tokenPower, sa); final int finalPower = AbilityUtils.calculateAmount(host, tokenPower, sa);
final int finalToughness = AbilityUtils.calculateAmount(host, tokenToughness, sa); final int finalToughness = AbilityUtils.calculateAmount(host, tokenToughness, sa);
@@ -460,7 +460,7 @@ public class TokenAi extends SpellAbilityAi {
final String substitutedName = tokenName.equals("ChosenType") ? host.getChosenType() : tokenName; final String substitutedName = tokenName.equals("ChosenType") ? host.getChosenType() : tokenName;
final String imageName = imageNames.get(MyRandom.getRandom().nextInt(imageNames.size())); final String imageName = imageNames.get(MyRandom.getRandom().nextInt(imageNames.size()));
final TokenInfo tokenInfo = new TokenInfo(substitutedName, imageName, final TokenInfo tokenInfo = new TokenInfo(substitutedName, imageName,
cost, substitutedTypes, tokenKeywords, finalPower, finalToughness); cost.toString(), substitutedTypes, tokenKeywords, finalPower, finalToughness);
Card token = tokenInfo.makeOneToken(ai); Card token = tokenInfo.makeOneToken(ai);
if (token == null) { if (token == null) {

View File

@@ -270,28 +270,28 @@ public class SpellAbilityPicker {
return abilityToString(sa, true); return abilityToString(sa, true);
} }
public static String abilityToString(SpellAbility sa, boolean withTargets) { public static String abilityToString(SpellAbility sa, boolean withTargets) {
String saString = "N/A"; StringBuilder saString = new StringBuilder("N/A");
if (sa != null) { if (sa != null) {
saString = sa.toString(); saString = new StringBuilder(sa.toString());
String cardName = sa.getHostCard().getName(); String cardName = sa.getHostCard().getName();
if (!cardName.isEmpty()) { if (!cardName.isEmpty()) {
saString = TextUtil.fastReplace(saString, cardName, "<$>"); saString = new StringBuilder(TextUtil.fastReplace(saString.toString(), cardName, "<$>"));
} }
if (saString.length() > 40) { if (saString.length() > 40) {
saString = saString.substring(0, 40) + "..."; saString = new StringBuilder(saString.substring(0, 40) + "...");
} }
if (withTargets) { if (withTargets) {
SpellAbility saOrSubSa = sa; SpellAbility saOrSubSa = sa;
do { do {
if (saOrSubSa.usesTargeting()) { if (saOrSubSa.usesTargeting()) {
saString += " (targets: " + saOrSubSa.getTargets().getTargetedString() + ")"; saString.append(" (targets: ").append(saOrSubSa.getTargets().getTargetedString()).append(")");
} }
saOrSubSa = saOrSubSa.getSubAbility(); saOrSubSa = saOrSubSa.getSubAbility();
} while (saOrSubSa != null); } while (saOrSubSa != null);
} }
saString = sa.getHostCard() + " -> " + saString; saString.insert(0, sa.getHostCard() + " -> ");
} }
return saString; return saString.toString();
} }
private boolean shouldWaitForLater(final SpellAbility sa) { private boolean shouldWaitForLater(final SpellAbility sa) {

View File

@@ -114,7 +114,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (this.genericCost > 0) { if (this.genericCost > 0) {
sb.append("{" + this.genericCost + "}"); sb.append("{").append(this.genericCost).append("}");
} }
for (final ManaCostShard s : this.shards) { for (final ManaCostShard s : this.shards) {
if (s == ManaCostShard.X) { if (s == ManaCostShard.X) {
@@ -251,7 +251,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(mc.hasNoCost ? -1 : mc.genericCost); builder.append(mc.hasNoCost ? -1 : mc.genericCost);
for (ManaCostShard shard : mc.shards) { for (ManaCostShard shard : mc.shards) {
builder.append(DELIM + shard.name()); builder.append(DELIM).append(shard.name());
} }
return builder.toString(); return builder.toString();
} }

View File

@@ -119,9 +119,7 @@ public class DeckGroup extends DeckBase {
* @param computer the computer * @param computer the computer
*/ */
public void addAiDecks(final Deck[] computer) { public void addAiDecks(final Deck[] computer) {
for (final Deck element : computer) { aiDecks.addAll(Arrays.asList(computer));
aiDecks.add(element);
}
} }
/* /*

View File

@@ -38,7 +38,7 @@ public class TextUtil {
} else { } else {
mapAsString.append("; "); mapAsString.append("; ");
} }
mapAsString.append(p.getKey() + " => " + (p.getValue() == null ? "(null)" : p.getValue().toString())); mapAsString.append(p.getKey()).append(" => ").append(p.getValue() == null ? "(null)" : p.getValue().toString());
} }
return mapAsString.toString(); return mapAsString.toString();
} }

View File

@@ -9,15 +9,7 @@ import com.google.common.collect.Sets;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.Set;
/** /**
* Collection with unique elements ({@link Set}) that maintains the order in * Collection with unique elements ({@link Set}) that maintains the order in
@@ -73,9 +65,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
* creation. * creation.
*/ */
public FCollection(final T[] c) { public FCollection(final T[] c) {
for (final T e : c) { this.addAll(Arrays.asList(c));
add(e);
}
} }
/** /**
@@ -87,9 +77,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
* creation. * creation.
*/ */
public FCollection(final Iterable<? extends T> i) { public FCollection(final Iterable<? extends T> i) {
for (final T e : i) { this.addAll(i);
add(e);
}
} }
/** /**

View File

@@ -229,11 +229,11 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
continue; continue;
} }
if (sb.length() > 0) sb.append("\n"); if (sb.length() > 0) sb.append("\n");
sb.append(ev.player + " assigned " + Lang.joinHomogenous(attackers)); sb.append(ev.player).append(" assigned ").append(Lang.joinHomogenous(attackers));
sb.append(" to attack " + k + "."); sb.append(" to attack ").append(k).append(".");
} }
if (sb.length() == 0) { if (sb.length() == 0) {
sb.append(ev.player + " didn't attack this turn."); sb.append(ev.player).append(" didn't attack this turn.");
} }
return new GameLogEntry(GameLogEntryType.COMBAT, sb.toString()); return new GameLogEntry(GameLogEntryType.COMBAT, sb.toString());
} }
@@ -265,10 +265,10 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
blockers = att.getValue(); blockers = att.getValue();
if (blockers.isEmpty()) { if (blockers.isEmpty()) {
sb.append(controllerName + " didn't block "); sb.append(controllerName).append(" didn't block ");
} }
else { else {
sb.append(controllerName + " assigned " + Lang.joinHomogenous(blockers) + " to block "); sb.append(controllerName).append(" assigned ").append(Lang.joinHomogenous(blockers)).append(" to block ");
} }
sb.append(att.getKey()).append("."); sb.append(att.getKey()).append(".");

View File

@@ -149,9 +149,7 @@ public class AbilityUtils {
if (crd instanceof Card) { if (crd instanceof Card) {
c = game.getCardState((Card) crd); c = game.getCardState((Card) crd);
} else if (crd instanceof Iterable) { } else if (crd instanceof Iterable) {
for (final Card cardItem : Iterables.filter((Iterable<?>) crd, Card.class)) { cards.addAll(Iterables.filter((Iterable<?>) crd, Card.class));
cards.add(cardItem);
}
} }
} }
} }
@@ -161,9 +159,7 @@ public class AbilityUtils {
if (crd instanceof Card) { if (crd instanceof Card) {
c = game.getCardState((Card) crd); c = game.getCardState((Card) crd);
} else if (crd instanceof List<?>) { } else if (crd instanceof List<?>) {
for (final Card cardItem : (CardCollection) crd) { cards.addAll((CardCollection) crd);
cards.add(cardItem);
}
} }
} }
else if (defined.equals("Remembered") || defined.equals("RememberedCard")) { else if (defined.equals("Remembered") || defined.equals("RememberedCard")) {
@@ -530,9 +526,7 @@ public class AbilityUtils {
} }
if (calcX[0].endsWith("LKI")) { // last known information if (calcX[0].endsWith("LKI")) { // last known information
for (final Card c : newCard.getImprintedCards()) { list.addAll(newCard.getImprintedCards());
list.add(c);
}
} }
else { else {
for (final Card c : newCard.getImprintedCards()) { for (final Card c : newCard.getImprintedCards()) {

View File

@@ -83,7 +83,7 @@ public abstract class SpellAbilityEffect {
"CARDNAME", sa.getHostCard().getName())); "CARDNAME", sa.getHostCard().getName()));
} }
if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) { if (sa.getTargets() != null && !sa.getTargets().getTargets().isEmpty()) {
sb.append(" (Targeting: " + sa.getTargets().getTargets() + ")"); sb.append(" (Targeting: ").append(sa.getTargets().getTargets()).append(")");
} }
} else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output } else if (!"None".equalsIgnoreCase(stackDesc)) { // by typing "none" they want to suppress output
makeSpellDescription(sa, sb, stackDesc); makeSpellDescription(sa, sb, stackDesc);
@@ -258,7 +258,7 @@ public abstract class SpellAbilityEffect {
if (your) { if (your) {
delTrig.append("| ValidPlayer$ You "); delTrig.append("| ValidPlayer$ You ");
} }
delTrig.append("| TriggerDescription$ " + desc); delTrig.append("| TriggerDescription$ ").append(desc);
final Trigger trig = TriggerHandler.parseTrigger(delTrig.toString(), sa.getHostCard(), intrinsic); final Trigger trig = TriggerHandler.parseTrigger(delTrig.toString(), sa.getHostCard(), intrinsic);
for (final Card c : crds) { for (final Card c : crds) {

View File

@@ -876,9 +876,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, 0, changeNum, delayedReveal, selectPrompt, decider); selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, 0, changeNum, delayedReveal, selectPrompt, decider);
} while (selectedCards != null && selectedCards.size() > changeNum); } while (selectedCards != null && selectedCards.size() > changeNum);
if (selectedCards != null) { if (selectedCards != null) {
for (Card card : selectedCards) { chosenCards.addAll(selectedCards);
chosenCards.add(card);
}
} }
// maybe prompt the user if they selected fewer than the maximum possible? // maybe prompt the user if they selected fewer than the maximum possible?
} else { } else {

View File

@@ -40,7 +40,7 @@ public class CloneEffect extends SpellAbilityEffect {
} }
sb.append(tgtCard); sb.append(tgtCard);
sb.append(" becomes a copy of " + cardToCopy + "."); sb.append(" becomes a copy of ").append(cardToCopy).append(".");
return sb.toString(); return sb.toString();
} // end cloneStackDescription() } // end cloneStackDescription()

View File

@@ -108,10 +108,8 @@ public class DamageDealEffect extends DamageBaseEffect {
} }
// Can't radiate from a player // Can't radiate from a player
if (origin != null) { if (origin != null) {
for (final Card c : CardUtil.getRadiance(hostCard, origin, tgts.addAll(CardUtil.getRadiance(hostCard, origin,
sa.getParam("ValidTgts").split(","))) { sa.getParam("ValidTgts").split(",")));
tgts.add(c);
}
} }
} }

View File

@@ -81,9 +81,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
} }
if (origin != null) { if (origin != null) {
// Can't radiate from a player // Can't radiate from a player
for (final Card c : CardUtil.getRadiance(host, origin, sa.getParam("ValidTgts").split(","))) { untargetedCards.addAll(CardUtil.getRadiance(host, origin, sa.getParam("ValidTgts").split(",")));
untargetedCards.add(c);
}
} }
} }

View File

@@ -78,10 +78,8 @@ public class DestroyEffect extends SpellAbilityEffect {
CardCollection untargetedCards = new CardCollection(); CardCollection untargetedCards = new CardCollection();
if (sa.hasParam("Radiance")) { if (sa.hasParam("Radiance")) {
for (final Card c : CardUtil.getRadiance(card, tgtCards.get(0), untargetedCards.addAll(CardUtil.getRadiance(card, tgtCards.get(0),
sa.getParam("ValidTgts").split(","))) { sa.getParam("ValidTgts").split(",")));
untargetedCards.add(c);
}
} }
if (tgtCards.size() > 1) { if (tgtCards.size() > 1) {

View File

@@ -167,9 +167,7 @@ public class DigEffect extends SpellAbilityEffect {
if (!noMove) { if (!noMove) {
CardCollection movedCards; CardCollection movedCards;
for (final Card c : top) { rest.addAll(top);
rest.add(c);
}
CardCollection valid; CardCollection valid;
if (mitosis) { if (mitosis) {
valid = sharesNameWithCardOnBattlefield(game, top); valid = sharesNameWithCardOnBattlefield(game, top);

View File

@@ -45,7 +45,7 @@ public class EncodeEffect extends SpellAbilityEffect {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Do you want to exile " + host + " and encode it onto a creature you control?"); sb.append("Do you want to exile ").append(host).append(" and encode it onto a creature you control?");
if (!player.getController().confirmAction(sa, null, sb.toString())) { if (!player.getController().confirmAction(sa, null, sb.toString())) {
return; return;
} }

View File

@@ -26,10 +26,10 @@ public class FightEffect extends DamageBaseEffect {
List<Card> fighters = getFighters(sa); List<Card> fighters = getFighters(sa);
if (fighters.size() > 1) { if (fighters.size() > 1) {
sb.append(fighters.get(0) + " fights " + fighters.get(1)); sb.append(fighters.get(0)).append(" fights ").append(fighters.get(1));
} }
else if (fighters.size() == 1) { else if (fighters.size() == 1) {
sb.append(fighters.get(0) + " fights unknown"); sb.append(fighters.get(0)).append(" fights unknown");
} }
return sb.toString(); return sb.toString();
} }

View File

@@ -35,7 +35,7 @@ public class FlipCoinEffect extends SpellAbilityEffect {
sb.append(player).append(" flips a coin."); sb.append(player).append(" flips a coin.");
if (tgts != null && !tgts.isEmpty()) { if (tgts != null && !tgts.isEmpty()) {
sb.append(" Targeting: " + tgts + "."); sb.append(" Targeting: ").append(tgts).append(".");
} }
return sb.toString(); return sb.toString();
} }

View File

@@ -105,7 +105,7 @@ public class MillEffect extends SpellAbilityEffect {
sb.append("s"); sb.append("s");
} }
final String millPosition = sa.hasParam("FromBottom") ? "bottom" : "top"; final String millPosition = sa.hasParam("FromBottom") ? "bottom" : "top";
sb.append(" from the " + millPosition + " of their library."); sb.append(" from the ").append(millPosition).append(" of their library.");
return sb.toString(); return sb.toString();

View File

@@ -132,10 +132,8 @@ public class ProtectEffect extends SpellAbilityEffect {
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
if (sa.hasParam("Radiance") && (tgt != null)) { if (sa.hasParam("Radiance") && (tgt != null)) {
for (final Card c : CardUtil.getRadiance(host, tgtCards.get(0), untargetedCards.addAll(CardUtil.getRadiance(host, tgtCards.get(0),
sa.getParam("ValidTgts").split(","))) { sa.getParam("ValidTgts").split(",")));
untargetedCards.add(c);
}
} }

View File

@@ -332,10 +332,8 @@ public class PumpEffect extends SpellAbilityEffect {
} }
if (sa.hasParam("Radiance")) { if (sa.hasParam("Radiance")) {
for (final Card c : CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts") untargetedCards.addAll(CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts")
.split(","))) { .split(",")));
untargetedCards.add(c);
}
} }
final ZoneType pumpZone = sa.hasParam("PumpZone") ? ZoneType.smartValueOf(sa.getParam("PumpZone")) final ZoneType pumpZone = sa.hasParam("PumpZone") ? ZoneType.smartValueOf(sa.getParam("PumpZone"))

View File

@@ -62,7 +62,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
game.updateLastStateForCard(card); game.updateLastStateForCard(card);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Cumulative upkeep for " + card); sb.append("Cumulative upkeep for ").append(card);
boolean isPaid = activator.getController().payManaOptional(card, payCost, sa, sb.toString(), ManaPaymentPurpose.CumulativeUpkeep); boolean isPaid = activator.getController().payManaOptional(card, payCost, sa, sb.toString(), ManaPaymentPurpose.CumulativeUpkeep);
final Map<String, Object> runParams = Maps.newHashMap(); final Map<String, Object> runParams = Maps.newHashMap();

View File

@@ -368,14 +368,14 @@ public class TokenEffect extends SpellAbilityEffect {
} }
private String parseColorForImage() { private String parseColorForImage() {
String originalColorDesc = ""; StringBuilder originalColorDesc = new StringBuilder();
for (final String col : this.tokenOriginalColors) { for (final String col : this.tokenOriginalColors) {
originalColorDesc += MagicColor.toShortString(col); originalColorDesc.append(MagicColor.toShortString(col));
if (originalColorDesc.equals("C")) { if (originalColorDesc.toString().equals("C")) {
return originalColorDesc; return originalColorDesc.toString();
} }
} }
return originalColorDesc; return originalColorDesc.toString();
} }
private String determineTokenColor(Card host) { private String determineTokenColor(Card host) {

View File

@@ -106,16 +106,16 @@ public class TwoPilesEffect extends SpellAbilityEffect {
CardCollectionView chosenPile = pile1WasChosen ? pile1 : pile2; CardCollectionView chosenPile = pile1WasChosen ? pile1 : pile2;
CardCollectionView unchosenPile = !pile1WasChosen ? pile1 : pile2; CardCollectionView unchosenPile = !pile1WasChosen ? pile1 : pile2;
String notification = chooser + " chooses Pile " + (pile1WasChosen ? "1" : "2") + ":\n"; StringBuilder notification = new StringBuilder(chooser + " chooses Pile " + (pile1WasChosen ? "1" : "2") + ":\n");
if (!chosenPile.isEmpty()) { if (!chosenPile.isEmpty()) {
for (Card c : chosenPile) { for (Card c : chosenPile) {
notification += c.getName() + "\n"; notification.append(c.getName()).append("\n");
} }
} else { } else {
notification += "(Empty pile)"; notification.append("(Empty pile)");
} }
p.getGame().getAction().nofityOfValue(sa, chooser, notification, chooser); p.getGame().getAction().nofityOfValue(sa, chooser, notification.toString(), chooser);
// take action on the chosen pile // take action on the chosen pile
if (sa.hasParam("ChosenPile")) { if (sa.hasParam("ChosenPile")) {

View File

@@ -1652,13 +1652,13 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!mCost.isOnlyManaCost()) { if (!mCost.isOnlyManaCost()) {
sbLong.append("."); sbLong.append(".");
} }
sbLong.append(" (" + inst.getReminderText() + ")"); sbLong.append(" (").append(inst.getReminderText()).append(")");
sbLong.append("\r\n"); sbLong.append("\r\n");
} }
} else if (keyword.startsWith("Emerge")) { } else if (keyword.startsWith("Emerge")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
sbLong.append(k[0]).append(" ").append(ManaCostParser.parse(k[1])); sbLong.append(k[0]).append(" ").append(ManaCostParser.parse(k[1]));
sbLong.append(" (" + inst.getReminderText() + ")"); sbLong.append(" (").append(inst.getReminderText()).append(")");
sbLong.append("\r\n"); sbLong.append("\r\n");
} else if (keyword.startsWith("Echo")) { } else if (keyword.startsWith("Echo")) {
sbLong.append("Echo "); sbLong.append("Echo ");
@@ -1689,7 +1689,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String[] n = keyword.split(":"); final String[] n = keyword.split(":");
final Cost cost = new Cost(n[1], false); final Cost cost = new Cost(n[1], false);
sbLong.append("Multikicker ").append(cost.toSimpleString()); sbLong.append("Multikicker ").append(cost.toSimpleString());
sbLong.append(" (" + inst.getReminderText() + ")").append("\r\n"); sbLong.append(" (").append(inst.getReminderText()).append(")").append("\r\n");
} }
} else if (keyword.startsWith("Kicker")) { } else if (keyword.startsWith("Kicker")) {
if (!keyword.endsWith("Generic")) { if (!keyword.endsWith("Generic")) {
@@ -1703,7 +1703,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final Cost cost2 = new Cost(n[2], false); final Cost cost2 = new Cost(n[2], false);
sbx.append(cost2.toSimpleString()); sbx.append(cost2.toSimpleString());
} }
sbx.append(" (" + inst.getReminderText() + ")"); sbx.append(" (").append(inst.getReminderText()).append(")");
sbLong.append(sbx).append("\r\n"); sbLong.append(sbx).append("\r\n");
} }
} else if (keyword.startsWith("Hexproof:")) { } else if (keyword.startsWith("Hexproof:")) {
@@ -1733,10 +1733,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|| keyword.equals("Hideaway") || keyword.equals("Ascend") || keyword.equals("Hideaway") || keyword.equals("Ascend")
|| keyword.equals("Totem armor") || keyword.equals("Battle cry") || keyword.equals("Totem armor") || keyword.equals("Battle cry")
|| keyword.equals("Devoid") || keyword.equals("Riot")){ || keyword.equals("Devoid") || keyword.equals("Riot")){
sbLong.append(keyword + " (" + inst.getReminderText() + ")"); sbLong.append(keyword).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.startsWith("Partner:")) { } else if (keyword.startsWith("Partner:")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
sbLong.append("Partner with " + k[1] + " (" + inst.getReminderText() + ")"); sbLong.append("Partner with ").append(k[1]).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.startsWith("Modular") || keyword.startsWith("Bloodthirst") || keyword.startsWith("Dredge") } else if (keyword.startsWith("Modular") || keyword.startsWith("Bloodthirst") || keyword.startsWith("Dredge")
|| keyword.startsWith("Fabricate") || keyword.startsWith("Soulshift") || keyword.startsWith("Bushido") || keyword.startsWith("Fabricate") || keyword.startsWith("Soulshift") || keyword.startsWith("Bushido")
|| keyword.startsWith("Crew") || keyword.startsWith("Tribute") || keyword.startsWith("Absorb") || keyword.startsWith("Crew") || keyword.startsWith("Tribute") || keyword.startsWith("Absorb")
@@ -1745,7 +1745,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|| keyword.startsWith("Afflict") || keyword.startsWith ("Poisonous") || keyword.startsWith("Rampage") || keyword.startsWith("Afflict") || keyword.startsWith ("Poisonous") || keyword.startsWith("Rampage")
|| keyword.startsWith("Renown") || keyword.startsWith("Annihilator") || keyword.startsWith("Devour")) { || keyword.startsWith("Renown") || keyword.startsWith("Annihilator") || keyword.startsWith("Devour")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
sbLong.append(k[0] + " " + k[1] + " (" + inst.getReminderText() + ")"); sbLong.append(k[0]).append(" ").append(k[1]).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.contains("Haunt")) { } else if (keyword.contains("Haunt")) {
sb.append("\r\nHaunt ("); sb.append("\r\nHaunt (");
if (isCreature()) { if (isCreature()) {
@@ -1766,14 +1766,14 @@ public class Card extends GameEntity implements Comparable<Card> {
if (sb.length() != 0) { if (sb.length() != 0) {
sb.append("\r\n"); sb.append("\r\n");
} }
sb.append(keyword + " (" + inst.getReminderText() + ")"); sb.append(keyword).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.endsWith(" offering")) { } else if (keyword.endsWith(" offering")) {
String offeringType = keyword.split(" ")[0]; String offeringType = keyword.split(" ")[0];
if (sb.length() != 0) { if (sb.length() != 0) {
sb.append("\r\n"); sb.append("\r\n");
} }
sbLong.append(keyword); sbLong.append(keyword);
sbLong.append(" (" + Keyword.getInstance("Offering:"+ offeringType).getReminderText() + ")"); sbLong.append(" (").append(Keyword.getInstance("Offering:" + offeringType).getReminderText()).append(")");
} else if (keyword.startsWith("Equip") || keyword.startsWith("Fortify") || keyword.startsWith("Outlast") } else if (keyword.startsWith("Equip") || keyword.startsWith("Fortify") || keyword.startsWith("Outlast")
|| keyword.startsWith("Unearth") || keyword.startsWith("Scavenge") || keyword.startsWith("Spectacle") || keyword.startsWith("Unearth") || keyword.startsWith("Scavenge") || keyword.startsWith("Spectacle")
|| keyword.startsWith("Evoke") || keyword.startsWith("Bestow") || keyword.startsWith("Dash") || keyword.startsWith("Evoke") || keyword.startsWith("Bestow") || keyword.startsWith("Dash")
@@ -1935,7 +1935,7 @@ public class Card extends GameEntity implements Comparable<Card> {
String meld = this.getRules().getMeldWith(); String meld = this.getRules().getMeldWith();
if (meld != "" && (!hasMeldEffect)) { if (meld != "" && (!hasMeldEffect)) {
sb.append("\r\n"); sb.append("\r\n");
sb.append("(Melds with " + meld + ".)"); sb.append("(Melds with ").append(meld).append(".)");
sb.append("\r\n"); sb.append("\r\n");
} }
} }
@@ -2042,7 +2042,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
if (isGoaded()) { if (isGoaded()) {
sb.append("is goaded by: " + Lang.joinHomogenous(getGoaded())); sb.append("is goaded by: ").append(Lang.joinHomogenous(getGoaded()));
sb.append("\r\n"); sb.append("\r\n");
} }
// replace triple line feeds with double line feeds // replace triple line feeds with double line feeds
@@ -2104,17 +2104,17 @@ public class Card extends GameEntity implements Comparable<Card> {
|| keyword.equals("Undaunted") || keyword.equals("Cascade") || keyword.equals("Undaunted") || keyword.equals("Cascade")
|| keyword.equals("Devoid") || keyword.equals("Lifelink") || keyword.equals("Devoid") || keyword.equals("Lifelink")
|| keyword.equals("Split second")) { || keyword.equals("Split second")) {
sbBefore.append(keyword + " (" + inst.getReminderText() + ")"); sbBefore.append(keyword).append(" (").append(inst.getReminderText()).append(")");
sbBefore.append("\r\n"); sbBefore.append("\r\n");
} else if(keyword.equals("Conspire") || keyword.equals("Epic") } else if(keyword.equals("Conspire") || keyword.equals("Epic")
|| keyword.equals("Suspend") || keyword.equals("Jump-start")) { || keyword.equals("Suspend") || keyword.equals("Jump-start")) {
sbAfter.append(keyword + " (" + inst.getReminderText() + ")"); sbAfter.append(keyword).append(" (").append(inst.getReminderText()).append(")");
sbAfter.append("\r\n"); sbAfter.append("\r\n");
} else if (keyword.startsWith("Ripple")) { } else if (keyword.startsWith("Ripple")) {
sbBefore.append(TextUtil.fastReplace(keyword, ":", " ") + " (" + inst.getReminderText() + ")"); sbBefore.append(TextUtil.fastReplace(keyword, ":", " ")).append(" (").append(inst.getReminderText()).append(")");
sbBefore.append("\r\n"); sbBefore.append("\r\n");
} else if (keyword.startsWith("Dredge")) { } else if (keyword.startsWith("Dredge")) {
sbAfter.append(TextUtil.fastReplace(keyword, ":", " ") + " (" + inst.getReminderText() + ")"); sbAfter.append(TextUtil.fastReplace(keyword, ":", " ")).append(" (").append(inst.getReminderText()).append(")");
sbAfter.append("\r\n"); sbAfter.append("\r\n");
} else if (keyword.startsWith("Escalate") || keyword.startsWith("Buyback") } else if (keyword.startsWith("Escalate") || keyword.startsWith("Buyback")
|| keyword.startsWith("Prowl")) { || keyword.startsWith("Prowl")) {
@@ -2129,14 +2129,13 @@ public class Card extends GameEntity implements Comparable<Card> {
sbCost.append(" "); sbCost.append(" ");
} }
sbCost.append(cost.toSimpleString()); sbCost.append(cost.toSimpleString());
sbBefore.append(sbCost + " (" + inst.getReminderText() + ")"); sbBefore.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
sbBefore.append("\r\n"); sbBefore.append("\r\n");
} else if (keyword.startsWith("Multikicker")) { } else if (keyword.startsWith("Multikicker")) {
if (!keyword.endsWith("Generic")) { if (!keyword.endsWith("Generic")) {
final String[] n = keyword.split(":"); final String[] n = keyword.split(":");
final Cost cost = new Cost(n[1], false); final Cost cost = new Cost(n[1], false);
sbBefore.append("Multikicker ").append(cost.toSimpleString()) sbBefore.append("Multikicker ").append(cost.toSimpleString()).append(" (").append(inst.getReminderText()).append(")").append("\r\n");
.append(" (" + inst.getReminderText() + ")").append("\r\n");
} }
} else if (keyword.startsWith("Kicker")) { } else if (keyword.startsWith("Kicker")) {
if (!keyword.endsWith("Generic")) { if (!keyword.endsWith("Generic")) {
@@ -2150,7 +2149,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final Cost cost2 = new Cost(n[2], false); final Cost cost2 = new Cost(n[2], false);
sbx.append(cost2.toSimpleString()); sbx.append(cost2.toSimpleString());
} }
sbx.append(" (" + inst.getReminderText() + ")"); sbx.append(" (").append(inst.getReminderText()).append(")");
sbBefore.append(sbx).append("\r\n"); sbBefore.append(sbx).append("\r\n");
} }
}else if (keyword.startsWith("AlternateAdditionalCost")) { }else if (keyword.startsWith("AlternateAdditionalCost")) {
@@ -2179,7 +2178,7 @@ public class Card extends GameEntity implements Comparable<Card> {
sbCost.append(" "); sbCost.append(" ");
} }
sbCost.append(cost.toSimpleString()); sbCost.append(cost.toSimpleString());
sbAfter.append(sbCost + " (" + inst.getReminderText() + ")"); sbAfter.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
sbAfter.append("\r\n"); sbAfter.append("\r\n");
} else if (keyword.equals("CARDNAME can't be countered.") || } else if (keyword.equals("CARDNAME can't be countered.") ||
keyword.equals("Remove CARDNAME from your deck before playing if you're not playing for ante.")) { keyword.equals("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
@@ -2209,7 +2208,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
sbAfter.append("Splice onto ").append(desc).append(" ").append(cost.toSimpleString()); sbAfter.append("Splice onto ").append(desc).append(" ").append(cost.toSimpleString());
sbAfter.append(" (" + inst.getReminderText() + ")").append("\r\n"); sbAfter.append(" (").append(inst.getReminderText()).append(")").append("\r\n");
} else if (keyword.equals("Storm")) { } else if (keyword.equals("Storm")) {
sbAfter.append("Storm ("); sbAfter.append("Storm (");

View File

@@ -901,11 +901,11 @@ public class CardFactoryUtil {
if (sq[0].contains("xColorPaid")) { if (sq[0].contains("xColorPaid")) {
String[] attrs = sq[0].split(" "); String[] attrs = sq[0].split(" ");
String colors = ""; StringBuilder colors = new StringBuilder();
for (int i = 1; i < attrs.length; i++) { for (int i = 1; i < attrs.length; i++) {
colors += attrs[i]; colors.append(attrs[i]);
} }
return doXMath(c.getXManaCostPaidCount(colors), m, c); return doXMath(c.getXManaCostPaidCount(colors.toString()), m, c);
} }
@@ -2113,7 +2113,7 @@ public class CardFactoryUtil {
} }
if (!zone.isEmpty()) { if (!zone.isEmpty()) {
repEffsb.append(" | ActiveZones$ " + zone); repEffsb.append(" | ActiveZones$ ").append(zone);
} }
ReplacementEffect re = ReplacementHandler.parseReplacement(repEffsb.toString(), card, intrinsic); ReplacementEffect re = ReplacementHandler.parseReplacement(repEffsb.toString(), card, intrinsic);
@@ -2323,7 +2323,7 @@ public class CardFactoryUtil {
StringBuilder trig = new StringBuilder(); StringBuilder trig = new StringBuilder();
trig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self"); trig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self");
trig.append(" | TriggerDescription$ Champion ").append(article + " ").append(desc); trig.append(" | TriggerDescription$ Champion ").append(article).append(" ").append(desc);
trig.append(" (").append(Keyword.getInstance("Champion:"+desc).getReminderText()) .append(")"); trig.append(" (").append(Keyword.getInstance("Champion:"+desc).getReminderText()) .append(")");
StringBuilder trigReturn = new StringBuilder(); StringBuilder trigReturn = new StringBuilder();
@@ -2677,7 +2677,7 @@ public class CardFactoryUtil {
final StringBuilder sbTrig = new StringBuilder(); final StringBuilder sbTrig = new StringBuilder();
sbTrig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | "); sbTrig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ");
sbTrig.append("ValidCard$ Card.Self | Secondary$ True | TriggerDescription$ "); sbTrig.append("ValidCard$ Card.Self | Secondary$ True | TriggerDescription$ ");
sbTrig.append("Living Weapon (" + inst.getReminderText() + ")"); sbTrig.append("Living Weapon (").append(inst.getReminderText()).append(")");
final StringBuilder sbGerm = new StringBuilder(); final StringBuilder sbGerm = new StringBuilder();
sbGerm.append("DB$ Token | TokenAmount$ 1 | TokenScript$ b_0_0_germ |TokenOwner$ You | RememberTokens$ True"); sbGerm.append("DB$ Token | TokenAmount$ 1 | TokenScript$ b_0_0_germ |TokenOwner$ You | RememberTokens$ True");
@@ -3142,7 +3142,7 @@ public class CardFactoryUtil {
} }
final String costStr = k.length == 3 ? k[2] : cost.toSimpleString(); final String costStr = k.length == 3 ? k[2] : cost.toSimpleString();
sb.append(costStr.substring(0,1).toLowerCase() + costStr.substring(1)); sb.append(costStr.substring(0, 1).toLowerCase()).append(costStr.substring(1));
sb.append("."); sb.append(".");
String upkeepTrig = "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | " + String upkeepTrig = "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | " +
@@ -3934,8 +3934,8 @@ public class CardFactoryUtil {
} else { } else {
abilityStr.append(" "); abilityStr.append(" ");
} }
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " "); abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")"); abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
// instantiate attach ability // instantiate attach ability
final SpellAbility newSA = AbilityFactory.getAbility(abilityStr.toString(), card); final SpellAbility newSA = AbilityFactory.getAbility(abilityStr.toString(), card);
newSA.setIntrinsic(intrinsic); newSA.setIntrinsic(intrinsic);
@@ -4008,7 +4008,7 @@ public class CardFactoryUtil {
abilityStr.append("| PrecostDesc$ Fortify"); abilityStr.append("| PrecostDesc$ Fortify");
Cost cost = new Cost(equipCost, true); Cost cost = new Cost(equipCost, true);
abilityStr.append(cost.isOnlyManaCost() ? " " : ""); abilityStr.append(cost.isOnlyManaCost() ? " " : "");
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " "); abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ ("); abilityStr.append("| SpellDescription$ (");
abilityStr.append(inst.getReminderText()).append(")"); abilityStr.append(inst.getReminderText()).append(")");
@@ -4169,8 +4169,8 @@ public class CardFactoryUtil {
} else { } else {
abilityStr.append(" "); abilityStr.append(" ");
} }
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " "); abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")"); abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card); final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
sa.setIntrinsic(intrinsic); sa.setIntrinsic(intrinsic);
@@ -4192,7 +4192,7 @@ public class CardFactoryUtil {
// makes new SpellDescription // makes new SpellDescription
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(newSA.getCostDescription()); sb.append(newSA.getCostDescription());
sb.append("(" + inst.getReminderText() + ")"); sb.append("(").append(inst.getReminderText()).append(")");
newSA.setDescription(sb.toString()); newSA.setDescription(sb.toString());
newSA.setBasicSpell(false); newSA.setBasicSpell(false);
@@ -4209,9 +4209,9 @@ public class CardFactoryUtil {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("AB$ PutCounter | CounterType$ P1P1 | ActivationZone$ Hand"); sb.append("AB$ PutCounter | CounterType$ P1P1 | ActivationZone$ Hand");
sb.append("| ValidTgts$ Creature | TgtPrompt$ Select target creature"); sb.append("| ValidTgts$ Creature | TgtPrompt$ Select target creature");
sb.append("| Cost$ " + manacost + " Discard<1/CARDNAME>"); sb.append("| Cost$ ").append(manacost).append(" Discard<1/CARDNAME>");
sb.append("| CounterNum$ ").append(n); sb.append("| CounterNum$ ").append(n);
sb.append("| CostDesc$ " + ManaCostParser.parse(manacost)); // to hide the Discard from the cost sb.append("| CostDesc$ ").append(ManaCostParser.parse(manacost)); // to hide the Discard from the cost
sb.append("| PrecostDesc$ Reinforce ").append(n).append(""); sb.append("| PrecostDesc$ Reinforce ").append(n).append("");
sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")"); sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
@@ -4421,7 +4421,7 @@ public class CardFactoryUtil {
sb.append(manacost); sb.append(manacost);
sb.append(" Discard<1/CARDNAME> | ActivationZone$ Hand | PrecostDesc$ Cycling"); sb.append(" Discard<1/CARDNAME> | ActivationZone$ Hand | PrecostDesc$ Cycling");
sb.append(cost.isOnlyManaCost() ? " " : ""); sb.append(cost.isOnlyManaCost() ? " " : "");
sb.append("| CostDesc$ " + cost.toSimpleString() + " "); sb.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")"); sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
SpellAbility sa = AbilityFactory.getAbility(sb.toString(), card); SpellAbility sa = AbilityFactory.getAbility(sb.toString(), card);
@@ -4494,7 +4494,7 @@ public class CardFactoryUtil {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Mode$ Continuous | EffectZone$ Exile | Affected$ Card.EncodedWithSource"); sb.append("Mode$ Continuous | EffectZone$ Exile | Affected$ Card.EncodedWithSource");
sb.append(" | AddTrigger$ CipherTrigger"); sb.append(" | AddTrigger$ CipherTrigger");
sb.append(" | Description$ Cipher (" + inst.getReminderText() + ")"); sb.append(" | Description$ Cipher (").append(inst.getReminderText()).append(")");
effect = sb.toString(); effect = sb.toString();

View File

@@ -82,7 +82,7 @@ public final class CardPlayOption {
switch (getPayManaCost()) { switch (getPayManaCost()) {
case YES: case YES:
if (altManaCost != null) { if (altManaCost != null) {
sb.append(" (by paying " + getFormattedAltManaCost() + " instead of paying its mana cost"); sb.append(" (by paying ").append(getFormattedAltManaCost()).append(" instead of paying its mana cost");
if (isWithFlash()) { if (isWithFlash()) {
sb.append(" and as though it has flash"); sb.append(" and as though it has flash");
} }

View File

@@ -92,7 +92,7 @@ public final class CardUtil {
public static String getShortColorsString(final Iterable<String> colors) { public static String getShortColorsString(final Iterable<String> colors) {
StringBuilder colorDesc = new StringBuilder(); StringBuilder colorDesc = new StringBuilder();
for (final String col : colors) { for (final String col : colors) {
colorDesc.append(MagicColor.toShortString(col) + " "); colorDesc.append(MagicColor.toShortString(col)).append(" ");
} }
return colorDesc.toString(); return colorDesc.toString();
} }

View File

@@ -559,7 +559,7 @@ public class CardView extends GameEntityView {
sb.append(rulesText).append("\r\n\r\n"); sb.append(rulesText).append("\r\n\r\n");
} }
if (isCommander()) { if (isCommander()) {
sb.append(getOwner()).append("'s " + getCommanderType() + "\r\n"); sb.append(getOwner()).append("'s ").append(getCommanderType()).append("\r\n");
sb.append(getOwner().getCommanderInfo(this)).append("\r\n"); sb.append(getOwner().getCommanderInfo(this)).append("\r\n");
} }

View File

@@ -71,9 +71,7 @@ public class Combat {
playerWhoAttacks = attacker; playerWhoAttacks = attacker;
// Create keys for all possible attack targets // Create keys for all possible attack targets
for (final GameEntity defender : CombatUtil.getAllPossibleDefenders(playerWhoAttacks)) { attackableEntries.addAll(CombatUtil.getAllPossibleDefenders(playerWhoAttacks));
attackableEntries.add(defender);
}
attackConstraints = new AttackConstraints(this); attackConstraints = new AttackConstraints(this);
} }

View File

@@ -123,7 +123,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
sb.append("Remove "); sb.append("Remove ");
sb.append(Cost.convertIntAndTypeToWords(this.convertAmount(), "counter")); sb.append(Cost.convertIntAndTypeToWords(this.convertAmount(), "counter"));
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
sb.append(" from " + desc); sb.append(" from ").append(desc);
return sb.toString(); return sb.toString();
} }

View File

@@ -77,7 +77,7 @@ public class CostTapType extends CostPartWithList {
sb.append("two untapped creatures you control that share a creature type"); sb.append("two untapped creatures you control that share a creature type");
} else if (type.contains("+withTotalPowerGE")) { } else if (type.contains("+withTotalPowerGE")) {
String num = type.split("\\+withTotalPowerGE")[1]; String num = type.split("\\+withTotalPowerGE")[1];
sb.append("Tap any number of untapped creatures you control other than CARDNAME with total power " + num + "or greater"); sb.append("Tap any number of untapped creatures you control other than CARDNAME with total power ").append(num).append("or greater");
} else { } else {
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), "untapped " + desc)); sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), "untapped " + desc));
sb.append(" you control"); sb.append(" you control");

View File

@@ -610,12 +610,12 @@ public class ManaCostBeingPaid {
if (nGeneric > 0) { if (nGeneric > 0) {
if (nGeneric <= 20) { if (nGeneric <= 20) {
sb.append("{" + nGeneric + "}"); sb.append("{").append(nGeneric).append("}");
} }
else { //if no mana symbol exists for generic amount, use combination of symbols for each digit else { //if no mana symbol exists for generic amount, use combination of symbols for each digit
String genericStr = String.valueOf(nGeneric); String genericStr = String.valueOf(nGeneric);
for (int i = 0; i < genericStr.length(); i++) { for (int i = 0; i < genericStr.length(); i++) {
sb.append("{" + genericStr.charAt(i) + "}"); sb.append("{").append(genericStr.charAt(i)).append("}");
} }
} }
} }

View File

@@ -220,19 +220,19 @@ public class Untap extends Phase {
private static void optionalUntap(final Card c) { private static void optionalUntap(final Card c) {
if (c.hasKeyword("You may choose not to untap CARDNAME during your untap step.")) { if (c.hasKeyword("You may choose not to untap CARDNAME during your untap step.")) {
if (c.isTapped()) { if (c.isTapped()) {
String prompt = "Untap " + c.toString() + "?"; StringBuilder prompt = new StringBuilder("Untap " + c.toString() + "?");
boolean defaultChoice = true; boolean defaultChoice = true;
if (c.getGainControlTargets().size() > 0) { if (c.getGainControlTargets().size() > 0) {
final Iterable<Card> targets = c.getGainControlTargets(); final Iterable<Card> targets = c.getGainControlTargets();
prompt += "\r\n" + c + " is controlling: "; prompt.append("\r\n").append(c).append(" is controlling: ");
for (final Card target : targets) { for (final Card target : targets) {
prompt += target; prompt.append(target);
if (target.isInPlay()) { if (target.isInPlay()) {
defaultChoice = false; defaultChoice = false;
} }
} }
} }
boolean untap = c.getController().getController().chooseBinary(new SpellAbility.EmptySa(c, c.getController()), prompt, BinaryChoiceType.UntapOrLeaveTapped, defaultChoice); boolean untap = c.getController().getController().chooseBinary(new SpellAbility.EmptySa(c, c.getController()), prompt.toString(), BinaryChoiceType.UntapOrLeaveTapped, defaultChoice);
if (untap) { if (untap) {
c.untap(); c.untap();
} }

View File

@@ -444,7 +444,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
if (decksComboBox.getDeckType() == null || decksComboBox.getDeckType() == DeckType.NET_DECK) { if (decksComboBox.getDeckType() == null || decksComboBox.getDeckType() == DeckType.NET_DECK) {
//handle special case of net decks //handle special case of net decks
if (netDeckCategory == null) { return ""; } if (netDeckCategory == null) { return ""; }
state.append(NetDeckCategory.PREFIX + netDeckCategory.getName()); state.append(NetDeckCategory.PREFIX).append(netDeckCategory.getName());
} }
else { else {
state.append(decksComboBox.getDeckType().name()); state.append(decksComboBox.getDeckType().name());

View File

@@ -98,9 +98,7 @@ public final class SRearrangingUtil {
} }
// Otherwise, add all of the documents. // Otherwise, add all of the documents.
else { else {
for (final IVDoc<? extends ICDoc> vDoc : cellSrc.getDocs()) { docsToMove.addAll(cellSrc.getDocs());
docsToMove.add(vDoc);
}
} }
// Reset and show preview panel // Reset and show preview panel

View File

@@ -136,9 +136,7 @@ public final class SResizingUtil {
int smoothVal = 0; int smoothVal = 0;
Set<Component> existingComponents = new HashSet<>(); Set<Component> existingComponents = new HashSet<>();
for (Component c : pnlContent.getComponents()) { existingComponents.addAll(Arrays.asList(pnlContent.getComponents()));
existingComponents.add(c);
}
// This is the core of the pixel-perfect layout. To avoid ±1 px errors on borders // This is the core of the pixel-perfect layout. To avoid ±1 px errors on borders
// from rounding individual panels, the intermediate values (exactly accurate, in %) // from rounding individual panels, the intermediate values (exactly accurate, in %)

View File

@@ -45,10 +45,10 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
labelBuilder.append("s: All"); labelBuilder.append("s: All");
break; break;
case 1: case 1:
labelBuilder.append(": " + getList().iterator().next()); labelBuilder.append(": ").append(getList().iterator().next());
break; break;
default: default:
labelBuilder.append("s: " + TextUtil.join(getList(), ", ")); labelBuilder.append("s: ").append(TextUtil.join(getList(), ", "));
break; break;
} }
label.setText(labelBuilder.toString()); label.setText(labelBuilder.toString());

View File

@@ -32,7 +32,7 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
final Localizer localizer = Localizer.getInstance(); final Localizer localizer = Localizer.getInstance();
StringBuilder tooltip = new StringBuilder(); StringBuilder tooltip = new StringBuilder();
tooltip.append(st.label); tooltip.append(st.label);
tooltip.append(" (" + localizer.getMessage("lblclicktotoogle") + " "); tooltip.append(" (").append(localizer.getMessage("lblclicktotoogle")).append(" ");
if (st.label.length() > 1 && !Character.isUpperCase(st.label.charAt(1))) { if (st.label.length() > 1 && !Character.isUpperCase(st.label.charAt(1))) {
tooltip.append(st.label.substring(0, 1).toLowerCase()); tooltip.append(st.label.substring(0, 1).toLowerCase());
tooltip.append(st.label.substring(1)); tooltip.append(st.label.substring(1));

View File

@@ -597,9 +597,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
piles.get(key).items.add(itemInfo); piles.get(key).items.add(itemInfo);
} }
group.piles.clear(); group.piles.clear();
for (Pile pile : piles.values()) { group.piles.addAll(piles.values());
group.piles.add(pile);
}
} }
groupY = y; groupY = y;

View File

@@ -2,6 +2,7 @@ package forge.screens.home;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.Vector; import java.util.Vector;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@@ -28,9 +29,7 @@ public class CLobby {
private void addDecks(final Iterable<DeckProxy> commanderDecks, FList<Object> deckList, String... initialItems) { private void addDecks(final Iterable<DeckProxy> commanderDecks, FList<Object> deckList, String... initialItems) {
Vector<Object> listData = new Vector<>(); Vector<Object> listData = new Vector<>();
for (String item : initialItems) { listData.addAll(Arrays.asList(initialItems));
listData.add(item);
}
listData.add("Generate"); listData.add("Generate");
if (!Iterables.isEmpty(commanderDecks)) { if (!Iterables.isEmpty(commanderDecks)) {
listData.add("Random"); listData.add("Random");

View File

@@ -45,7 +45,7 @@ public class ContestGauntletLister extends JPanel {
this.removeAll(); this.removeAll();
final List<RowPanel> tempRows = new ArrayList<>(); final List<RowPanel> tempRows = new ArrayList<>();
final List<GauntletData> sorted = new ArrayList<>(); final List<GauntletData> sorted = new ArrayList<>();
for (final GauntletData gd : gd0) { sorted.add(gd); } sorted.addAll(gd0);
sorted.sort(new Comparator<GauntletData>() { sorted.sort(new Comparator<GauntletData>() {
@Override @Override
public int compare(final GauntletData x, final GauntletData y) { public int compare(final GauntletData x, final GauntletData y) {

View File

@@ -64,7 +64,7 @@ public class QuickGauntletLister extends JPanel {
this.removeAll(); this.removeAll();
final List<RowPanel> tempRows = new ArrayList<>(); final List<RowPanel> tempRows = new ArrayList<>();
final List<GauntletData> sorted = new ArrayList<>(); final List<GauntletData> sorted = new ArrayList<>();
for (final GauntletData gd : gauntlets) { sorted.add(gd); } sorted.addAll(gauntlets);
sorted.sort(new Comparator<GauntletData>() { sorted.sort(new Comparator<GauntletData>() {
@Override @Override
public int compare(final GauntletData x, final GauntletData y) { public int compare(final GauntletData x, final GauntletData y) {

View File

@@ -161,7 +161,7 @@ public enum CSubmenuChallenges implements ICDoc {
final JXButtonPanel grpPanel = new JXButtonPanel(); final JXButtonPanel grpPanel = new JXButtonPanel();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(localizer.getMessage("lblMatchBestof") + " ").append(FModel.getQuest().getMatchLength()); sb.append(localizer.getMessage("lblMatchBestof")).append(" ").append(FModel.getQuest().getMatchLength());
view.getCbxMatchLength().setSelectedItem(sb.toString()); view.getCbxMatchLength().setSelectedItem(sb.toString());
boolean haveAnyChallenges = true; boolean haveAnyChallenges = true;

View File

@@ -197,7 +197,7 @@ public enum CSubmenuDuels implements ICDoc {
view.getPnlDuels().add(grpPanel, "w 100%!"); view.getPnlDuels().add(grpPanel, "w 100%!");
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(localizer.getMessage("lblMatchBestof") + " ").append(FModel.getQuest().getMatchLength()); sb.append(localizer.getMessage("lblMatchBestof")).append(" ").append(FModel.getQuest().getMatchLength());
view.getCbxMatchLength().setSelectedItem(sb.toString()); view.getCbxMatchLength().setSelectedItem(sb.toString());
} }
} }

View File

@@ -66,7 +66,7 @@ public class QuestFileLister extends JPanel {
this.removeAll(); this.removeAll();
List<RowPanel> tempRows = new ArrayList<>(); List<RowPanel> tempRows = new ArrayList<>();
List<QuestData> sorted = new ArrayList<>(); List<QuestData> sorted = new ArrayList<>();
for (QuestData qd : qd0) { sorted.add(qd); } sorted.addAll(qd0);
sorted.sort(new Comparator<QuestData>() { sorted.sort(new Comparator<QuestData>() {
@Override @Override
public int compare(final QuestData x, final QuestData y) { public int compare(final QuestData x, final QuestData y) {

View File

@@ -234,8 +234,8 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
cniSB.append("-------------------\n\n"); cniSB.append("-------------------\n\n");
for (CardEdition e : editions) { for (CardEdition e : editions) {
nifSB.append("Edition: " + e.getName() + " " + "(" + e.getCode() + "/" + e.getCode2() + ")\n"); nifSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
cniSB.append("Edition: " + e.getName() + " " + "(" + e.getCode() + "/" + e.getCode2() + ")\n"); cniSB.append("Edition: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
String imagePath; String imagePath;
int artIndex = 1; int artIndex = 1;
@@ -261,7 +261,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
} }
if (cp == null) { if (cp == null) {
cniSB.append(" " + c + "\n"); cniSB.append(" ").append(c).append("\n");
notImplementedCount++; notImplementedCount++;
continue; continue;
} }
@@ -274,7 +274,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
if (imagePath != null) { if (imagePath != null) {
File file = ImageKeys.getImageFile(imagePath); File file = ImageKeys.getImageFile(imagePath);
if (file == null) { if (file == null) {
nifSB.append(" " + imagePath + "\n"); nifSB.append(" ").append(imagePath).append("\n");
missingCount++; missingCount++;
} }
} }
@@ -287,7 +287,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
if (imagePath != null) { if (imagePath != null) {
File file = ImageKeys.getImageFile(imagePath); File file = ImageKeys.getImageFile(imagePath);
if (file == null) { if (file == null) {
nifSB.append(" " + imagePath + "\n"); nifSB.append(" ").append(imagePath).append("\n");
missingCount++; missingCount++;
} }
} }
@@ -310,7 +310,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
String imgKey = token.getImageKey(i); String imgKey = token.getImageKey(i);
File file = ImageKeys.getImageFile(imgKey); File file = ImageKeys.getImageFile(imgKey);
if (file == null) { if (file == null) {
nifSB.append(" " + token.getImageFilename(i+1) + "\n"); nifSB.append(" ").append(token.getImageFilename(i + 1)).append("\n");
missingCount++; missingCount++;
} }
} }

View File

@@ -403,7 +403,7 @@ public class VAssignDamage {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(dmg); sb.append(dmg);
if( overkill >= 0 ) { if( overkill >= 0 ) {
sb.append(" (" +localizer.getMessage("lblLethal")); sb.append(" (").append(localizer.getMessage("lblLethal"));
if( overkill > 0 ) if( overkill > 0 )
sb.append(" +").append(overkill); sb.append(" +").append(overkill);
sb.append(")"); sb.append(")");

View File

@@ -459,8 +459,7 @@ public enum FView {
* @return {@link java.util.List}<{@link forge.gui.framework.DragCell}> * @return {@link java.util.List}<{@link forge.gui.framework.DragCell}>
*/ */
public List<DragCell> getDragCells() { public List<DragCell> getDragCells() {
final List<DragCell> clone = new ArrayList<>(); final List<DragCell> clone = new ArrayList<>(allCells);
clone.addAll(allCells);
return clone; return clone;
} }

View File

@@ -504,11 +504,11 @@ public class GifDecoder {
break; break;
case 0xff: // application extension case 0xff: // application extension
readBlock(); readBlock();
String app = ""; StringBuilder app = new StringBuilder();
for (int i = 0; i < 11; i++) { for (int i = 0; i < 11; i++) {
app += (char) block[i]; app.append((char) block[i]);
} }
if (app.equals("NETSCAPE2.0")) { if (app.toString().equals("NETSCAPE2.0")) {
readNetscapeExt(); readNetscapeExt();
} else { } else {
skip(); // don't care skip(); // don't care
@@ -554,11 +554,11 @@ public class GifDecoder {
* Reads GIF file header information. * Reads GIF file header information.
*/ */
protected void readHeader() { protected void readHeader() {
String id = ""; StringBuilder id = new StringBuilder();
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
id += (char) read(); id.append((char) read());
} }
if (!id.startsWith("GIF")) { if (!id.toString().startsWith("GIF")) {
status = STATUS_FORMAT_ERROR; status = STATUS_FORMAT_ERROR;
return; return;
} }

View File

@@ -950,7 +950,7 @@ public class FDeckChooser extends FScreen {
if (cmbDeckTypes.getSelectedItem() == null || cmbDeckTypes.getSelectedItem() == DeckType.NET_DECK) { if (cmbDeckTypes.getSelectedItem() == null || cmbDeckTypes.getSelectedItem() == DeckType.NET_DECK) {
//handle special case of net decks //handle special case of net decks
if (netDeckCategory == null) { return ""; } if (netDeckCategory == null) { return ""; }
state.append(NetDeckCategory.PREFIX + netDeckCategory.getName()); state.append(NetDeckCategory.PREFIX).append(netDeckCategory.getName());
} }
else { else {
state.append(cmbDeckTypes.getSelectedItem().name()); state.append(cmbDeckTypes.getSelectedItem().name());

View File

@@ -79,7 +79,7 @@ public class FDeckImportDialog extends FDialog {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append("\n"); sb.append("\n");
} }
sb.append(token.getNumber() + " " + token.getText()); sb.append(token.getNumber()).append(" ").append(token.getText());
} }
} }
if (sb.length() > 0) { if (sb.length() > 0) {

View File

@@ -43,10 +43,10 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
labelBuilder.append("s: All"); labelBuilder.append("s: All");
break; break;
case 1: case 1:
labelBuilder.append(": " + getList().iterator().next()); labelBuilder.append(": ").append(getList().iterator().next());
break; break;
default: default:
labelBuilder.append("s: " + TextUtil.join(getList(), ", ")); labelBuilder.append("s: ").append(TextUtil.join(getList(), ", "));
break; break;
} }
label.setText(labelBuilder.toString()); label.setText(labelBuilder.toString());

View File

@@ -433,9 +433,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
piles.get(key).items.add(itemInfo); piles.get(key).items.add(itemInfo);
} }
group.piles.clear(); group.piles.clear();
for (Pile pile : piles.values()) { group.piles.addAll(piles.values());
group.piles.add(pile);
}
} }
groupY = y; groupY = y;

View File

@@ -216,14 +216,14 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
cbVariants.setSelectedItem(appliedVariants.iterator().next()); cbVariants.setSelectedItem(appliedVariants.iterator().next());
} }
else { else {
String text = ""; StringBuilder text = new StringBuilder();
for (GameType variantType : appliedVariants) { for (GameType variantType : appliedVariants) {
if (text.length() > 0) { if (text.length() > 0) {
text += ", "; text.append(", ");
} }
text += variantType.toString(); text.append(variantType.toString());
} }
cbVariants.setText(text); cbVariants.setText(text.toString());
} }
} }

View File

@@ -295,9 +295,7 @@ public class LoadGauntletScreen extends LaunchScreen {
public void refresh() { public void refresh() {
List<GauntletData> sorted = new ArrayList<>(); List<GauntletData> sorted = new ArrayList<>();
for (GauntletData gauntlet : gauntlets) { sorted.addAll(gauntlets);
sorted.add(gauntlet);
}
sorted.sort(new Comparator<GauntletData>() { sorted.sort(new Comparator<GauntletData>() {
@Override @Override
public int compare(final GauntletData x, final GauntletData y) { public int compare(final GauntletData x, final GauntletData y) {

View File

@@ -52,17 +52,16 @@ public class GauntletWinLose extends ControlWinLose {
if (!lstEventNames.isEmpty()) { if (!lstEventNames.isEmpty()) {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (i <= num) { if (i <= num) {
sb.append((i + 1) + ". " + lstEventNames.get(i) sb.append(i + 1).append(". ").append(lstEventNames.get(i)).append(" (").append(lstEventRecords.get(i)).append(")\n");
+ " (" + lstEventRecords.get(i) + ")\n");
} else { } else {
sb.append((i + 1) + ". ??????\n"); sb.append(i + 1).append(". ??????\n");
} }
} }
} }
if (message1 != null) { if (message1 != null) {
sb.append("\n"); sb.append("\n");
sb.append(message1 + "\n\n"); sb.append(message1).append("\n\n");
sb.append(message2); sb.append(message2);
} }
else { else {

View File

@@ -333,9 +333,7 @@ public class LoadConquestScreen extends LaunchScreen {
public void setConquests(List<ConquestData> qd0) { public void setConquests(List<ConquestData> qd0) {
List<ConquestData> sorted = new ArrayList<>(); List<ConquestData> sorted = new ArrayList<>();
for (ConquestData qd : qd0) { sorted.addAll(qd0);
sorted.add(qd);
}
sorted.sort(new Comparator<ConquestData>() { sorted.sort(new Comparator<ConquestData>() {
@Override @Override
public int compare(final ConquestData x, final ConquestData y) { public int compare(final ConquestData x, final ConquestData y) {

View File

@@ -335,9 +335,7 @@ public class LoadQuestScreen extends LaunchScreen {
public void setQuests(List<QuestData> qd0) { public void setQuests(List<QuestData> qd0) {
List<QuestData> sorted = new ArrayList<>(); List<QuestData> sorted = new ArrayList<>();
for (QuestData qd : qd0) { sorted.addAll(qd0);
sorted.add(qd);
}
sorted.sort(new Comparator<QuestData>() { sorted.sort(new Comparator<QuestData>() {
@Override @Override
public int compare(final QuestData x, final QuestData y) { public int compare(final QuestData x, final QuestData y) {

View File

@@ -29,6 +29,7 @@ import forge.util.Callback;
import forge.util.Utils; import forge.util.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class SettingsPage extends TabPage<SettingsScreen> { public class SettingsPage extends TabPage<SettingsScreen> {
@@ -402,9 +403,7 @@ public class SettingsPage extends TabPage<SettingsScreen> {
public CustomSelectSetting(FPref pref0, String label0, String description0, String[] options0) { public CustomSelectSetting(FPref pref0, String label0, String description0, String[] options0) {
super(pref0, label0 + ":", description0); super(pref0, label0 + ":", description0);
for (String option : options0) { options.addAll(Arrays.asList(options0));
options.add(option);
}
} }
public CustomSelectSetting(FPref pref0, String label0, String description0, Iterable<String> options0) { public CustomSelectSetting(FPref pref0, String label0, String description0, Iterable<String> options0) {
super(pref0, label0 + ":", description0); super(pref0, label0 + ":", description0);

View File

@@ -1,6 +1,7 @@
package forge.toolbox; package forge.toolbox;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
@@ -26,9 +27,7 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
setLabel(label0); setLabel(label0);
} }
public FComboBox(T[] itemArray) { public FComboBox(T[] itemArray) {
for (T item : itemArray) { items.addAll(Arrays.asList(itemArray));
items.add(item);
}
initialize(); initialize();
} }
public FComboBox(Iterable<T> items0) { public FComboBox(Iterable<T> items0) {
@@ -66,9 +65,7 @@ public class FComboBox<T> extends FTextField implements IComboBox<T> {
public void setItems(T[] itemArray, T selectedItem0) { public void setItems(T[] itemArray, T selectedItem0) {
items.clear(); items.clear();
if (itemArray != null) { if (itemArray != null) {
for (T item : itemArray) { items.addAll(Arrays.asList(itemArray));
items.add(item);
}
} }
setSelectedItem(selectedItem0); setSelectedItem(selectedItem0);
} }

View File

@@ -339,7 +339,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append(c.getKey().getName() + " counters: "); area.append(c.getKey().getName()).append(" counters: ");
area.append(c.getValue()); area.append(c.getValue());
} }
} }
@@ -351,7 +351,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("Damage: " + damage); area.append("Damage: ").append(damage);
} }
} }
if (state.isCreature() || state.isPlaneswalker()) { if (state.isCreature() || state.isPlaneswalker()) {
@@ -360,7 +360,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("Assigned Damage: " + assigned); area.append("Assigned Damage: ").append(assigned);
} }
} }
@@ -416,7 +416,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("(chosen player: " + card.getChosenPlayer() + ")"); area.append("(chosen player: ").append(card.getChosenPlayer()).append(")");
} }
// chosen mode // chosen mode
@@ -424,7 +424,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("(chosen mode: " + card.getChosenMode() + ")"); area.append("(chosen mode: ").append(card.getChosenMode()).append(")");
} }
// named card // named card
@@ -506,7 +506,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("Haunting " + card.getHaunting()); area.append("Haunting ").append(card.getHaunting());
} }
// Cipher // Cipher
@@ -514,7 +514,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n"); area.append("\n");
} }
area.append("Encoded: " + card.getEncodedCards()); area.append("Encoded: ").append(card.getEncodedCards());
} }
// must block // must block
@@ -523,7 +523,7 @@ public class CardDetailUtil {
area.append("\n"); area.append("\n");
} }
final String mustBlockThese = Lang.joinHomogenous(card.getMustBlockCards()); final String mustBlockThese = Lang.joinHomogenous(card.getMustBlockCards());
area.append("Must block " + mustBlockThese); area.append("Must block ").append(mustBlockThese);
} }
// exerted // exerted
@@ -550,7 +550,7 @@ public class CardDetailUtil {
if (area.length() != 0) { if (area.length() != 0) {
area.append("\n\n"); area.append("\n\n");
} }
area.append("Current Storm Count: " + gameView.getStormCount()); area.append("Current Storm Count: ").append(gameView.getStormCount());
} }
} }
return area.toString(); return area.toString();

View File

@@ -164,7 +164,7 @@ public class CardReaderExperiments {
StringBuilder newLineBuilder = new StringBuilder(); StringBuilder newLineBuilder = new StringBuilder();
newLineBuilder.append(line, 0, m.start(1)); newLineBuilder.append(line, 0, m.start(1));
for (String sym : m.group(1).split(" ")) { for (String sym : m.group(1).split(" ")) {
newLineBuilder.append("{" + sym + "}"); newLineBuilder.append("{").append(sym).append("}");
} }
newLineBuilder.append(line.substring(m.end(1) - 1)); //-1 so final space appended newLineBuilder.append(line.substring(m.end(1) - 1)); //-1 so final space appended
updated = true; updated = true;

View File

@@ -124,7 +124,7 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
final float p = (float) (g.percentage * .01); final float p = (float) (g.percentage * .01);
final int grpCnt = (int) (p * size); final int grpCnt = (int) (p * size);
final int cnSize = g.cardnames.size(); final int cnSize = g.cardnames.size();
errorBuilder.append("Group" + i + ":" + grpCnt + "\n"); errorBuilder.append("Group").append(i).append(":").append(grpCnt).append("\n");
for (int j = 0; j < grpCnt; j++) { for (int j = 0; j < grpCnt; j++) {
s = g.cardnames.get(MyRandom.getRandom().nextInt(cnSize)); s = g.cardnames.get(MyRandom.getRandom().nextInt(cnSize));
@@ -150,7 +150,7 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
tDeck.add(pool.getCard(ss[0],ss[1])); tDeck.add(pool.getCard(ss[0],ss[1]));
} }
cardCounts.put(ss[0], n + 1); cardCounts.put(ss[0], n + 1);
errorBuilder.append(s + "\n"); errorBuilder.append(s).append("\n");
} }
} }
@@ -162,15 +162,15 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
numBLands = size - tDeck.countAll(); numBLands = size - tDeck.countAll();
} }
errorBuilder.append("numBLands:" + numBLands + "\n"); errorBuilder.append("numBLands:").append(numBLands).append("\n");
addBasicLand(numBLands,basicLandSet); addBasicLand(numBLands,basicLandSet);
errorBuilder.append("DeckSize:" + tDeck.countAll() + "\n"); errorBuilder.append("DeckSize:").append(tDeck.countAll()).append("\n");
adjustDeckSize(size); adjustDeckSize(size);
errorBuilder.append("DeckSize:" + tDeck.countAll() + "\n"); errorBuilder.append("DeckSize:").append(tDeck.countAll()).append("\n");
if (!testing) { if (!testing) {
errorBuilder.delete(0, errorBuilder.length()); //clear if not testing errorBuilder.delete(0, errorBuilder.length()); //clear if not testing
} }

View File

@@ -622,9 +622,8 @@ public class DeckgenUtil {
} }
} }
}else { }else {
List<Map.Entry<PaperCard,Integer>> potentialCards = new ArrayList<>();
String matrixKey = (format.equals(DeckFormat.TinyLeaders) ? DeckFormat.Commander : format).toString(); //use Commander for Tiny Leaders String matrixKey = (format.equals(DeckFormat.TinyLeaders) ? DeckFormat.Commander : format).toString(); //use Commander for Tiny Leaders
potentialCards.addAll(CardRelationMatrixGenerator.cardPools.get(matrixKey).get(commander.getName())); List<Map.Entry<PaperCard, Integer>> potentialCards = new ArrayList<>(CardRelationMatrixGenerator.cardPools.get(matrixKey).get(commander.getName()));
Collections.shuffle(potentialCards, MyRandom.getRandom()); Collections.shuffle(potentialCards, MyRandom.getRandom());
for(Map.Entry<PaperCard,Integer> pair:potentialCards){ for(Map.Entry<PaperCard,Integer> pair:potentialCards){
if(format.isLegalCard(pair.getKey())) { if(format.isLegalCard(pair.getKey())) {

View File

@@ -886,12 +886,12 @@ public class AdvancedSearch {
return formatValue(values.get(0)) + finalDelim + formatValue(values.get(1)); return formatValue(values.get(0)) + finalDelim + formatValue(values.get(1));
default: default:
int lastValueIdx = valueCount - 1; int lastValueIdx = valueCount - 1;
String result = formatValue(values.get(0)); StringBuilder result = new StringBuilder(formatValue(values.get(0)));
for (int i = 1; i < lastValueIdx; i++) { for (int i = 1; i < lastValueIdx; i++) {
result += delim + formatValue(values.get(i)); result.append(delim).append(formatValue(values.get(i)));
} }
result += delim.trim() + finalDelim + formatValue(values.get(lastValueIdx)); result.append(delim.trim()).append(finalDelim).append(formatValue(values.get(lastValueIdx)));
return result; return result.toString();
} }
} }
@@ -1233,15 +1233,15 @@ public class AdvancedSearch {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("Filter:\n"); builder.append("Filter:\n");
String indent = ""; StringBuilder indent = new StringBuilder();
for (Object piece : expression) { for (Object piece : expression) {
if (piece.equals(Operator.CLOSE_PAREN) && !indent.isEmpty()) { if (piece.equals(Operator.CLOSE_PAREN) && (indent.length() > 0)) {
indent = indent.substring(2); //trim an indent level when a close paren is hit indent = new StringBuilder(indent.substring(2)); //trim an indent level when a close paren is hit
} }
builder.append("\n" + indent + piece.toString().trim()); builder.append("\n").append(indent).append(piece.toString().trim());
if (piece.equals(Operator.OPEN_PAREN)) { if (piece.equals(Operator.OPEN_PAREN)) {
indent += " "; //add an indent level when an open paren is hit indent.append(" "); //add an indent level when an open paren is hit
} }
} }
return GuiBase.getInterface().encodeSymbols(builder.toString(), false); return GuiBase.getInterface().encodeSymbols(builder.toString(), false);

View File

@@ -43,7 +43,7 @@ public class BooleanExpression {
public Predicate<CardRules> evaluate() { public Predicate<CardRules> evaluate() {
String currentValue = ""; StringBuilder currentValue = new StringBuilder();
boolean escapeNext = false; boolean escapeNext = false;
while (expression.hasNext()) { while (expression.hasNext()) {
@@ -59,7 +59,7 @@ public class BooleanExpression {
operator = Operator.OPEN_PAREN; operator = Operator.OPEN_PAREN;
} else if (token.equals(Operator.CLOSE_PAREN.token)) { } else if (token.equals(Operator.CLOSE_PAREN.token)) {
operator = Operator.CLOSE_PAREN; operator = Operator.CLOSE_PAREN;
} else if (token.equals(Operator.NOT.token) && currentValue.trim().isEmpty()) { //Ignore ! operators that aren't the first token in a search term (Don't use '!' in 'Kaboom!') } else if (token.equals(Operator.NOT.token) && currentValue.toString().trim().isEmpty()) { //Ignore ! operators that aren't the first token in a search term (Don't use '!' in 'Kaboom!')
operator = Operator.NOT; operator = Operator.NOT;
} else if (token.equals(Operator.ESCAPE.token)) { } else if (token.equals(Operator.ESCAPE.token)) {
escapeNext = true; escapeNext = true;
@@ -67,20 +67,20 @@ public class BooleanExpression {
} }
if (operator == null) { if (operator == null) {
currentValue += token; currentValue.append(token);
} else { } else {
if (escapeNext) { if (escapeNext) {
escapeNext = false; escapeNext = false;
currentValue += token; currentValue.append(token);
continue; continue;
} }
if (!currentValue.trim().isEmpty()) { if (!currentValue.toString().trim().isEmpty()) {
operands.push(valueOf(currentValue.trim())); operands.push(valueOf(currentValue.toString().trim()));
} }
currentValue = ""; currentValue = new StringBuilder();
if (!operators.isEmpty() && operator.precedence < operators.peek().precedence) { if (!operators.isEmpty() && operator.precedence < operators.peek().precedence) {
resolve(true); resolve(true);
@@ -98,8 +98,8 @@ public class BooleanExpression {
} }
if (!currentValue.trim().isEmpty()) { if (!currentValue.toString().trim().isEmpty()) {
operands.push(valueOf(currentValue.trim())); operands.push(valueOf(currentValue.toString().trim()));
} }
while (!operators.isEmpty()) { while (!operators.isEmpty()) {

View File

@@ -70,7 +70,7 @@ public class SFilterUtil {
private static List<String> getSplitText(String text) { private static List<String> getSplitText(String text) {
boolean inQuotes = false; boolean inQuotes = false;
String entry = ""; StringBuilder entry = new StringBuilder();
List<String> splitText = new ArrayList<>(); List<String> splitText = new ArrayList<>();
for (int i = 0; i < text.length(); i++) { for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i); char ch = text.charAt(i);
@@ -78,8 +78,8 @@ public class SFilterUtil {
case ' ': case ' ':
if (!inQuotes) { //if not in quotes, end current entry if (!inQuotes) { //if not in quotes, end current entry
if (entry.length() > 0) { if (entry.length() > 0) {
splitText.add(entry); splitText.add(entry.toString());
entry = ""; entry = new StringBuilder();
} }
continue; continue;
} }
@@ -99,10 +99,10 @@ public class SFilterUtil {
} }
break; break;
} }
entry += ch; entry.append(ch);
} }
if (entry.length() > 0) { if (entry.length() > 0) {
splitText.add(entry); splitText.add(entry.toString());
} }
return splitText; return splitText;
} }

View File

@@ -154,7 +154,7 @@ public final class SItemManagerUtil {
}); });
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
for (final Entry<InventoryItem, Integer> itemEntry : sorted) { for (final Entry<InventoryItem, Integer> itemEntry : sorted) {
builder.append("\n" + itemEntry.getValue() + " * " + itemEntry.getKey().toString()); builder.append("\n").append(itemEntry.getValue()).append(" * ").append(itemEntry.getKey().toString());
} }
return builder.toString(); return builder.toString();
} }

View File

@@ -135,8 +135,7 @@ public class CardRanker {
} }
private static List<PaperCard> getCardsExceptOne(List<PaperCard> cache, int i) { private static List<PaperCard> getCardsExceptOne(List<PaperCard> cache, int i) {
List<PaperCard> otherCards = new ArrayList<>(); List<PaperCard> otherCards = new ArrayList<>(cache.subList(0, i));
otherCards.addAll(cache.subList(0, i));
if (i + 1 < cache.size()) { if (i + 1 < cache.size()) {
otherCards.addAll(cache.subList(i + 1, cache.size())); otherCards.addAll(cache.subList(i + 1, cache.size()));
} }

View File

@@ -63,11 +63,11 @@ public class InputConfirmMulligan extends InputSyncronizedBase {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (startingPlayer == player) { if (startingPlayer == player) {
sb.append(player).append(", "+ localizer.getMessage("lblYouAreGoingFirst") +"\n\n"); sb.append(player).append(", ").append(localizer.getMessage("lblYouAreGoingFirst")).append("\n\n");
} }
else { else {
sb.append(startingPlayer.getName()).append(" " + localizer.getMessage("lblIsGoingFirst") +".\n"); sb.append(startingPlayer.getName()).append(" ").append(localizer.getMessage("lblIsGoingFirst")).append(".\n");
sb.append(player).append(", "+ localizer.getMessage("lblYouAreGoing") + " ").append(Lang.getOrdinal(game.getPosition(player, startingPlayer))).append(".\n\n"); sb.append(player).append(", ").append(localizer.getMessage("lblYouAreGoing")).append(" ").append(Lang.getOrdinal(game.getPosition(player, startingPlayer))).append(".\n\n");
} }
getController().getGui().updateButtons(getOwner(), localizer.getMessage("lblKeep"), localizer.getMessage("lblMulligan"), true, true, true); getController().getGui().updateButtons(getOwner(), localizer.getMessage("lblKeep"), localizer.getMessage("lblMulligan"), true, true, true);

View File

@@ -270,14 +270,14 @@ public final class ConquestData {
List<ConquestCommander> commandersBeingExiled = null; List<ConquestCommander> commandersBeingExiled = null;
String message = "Exile the following " + cardStr + " to receive {AE}" + value + "?\n"; StringBuilder message = new StringBuilder("Exile the following " + cardStr + " to receive {AE}" + value + "?\n");
for (PaperCard card : cards) { for (PaperCard card : cards) {
if (planeswalker == card) { if (planeswalker == card) {
SOptionPane.showMessageDialog("Current planeswalker cannot be exiled.", title, SOptionPane.INFORMATION_ICON); SOptionPane.showMessageDialog("Current planeswalker cannot be exiled.", title, SOptionPane.INFORMATION_ICON);
return false; return false;
} }
String commandersUsingCard = ""; StringBuilder commandersUsingCard = new StringBuilder();
for (ConquestCommander commander : commanders) { for (ConquestCommander commander : commanders) {
if (commander.getCard() == card) { if (commander.getCard() == card) {
if (!commander.getDeck().getMain().isEmpty()) { if (!commander.getDeck().getMain().isEmpty()) {
@@ -290,19 +290,19 @@ public final class ConquestData {
commandersBeingExiled.add(commander); //cache commander to make it easier to remove later commandersBeingExiled.add(commander); //cache commander to make it easier to remove later
} }
if (commander.getDeck().getMain().contains(card)) { if (commander.getDeck().getMain().contains(card)) {
commandersUsingCard += "\n" + commander.getName(); commandersUsingCard.append("\n").append(commander.getName());
} }
} }
if (!commandersUsingCard.isEmpty()) { if (commandersUsingCard.length() > 0) {
SOptionPane.showMessageDialog(card.getName() + " is in use by the following commanders and cannot be exiled:\n" + commandersUsingCard, title, SOptionPane.INFORMATION_ICON); SOptionPane.showMessageDialog(card.getName() + " is in use by the following commanders and cannot be exiled:\n" + commandersUsingCard, title, SOptionPane.INFORMATION_ICON);
return false; return false;
} }
message += "\n" + card.getName(); message.append("\n").append(card.getName());
} }
if (SOptionPane.showConfirmDialog(message, title, "OK", "Cancel")) { if (SOptionPane.showConfirmDialog(message.toString(), title, "OK", "Cancel")) {
if (exiledCards.addAll(cards)) { if (exiledCards.addAll(cards)) {
if (commandersBeingExiled != null) { if (commandersBeingExiled != null) {
commanders.removeAll(commandersBeingExiled); commanders.removeAll(commandersBeingExiled);
@@ -326,11 +326,11 @@ public final class ConquestData {
return false; return false;
} }
String message = "Spend {AE}" + cost + " to retrieve the following " + cardStr + " from exile?\n"; StringBuilder message = new StringBuilder("Spend {AE}" + cost + " to retrieve the following " + cardStr + " from exile?\n");
for (PaperCard card : cards) { for (PaperCard card : cards) {
message += "\n" + card.getName(); message.append("\n").append(card.getName());
} }
if (SOptionPane.showConfirmDialog(message, title, "OK", "Cancel")) { if (SOptionPane.showConfirmDialog(message.toString(), title, "OK", "Cancel")) {
if (exiledCards.removeAll(cards)) { if (exiledCards.removeAll(cards)) {
for (PaperCard card : cards) { for (PaperCard card : cards) {
if (card.getRules().canBeCommander()) { //add back commander for card if needed if (card.getRules().canBeCommander()) { //add back commander for card if needed

View File

@@ -311,13 +311,13 @@ public class ConquestUtil {
} }
public static AEtherFilter getColorFilter(ColorSet color) { public static AEtherFilter getColorFilter(ColorSet color) {
String name = ""; StringBuilder name = new StringBuilder();
for (ManaCostShard s : color.getOrderedShards()) { for (ManaCostShard s : color.getOrderedShards()) {
name += s.toString(); name.append(s.toString());
} }
name = name.replaceAll("[{}]", ""); //remove all brackets name = new StringBuilder(name.toString().replaceAll("[{}]", "")); //remove all brackets
try { try {
return AEtherFilter.valueOf(name); return AEtherFilter.valueOf(name.toString());
} }
catch (Exception e) { catch (Exception e) {
System.err.println("No color filter with name " + name); System.err.println("No color filter with name " + name);
@@ -462,7 +462,7 @@ public class ConquestUtil {
double baseOdds = 0; double baseOdds = 0;
double remainingOdds = 1; double remainingOdds = 1;
CardRarity baseRarity = null; CardRarity baseRarity = null;
String caption = ""; StringBuilder caption = new StringBuilder();
for (CardRarity rarity : rarityOdds.keySet()) { for (CardRarity rarity : rarityOdds.keySet()) {
Double odds = oddsLookup.get(rarity); Double odds = oddsLookup.get(rarity);
@@ -479,16 +479,16 @@ public class ConquestUtil {
final String display = rounded < 1d final String display = rounded < 1d
? Double.toString(rounded) // Display decimal if < 1% ? Double.toString(rounded) // Display decimal if < 1%
: Long.toString(Math.round(rounded)); : Long.toString(Math.round(rounded));
caption += ", " + rarity.getLongName() + " (" + display + "%)"; caption.append(", ").append(rarity.getLongName()).append(" (").append(display).append("%)");
rarityOdds.put(rarity, odds); rarityOdds.put(rarity, odds);
} }
} }
//prepend base rarity and odds //prepend base rarity and odds
caption = baseRarity.getLongName() + " (" + (Math.round(1000 * remainingOdds) / 10) + "%)" + caption; caption.insert(0, baseRarity.getLongName() + " (" + (Math.round(1000 * remainingOdds) / 10) + "%)");
rarityOdds.put(baseRarity, remainingOdds); rarityOdds.put(baseRarity, remainingOdds);
return caption; return caption.toString();
} }
@Override @Override

View File

@@ -333,7 +333,7 @@ public class HumanPlay {
StringBuilder sb = new StringBuilder("Do you want to "); StringBuilder sb = new StringBuilder("Do you want to ");
sb.append(res.contains(p) ? "" : "let that player "); sb.append(res.contains(p) ? "" : "let that player ");
sb.append("draw " + Lang.nounWithAmount(amount, " card") + "?" + orString); sb.append("draw ").append(Lang.nounWithAmount(amount, " card")).append("?").append(orString);
if (!p.getController().confirmPayment(part, sb.toString(), sourceAbility)) { if (!p.getController().confirmPayment(part, sb.toString(), sourceAbility)) {
return false; return false;

View File

@@ -337,7 +337,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
if (min == 0) { if (min == 0) {
builder.append("up to "); builder.append("up to ");
} }
builder.append("%d " + message + "(s) to " + action + "."); builder.append("%d ").append(message).append("(s) to ").append(action).append(".");
final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid, sa); final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid, sa);
inp.setMessage(builder.toString()); inp.setMessage(builder.toString());
@@ -544,8 +544,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
for (SpellAbility spellAbility : spells) { for (SpellAbility spellAbility : spells) {
spellViewCache.put(spellAbility.getView(), spellAbility); spellViewCache.put(spellAbility.getView(), spellAbility);
} }
List<TrackableObject> choices = new ArrayList<>(); List<TrackableObject> choices = new ArrayList<>(spellViewCache.keySet());
choices.addAll(spellViewCache.keySet());
Object choice = getGui().one(title, choices); Object choice = getGui().one(title, choices);
// Human is supposed to read the message and understand from it what to // Human is supposed to read the message and understand from it what to
@@ -634,13 +633,13 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} }
final Map<String, Object> tos = sa.getTriggeringObjects(); final Map<String, Object> tos = sa.getTriggeringObjects();
if (tos.containsKey("Attacker")) { if (tos.containsKey("Attacker")) {
buildQuestion.append("\nAttacker: " + tos.get("Attacker")); buildQuestion.append("\nAttacker: ").append(tos.get("Attacker"));
} }
if (tos.containsKey("Card")) { if (tos.containsKey("Card")) {
final Card card = (Card) tos.get("Card"); final Card card = (Card) tos.get("Card");
if (card != null && (card.getController() == player || game.getZoneOf(card) == null if (card != null && (card.getController() == player || game.getZoneOf(card) == null
|| game.getZoneOf(card).getZoneType().isKnown())) { || game.getZoneOf(card).getZoneType().isKnown())) {
buildQuestion.append("\nTriggered by: " + tos.get("Card")); buildQuestion.append("\nTriggered by: ").append(tos.get("Card"));
} }
} }
@@ -1623,7 +1622,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// for the purpose of pre-ordering, no need for extra granularity // for the purpose of pre-ordering, no need for extra granularity
Integer idxAdditionalInfo = firstStr.indexOf(" ["); Integer idxAdditionalInfo = firstStr.indexOf(" [");
String saLookupKey = idxAdditionalInfo != -1 ? firstStr.substring(0, idxAdditionalInfo - 1) : firstStr; StringBuilder saLookupKey = new StringBuilder(idxAdditionalInfo != -1 ? firstStr.substring(0, idxAdditionalInfo - 1) : firstStr);
char delim = (char) 5; char delim = (char) 5;
for (int i = 1; i < activePlayerSAs.size(); i++) { for (int i = 1; i < activePlayerSAs.size(); i++) {
@@ -1635,14 +1634,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// are the same // are the same
} }
saLookupKey += delim + saStr; saLookupKey.append(delim).append(saStr);
idxAdditionalInfo = saLookupKey.indexOf(" ["); idxAdditionalInfo = saLookupKey.indexOf(" [");
if (idxAdditionalInfo != -1) { if (idxAdditionalInfo != -1) {
saLookupKey = saLookupKey.substring(0, idxAdditionalInfo - 1); saLookupKey = new StringBuilder(saLookupKey.substring(0, idxAdditionalInfo - 1));
} }
} }
if (needPrompt) { if (needPrompt) {
List<Integer> savedOrder = orderedSALookup.get(saLookupKey); List<Integer> savedOrder = orderedSALookup.get(saLookupKey.toString());
List<SpellAbilityView> orderedSAVs = Lists.newArrayList(); List<SpellAbilityView> orderedSAVs = Lists.newArrayList();
// create a mapping between a spell's view and the spell itself // create a mapping between a spell's view and the spell itself
@@ -1681,7 +1680,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
for (SpellAbility sa : orderedSAs) { for (SpellAbility sa : orderedSAs) {
savedOrder.add(activePlayerSAs.indexOf(sa)); savedOrder.add(activePlayerSAs.indexOf(sa));
} }
orderedSALookup.put(saLookupKey, savedOrder); orderedSALookup.put(saLookupKey.toString(), savedOrder);
} }
} }
for (int i = orderedSAs.size() - 1; i >= 0; i--) { for (int i = orderedSAs.size() - 1; i >= 0; i--) {

View File

@@ -212,16 +212,16 @@ public class ForgeProfileProperties {
//only append values that aren't equal to defaults //only append values that aren't equal to defaults
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
if (!userDir.equals(defaultUserDir)) { //ensure backslashes are escaped if (!userDir.equals(defaultUserDir)) { //ensure backslashes are escaped
sb.append(USER_DIR_KEY + "=" + userDir.replace("\\", "\\\\") + "\n"); sb.append(USER_DIR_KEY + "=").append(userDir.replace("\\", "\\\\")).append("\n");
} }
if (!decksDir.equals(defaultDecksDir)) { if (!decksDir.equals(defaultDecksDir)) {
sb.append(DECKS_DIR_KEY + "=" + decksDir.replace("\\", "\\\\") + "\n"); sb.append(DECKS_DIR_KEY + "=").append(decksDir.replace("\\", "\\\\")).append("\n");
} }
if (!cacheDir.equals(defaultCacheDir)) { if (!cacheDir.equals(defaultCacheDir)) {
sb.append(CACHE_DIR_KEY + "=" + cacheDir.replace("\\", "\\\\") + "\n"); sb.append(CACHE_DIR_KEY + "=").append(cacheDir.replace("\\", "\\\\")).append("\n");
} }
if (!cardPicsDir.equals(defaultCardPicsDir)) { if (!cardPicsDir.equals(defaultCardPicsDir)) {
sb.append(CARD_PICS_DIR_KEY + "=" + cardPicsDir.replace("\\", "\\\\") + "\n"); sb.append(CARD_PICS_DIR_KEY + "=").append(cardPicsDir.replace("\\", "\\\\")).append("\n");
} }
if (cardPicsSubDirs.size() > 0) { if (cardPicsSubDirs.size() > 0) {
sb.append(CARD_PICS_SUB_DIRS_KEY + "="); sb.append(CARD_PICS_SUB_DIRS_KEY + "=");
@@ -230,12 +230,12 @@ public class ForgeProfileProperties {
if (needDelim) { if (needDelim) {
sb.append("|"); sb.append("|");
} }
sb.append(entry.getKey() + "->" + entry.getValue()); sb.append(entry.getKey()).append("->").append(entry.getValue());
} }
sb.append("\n"); sb.append("\n");
} }
if (serverPort != 0) { if (serverPort != 0) {
sb.append(SERVER_PORT_KEY + "=" + serverPort); sb.append(SERVER_PORT_KEY + "=").append(serverPort);
} }
if (sb.length() > 0) { if (sb.length() > 0) {
FileUtil.writeFile(ForgeConstants.PROFILE_FILE, sb.toString()); FileUtil.writeFile(ForgeConstants.PROFILE_FILE, sb.toString());

View File

@@ -693,17 +693,17 @@ public class QuestEventDraft implements IQuestEvent {
if (edition != null) { if (edition != null) {
return edition.getName() + " (" + edition.getCode() + ")"; return edition.getName() + " (" + edition.getCode() + ")";
} }
String blockString = block.getName() + " ("; StringBuilder blockString = new StringBuilder(block.getName() + " (");
List<CardEdition> sets = block.getSets(); List<CardEdition> sets = block.getSets();
for (int i = 0; i < sets.size(); i++) { for (int i = 0; i < sets.size(); i++) {
CardEdition cardEdition = sets.get(i); CardEdition cardEdition = sets.get(i);
blockString += cardEdition.getCode(); blockString.append(cardEdition.getCode());
if (i < sets.size() - 1) { if (i < sets.size() - 1) {
blockString += ", "; blockString.append(", ");
} }
} }
blockString += ")"; blockString.append(")");
return blockString; return blockString.toString();
} }
public String getName() { public String getName() {
@@ -959,14 +959,14 @@ public class QuestEventDraft implements IQuestEvent {
final String s0c = sets.get(0).getCode(); final String s0c = sets.get(0).getCode();
if (sets.size() == 1) { if (sets.size() == 1) {
int numBoosters = block.getCntBoostersDraft(); int numBoosters = block.getCntBoostersDraft();
String combination = ""; StringBuilder combination = new StringBuilder();
for (int i = 0; i < numBoosters; i++) { for (int i = 0; i < numBoosters; i++) {
combination += s0c; combination.append(s0c);
if (i < numBoosters - 1) { if (i < numBoosters - 1) {
combination += "/"; combination.append("/");
} }
} }
possibleCombinations.add(combination); possibleCombinations.add(combination.toString());
return possibleCombinations; return possibleCombinations;
} }
@@ -1087,15 +1087,15 @@ public class QuestEventDraft implements IQuestEvent {
} }
public String getBoosterList() { public String getBoosterList() {
String boosterList = ""; StringBuilder boosterList = new StringBuilder();
String[] boosterArray = boosterConfiguration.split("/"); String[] boosterArray = boosterConfiguration.split("/");
for (int i = 0; i < boosterArray.length; i++) { for (int i = 0; i < boosterArray.length; i++) {
boosterList += FModel.getMagicDb().getEditions().get(boosterArray[i]).getName(); boosterList.append(FModel.getMagicDb().getEditions().get(boosterArray[i]).getName());
if (i != boosterArray.length - 1) { if (i != boosterArray.length - 1) {
boosterList += " | "; boosterList.append(" | ");
} }
} }
return boosterList; return boosterList.toString();
} }
@Override @Override

View File

@@ -19,27 +19,27 @@ public abstract class QuestRewardCard implements IQuestRewardCard {
return defaultDescription; return defaultDescription;
} }
String buildDesc = null; StringBuilder buildDesc = null;
for (final String s : input) { for (final String s : input) {
if (s.startsWith("desc:") || s.startsWith("Desc:")) { if (s.startsWith("desc:") || s.startsWith("Desc:")) {
final String[] tmp = s.split(":"); final String[] tmp = s.split(":");
if (tmp.length > 1) { if (tmp.length > 1) {
buildDesc = tmp[1]; buildDesc = new StringBuilder(tmp[1]);
} else { } else {
buildDesc = ""; buildDesc = new StringBuilder();
} }
} else if (buildDesc != null) { } else if (buildDesc != null) {
if (s.contains(":")) { if (s.contains(":")) {
return buildDesc; return buildDesc.toString();
} else { } else {
buildDesc = buildDesc + " " + s; buildDesc.append(" ").append(s);
} }
} }
} }
if (buildDesc != null) { if (buildDesc != null) {
return buildDesc; return buildDesc.toString();
} }
return defaultDescription; return defaultDescription;
} }

View File

@@ -323,7 +323,7 @@ public class QuestUtil {
view.getCbxMatchLength().removeAllItems(); view.getCbxMatchLength().removeAllItems();
boolean activeCharms = false; boolean activeCharms = false;
StringBuilder matchLength = new StringBuilder(); StringBuilder matchLength = new StringBuilder();
matchLength.append(localizer.getMessage("lblMatchBestof") + " ").append(qCtrl.getMatchLength()); matchLength.append(localizer.getMessage("lblMatchBestof")).append(" ").append(qCtrl.getMatchLength());
if (qCtrl.getAssets().hasItem(QuestItemType.CHARM_VIM)) { if (qCtrl.getAssets().hasItem(QuestItemType.CHARM_VIM)) {
view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf1")); view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf1"));
activeCharms = true; activeCharms = true;

View File

@@ -227,7 +227,7 @@ public class QuestWinLoseController {
sb.append(" opponent: ").append(credBase).append(" credits.\n"); sb.append(" opponent: ").append(credBase).append(" credits.\n");
if(qEvent.getIsRandomMatch()){ if(qEvent.getIsRandomMatch()){
sb.append("Random Opponent Bonus: " + credBase + " credit" + (credBase > 1 ? "s." : ".") + "\n"); sb.append("Random Opponent Bonus: ").append(credBase).append(" credit").append(credBase > 1 ? "s." : ".").append("\n");
credBase += credBase; credBase += credBase;
} }

View File

@@ -142,9 +142,7 @@ public class QuestPetStorage {
final List<QuestPetController> result = new ArrayList<>(); final List<QuestPetController> result = new ArrayList<>();
final List<QuestPetController> allPossible = this.petsBySlot.get(Integer.valueOf(iSlot)); final List<QuestPetController> allPossible = this.petsBySlot.get(Integer.valueOf(iSlot));
if (null != allPossible) { if (null != allPossible) {
for (final QuestPetController c : allPossible) { result.addAll(allPossible);
result.add(c);
}
} }
return result; return result;
} }

View File

@@ -540,14 +540,14 @@ public class QuestDataIO {
writer.endNode(); writer.endNode();
writer.startNode("packs"); writer.startNode("packs");
String output = ""; StringBuilder output = new StringBuilder();
for (int i = 0; i < draft.getBoosterConfiguration().length; i++) { for (int i = 0; i < draft.getBoosterConfiguration().length; i++) {
output += draft.getBoosterConfiguration()[i]; output.append(draft.getBoosterConfiguration()[i]);
if (i != draft.getBoosterConfiguration().length - 1) { if (i != draft.getBoosterConfiguration().length - 1) {
output += "/"; output.append("/");
} }
} }
writer.setValue(output); writer.setValue(output.toString());
writer.endNode(); writer.endNode();
writer.startNode("entryFee"); writer.startNode("entryFee");

View File

@@ -199,40 +199,40 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
resultSound = SoundEffectType.ScriptedEffect; resultSound = SoundEffectType.ScriptedEffect;
} else { } else {
// I want to get all real colors this land can produce - no interest in colorless or devoid // I want to get all real colors this land can produce - no interest in colorless or devoid
String fullManaColors = ""; StringBuilder fullManaColors = new StringBuilder();
for (final SpellAbility sa : land.getManaAbilities()) { for (final SpellAbility sa : land.getManaAbilities()) {
String currManaColor = sa.getManaPartRecursive().getOrigProduced(); String currManaColor = sa.getManaPartRecursive().getOrigProduced();
if(!"C".equals(currManaColor)) { if(!"C".equals(currManaColor)) {
fullManaColors = fullManaColors + currManaColor; fullManaColors.append(currManaColor);
} }
} }
// No interest if "colors together" or "alternative colors" - only interested in colors themselves // No interest if "colors together" or "alternative colors" - only interested in colors themselves
fullManaColors = fullManaColors.replaceAll("\\s", ""); fullManaColors = new StringBuilder(fullManaColors.toString().replaceAll("\\s", ""));
int fullManaColorsLength = fullManaColors.length(); int fullManaColorsLength = fullManaColors.length();
if(fullManaColorsLength >= 3) { if(fullManaColorsLength >= 3) {
// three color land // three color land
fullManaColors = fullManaColors.substring(0,3); fullManaColors = new StringBuilder(fullManaColors.substring(0, 3));
if (fullManaColors.contains("W") && fullManaColors.contains("U") && fullManaColors.contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueBlackLand)) { if (fullManaColors.toString().contains("W") && fullManaColors.toString().contains("U") && fullManaColors.toString().contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueBlackLand)) {
resultSound = SoundEffectType.WhiteBlueBlackLand; resultSound = SoundEffectType.WhiteBlueBlackLand;
} else if (fullManaColors.contains("W") && fullManaColors.contains("G") && fullManaColors.contains("U") && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenBlueLand)) { } else if (fullManaColors.toString().contains("W") && fullManaColors.toString().contains("G") && fullManaColors.toString().contains("U") && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenBlueLand)) {
resultSound = SoundEffectType.WhiteGreenBlueLand; resultSound = SoundEffectType.WhiteGreenBlueLand;
} else if (fullManaColors.contains("W") && fullManaColors.contains("R") && fullManaColors.contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedBlackLand)) { } else if (fullManaColors.toString().contains("W") && fullManaColors.toString().contains("R") && fullManaColors.toString().contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedBlackLand)) {
resultSound = SoundEffectType.WhiteRedBlackLand; resultSound = SoundEffectType.WhiteRedBlackLand;
} else if (fullManaColors.contains("B") && fullManaColors.contains("W") && fullManaColors.contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteGreenLand)) { } else if (fullManaColors.toString().contains("B") && fullManaColors.toString().contains("W") && fullManaColors.toString().contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteGreenLand)) {
resultSound = SoundEffectType.BlackWhiteGreenLand; resultSound = SoundEffectType.BlackWhiteGreenLand;
} else if (fullManaColors.contains("B") && fullManaColors.contains("R") && fullManaColors.contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackRedGreenLand)) { } else if (fullManaColors.toString().contains("B") && fullManaColors.toString().contains("R") && fullManaColors.toString().contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackRedGreenLand)) {
resultSound = SoundEffectType.BlackRedGreenLand; resultSound = SoundEffectType.BlackRedGreenLand;
} else if (fullManaColors.contains("U") && fullManaColors.contains("B") && fullManaColors.contains("R") && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackRedLand)) { } else if (fullManaColors.toString().contains("U") && fullManaColors.toString().contains("B") && fullManaColors.toString().contains("R") && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackRedLand)) {
resultSound = SoundEffectType.BlueBlackRedLand; resultSound = SoundEffectType.BlueBlackRedLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("U") && fullManaColors.contains("R") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueRedLand)) { } else if (fullManaColors.toString().contains("G") && fullManaColors.toString().contains("U") && fullManaColors.toString().contains("R") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueRedLand)) {
resultSound = SoundEffectType.GreenBlueRedLand; resultSound = SoundEffectType.GreenBlueRedLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("B") && fullManaColors.contains("U") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackBlueLand)) { } else if (fullManaColors.toString().contains("G") && fullManaColors.toString().contains("B") && fullManaColors.toString().contains("U") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackBlueLand)) {
resultSound = SoundEffectType.GreenBlackBlueLand; resultSound = SoundEffectType.GreenBlackBlueLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("R") && fullManaColors.contains("W") && SoundSystem.instance.hasResource(SoundEffectType.GreenRedWhiteLand)) { } else if (fullManaColors.toString().contains("G") && fullManaColors.toString().contains("R") && fullManaColors.toString().contains("W") && SoundSystem.instance.hasResource(SoundEffectType.GreenRedWhiteLand)) {
resultSound = SoundEffectType.GreenRedWhiteLand; resultSound = SoundEffectType.GreenRedWhiteLand;
} else if (fullManaColors.contains("R") && fullManaColors.contains("U") && fullManaColors.contains("W") && SoundSystem.instance.hasResource(SoundEffectType.RedBlueWhiteLand)) { } else if (fullManaColors.toString().contains("R") && fullManaColors.toString().contains("U") && fullManaColors.toString().contains("W") && SoundSystem.instance.hasResource(SoundEffectType.RedBlueWhiteLand)) {
resultSound = SoundEffectType.RedBlueWhiteLand; resultSound = SoundEffectType.RedBlueWhiteLand;
} }
} }
@@ -240,26 +240,26 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
if(resultSound == null && fullManaColorsLength >= 2) { if(resultSound == null && fullManaColorsLength >= 2) {
// three color land without sounds installed, or two color land // three color land without sounds installed, or two color land
// lets try // lets try
fullManaColors = fullManaColors.substring(0,2); fullManaColors = new StringBuilder(fullManaColors.substring(0, 2));
if (fullManaColors.contains("W") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) { if (fullManaColors.toString().contains("W") && (fullManaColors.toString().contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) {
resultSound = SoundEffectType.WhiteBlueLand; resultSound = SoundEffectType.WhiteBlueLand;
} else if (fullManaColors.contains("W") && (fullManaColors.contains("G")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenLand)) { } else if (fullManaColors.toString().contains("W") && (fullManaColors.toString().contains("G")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenLand)) {
resultSound = SoundEffectType.WhiteGreenLand; resultSound = SoundEffectType.WhiteGreenLand;
} else if (fullManaColors.contains("W") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedLand)) { } else if (fullManaColors.toString().contains("W") && (fullManaColors.toString().contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedLand)) {
resultSound = SoundEffectType.WhiteRedLand; resultSound = SoundEffectType.WhiteRedLand;
} else if (fullManaColors.contains("B") && (fullManaColors.contains("W")) && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteLand)) { } else if (fullManaColors.toString().contains("B") && (fullManaColors.toString().contains("W")) && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteLand)) {
resultSound = SoundEffectType.BlackWhiteLand; resultSound = SoundEffectType.BlackWhiteLand;
} else if (fullManaColors.contains("B") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.BlackRedLand)) { } else if (fullManaColors.toString().contains("B") && (fullManaColors.toString().contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.BlackRedLand)) {
resultSound = SoundEffectType.BlackRedLand; resultSound = SoundEffectType.BlackRedLand;
} else if (fullManaColors.contains("U") && (fullManaColors.contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackLand)) { } else if (fullManaColors.toString().contains("U") && (fullManaColors.toString().contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackLand)) {
resultSound = SoundEffectType.BlueBlackLand; resultSound = SoundEffectType.BlueBlackLand;
} else if (fullManaColors.contains("G") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueLand)) { } else if (fullManaColors.toString().contains("G") && (fullManaColors.toString().contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueLand)) {
resultSound = SoundEffectType.GreenBlueLand; resultSound = SoundEffectType.GreenBlueLand;
} else if (fullManaColors.contains("G") && (fullManaColors.contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackLand)) { } else if (fullManaColors.toString().contains("G") && (fullManaColors.toString().contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackLand)) {
resultSound = SoundEffectType.GreenBlackLand; resultSound = SoundEffectType.GreenBlackLand;
} else if (fullManaColors.contains("G") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.GreenRedLand)) { } else if (fullManaColors.toString().contains("G") && (fullManaColors.toString().contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.GreenRedLand)) {
resultSound = SoundEffectType.GreenRedLand; resultSound = SoundEffectType.GreenRedLand;
} else if (fullManaColors.contains("R") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.RedBlueLand)) { } else if (fullManaColors.toString().contains("R") && (fullManaColors.toString().contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.RedBlueLand)) {
resultSound = SoundEffectType.RedBlueLand; resultSound = SoundEffectType.RedBlueLand;
} }
} }
@@ -268,17 +268,17 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
// multicolor land without sounds installed, or single mana land, or colorless/devoid land // multicolor land without sounds installed, or single mana land, or colorless/devoid land
// in case of multicolor, lets take only the 1st color of the list, it sure has sound // in case of multicolor, lets take only the 1st color of the list, it sure has sound
if(fullManaColorsLength >= 2) { if(fullManaColorsLength >= 2) {
fullManaColors = fullManaColors.substring(0,1); fullManaColors = new StringBuilder(fullManaColors.substring(0, 1));
} }
if (fullManaColors.contains("B")) { if (fullManaColors.toString().contains("B")) {
resultSound = SoundEffectType.BlackLand; resultSound = SoundEffectType.BlackLand;
} else if (fullManaColors.contains("U")) { } else if (fullManaColors.toString().contains("U")) {
resultSound = SoundEffectType.BlueLand; resultSound = SoundEffectType.BlueLand;
} else if (fullManaColors.contains("G")) { } else if (fullManaColors.toString().contains("G")) {
resultSound = SoundEffectType.GreenLand; resultSound = SoundEffectType.GreenLand;
} else if (fullManaColors.contains("R")) { } else if (fullManaColors.toString().contains("R")) {
resultSound = SoundEffectType.RedLand; resultSound = SoundEffectType.RedLand;
} else if (fullManaColors.contains("W")) { } else if (fullManaColors.toString().contains("W")) {
resultSound = SoundEffectType.WhiteLand; resultSound = SoundEffectType.WhiteLand;
} else { } else {
resultSound = SoundEffectType.OtherLand; resultSound = SoundEffectType.OtherLand;

View File

@@ -45,10 +45,10 @@ public class RestartUtil {
// program main is a jar // program main is a jar
if (mainCommand[0].endsWith(".jar")) { if (mainCommand[0].endsWith(".jar")) {
// if it's a jar, add -jar mainJar // if it's a jar, add -jar mainJar
cmd.append("-jar " + new File(mainCommand[0]).getPath()); cmd.append("-jar ").append(new File(mainCommand[0]).getPath());
} else { } else {
// else it's a .class, add the classpath and mainClass // else it's a .class, add the classpath and mainClass
cmd.append("-cp \"" + System.getProperty("java.class.path") + "\" " + mainCommand[0]); cmd.append("-cp \"").append(System.getProperty("java.class.path")).append("\" ").append(mainCommand[0]);
} }
// finally add program arguments // finally add program arguments
for (int i = 1; i < mainCommand.length; i++) { for (int i = 1; i < mainCommand.length; i++) {