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

@@ -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++) {