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
public static List<Card> getOpponentCreatures(final Player defender) {
List<Card> defenders = new ArrayList<>();
defenders.addAll(defender.getCreaturesInPlay());
List<Card> defenders = new ArrayList<>(defender.getCreaturesInPlay());
Predicate<Card> canAnimate = new Predicate<Card>() {
@Override
public boolean apply(Card c) {

View File

@@ -148,9 +148,7 @@ public class AiBlockController {
final CardCollection attackers = combat.getAttackersOf(defender);
// Begin with the attackers that pose the biggest threat
CardLists.sortByPowerDesc(attackers);
for (final Card c : attackers) {
sortedAttackers.add(c);
}
sortedAttackers.addAll(attackers);
} else if (defender instanceof Player && defender.equals(ai)) {
firstAttacker = combat.getAttackersOf(defender);
}
@@ -163,9 +161,7 @@ public class AiBlockController {
}
} else {
// add creatures attacking the Player to the back of the list
for (final Card c : firstAttacker) {
sortedAttackers.add(c);
}
sortedAttackers.addAll(firstAttacker);
}
return sortedAttackers;
}
@@ -481,8 +477,7 @@ public class AiBlockController {
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, secondBlocker, combat, false);
List<Card> usableBlockersAsThird = new ArrayList<>();
usableBlockersAsThird.addAll(usableBlockers);
List<Card> usableBlockersAsThird = new ArrayList<>(usableBlockers);
usableBlockersAsThird.remove(secondBlocker);
// 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);
} else if (logic.equals("MostNeededType")) {
// Choose a type that is in the deck, but not in hand or on the battlefield
final List<String> basics = new ArrayList<>();
basics.addAll(CardType.Constant.BASIC_TYPES);
final List<String> basics = new ArrayList<>(CardType.Constant.BASIC_TYPES);
CardCollectionView presentCards = CardCollection.combine(ai.getCardsIn(ZoneType.Battlefield), ai.getCardsIn(ZoneType.Hand));
CardCollectionView possibleCards = ai.getAllCards();

View File

@@ -254,7 +254,7 @@ public abstract class GameState {
newText.append(";");
}
if (c.isToken()) {
newText.append("t:" + new TokenInfo(c).toString());
newText.append("t:").append(new TokenInfo(c).toString());
} else {
if (c.getPaperCard() == null) {
return;
@@ -377,7 +377,7 @@ public abstract class GameState {
newText.append("|Attacking");
GameEntity def = c.getGame().getCombat().getDefenderByAttacker(c);
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) {
String mana = "";
StringBuilder mana = new StringBuilder();
for (final byte c : MagicColor.WUBRGC) {
int amount = manaPool.getAmountOfColor(c);
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) {

View File

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

View File

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

View File

@@ -270,28 +270,28 @@ public class SpellAbilityPicker {
return abilityToString(sa, true);
}
public static String abilityToString(SpellAbility sa, boolean withTargets) {
String saString = "N/A";
StringBuilder saString = new StringBuilder("N/A");
if (sa != null) {
saString = sa.toString();
saString = new StringBuilder(sa.toString());
String cardName = sa.getHostCard().getName();
if (!cardName.isEmpty()) {
saString = TextUtil.fastReplace(saString, cardName, "<$>");
saString = new StringBuilder(TextUtil.fastReplace(saString.toString(), cardName, "<$>"));
}
if (saString.length() > 40) {
saString = saString.substring(0, 40) + "...";
saString = new StringBuilder(saString.substring(0, 40) + "...");
}
if (withTargets) {
SpellAbility saOrSubSa = sa;
do {
if (saOrSubSa.usesTargeting()) {
saString += " (targets: " + saOrSubSa.getTargets().getTargetedString() + ")";
saString.append(" (targets: ").append(saOrSubSa.getTargets().getTargetedString()).append(")");
}
saOrSubSa = saOrSubSa.getSubAbility();
} while (saOrSubSa != null);
}
saString = sa.getHostCard() + " -> " + saString;
saString.insert(0, sa.getHostCard() + " -> ");
}
return saString;
return saString.toString();
}
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();
if (this.genericCost > 0) {
sb.append("{" + this.genericCost + "}");
sb.append("{").append(this.genericCost).append("}");
}
for (final ManaCostShard s : this.shards) {
if (s == ManaCostShard.X) {
@@ -251,7 +251,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
StringBuilder builder = new StringBuilder();
builder.append(mc.hasNoCost ? -1 : mc.genericCost);
for (ManaCostShard shard : mc.shards) {
builder.append(DELIM + shard.name());
builder.append(DELIM).append(shard.name());
}
return builder.toString();
}

View File

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

View File

@@ -38,7 +38,7 @@ public class TextUtil {
} else {
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();
}

View File

@@ -9,15 +9,7 @@ import com.google.common.collect.Sets;
import org.apache.commons.lang3.ArrayUtils;
import java.io.Serializable;
import java.util.Collection;
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;
import java.util.*;
/**
* 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.
*/
public FCollection(final T[] c) {
for (final T e : c) {
add(e);
}
this.addAll(Arrays.asList(c));
}
/**
@@ -87,9 +77,7 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
* creation.
*/
public FCollection(final Iterable<? extends T> i) {
for (final T e : i) {
add(e);
}
this.addAll(i);
}
/**

View File

@@ -229,11 +229,11 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
continue;
}
if (sb.length() > 0) sb.append("\n");
sb.append(ev.player + " assigned " + Lang.joinHomogenous(attackers));
sb.append(" to attack " + k + ".");
sb.append(ev.player).append(" assigned ").append(Lang.joinHomogenous(attackers));
sb.append(" to attack ").append(k).append(".");
}
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());
}
@@ -265,10 +265,10 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
blockers = att.getValue();
if (blockers.isEmpty()) {
sb.append(controllerName + " didn't block ");
sb.append(controllerName).append(" didn't block ");
}
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(".");

View File

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

View File

@@ -83,7 +83,7 @@ public abstract class SpellAbilityEffect {
"CARDNAME", sa.getHostCard().getName()));
}
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
makeSpellDescription(sa, sb, stackDesc);
@@ -258,7 +258,7 @@ public abstract class SpellAbilityEffect {
if (your) {
delTrig.append("| ValidPlayer$ You ");
}
delTrig.append("| TriggerDescription$ " + desc);
delTrig.append("| TriggerDescription$ ").append(desc);
final Trigger trig = TriggerHandler.parseTrigger(delTrig.toString(), sa.getHostCard(), intrinsic);
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);
} while (selectedCards != null && selectedCards.size() > changeNum);
if (selectedCards != null) {
for (Card card : selectedCards) {
chosenCards.add(card);
}
chosenCards.addAll(selectedCards);
}
// maybe prompt the user if they selected fewer than the maximum possible?
} else {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ public class EncodeEffect extends SpellAbilityEffect {
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())) {
return;
}

View File

@@ -26,10 +26,10 @@ public class FightEffect extends DamageBaseEffect {
List<Card> fighters = getFighters(sa);
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) {
sb.append(fighters.get(0) + " fights unknown");
sb.append(fighters.get(0)).append(" fights unknown");
}
return sb.toString();
}

View File

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

View File

@@ -105,7 +105,7 @@ public class MillEffect extends SpellAbilityEffect {
sb.append("s");
}
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();

View File

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

View File

@@ -332,10 +332,8 @@ public class PumpEffect extends SpellAbilityEffect {
}
if (sa.hasParam("Radiance")) {
for (final Card c : CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts")
.split(","))) {
untargetedCards.add(c);
}
untargetedCards.addAll(CardUtil.getRadiance(host, tgtCards.get(0), sa.getParam("ValidTgts")
.split(",")));
}
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);
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);
final Map<String, Object> runParams = Maps.newHashMap();

View File

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

View File

@@ -106,16 +106,16 @@ public class TwoPilesEffect extends SpellAbilityEffect {
CardCollectionView chosenPile = 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()) {
for (Card c : chosenPile) {
notification += c.getName() + "\n";
notification.append(c.getName()).append("\n");
}
} 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
if (sa.hasParam("ChosenPile")) {

View File

@@ -1652,13 +1652,13 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!mCost.isOnlyManaCost()) {
sbLong.append(".");
}
sbLong.append(" (" + inst.getReminderText() + ")");
sbLong.append(" (").append(inst.getReminderText()).append(")");
sbLong.append("\r\n");
}
} else if (keyword.startsWith("Emerge")) {
final String[] k = keyword.split(":");
sbLong.append(k[0]).append(" ").append(ManaCostParser.parse(k[1]));
sbLong.append(" (" + inst.getReminderText() + ")");
sbLong.append(" (").append(inst.getReminderText()).append(")");
sbLong.append("\r\n");
} else if (keyword.startsWith("Echo")) {
sbLong.append("Echo ");
@@ -1689,7 +1689,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final String[] n = keyword.split(":");
final Cost cost = new Cost(n[1], false);
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")) {
if (!keyword.endsWith("Generic")) {
@@ -1703,7 +1703,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final Cost cost2 = new Cost(n[2], false);
sbx.append(cost2.toSimpleString());
}
sbx.append(" (" + inst.getReminderText() + ")");
sbx.append(" (").append(inst.getReminderText()).append(")");
sbLong.append(sbx).append("\r\n");
}
} 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("Totem armor") || keyword.equals("Battle cry")
|| keyword.equals("Devoid") || keyword.equals("Riot")){
sbLong.append(keyword + " (" + inst.getReminderText() + ")");
sbLong.append(keyword).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.startsWith("Partner:")) {
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")
|| keyword.startsWith("Fabricate") || keyword.startsWith("Soulshift") || keyword.startsWith("Bushido")
|| 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("Renown") || keyword.startsWith("Annihilator") || keyword.startsWith("Devour")) {
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")) {
sb.append("\r\nHaunt (");
if (isCreature()) {
@@ -1766,14 +1766,14 @@ public class Card extends GameEntity implements Comparable<Card> {
if (sb.length() != 0) {
sb.append("\r\n");
}
sb.append(keyword + " (" + inst.getReminderText() + ")");
sb.append(keyword).append(" (").append(inst.getReminderText()).append(")");
} else if (keyword.endsWith(" offering")) {
String offeringType = keyword.split(" ")[0];
if (sb.length() != 0) {
sb.append("\r\n");
}
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")
|| keyword.startsWith("Unearth") || keyword.startsWith("Scavenge") || keyword.startsWith("Spectacle")
|| 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();
if (meld != "" && (!hasMeldEffect)) {
sb.append("\r\n");
sb.append("(Melds with " + meld + ".)");
sb.append("(Melds with ").append(meld).append(".)");
sb.append("\r\n");
}
}
@@ -2042,7 +2042,7 @@ public class Card extends GameEntity implements Comparable<Card> {
}
if (isGoaded()) {
sb.append("is goaded by: " + Lang.joinHomogenous(getGoaded()));
sb.append("is goaded by: ").append(Lang.joinHomogenous(getGoaded()));
sb.append("\r\n");
}
// 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("Devoid") || keyword.equals("Lifelink")
|| keyword.equals("Split second")) {
sbBefore.append(keyword + " (" + inst.getReminderText() + ")");
sbBefore.append(keyword).append(" (").append(inst.getReminderText()).append(")");
sbBefore.append("\r\n");
} else if(keyword.equals("Conspire") || keyword.equals("Epic")
|| keyword.equals("Suspend") || keyword.equals("Jump-start")) {
sbAfter.append(keyword + " (" + inst.getReminderText() + ")");
sbAfter.append(keyword).append(" (").append(inst.getReminderText()).append(")");
sbAfter.append("\r\n");
} 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");
} 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");
} else if (keyword.startsWith("Escalate") || keyword.startsWith("Buyback")
|| keyword.startsWith("Prowl")) {
@@ -2129,14 +2129,13 @@ public class Card extends GameEntity implements Comparable<Card> {
sbCost.append(" ");
}
sbCost.append(cost.toSimpleString());
sbBefore.append(sbCost + " (" + inst.getReminderText() + ")");
sbBefore.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
sbBefore.append("\r\n");
} else if (keyword.startsWith("Multikicker")) {
if (!keyword.endsWith("Generic")) {
final String[] n = keyword.split(":");
final Cost cost = new Cost(n[1], false);
sbBefore.append("Multikicker ").append(cost.toSimpleString())
.append(" (" + inst.getReminderText() + ")").append("\r\n");
sbBefore.append("Multikicker ").append(cost.toSimpleString()).append(" (").append(inst.getReminderText()).append(")").append("\r\n");
}
} else if (keyword.startsWith("Kicker")) {
if (!keyword.endsWith("Generic")) {
@@ -2150,7 +2149,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final Cost cost2 = new Cost(n[2], false);
sbx.append(cost2.toSimpleString());
}
sbx.append(" (" + inst.getReminderText() + ")");
sbx.append(" (").append(inst.getReminderText()).append(")");
sbBefore.append(sbx).append("\r\n");
}
}else if (keyword.startsWith("AlternateAdditionalCost")) {
@@ -2179,7 +2178,7 @@ public class Card extends GameEntity implements Comparable<Card> {
sbCost.append(" ");
}
sbCost.append(cost.toSimpleString());
sbAfter.append(sbCost + " (" + inst.getReminderText() + ")");
sbAfter.append(sbCost).append(" (").append(inst.getReminderText()).append(")");
sbAfter.append("\r\n");
} 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.")) {
@@ -2209,7 +2208,7 @@ public class Card extends GameEntity implements Comparable<Card> {
}
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")) {
sbAfter.append("Storm (");

View File

@@ -901,11 +901,11 @@ public class CardFactoryUtil {
if (sq[0].contains("xColorPaid")) {
String[] attrs = sq[0].split(" ");
String colors = "";
StringBuilder colors = new StringBuilder();
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()) {
repEffsb.append(" | ActiveZones$ " + zone);
repEffsb.append(" | ActiveZones$ ").append(zone);
}
ReplacementEffect re = ReplacementHandler.parseReplacement(repEffsb.toString(), card, intrinsic);
@@ -2323,7 +2323,7 @@ public class CardFactoryUtil {
StringBuilder trig = new StringBuilder();
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(")");
StringBuilder trigReturn = new StringBuilder();
@@ -2677,7 +2677,7 @@ public class CardFactoryUtil {
final StringBuilder sbTrig = new StringBuilder();
sbTrig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ");
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();
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();
sb.append(costStr.substring(0,1).toLowerCase() + costStr.substring(1));
sb.append(costStr.substring(0, 1).toLowerCase()).append(costStr.substring(1));
sb.append(".");
String upkeepTrig = "Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | " +
@@ -3934,8 +3934,8 @@ public class CardFactoryUtil {
} else {
abilityStr.append(" ");
}
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")");
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
// instantiate attach ability
final SpellAbility newSA = AbilityFactory.getAbility(abilityStr.toString(), card);
newSA.setIntrinsic(intrinsic);
@@ -4008,7 +4008,7 @@ public class CardFactoryUtil {
abilityStr.append("| PrecostDesc$ Fortify");
Cost cost = new Cost(equipCost, true);
abilityStr.append(cost.isOnlyManaCost() ? " " : "");
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (");
abilityStr.append(inst.getReminderText()).append(")");
@@ -4169,8 +4169,8 @@ public class CardFactoryUtil {
} else {
abilityStr.append(" ");
}
abilityStr.append("| CostDesc$ " + cost.toSimpleString() + " ");
abilityStr.append("| SpellDescription$ (" + inst.getReminderText() + ")");
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
final SpellAbility sa = AbilityFactory.getAbility(abilityStr.toString(), card);
sa.setIntrinsic(intrinsic);
@@ -4192,7 +4192,7 @@ public class CardFactoryUtil {
// makes new SpellDescription
final StringBuilder sb = new StringBuilder();
sb.append(newSA.getCostDescription());
sb.append("(" + inst.getReminderText() + ")");
sb.append("(").append(inst.getReminderText()).append(")");
newSA.setDescription(sb.toString());
newSA.setBasicSpell(false);
@@ -4209,9 +4209,9 @@ public class CardFactoryUtil {
StringBuilder sb = new StringBuilder();
sb.append("AB$ PutCounter | CounterType$ P1P1 | ActivationZone$ Hand");
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("| 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("| SpellDescription$ (").append(inst.getReminderText()).append(")");
@@ -4421,7 +4421,7 @@ public class CardFactoryUtil {
sb.append(manacost);
sb.append(" Discard<1/CARDNAME> | ActivationZone$ Hand | PrecostDesc$ Cycling");
sb.append(cost.isOnlyManaCost() ? " " : "");
sb.append("| CostDesc$ " + cost.toSimpleString() + " ");
sb.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
sb.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
SpellAbility sa = AbilityFactory.getAbility(sb.toString(), card);
@@ -4494,7 +4494,7 @@ public class CardFactoryUtil {
StringBuilder sb = new StringBuilder();
sb.append("Mode$ Continuous | EffectZone$ Exile | Affected$ Card.EncodedWithSource");
sb.append(" | AddTrigger$ CipherTrigger");
sb.append(" | Description$ Cipher (" + inst.getReminderText() + ")");
sb.append(" | Description$ Cipher (").append(inst.getReminderText()).append(")");
effect = sb.toString();

View File

@@ -82,7 +82,7 @@ public final class CardPlayOption {
switch (getPayManaCost()) {
case YES:
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()) {
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) {
StringBuilder colorDesc = new StringBuilder();
for (final String col : colors) {
colorDesc.append(MagicColor.toShortString(col) + " ");
colorDesc.append(MagicColor.toShortString(col)).append(" ");
}
return colorDesc.toString();
}

View File

@@ -559,7 +559,7 @@ public class CardView extends GameEntityView {
sb.append(rulesText).append("\r\n\r\n");
}
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");
}

View File

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

View File

@@ -123,7 +123,7 @@ public class CostRemoveAnyCounter extends CostPartWithList {
sb.append("Remove ");
sb.append(Cost.convertIntAndTypeToWords(this.convertAmount(), "counter"));
final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
sb.append(" from " + desc);
sb.append(" from ").append(desc);
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");
} else if (type.contains("+withTotalPowerGE")) {
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 {
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), "untapped " + desc));
sb.append(" you control");

View File

@@ -610,12 +610,12 @@ public class ManaCostBeingPaid {
if (nGeneric > 0) {
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
String genericStr = String.valueOf(nGeneric);
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) {
if (c.hasKeyword("You may choose not to untap CARDNAME during your untap step.")) {
if (c.isTapped()) {
String prompt = "Untap " + c.toString() + "?";
StringBuilder prompt = new StringBuilder("Untap " + c.toString() + "?");
boolean defaultChoice = true;
if (c.getGainControlTargets().size() > 0) {
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) {
prompt += target;
prompt.append(target);
if (target.isInPlay()) {
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) {
c.untap();
}

View File

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

View File

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

View File

@@ -136,9 +136,7 @@ public final class SResizingUtil {
int smoothVal = 0;
Set<Component> existingComponents = new HashSet<>();
for (Component c : pnlContent.getComponents()) {
existingComponents.add(c);
}
existingComponents.addAll(Arrays.asList(pnlContent.getComponents()));
// 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 %)

View File

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

View File

@@ -32,7 +32,7 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
final Localizer localizer = Localizer.getInstance();
StringBuilder tooltip = new StringBuilder();
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))) {
tooltip.append(st.label.substring(0, 1).toLowerCase());
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);
}
group.piles.clear();
for (Pile pile : piles.values()) {
group.piles.add(pile);
}
group.piles.addAll(piles.values());
}
groupY = y;

View File

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

View File

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

View File

@@ -64,7 +64,7 @@ public class QuickGauntletLister extends JPanel {
this.removeAll();
final List<RowPanel> tempRows = new ArrayList<>();
final List<GauntletData> sorted = new ArrayList<>();
for (final GauntletData gd : gauntlets) { sorted.add(gd); }
sorted.addAll(gauntlets);
sorted.sort(new Comparator<GauntletData>() {
@Override
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();
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());
boolean haveAnyChallenges = true;

View File

@@ -197,7 +197,7 @@ public enum CSubmenuDuels implements ICDoc {
view.getPnlDuels().add(grpPanel, "w 100%!");
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 File

@@ -66,7 +66,7 @@ public class QuestFileLister extends JPanel {
this.removeAll();
List<RowPanel> tempRows = new ArrayList<>();
List<QuestData> sorted = new ArrayList<>();
for (QuestData qd : qd0) { sorted.add(qd); }
sorted.addAll(qd0);
sorted.sort(new Comparator<QuestData>() {
@Override
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");
for (CardEdition e : editions) {
nifSB.append("Edition: " + e.getName() + " " + "(" + e.getCode() + "/" + e.getCode2() + ")\n");
cniSB.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: ").append(e.getName()).append(" ").append("(").append(e.getCode()).append("/").append(e.getCode2()).append(")\n");
String imagePath;
int artIndex = 1;
@@ -261,7 +261,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
}
if (cp == null) {
cniSB.append(" " + c + "\n");
cniSB.append(" ").append(c).append("\n");
notImplementedCount++;
continue;
}
@@ -274,7 +274,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
if (imagePath != null) {
File file = ImageKeys.getImageFile(imagePath);
if (file == null) {
nifSB.append(" " + imagePath + "\n");
nifSB.append(" ").append(imagePath).append("\n");
missingCount++;
}
}
@@ -287,7 +287,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
if (imagePath != null) {
File file = ImageKeys.getImageFile(imagePath);
if (file == null) {
nifSB.append(" " + imagePath + "\n");
nifSB.append(" ").append(imagePath).append("\n");
missingCount++;
}
}
@@ -310,7 +310,7 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
String imgKey = token.getImageKey(i);
File file = ImageKeys.getImageFile(imgKey);
if (file == null) {
nifSB.append(" " + token.getImageFilename(i+1) + "\n");
nifSB.append(" ").append(token.getImageFilename(i + 1)).append("\n");
missingCount++;
}
}

View File

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

View File

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

View File

@@ -504,11 +504,11 @@ public class GifDecoder {
break;
case 0xff: // application extension
readBlock();
String app = "";
StringBuilder app = new StringBuilder();
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();
} else {
skip(); // don't care
@@ -554,11 +554,11 @@ public class GifDecoder {
* Reads GIF file header information.
*/
protected void readHeader() {
String id = "";
StringBuilder id = new StringBuilder();
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;
return;
}

View File

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

View File

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

View File

@@ -43,10 +43,10 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
labelBuilder.append("s: All");
break;
case 1:
labelBuilder.append(": " + getList().iterator().next());
labelBuilder.append(": ").append(getList().iterator().next());
break;
default:
labelBuilder.append("s: " + TextUtil.join(getList(), ", "));
labelBuilder.append("s: ").append(TextUtil.join(getList(), ", "));
break;
}
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);
}
group.piles.clear();
for (Pile pile : piles.values()) {
group.piles.add(pile);
}
group.piles.addAll(piles.values());
}
groupY = y;

View File

@@ -216,14 +216,14 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
cbVariants.setSelectedItem(appliedVariants.iterator().next());
}
else {
String text = "";
StringBuilder text = new StringBuilder();
for (GameType variantType : appliedVariants) {
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() {
List<GauntletData> sorted = new ArrayList<>();
for (GauntletData gauntlet : gauntlets) {
sorted.add(gauntlet);
}
sorted.addAll(gauntlets);
sorted.sort(new Comparator<GauntletData>() {
@Override
public int compare(final GauntletData x, final GauntletData y) {

View File

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

View File

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

View File

@@ -29,6 +29,7 @@ import forge.util.Callback;
import forge.util.Utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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) {
super(pref0, label0 + ":", description0);
for (String option : options0) {
options.add(option);
}
options.addAll(Arrays.asList(options0));
}
public CustomSelectSetting(FPref pref0, String label0, String description0, Iterable<String> options0) {
super(pref0, label0 + ":", description0);

View File

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

View File

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

View File

@@ -164,7 +164,7 @@ public class CardReaderExperiments {
StringBuilder newLineBuilder = new StringBuilder();
newLineBuilder.append(line, 0, m.start(1));
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
updated = true;

View File

@@ -124,7 +124,7 @@ public class DeckGeneratorTheme extends DeckGeneratorBase {
final float p = (float) (g.percentage * .01);
final int grpCnt = (int) (p * 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++) {
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]));
}
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();
}
errorBuilder.append("numBLands:" + numBLands + "\n");
errorBuilder.append("numBLands:").append(numBLands).append("\n");
addBasicLand(numBLands,basicLandSet);
errorBuilder.append("DeckSize:" + tDeck.countAll() + "\n");
errorBuilder.append("DeckSize:").append(tDeck.countAll()).append("\n");
adjustDeckSize(size);
errorBuilder.append("DeckSize:" + tDeck.countAll() + "\n");
errorBuilder.append("DeckSize:").append(tDeck.countAll()).append("\n");
if (!testing) {
errorBuilder.delete(0, errorBuilder.length()); //clear if not testing
}

View File

@@ -622,9 +622,8 @@ public class DeckgenUtil {
}
}
}else {
List<Map.Entry<PaperCard,Integer>> potentialCards = new ArrayList<>();
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());
for(Map.Entry<PaperCard,Integer> pair:potentialCards){
if(format.isLegalCard(pair.getKey())) {

View File

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

View File

@@ -43,7 +43,7 @@ public class BooleanExpression {
public Predicate<CardRules> evaluate() {
String currentValue = "";
StringBuilder currentValue = new StringBuilder();
boolean escapeNext = false;
while (expression.hasNext()) {
@@ -59,7 +59,7 @@ public class BooleanExpression {
operator = Operator.OPEN_PAREN;
} else if (token.equals(Operator.CLOSE_PAREN.token)) {
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;
} else if (token.equals(Operator.ESCAPE.token)) {
escapeNext = true;
@@ -67,20 +67,20 @@ public class BooleanExpression {
}
if (operator == null) {
currentValue += token;
currentValue.append(token);
} else {
if (escapeNext) {
escapeNext = false;
currentValue += token;
currentValue.append(token);
continue;
}
if (!currentValue.trim().isEmpty()) {
operands.push(valueOf(currentValue.trim()));
if (!currentValue.toString().trim().isEmpty()) {
operands.push(valueOf(currentValue.toString().trim()));
}
currentValue = "";
currentValue = new StringBuilder();
if (!operators.isEmpty() && operator.precedence < operators.peek().precedence) {
resolve(true);
@@ -98,8 +98,8 @@ public class BooleanExpression {
}
if (!currentValue.trim().isEmpty()) {
operands.push(valueOf(currentValue.trim()));
if (!currentValue.toString().trim().isEmpty()) {
operands.push(valueOf(currentValue.toString().trim()));
}
while (!operators.isEmpty()) {

View File

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

View File

@@ -154,7 +154,7 @@ public final class SItemManagerUtil {
});
final StringBuilder builder = new StringBuilder();
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();
}

View File

@@ -135,8 +135,7 @@ public class CardRanker {
}
private static List<PaperCard> getCardsExceptOne(List<PaperCard> cache, int i) {
List<PaperCard> otherCards = new ArrayList<>();
otherCards.addAll(cache.subList(0, i));
List<PaperCard> otherCards = new ArrayList<>(cache.subList(0, i));
if (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();
if (startingPlayer == player) {
sb.append(player).append(", "+ localizer.getMessage("lblYouAreGoingFirst") +"\n\n");
sb.append(player).append(", ").append(localizer.getMessage("lblYouAreGoingFirst")).append("\n\n");
}
else {
sb.append(startingPlayer.getName()).append(" " + localizer.getMessage("lblIsGoingFirst") +".\n");
sb.append(player).append(", "+ localizer.getMessage("lblYouAreGoing") + " ").append(Lang.getOrdinal(game.getPosition(player, startingPlayer))).append(".\n\n");
sb.append(startingPlayer.getName()).append(" ").append(localizer.getMessage("lblIsGoingFirst")).append(".\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);

View File

@@ -270,14 +270,14 @@ public final class ConquestData {
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) {
if (planeswalker == card) {
SOptionPane.showMessageDialog("Current planeswalker cannot be exiled.", title, SOptionPane.INFORMATION_ICON);
return false;
}
String commandersUsingCard = "";
StringBuilder commandersUsingCard = new StringBuilder();
for (ConquestCommander commander : commanders) {
if (commander.getCard() == card) {
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
}
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);
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 (commandersBeingExiled != null) {
commanders.removeAll(commandersBeingExiled);
@@ -326,11 +326,11 @@ public final class ConquestData {
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) {
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)) {
for (PaperCard card : cards) {
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) {
String name = "";
StringBuilder name = new StringBuilder();
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 {
return AEtherFilter.valueOf(name);
return AEtherFilter.valueOf(name.toString());
}
catch (Exception e) {
System.err.println("No color filter with name " + name);
@@ -462,7 +462,7 @@ public class ConquestUtil {
double baseOdds = 0;
double remainingOdds = 1;
CardRarity baseRarity = null;
String caption = "";
StringBuilder caption = new StringBuilder();
for (CardRarity rarity : rarityOdds.keySet()) {
Double odds = oddsLookup.get(rarity);
@@ -479,16 +479,16 @@ public class ConquestUtil {
final String display = rounded < 1d
? Double.toString(rounded) // Display decimal if < 1%
: Long.toString(Math.round(rounded));
caption += ", " + rarity.getLongName() + " (" + display + "%)";
caption.append(", ").append(rarity.getLongName()).append(" (").append(display).append("%)");
rarityOdds.put(rarity, 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);
return caption;
return caption.toString();
}
@Override

View File

@@ -333,7 +333,7 @@ public class HumanPlay {
StringBuilder sb = new StringBuilder("Do you want to ");
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)) {
return false;

View File

@@ -337,7 +337,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
if (min == 0) {
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);
inp.setMessage(builder.toString());
@@ -544,8 +544,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
for (SpellAbility spellAbility : spells) {
spellViewCache.put(spellAbility.getView(), spellAbility);
}
List<TrackableObject> choices = new ArrayList<>();
choices.addAll(spellViewCache.keySet());
List<TrackableObject> choices = new ArrayList<>(spellViewCache.keySet());
Object choice = getGui().one(title, choices);
// 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();
if (tos.containsKey("Attacker")) {
buildQuestion.append("\nAttacker: " + tos.get("Attacker"));
buildQuestion.append("\nAttacker: ").append(tos.get("Attacker"));
}
if (tos.containsKey("Card")) {
final Card card = (Card) tos.get("Card");
if (card != null && (card.getController() == player || game.getZoneOf(card) == null
|| 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
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;
for (int i = 1; i < activePlayerSAs.size(); i++) {
@@ -1635,14 +1634,14 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
// are the same
}
saLookupKey += delim + saStr;
saLookupKey.append(delim).append(saStr);
idxAdditionalInfo = saLookupKey.indexOf(" [");
if (idxAdditionalInfo != -1) {
saLookupKey = saLookupKey.substring(0, idxAdditionalInfo - 1);
saLookupKey = new StringBuilder(saLookupKey.substring(0, idxAdditionalInfo - 1));
}
}
if (needPrompt) {
List<Integer> savedOrder = orderedSALookup.get(saLookupKey);
List<Integer> savedOrder = orderedSALookup.get(saLookupKey.toString());
List<SpellAbilityView> orderedSAVs = Lists.newArrayList();
// 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) {
savedOrder.add(activePlayerSAs.indexOf(sa));
}
orderedSALookup.put(saLookupKey, savedOrder);
orderedSALookup.put(saLookupKey.toString(), savedOrder);
}
}
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
final StringBuilder sb = new StringBuilder();
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)) {
sb.append(DECKS_DIR_KEY + "=" + decksDir.replace("\\", "\\\\") + "\n");
sb.append(DECKS_DIR_KEY + "=").append(decksDir.replace("\\", "\\\\")).append("\n");
}
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)) {
sb.append(CARD_PICS_DIR_KEY + "=" + cardPicsDir.replace("\\", "\\\\") + "\n");
sb.append(CARD_PICS_DIR_KEY + "=").append(cardPicsDir.replace("\\", "\\\\")).append("\n");
}
if (cardPicsSubDirs.size() > 0) {
sb.append(CARD_PICS_SUB_DIRS_KEY + "=");
@@ -230,12 +230,12 @@ public class ForgeProfileProperties {
if (needDelim) {
sb.append("|");
}
sb.append(entry.getKey() + "->" + entry.getValue());
sb.append(entry.getKey()).append("->").append(entry.getValue());
}
sb.append("\n");
}
if (serverPort != 0) {
sb.append(SERVER_PORT_KEY + "=" + serverPort);
sb.append(SERVER_PORT_KEY + "=").append(serverPort);
}
if (sb.length() > 0) {
FileUtil.writeFile(ForgeConstants.PROFILE_FILE, sb.toString());

View File

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

View File

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

View File

@@ -323,7 +323,7 @@ public class QuestUtil {
view.getCbxMatchLength().removeAllItems();
boolean activeCharms = false;
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)) {
view.getCbxMatchLength().addItem(localizer.getMessage("lblMatchBestOf1"));
activeCharms = true;

View File

@@ -227,7 +227,7 @@ public class QuestWinLoseController {
sb.append(" opponent: ").append(credBase).append(" credits.\n");
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;
}

View File

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

View File

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

View File

@@ -199,40 +199,40 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
resultSound = SoundEffectType.ScriptedEffect;
} else {
// 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()) {
String currManaColor = sa.getManaPartRecursive().getOrigProduced();
if(!"C".equals(currManaColor)) {
fullManaColors = fullManaColors + currManaColor;
fullManaColors.append(currManaColor);
}
}
// 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();
if(fullManaColorsLength >= 3) {
// three color land
fullManaColors = fullManaColors.substring(0,3);
if (fullManaColors.contains("W") && fullManaColors.contains("U") && fullManaColors.contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueBlackLand)) {
fullManaColors = new StringBuilder(fullManaColors.substring(0, 3));
if (fullManaColors.toString().contains("W") && fullManaColors.toString().contains("U") && fullManaColors.toString().contains("B") && SoundSystem.instance.hasResource(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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
}
}
@@ -240,26 +240,26 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
if(resultSound == null && fullManaColorsLength >= 2) {
// three color land without sounds installed, or two color land
// lets try
fullManaColors = fullManaColors.substring(0,2);
if (fullManaColors.contains("W") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) {
fullManaColors = new StringBuilder(fullManaColors.substring(0, 2));
if (fullManaColors.toString().contains("W") && (fullManaColors.toString().contains("U")) && SoundSystem.instance.hasResource(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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
} 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;
}
}
@@ -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
// in case of multicolor, lets take only the 1st color of the list, it sure has sound
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;
} else if (fullManaColors.contains("U")) {
} else if (fullManaColors.toString().contains("U")) {
resultSound = SoundEffectType.BlueLand;
} else if (fullManaColors.contains("G")) {
} else if (fullManaColors.toString().contains("G")) {
resultSound = SoundEffectType.GreenLand;
} else if (fullManaColors.contains("R")) {
} else if (fullManaColors.toString().contains("R")) {
resultSound = SoundEffectType.RedLand;
} else if (fullManaColors.contains("W")) {
} else if (fullManaColors.toString().contains("W")) {
resultSound = SoundEffectType.WhiteLand;
} else {
resultSound = SoundEffectType.OtherLand;

View File

@@ -45,10 +45,10 @@ public class RestartUtil {
// program main is a jar
if (mainCommand[0].endsWith(".jar")) {
// 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 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
for (int i = 1; i < mainCommand.length; i++) {