Miscallaneous Cleanup (#5703)

* Cleanup - Unnecessary Boxing

* Cleanup - Unnecessary Unboxing

* Cleanup - For-Each Loops

* Cleanup - `indexOf != -1` -> `contains`

* Cleanup - Merge identical catch blocks

* Cleanup - Try-with-resources

* Cleanup - System.lineSeparator

* Cleanup - Reference types to primitives
Some loops over Integers were switched to IntStreams to hopefully cut down on overall boxing.

* Cleanup - Manually filling and copying arrays

* Remove unused imports

* Switch a lambda to a method reference

---------

Co-authored-by: Jetz <Jetz722@gmail.com>
This commit is contained in:
Jetz72
2024-07-29 10:23:43 -04:00
committed by GitHub
parent 5d959ca545
commit 3968c7e197
163 changed files with 370 additions and 497 deletions

View File

@@ -34,8 +34,7 @@ public class EditorMainWindow extends JFrame {
Localizer.getInstance().initialize(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR); Localizer.getInstance().initialize(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
int var2 = var1.length; int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) { for (UIManager.LookAndFeelInfo info : var1) {
UIManager.LookAndFeelInfo info = var1[var3];
if ("Nimbus".equals(info.getName())) { if ("Nimbus".equals(info.getName())) {
try { try {
UIManager.setLookAndFeel(info.getClassName()); UIManager.setLookAndFeel(info.getClassName());

View File

@@ -57,9 +57,9 @@ public class EffectEditor extends JComponent {
currentData.name=name.getText(); currentData.name=name.getText();
currentData.changeStartCards=((Integer)changeStartCards.getValue()).intValue(); currentData.changeStartCards = (Integer) changeStartCards.getValue();
currentData.lifeModifier= ((Integer)lifeModifier.getValue()).intValue(); currentData.lifeModifier = (Integer) lifeModifier.getValue();
currentData.moveSpeed= ((Float)moveSpeed.getValue()).floatValue(); currentData.moveSpeed = (Float) moveSpeed.getValue();
currentData.startBattleWithCard = startBattleWithCard.getList(); currentData.startBattleWithCard = startBattleWithCard.getList();
currentData.colorView = colorView.isSelected(); currentData.colorView = colorView.isSelected();
currentData.opponent = opponent.currentData; currentData.opponent = opponent.currentData;

View File

@@ -14,6 +14,6 @@ public class FloatSpinner extends JSpinner{
} }
public float floatValue() public float floatValue()
{ {
return ((Float)getValue()).floatValue(); return (Float) getValue();
} }
} }

View File

@@ -15,6 +15,6 @@ public class IntSpinner extends JSpinner {
} }
public int intValue() public int intValue()
{ {
return ((Integer)getValue()).intValue(); return (Integer) getValue();
} }
} }

View File

@@ -57,7 +57,7 @@ public class ItemEdit extends JComponent {
currentData.description=description.getText(); currentData.description=description.getText();
currentData.iconName=iconName.getText(); currentData.iconName=iconName.getText();
currentData.questItem=questItem.isSelected(); currentData.questItem=questItem.isSelected();
currentData.cost=((Integer) cost.getValue()).intValue(); currentData.cost= (Integer) cost.getValue();
} }
public void setCurrentItem(ItemData data) public void setCurrentItem(ItemData data)

View File

@@ -122,7 +122,7 @@ public class RewardEdit extends FormPanel {
updating=true; updating=true;
typeField.setSelectedItem(currentData.type); typeField.setSelectedItem(currentData.type);
probability.setValue(new Double(currentData.probability)); probability.setValue((double) currentData.probability);
count.setValue(currentData.count); count.setValue(currentData.count);
addMaxCount.setValue(currentData.addMaxCount); addMaxCount.setValue(currentData.addMaxCount);
cardName.setText(currentData.cardName); cardName.setText(currentData.cardName);

View File

@@ -1173,8 +1173,8 @@ public class AiAttackController {
while (!attritionalAttackers.isEmpty() && humanLife > 0 && attackRounds < 99) { while (!attritionalAttackers.isEmpty() && humanLife > 0 && attackRounds < 99) {
// sum attacker damage // sum attacker damage
int damageThisRound = 0; int damageThisRound = 0;
for (int y = 0; y < attritionalAttackers.size(); y++) { for (Card attritionalAttacker : attritionalAttackers) {
damageThisRound += attritionalAttackers.get(y).getNetCombatDamage(); damageThisRound += attritionalAttacker.getNetCombatDamage();
} }
// remove from player life // remove from player life
humanLife -= damageThisRound; humanLife -= damageThisRound;

View File

@@ -19,7 +19,6 @@
package forge.ai; package forge.ai;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import forge.game.card.Card; import forge.game.card.Card;
@@ -164,10 +163,7 @@ public class AiCardMemory {
Set<Card> memorySet = getMemorySet(set); Set<Card> memorySet = getMemorySet(set);
if (memorySet != null) { if (memorySet != null) {
Iterator<Card> it = memorySet.iterator(); for (Card c : memorySet) {
while (it.hasNext()) {
Card c = it.next();
if (c.getName().equals(cardName)) { if (c.getName().equals(cardName)) {
return true; return true;
} }
@@ -191,10 +187,7 @@ public class AiCardMemory {
Set<Card> memorySet = getMemorySet(set); Set<Card> memorySet = getMemorySet(set);
if (memorySet != null) { if (memorySet != null) {
Iterator<Card> it = memorySet.iterator(); for (Card c : memorySet) {
while (it.hasNext()) {
Card c = it.next();
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) { if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
return true; return true;
} }
@@ -259,10 +252,7 @@ public class AiCardMemory {
Set<Card> memorySet = getMemorySet(set); Set<Card> memorySet = getMemorySet(set);
if (memorySet != null) { if (memorySet != null) {
Iterator<Card> it = memorySet.iterator(); for (Card c : memorySet) {
while (it.hasNext()) {
Card c = it.next();
if (c.getName().equals(cardName)) { if (c.getName().equals(cardName)) {
return forgetCard(c, set); return forgetCard(c, set);
} }
@@ -284,10 +274,7 @@ public class AiCardMemory {
Set<Card> memorySet = getMemorySet(set); Set<Card> memorySet = getMemorySet(set);
if (memorySet != null) { if (memorySet != null) {
Iterator<Card> it = memorySet.iterator(); for (Card c : memorySet) {
while (it.hasNext()) {
Card c = it.next();
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) { if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
return forgetCard(c, set); return forgetCard(c, set);
} }

View File

@@ -1996,7 +1996,7 @@ public class AiController {
break; break;
case FlipOntoBattlefield: case FlipOntoBattlefield:
if ("DamageCreatures".equals(sa.getParam("AILogic"))) { if ("DamageCreatures".equals(sa.getParam("AILogic"))) {
int maxToughness = Integer.valueOf(sa.getSubAbility().getParam("NumDmg")); int maxToughness = Integer.parseInt(sa.getSubAbility().getParam("NumDmg"));
CardCollectionView rightToughness = CardLists.filter(pool, new Predicate<Card>() { CardCollectionView rightToughness = CardLists.filter(pool, new Predicate<Card>() {
@Override @Override
public boolean apply(Card card) { public boolean apply(Card card) {
@@ -2112,9 +2112,9 @@ public class AiController {
} }
// add the rest of land to the end of the deck // add the rest of land to the end of the deck
for (int i = 0; i < land.size(); i++) { for (Card card : land) {
if (!library.contains(land.get(i))) { if (!library.contains(card)) {
library.add(land.get(i)); library.add(card);
} }
} }

View File

@@ -147,9 +147,9 @@ public class AiProfileUtil {
if (children == null) { if (children == null) {
System.err.println("AIProfile > can't find AI profile directory!"); System.err.println("AIProfile > can't find AI profile directory!");
} else { } else {
for (int i = 0; i < children.length; i++) { for (String child : children) {
if (children[i].endsWith(AI_PROFILE_EXT)) { if (child.endsWith(AI_PROFILE_EXT)) {
availableProfiles.add(children[i].substring(0, children[i].length() - AI_PROFILE_EXT.length())); availableProfiles.add(child.substring(0, child.length() - AI_PROFILE_EXT.length()));
} }
} }
} }

View File

@@ -983,11 +983,11 @@ public class ComputerUtilCard {
for (final Card crd : list) { for (final Card crd : list) {
ColorSet color = crd.getColor(); ColorSet color = crd.getColor();
if (color.hasWhite()) map.get(0).setValue(Integer.valueOf(map.get(0).getValue() + 1)); if (color.hasWhite()) map.get(0).setValue(map.get(0).getValue() + 1);
if (color.hasBlue()) map.get(1).setValue(Integer.valueOf(map.get(1).getValue() + 1)); if (color.hasBlue()) map.get(1).setValue(map.get(1).getValue() + 1);
if (color.hasBlack()) map.get(2).setValue(Integer.valueOf(map.get(2).getValue() + 1)); if (color.hasBlack()) map.get(2).setValue(map.get(2).getValue() + 1);
if (color.hasRed()) map.get(3).setValue(Integer.valueOf(map.get(3).getValue() + 1)); if (color.hasRed()) map.get(3).setValue(map.get(3).getValue() + 1);
if (color.hasGreen()) map.get(4).setValue(Integer.valueOf(map.get(4).getValue() + 1)); if (color.hasGreen()) map.get(4).setValue(map.get(4).getValue() + 1);
} }
Collections.sort(map, new Comparator<Pair<Byte, Integer>>() { Collections.sort(map, new Comparator<Pair<Byte, Integer>>() {

View File

@@ -710,7 +710,7 @@ public class ComputerUtilCost {
} else if ("LowPriority".equals(aiLogic) && MyRandom.getRandom().nextInt(100) < 67) { } else if ("LowPriority".equals(aiLogic) && MyRandom.getRandom().nextInt(100) < 67) {
return false; return false;
} else if (aiLogic != null && aiLogic.startsWith("Fabricate")) { } else if (aiLogic != null && aiLogic.startsWith("Fabricate")) {
final int n = Integer.valueOf(aiLogic.substring("Fabricate".length())); final int n = Integer.parseInt(aiLogic.substring("Fabricate".length()));
// if host would leave the play or if host is useless, create tokens // if host would leave the play or if host is useless, create tokens
if (source.hasSVar("EndOfTurnLeavePlay") || ComputerUtilCard.isUselessCreature(payer, source)) { if (source.hasSVar("EndOfTurnLeavePlay") || ComputerUtilCard.isUselessCreature(payer, source)) {

View File

@@ -222,8 +222,7 @@ public class ComputerUtilMana {
for (int i = 0; i < preferredShardAmount && i < prefSortedAbilities.size(); i++) { for (int i = 0; i < preferredShardAmount && i < prefSortedAbilities.size(); i++) {
finalAbilities.add(prefSortedAbilities.get(i)); finalAbilities.add(prefSortedAbilities.get(i));
} }
for (int i = 0; i < otherSortedAbilities.size(); i++) { for (SpellAbility ab : otherSortedAbilities) {
SpellAbility ab = otherSortedAbilities.get(i);
if (!finalAbilities.contains(ab)) if (!finalAbilities.contains(ab))
finalAbilities.add(ab); finalAbilities.add(ab);
} }
@@ -491,7 +490,7 @@ public class ComputerUtilMana {
if (!replaceAmount.isEmpty()) { if (!replaceAmount.isEmpty()) {
int totalAmount = 1; int totalAmount = 1;
for (SpellAbility saMana : replaceAmount) { for (SpellAbility saMana : replaceAmount) {
totalAmount *= Integer.valueOf(saMana.getParam("ReplaceAmount")); totalAmount *= Integer.parseInt(saMana.getParam("ReplaceAmount"));
} }
manaProduced = StringUtils.repeat(manaProduced, " ", totalAmount); manaProduced = StringUtils.repeat(manaProduced, " ", totalAmount);
} }

View File

@@ -965,7 +965,7 @@ public class PlayerControllerAi extends PlayerController {
break; break;
} }
} }
return defaultVal != null && defaultVal.booleanValue(); return defaultVal != null && defaultVal;
case UntapTimeVault: return false; // TODO Should AI skip his turn for time vault? case UntapTimeVault: return false; // TODO Should AI skip his turn for time vault?
case LeftOrRight: return brains.chooseDirection(sa); case LeftOrRight: return brains.chooseDirection(sa);
case OddsOrEvens: return brains.chooseEvenOdd(sa); // false is Odd, true is Even case OddsOrEvens: return brains.chooseEvenOdd(sa); // false is Odd, true is Even

View File

@@ -18,7 +18,7 @@ public class AlterAttributeAi extends SpellAbilityAi {
@Override @Override
protected boolean checkApiLogic(Player aiPlayer, SpellAbility sa) { protected boolean checkApiLogic(Player aiPlayer, SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
boolean activate = Boolean.valueOf(sa.getParamOrDefault("Activate", "true")); boolean activate = Boolean.parseBoolean(sa.getParamOrDefault("Activate", "true"));
String[] attributes = sa.getParam("Attributes").split(","); String[] attributes = sa.getParam("Attributes").split(",");
if (sa.usesTargeting()) { if (sa.usesTargeting()) {
@@ -91,7 +91,7 @@ public class AlterAttributeAi extends SpellAbilityAi {
@Override @Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) { public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message, Map<String, Object> params) {
boolean activate = Boolean.valueOf(sa.getParamOrDefault("Activate", "true")); boolean activate = Boolean.parseBoolean(sa.getParamOrDefault("Activate", "true"));
String[] attributes = sa.getParam("Attributes").split(","); String[] attributes = sa.getParam("Attributes").split(",");
for (String attr : attributes) { for (String attr : attributes) {

View File

@@ -410,9 +410,7 @@ public class AttachAi extends SpellAbilityAi {
} }
final Iterable<Card> auras = c.getEnchantedBy(); final Iterable<Card> auras = c.getEnchantedBy();
final Iterator<Card> itr = auras.iterator(); for (Card aura : auras) {
while (itr.hasNext()) {
final Card aura = itr.next();
SpellAbility auraSA = aura.getSpells().get(0); SpellAbility auraSA = aura.getSpells().get(0);
if (auraSA.getApi() == ApiType.Attach) { if (auraSA.getApi() == ApiType.Attach) {
if ("KeepTapped".equals(auraSA.getParam("AILogic"))) { if ("KeepTapped".equals(auraSA.getParam("AILogic"))) {

View File

@@ -1390,7 +1390,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
aiPlaneswalkers.sort(CardPredicates.compareByCounterType(CounterEnumType.LOYALTY)); aiPlaneswalkers.sort(CardPredicates.compareByCounterType(CounterEnumType.LOYALTY));
for (Card pw : aiPlaneswalkers) { for (Card pw : aiPlaneswalkers) {
int curLoyalty = pw.getCounters(CounterEnumType.LOYALTY); int curLoyalty = pw.getCounters(CounterEnumType.LOYALTY);
int freshLoyalty = Integer.valueOf(pw.getCurrentState().getBaseLoyalty()); int freshLoyalty = Integer.parseInt(pw.getCurrentState().getBaseLoyalty());
if (freshLoyalty - curLoyalty >= loyaltyDiff && curLoyalty <= maxLoyaltyToConsider) { if (freshLoyalty - curLoyalty >= loyaltyDiff && curLoyalty <= maxLoyaltyToConsider) {
return pw; return pw;
} }
@@ -1748,7 +1748,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
} }
if (MyRandom.percentTrue(chance)) { if (MyRandom.percentTrue(chance)) {
int curLoyalty = card.getCounters(CounterEnumType.LOYALTY); int curLoyalty = card.getCounters(CounterEnumType.LOYALTY);
int freshLoyalty = Integer.valueOf(card.getCurrentState().getBaseLoyalty()); int freshLoyalty = Integer.parseInt(card.getCurrentState().getBaseLoyalty());
if (freshLoyalty - curLoyalty >= loyaltyDiff && curLoyalty <= maxLoyaltyToConsider) { if (freshLoyalty - curLoyalty >= loyaltyDiff && curLoyalty <= maxLoyaltyToConsider) {
return true; return true;
} }

View File

@@ -308,7 +308,7 @@ public class EffectAi extends SpellAbilityAi {
} }
if (logic.contains(":")) { if (logic.contains(":")) {
String[] k = logic.split(":"); String[] k = logic.split(":");
Integer i = Integer.valueOf(k[1]); int i = Integer.parseInt(k[1]);
return ai.getCreaturesInPlay().size() >= i; return ai.getCreaturesInPlay().size() >= i;
} }
return true; return true;

View File

@@ -25,7 +25,7 @@ public class FlipOntoBattlefieldAi extends SpellAbilityAi {
} }
if ("DamageCreatures".equals(logic)) { if ("DamageCreatures".equals(logic)) {
int maxToughness = Integer.valueOf(sa.getSubAbility().getParam("NumDmg")); int maxToughness = Integer.parseInt(sa.getSubAbility().getParam("NumDmg"));
CardCollectionView rightToughness = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), new Predicate<Card>() { CardCollectionView rightToughness = CardLists.filter(aiPlayer.getOpponents().getCreaturesInPlay(), new Predicate<Card>() {
@Override @Override
public boolean apply(Card card) { public boolean apply(Card card) {

View File

@@ -169,7 +169,7 @@ public class ManaAi extends SpellAbilityAi {
numCounters = host.getCounters(ctrType); numCounters = host.getCounters(ctrType);
manaReceived = numCounters; manaReceived = numCounters;
if (logic.startsWith("ManaRitualBattery.")) { if (logic.startsWith("ManaRitualBattery.")) {
manaSurplus = Integer.valueOf(logic.substring(18)); // adds an extra mana even if no counters removed manaSurplus = Integer.parseInt(logic.substring(18)); // adds an extra mana even if no counters removed
manaReceived += manaSurplus; manaReceived += manaSurplus;
} }
} }

View File

@@ -52,7 +52,7 @@ public class TapAllAi extends SpellAbilityAi {
if (sa.hasParam("AILogic")) { if (sa.hasParam("AILogic")) {
String logic = sa.getParam("AILogic"); String logic = sa.getParam("AILogic");
if (logic.startsWith("AtLeast")) { if (logic.startsWith("AtLeast")) {
Integer num = AbilityUtils.calculateAmount(source, logic.substring(7), sa); int num = AbilityUtils.calculateAmount(source, logic.substring(7), sa);
if (validTappables.size() < num) { if (validTappables.size() < num) {
return false; return false;
} }

View File

@@ -421,24 +421,11 @@ public class CardStorageReader {
* @return a new Card instance * @return a new Card instance
*/ */
protected final CardRules loadCard(final CardRules.Reader rulesReader, final ZipEntry entry) { protected final CardRules loadCard(final CardRules.Reader rulesReader, final ZipEntry entry) {
InputStream zipInputStream = null; try (InputStream zipInputStream = this.zip.getInputStream(entry)) {
try {
zipInputStream = this.zip.getInputStream(entry);
rulesReader.reset(); rulesReader.reset();
return rulesReader.readCard(readScript(zipInputStream), Files.getNameWithoutExtension(entry.getName())); return rulesReader.readCard(readScript(zipInputStream), Files.getNameWithoutExtension(entry.getName()));
} catch (final IOException exn) { } catch (final IOException exn) {
throw new RuntimeException(exn); throw new RuntimeException(exn);
// PM
} finally {
try {
if (zipInputStream != null) {
zipInputStream.close();
}
} catch (final IOException ignored) {
// 11:08
// PM
}
} }
} }

View File

@@ -78,13 +78,13 @@ public class CardAiHints {
*/ */
public Integer getAiStatusComparable() { public Integer getAiStatusComparable() {
if (this.isRemovedFromAIDecks && this.isRemovedFromRandomDecks) { if (this.isRemovedFromAIDecks && this.isRemovedFromRandomDecks) {
return Integer.valueOf(3); return 3;
} else if (this.isRemovedFromAIDecks) { } else if (this.isRemovedFromAIDecks) {
return Integer.valueOf(4); return 4;
} else if (this.isRemovedFromRandomDecks) { } else if (this.isRemovedFromRandomDecks) {
return Integer.valueOf(2); return 2;
} else { } else {
return Integer.valueOf(1); return 1;
} }
} }

View File

@@ -242,7 +242,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
if (this.hasNoCost) { if (this.hasNoCost) {
weight = -1; // for those who doesn't even have a 0 sign on card weight = -1; // for those who doesn't even have a 0 sign on card
} }
this.compareWeight = Float.valueOf(weight); this.compareWeight = weight;
} }
return this.compareWeight; return this.compareWeight;
} }

View File

@@ -468,9 +468,7 @@ public class CardPool extends ItemPool<PaperCard> {
*/ */
public CardPool getFilteredPool(Predicate<PaperCard> predicate) { public CardPool getFilteredPool(Predicate<PaperCard> predicate) {
CardPool filteredPool = new CardPool(); CardPool filteredPool = new CardPool();
Iterator<PaperCard> cardsInPool = this.items.keySet().iterator(); for (PaperCard c : this.items.keySet()) {
while (cardsInPool.hasNext()) {
PaperCard c = cardsInPool.next();
if (predicate.apply(c)) if (predicate.apply(c))
filteredPool.add(c, this.items.get(c)); filteredPool.add(c, this.items.get(c));
} }

View File

@@ -100,8 +100,7 @@ public class DeckGroup extends DeckBase {
DeckGroup myClone = (DeckGroup) clone; DeckGroup myClone = (DeckGroup) clone;
myClone.setHumanDeck((Deck) humanDeck.copyTo(getName())); //human deck name should always match DeckGroup name myClone.setHumanDeck((Deck) humanDeck.copyTo(getName())); //human deck name should always match DeckGroup name
for (int i = 0; i < aiDecks.size(); i++) { for (Deck src : aiDecks) {
Deck src = aiDecks.get(i);
myClone.addAiDeck((Deck) src.copyTo(src.getName())); myClone.addAiDeck((Deck) src.copyTo(src.getName()));
} }
} }

View File

@@ -267,9 +267,9 @@ public abstract class DeckGeneratorBase {
for (ImmutablePair<FilterCMC, Integer> pair : cmcLevels) { for (ImmutablePair<FilterCMC, Integer> pair : cmcLevels) {
Iterable<PaperCard> matchingCards = Iterables.filter(source, Predicates.compose(pair.getLeft(), PaperCard.FN_GET_RULES)); Iterable<PaperCard> matchingCards = Iterables.filter(source, Predicates.compose(pair.getLeft(), PaperCard.FN_GET_RULES));
int cmcCountForPool = (int) Math.ceil(pair.getRight().intValue() * desiredOverTotal); int cmcCountForPool = (int) Math.ceil(pair.getRight() * desiredOverTotal);
int addOfThisCmc = Math.round(pair.getRight().intValue() * requestedOverTotal); int addOfThisCmc = Math.round(pair.getRight() * requestedOverTotal);
trace.append(String.format("Adding %d cards for cmc range from a pool with %d cards:%n", addOfThisCmc, cmcCountForPool)); trace.append(String.format("Adding %d cards for cmc range from a pool with %d cards:%n", addOfThisCmc, cmcCountForPool));
final List<PaperCard> curved = Aggregates.random(matchingCards, cmcCountForPool); final List<PaperCard> curved = Aggregates.random(matchingCards, cmcCountForPool);
@@ -332,7 +332,7 @@ public abstract class DeckGeneratorBase {
protected static void increment(Map<String, Integer> map, String key, int delta) { protected static void increment(Map<String, Integer> map, String key, int delta) {
final Integer boxed = map.get(key); final Integer boxed = map.get(key);
map.put(key, boxed == null ? delta : boxed.intValue() + delta); map.put(key, boxed == null ? delta : boxed + delta);
} }
public static final Predicate<CardRules> AI_CAN_PLAY = Predicates.and(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS); public static final Predicate<CardRules> AI_CAN_PLAY = Predicates.and(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, CardRulesPredicates.IS_KEPT_IN_RANDOM_DECKS);

View File

@@ -213,9 +213,9 @@ public class Aggregates {
U k = fnGetField.apply(kv.getKey()); U k = fnGetField.apply(kv.getKey());
Integer v = kv.getValue(); Integer v = kv.getValue();
Integer sum = result.get(k); Integer sum = result.get(k);
int n = v == null ? 0 : v.intValue(); int n = v == null ? 0 : v;
int s = sum == null ? 0 : sum.intValue(); int s = sum == null ? 0 : sum;
result.put(k, Integer.valueOf(s + n)); result.put(k, s + n);
} }
return result.entrySet(); return result.entrySet();
} }

View File

@@ -32,6 +32,7 @@
package forge.util; package forge.util;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
@@ -63,7 +64,7 @@ public final class Base64Coder {
* Constant. * Constant.
* <code>systemLineSeparator="System.getProperty(line.separator)"</code> * <code>systemLineSeparator="System.getProperty(line.separator)"</code>
*/ */
private static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator"); private static final String SYSTEM_LINE_SEPARATOR = System.lineSeparator();
// Mapping table from 6-bit nibbles to Base64 characters. // Mapping table from 6-bit nibbles to Base64 characters.
/** Constant <code>map1=new char[64]</code>. */ /** Constant <code>map1=new char[64]</code>. */
@@ -89,9 +90,7 @@ public final class Base64Coder {
private static byte[] map2 = new byte[128]; private static byte[] map2 = new byte[128];
static { static {
for (int i = 0; i < Base64Coder.map2.length; i++) { Arrays.fill(Base64Coder.map2, (byte) -1);
Base64Coder.map2[i] = -1;
}
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
Base64Coder.map2[Base64Coder.map1[i]] = (byte) i; Base64Coder.map2[Base64Coder.map1[i]] = (byte) i;
} }

View File

@@ -90,7 +90,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
if (from != null) { if (from != null) {
for (final Tin srcKey : from) { for (final Tin srcKey : from) {
if (clsHint.isInstance(srcKey)) { if (clsHint.isInstance(srcKey)) {
result.add((Tout) srcKey, Integer.valueOf(1)); result.add((Tout) srcKey, 1);
} }
} }
} }
@@ -126,7 +126,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
return 0; return 0;
} }
final Integer boxed = items.get(item); final Integer boxed = items.get(item);
return boxed == null ? 0 : boxed.intValue(); return boxed == null ? 0 : boxed;
} }
public final int countAll() { public final int countAll() {

View File

@@ -355,9 +355,7 @@ public class TextUtil {
* @return The sort-friendly name of the card. Example: "The Hive" becomes "Hive The". * @return The sort-friendly name of the card. Example: "The Hive" becomes "Hive The".
*/ */
public static String moveArticleToEnd(String str) { public static String moveArticleToEnd(String str) {
String articleWord; for (String articleWord : ARTICLE_WORDS) {
for (int i = 0; i < ARTICLE_WORDS.length; i++) {
articleWord = ARTICLE_WORDS[i];
if (str.startsWith(articleWord + " ")) { if (str.startsWith(articleWord + " ")) {
str = str.substring(articleWord.length() + 1) + " " + articleWord; str = str.substring(articleWord.length() + 1) + " " + articleWord;
return str; return str;

View File

@@ -32,8 +32,8 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
public void add(T item, int amount) { public void add(T item, int amount) {
if (amount <= 0) { return; } // throw an exception maybe? if (amount <= 0) { return; } // throw an exception maybe?
Integer cur = get(item); Integer cur = get(item);
int newVal = cur == null ? amount : amount + cur.intValue(); int newVal = cur == null ? amount : amount + cur;
put(item, Integer.valueOf(newVal)); put(item, newVal);
} }
@Override @Override
@@ -52,9 +52,9 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
public boolean substract(T item, int amount) { public boolean substract(T item, int amount) {
Integer cur = get(item); Integer cur = get(item);
if (cur == null) { return false; } if (cur == null) { return false; }
int newVal = cur.intValue() - amount; int newVal = cur - amount;
if (newVal > 0) { if (newVal > 0) {
put(item, Integer.valueOf(newVal)); put(item, newVal);
} }
else { else {
remove(item); remove(item);
@@ -73,7 +73,7 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
public int countAll() { public int countAll() {
int c = 0; int c = 0;
for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) { for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) {
c += kv.getValue().intValue(); c += kv.getValue();
} }
return c; return c;
} }
@@ -81,6 +81,6 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
@Override @Override
public int count(T item) { public int count(T item) {
Integer cur = get(item); Integer cur = get(item);
return cur == null ? 0 : cur.intValue(); return cur == null ? 0 : cur;
} }
} }

View File

@@ -55,8 +55,8 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
public void add(final T item, final int amount) { public void add(final T item, final int amount) {
if (amount <= 0) { return; } // throw an exception maybe? if (amount <= 0) { return; } // throw an exception maybe?
Integer cur = get(item); Integer cur = get(item);
int newVal = cur == null ? amount : amount + cur.intValue(); int newVal = cur == null ? amount : amount + cur;
put(item, Integer.valueOf(newVal)); put(item, newVal);
} }
@Override @Override
@@ -75,9 +75,9 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
public boolean substract(final T item, final int amount) { public boolean substract(final T item, final int amount) {
Integer cur = get(item); Integer cur = get(item);
if (cur == null) { return false; } if (cur == null) { return false; }
int newVal = cur.intValue() - amount; int newVal = cur - amount;
if (newVal > 0) { if (newVal > 0) {
put(item, Integer.valueOf(newVal)); put(item, newVal);
} else { } else {
remove(item); remove(item);
} }
@@ -95,7 +95,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
public int countAll() { public int countAll() {
int c = 0; int c = 0;
for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) { for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) {
c += kv.getValue().intValue(); c += kv.getValue();
} }
return c; return c;
} }
@@ -103,7 +103,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
@Override @Override
public int count(final T item) { public int count(final T item) {
Integer cur = get(item); Integer cur = get(item);
return cur == null ? 0 : cur.intValue(); return cur == null ? 0 : cur;
} }
} }

View File

@@ -38,12 +38,12 @@ public final class MapToAmountUtil {
int max = Integer.MIN_VALUE; int max = Integer.MIN_VALUE;
T maxElement = null; T maxElement = null;
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() > max) { if (entry.getValue() > max) {
max = entry.getValue().intValue(); max = entry.getValue();
maxElement = entry.getKey(); maxElement = entry.getKey();
} }
} }
return Pair.of(maxElement, Integer.valueOf(max)); return Pair.of(maxElement, max);
} }
/** /**
@@ -67,7 +67,7 @@ public final class MapToAmountUtil {
final int max = Collections.max(map.values()); final int max = Collections.max(map.values());
final FCollection<T> set = new FCollection<>(); final FCollection<T> set = new FCollection<>();
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() == max) { if (entry.getValue() == max) {
set.add(entry.getKey()); set.add(entry.getKey());
} }
} }
@@ -93,12 +93,12 @@ public final class MapToAmountUtil {
int min = Integer.MAX_VALUE; int min = Integer.MAX_VALUE;
T minElement = null; T minElement = null;
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() < min) { if (entry.getValue() < min) {
min = entry.getValue().intValue(); min = entry.getValue();
minElement = entry.getKey(); minElement = entry.getKey();
} }
} }
return Pair.of(minElement, Integer.valueOf(min)); return Pair.of(minElement, min);
} }
/** /**
@@ -122,7 +122,7 @@ public final class MapToAmountUtil {
final int min = Collections.min(map.values()); final int min = Collections.min(map.values());
final FCollection<T> set = new FCollection<>(); final FCollection<T> set = new FCollection<>();
for (final Entry<T, Integer> entry : map.entrySet()) { for (final Entry<T, Integer> entry : map.entrySet()) {
if (entry.getValue().intValue() == min) { if (entry.getValue() == min) {
set.add(entry.getKey()); set.add(entry.getKey());
} }
} }

View File

@@ -259,7 +259,7 @@ public class Game {
public void addPlayer(int id, Player player) { public void addPlayer(int id, Player player) {
playerCache.put(Integer.valueOf(id), player); playerCache.put(id, player);
} }
// methods that deal with saving, retrieving and clearing LKI information about cards on zone change // methods that deal with saving, retrieving and clearing LKI information about cards on zone change
@@ -1320,7 +1320,7 @@ public class Game {
} }
} }
public void addFacedownWhileCasting(Card c, int numDrawn) { public void addFacedownWhileCasting(Card c, int numDrawn) {
facedownWhileCasting.put(c, Integer.valueOf(numDrawn)); facedownWhileCasting.put(c, numDrawn);
} }
public boolean isDay() { public boolean isDay() {

View File

@@ -2065,7 +2065,7 @@ public class GameAction {
if (landCount == 0) { if (landCount == 0) {
return 0; return 0;
} }
return Float.valueOf(landCount)/Float.valueOf(deck.size()); return ((float) landCount) / ((float) deck.size());
} }
private float getHandScore(List<Card> hand, float landRatio) { private float getHandScore(List<Card> hand, float landRatio) {
@@ -2514,7 +2514,7 @@ public class GameAction {
lethalDamage.put(c, c.getExcessDamageValue(false)); lethalDamage.put(c, c.getExcessDamageValue(false));
} }
e.setValue(Integer.valueOf(e.getKey().addDamageAfterPrevention(e.getValue(), sourceLKI, cause, isCombat, counterTable))); e.setValue(e.getKey().addDamageAfterPrevention(e.getValue(), sourceLKI, cause, isCombat, counterTable));
sum += e.getValue(); sum += e.getValue();
sourceLKI.getDamageHistory().registerDamage(e.getValue(), isCombat, sourceLKI, e.getKey(), lkiCache); sourceLKI.getDamageHistory().registerDamage(e.getValue(), isCombat, sourceLKI, e.getKey(), lkiCache);
@@ -2648,7 +2648,7 @@ public class GameAction {
private static void unanimateOnAbortedChange(final SpellAbility cause, final Card c) { private static void unanimateOnAbortedChange(final SpellAbility cause, final Card c) {
if (cause.hasParam("AnimateSubAbility")) { if (cause.hasParam("AnimateSubAbility")) {
long unanimateTimestamp = Long.valueOf(cause.getAdditionalAbility("AnimateSubAbility").getSVar("unanimateTimestamp")); long unanimateTimestamp = Long.parseLong(cause.getAdditionalAbility("AnimateSubAbility").getSVar("unanimateTimestamp"));
c.removeChangedCardKeywords(unanimateTimestamp, 0); c.removeChangedCardKeywords(unanimateTimestamp, 0);
c.removeChangedCardTypes(unanimateTimestamp, 0); c.removeChangedCardTypes(unanimateTimestamp, 0);
c.removeChangedName(unanimateTimestamp, 0); c.removeChangedName(unanimateTimestamp, 0);

View File

@@ -211,8 +211,8 @@ public final class GameActionUtil {
&& source.isForetold() && !source.enteredThisTurn() && !source.getManaCost().isNoCost()) { && source.isForetold() && !source.enteredThisTurn() && !source.getManaCost().isNoCost()) {
// Its foretell cost is equal to its mana cost reduced by {2}. // Its foretell cost is equal to its mana cost reduced by {2}.
final SpellAbility foretold = sa.copy(activator); final SpellAbility foretold = sa.copy(activator);
Integer reduced = Math.min(2, sa.getPayCosts().getCostMana().getMana().getGenericCost()); int reduced = Math.min(2, sa.getPayCosts().getCostMana().getMana().getGenericCost());
foretold.putParam("ReduceCost", reduced.toString()); foretold.putParam("ReduceCost", Integer.toString(reduced));
foretold.setAlternativeCost(AlternativeCost.Foretold); foretold.setAlternativeCost(AlternativeCost.Foretold);
foretold.getRestrictions().setZone(ZoneType.Exile); foretold.getRestrictions().setZone(ZoneType.Exile);
foretold.putParam("AfterDescription", "(Foretold)"); foretold.putParam("AfterDescription", "(Foretold)");
@@ -887,7 +887,7 @@ public final class GameActionUtil {
// skip GameAction // skip GameAction
oldCard.getZone().remove(oldCard); oldCard.getZone().remove(oldCard);
// in some rare cases the old position no longer exists (Panglacial Wurm + Selvala) // in some rare cases the old position no longer exists (Panglacial Wurm + Selvala)
Integer newPosition = zonePosition >= 0 ? Math.min(Integer.valueOf(zonePosition), fromZone.size()) : null; Integer newPosition = zonePosition >= 0 ? Math.min(zonePosition, fromZone.size()) : null;
fromZone.add(oldCard, newPosition, null, true); fromZone.add(oldCard, newPosition, null, true);
ability.setHostCard(oldCard); ability.setHostCard(oldCard);
ability.setXManaCostPaid(null); ability.setXManaCostPaid(null);

View File

@@ -78,7 +78,7 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
} }
Map<CounterType, Integer> alreadyRemoved = column(ge).get(Optional.absent()); Map<CounterType, Integer> alreadyRemoved = column(ge).get(Optional.absent());
for (Map.Entry<CounterType, Integer> e : ge.getCounters().entrySet()) { for (Map.Entry<CounterType, Integer> e : ge.getCounters().entrySet()) {
Integer rest = e.getValue() - (alreadyRemoved.containsKey(e.getKey()) ? alreadyRemoved.get(e.getKey()) : 0); int rest = e.getValue() - (alreadyRemoved.containsKey(e.getKey()) ? alreadyRemoved.get(e.getKey()) : 0);
if (rest > 0) { if (rest > 0) {
result.put(e.getKey(), rest); result.put(e.getKey(), rest);
} }

View File

@@ -410,7 +410,7 @@ public class GameFormat implements Comparable<GameFormat> {
} catch (Exception e) { } catch (Exception e) {
formatsubType = FormatSubType.CUSTOM; formatsubType = FormatSubType.CUSTOM;
} }
Integer idx = section.getInt("order"); int idx = section.getInt("order");
String dateStr = section.get("effective"); String dateStr = section.get("effective");
if (dateStr == null){ if (dateStr == null){
dateStr = DEFAULTDATE; dateStr = DEFAULTDATE;

View File

@@ -7,7 +7,7 @@ public interface IIdentifiable {
Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() { Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() {
@Override @Override
public Integer apply(final IIdentifiable input) { public Integer apply(final IIdentifiable input) {
return Integer.valueOf(input.getId()); return input.getId();
} }
}; };
} }

View File

@@ -310,7 +310,7 @@ public class AbilityUtils {
} else if (defined.startsWith("CardUID_")) { } else if (defined.startsWith("CardUID_")) {
String idString = defined.substring(8); String idString = defined.substring(8);
for (final Card cardByID : game.getCardsInGame()) { for (final Card cardByID : game.getCardsInGame()) {
if (cardByID.getId() == Integer.valueOf(idString)) { if (cardByID.getId() == Integer.parseInt(idString)) {
cards.add(game.getCardState(cardByID)); cards.add(game.getCardState(cardByID));
} }
} }

View File

@@ -15,7 +15,7 @@ import forge.util.TextUtil;
public class AlterAttributeEffect extends SpellAbilityEffect { public class AlterAttributeEffect extends SpellAbilityEffect {
@Override @Override
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
boolean activate = Boolean.valueOf(sa.getParamOrDefault("Activate", "true")); boolean activate = Boolean.parseBoolean(sa.getParamOrDefault("Activate", "true"));
String[] attributes = sa.getParam("Attributes").split(","); String[] attributes = sa.getParam("Attributes").split(",");
CardCollection defined = getDefinedCardsOrTargeted(sa, "Defined"); CardCollection defined = getDefinedCardsOrTargeted(sa, "Defined");

View File

@@ -90,7 +90,7 @@ public class CamouflageEffect extends SpellAbilityEffect {
// Remove chosen creatures, unless it can block additional attackers // Remove chosen creatures, unless it can block additional attackers
for (final Card blocker : blockers) { for (final Card blocker : blockers) {
int index = pool.indexOf(blocker); int index = pool.indexOf(blocker);
Integer blockedCount = blockedSoFar.get(index) + 1; int blockedCount = blockedSoFar.get(index) + 1;
if (!blocker.canBlockAny() && blocker.canBlockAdditional() < blockedCount) { if (!blocker.canBlockAny() && blocker.canBlockAdditional() < blockedCount) {
pool.remove(index); pool.remove(index);
blockedSoFar.remove(index); blockedSoFar.remove(index);

View File

@@ -25,7 +25,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
public void resolve(final SpellAbility sa) { public void resolve(final SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
final Long timestamp = Long.valueOf(game.getNextTimestamp()); final Long timestamp = game.getNextTimestamp();
final boolean permanent = "Permanent".equals(sa.getParam("Duration")); final boolean permanent = "Permanent".equals(sa.getParam("Duration"));
final String changedColorWordOriginal, changedColorWordNew; final String changedColorWordOriginal, changedColorWordNew;

View File

@@ -142,7 +142,7 @@ public class CloneEffect extends SpellAbilityEffect {
game.getTriggerHandler().clearActiveTriggers(tgtCard, null); game.getTriggerHandler().clearActiveTriggers(tgtCard, null);
final Long ts = game.getNextTimestamp(); final long ts = game.getNextTimestamp();
tgtCard.addCloneState(CardFactory.getCloneStates(cardToCopy, tgtCard, sa), ts); tgtCard.addCloneState(CardFactory.getCloneStates(cardToCopy, tgtCard, sa), ts);
// set ETB tapped of clone // set ETB tapped of clone

View File

@@ -228,7 +228,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
} }
} else if (chosenMap) { } else if (chosenMap) {
if (sa.hasParam("ChosenMapIndex")) { if (sa.hasParam("ChosenMapIndex")) {
final int index = Integer.valueOf(sa.getParam("ChosenMapIndex")); final int index = Integer.parseInt(sa.getParam("ChosenMapIndex"));
if (index >= host.getChosenMap().get(controller).size()) continue; if (index >= host.getChosenMap().get(controller).size()) continue;
tgtCards.add(host.getChosenMap().get(controller).get(index)); tgtCards.add(host.getChosenMap().get(controller).get(index));
} else tgtCards = host.getChosenMap().get(controller); } else tgtCards = host.getChosenMap().get(controller);

View File

@@ -61,7 +61,7 @@ public class CounterEffect extends SpellAbilityEffect {
// currently all effects using this are targeted in case the spell gets countered before // currently all effects using this are targeted in case the spell gets countered before
// so don't need to worry about LKI (else X amounts would be missing) // so don't need to worry about LKI (else X amounts would be missing)
if (sa.hasParam("RememberCounteredCMC")) { if (sa.hasParam("RememberCounteredCMC")) {
sa.getHostCard().addRemembered(Integer.valueOf(tgtSACard.getCMC())); sa.getHostCard().addRemembered(tgtSACard.getCMC());
} }
if (sa.hasParam("RememberForCounter")) { if (sa.hasParam("RememberForCounter")) {
sa.getHostCard().addRemembered(tgtSACard); sa.getHostCard().addRemembered(tgtSACard);

View File

@@ -42,7 +42,7 @@ public class CountersMultiplyEffect extends SpellAbilityEffect {
final Player player = sa.getActivatingPlayer(); final Player player = sa.getActivatingPlayer();
final CounterType counterType = getCounterType(sa); final CounterType counterType = getCounterType(sa);
final int n = Integer.valueOf(sa.getParamOrDefault("Multiplier", "2")) - 1; final int n = Integer.parseInt(sa.getParamOrDefault("Multiplier", "2")) - 1;
GameEntityCounterTable table = new GameEntityCounterTable(); GameEntityCounterTable table = new GameEntityCounterTable();
for (final Card tgtCard : getTargetCards(sa)) { for (final Card tgtCard : getTargetCards(sa)) {

View File

@@ -84,7 +84,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
} }
if (sa.hasParam("AmountByChosenMap")) { if (sa.hasParam("AmountByChosenMap")) {
final String[] parse = sa.getParam("AmountByChosenMap").split(" INDEX "); final String[] parse = sa.getParam("AmountByChosenMap").split(" INDEX ");
final int index = parse.length > 1 ? Integer.valueOf(parse[1]) : 0; final int index = parse.length > 1 ? Integer.parseInt(parse[1]) : 0;
if (index >= host.getChosenMap().get(placer).size()) continue; if (index >= host.getChosenMap().get(placer).size()) continue;
final Card chosen = host.getChosenMap().get(placer).get(index); final Card chosen = host.getChosenMap().get(placer).get(index);
counterAmount = AbilityUtils.xCount(chosen, parse[0], sa); counterAmount = AbilityUtils.xCount(chosen, parse[0], sa);

View File

@@ -634,7 +634,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
int totalAdded = table.totalValues(); int totalAdded = table.totalValues();
if (totalAdded > 0 && rememberAmount) { if (totalAdded > 0 && rememberAmount) {
// TODO use SpellAbility Remember later // TODO use SpellAbility Remember later
card.addRemembered(Integer.valueOf(totalAdded)); card.addRemembered(totalAdded);
} }
if (sa.hasParam("RemovePhase")) { if (sa.hasParam("RemovePhase")) {

View File

@@ -79,7 +79,7 @@ public class CountersRemoveAllEffect extends SpellAbilityEffect {
} }
} }
if (sa.hasParam("RememberAmount")) { if (sa.hasParam("RememberAmount")) {
sa.getHostCard().addRemembered(Integer.valueOf(numberRemoved)); sa.getHostCard().addRemembered(numberRemoved);
} }
} }
} }

View File

@@ -208,7 +208,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
if (totalRemoved > 0 && rememberAmount) { if (totalRemoved > 0 && rememberAmount) {
// TODO use SpellAbility Remember later // TODO use SpellAbility Remember later
card.addRemembered(Integer.valueOf(totalRemoved)); card.addRemembered(totalRemoved);
} }
} }

View File

@@ -172,8 +172,7 @@ public class DigMultipleEffect extends SpellAbilityEffect {
} }
} else { } else {
// just move them randomly // just move them randomly
for (int i = 0; i < rest.size(); i++) { for (Card c : rest) {
Card c = rest.get(i);
final ZoneType origin = c.getZone().getZoneType(); final ZoneType origin = c.getZone().getZoneType();
final PlayerZone toZone = c.getOwner().getZone(destZone2); final PlayerZone toZone = c.getOwner().getZone(destZone2);
c = game.getAction().moveTo(toZone, c, sa); c = game.getAction().moveTo(toZone, c, sa);

View File

@@ -57,7 +57,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
sa.getActivatingPlayer().getManaPool().add(drained); sa.getActivatingPlayer().getManaPool().add(drained);
} }
if (sa.hasParam("RememberDrainedMana")) { if (sa.hasParam("RememberDrainedMana")) {
sa.getHostCard().addRemembered(Integer.valueOf(drained.size())); sa.getHostCard().addRemembered(drained.size());
} }
} }

View File

@@ -65,7 +65,7 @@ public class MutateEffect extends SpellAbilityEffect {
// First remove current mutated states // First remove current mutated states
target.removeMutatedStates(); target.removeMutatedStates();
// Now add all abilities from bottom cards // Now add all abilities from bottom cards
final Long ts = game.getNextTimestamp(); final long ts = game.getNextTimestamp();
target.setMutatedTimestamp(ts); target.setMutatedTimestamp(ts);
target.addCloneState(CardFactory.getMutatedCloneStates(target, sa), ts); target.addCloneState(CardFactory.getMutatedCloneStates(target, sa), ts);

View File

@@ -45,7 +45,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
public void resolve(SpellAbility sa) { public void resolve(SpellAbility sa) {
final Card host = sa.getHostCard(); final Card host = sa.getHostCard();
final Game game = sa.getActivatingPlayer().getGame(); final Game game = sa.getActivatingPlayer().getGame();
final Long timestamp = Long.valueOf(game.getNextTimestamp()); final long timestamp = game.getNextTimestamp();
final boolean isChoice = sa.getParam("Gains").contains("Choice"); final boolean isChoice = sa.getParam("Gains").contains("Choice");
final List<String> choices = ProtectEffect.getProtectionList(sa); final List<String> choices = ProtectEffect.getProtectionList(sa);

View File

@@ -29,7 +29,7 @@ public class RepeatEffect extends SpellAbilityEffect {
Integer maxRepeat = null; Integer maxRepeat = null;
if (sa.hasParam("MaxRepeat")) { if (sa.hasParam("MaxRepeat")) {
maxRepeat = AbilityUtils.calculateAmount(source, sa.getParam("MaxRepeat"), sa); maxRepeat = AbilityUtils.calculateAmount(source, sa.getParam("MaxRepeat"), sa);
if (maxRepeat.intValue() == 0) return; // do nothing if maxRepeat is 0. the next loop will execute at least once if (maxRepeat == 0) return; // do nothing if maxRepeat is 0. the next loop will execute at least once
} }
//execute repeat ability at least once //execute repeat ability at least once

View File

@@ -72,7 +72,7 @@ public class ReplaceManaEffect extends SpellAbilityEffect {
} }
} else if (sa.hasParam("ReplaceAmount")) { } else if (sa.hasParam("ReplaceAmount")) {
// replace amount = multiples // replace amount = multiples
replaced = StringUtils.repeat(replaced, " ", Integer.valueOf(sa.getParam("ReplaceAmount"))); replaced = StringUtils.repeat(replaced, " ", Integer.parseInt(sa.getParam("ReplaceAmount")));
} }
params.put(AbilityKey.Mana, replaced); params.put(AbilityKey.Mana, replaced);
// effect was updated // effect was updated

View File

@@ -307,9 +307,9 @@ public class RollDiceEffect extends SpellAbilityEffect {
} }
if (rememberHighest) { if (rememberHighest) {
int highest = 0; int highest = 0;
for (int i = 0; i < results.size(); ++i) { for (Integer result : results) {
if (highest < results.get(i)) { if (highest < result) {
highest = results.get(i); highest = result;
} }
} }
for (int i = 0; i < results.size(); ++i) { for (int i = 0; i < results.size(); ++i) {

View File

@@ -43,7 +43,7 @@ public class StoreSVarEffect extends SpellAbilityEffect {
value = AbilityUtils.xCount(source, expr, sa); value = AbilityUtils.xCount(source, expr, sa);
} }
else if (type.equals("Number")) { else if (type.equals("Number")) {
value = Integer.valueOf(expr); value = Integer.parseInt(expr);
} }
else if (type.equals("CountSVar")) { else if (type.equals("CountSVar")) {
if (expr.contains("/")) { if (expr.contains("/")) {

View File

@@ -7370,7 +7370,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
incrementTransformedTimestamp(); incrementTransformedTimestamp();
} }
if (sa.hasParam("Prototype") && prototypeTimestamp == -1) { if (sa.hasParam("Prototype") && prototypeTimestamp == -1) {
Long next = game.getNextTimestamp(); long next = game.getNextTimestamp();
addCloneState(CardFactory.getCloneStates(this, this, sa), next); addCloneState(CardFactory.getCloneStates(this, this, sa), next);
prototypeTimestamp = next; prototypeTimestamp = next;
} }

View File

@@ -33,14 +33,14 @@ public final class CardChangedWords extends ForwardingMap<String, String> {
} }
public Long addEmpty(final long timestamp, final long staticId) { public Long addEmpty(final long timestamp, final long staticId) {
final Long stamp = Long.valueOf(timestamp); final Long stamp = timestamp;
map.put(stamp, staticId, new WordHolder()); // Table doesn't allow null value map.put(stamp, staticId, new WordHolder()); // Table doesn't allow null value
isDirty = true; isDirty = true;
return stamp; return stamp;
} }
public Long add(final long timestamp, final long staticId, final String originalWord, final String newWord) { public Long add(final long timestamp, final long staticId, final String originalWord, final String newWord) {
final Long stamp = Long.valueOf(timestamp); final Long stamp = timestamp;
map.put(stamp, staticId, new WordHolder(originalWord, newWord)); map.put(stamp, staticId, new WordHolder(originalWord, newWord));
isDirty = true; isDirty = true;
return stamp; return stamp;

View File

@@ -271,9 +271,7 @@ public class CardFactoryUtil {
public static byte getMostProminentColors(final Iterable<Card> list) { public static byte getMostProminentColors(final Iterable<Card> list) {
int cntColors = MagicColor.WUBRG.length; int cntColors = MagicColor.WUBRG.length;
final Integer[] map = new Integer[cntColors]; final Integer[] map = new Integer[cntColors];
for (int i = 0; i < cntColors; i++) { Arrays.fill(map, 0);
map[i] = 0;
}
for (final Card crd : list) { for (final Card crd : list) {
ColorSet color = crd.getColor(); ColorSet color = crd.getColor();
@@ -309,9 +307,6 @@ public class CardFactoryUtil {
public static int[] SortColorsFromList(final CardCollection list) { public static int[] SortColorsFromList(final CardCollection list) {
int cntColors = MagicColor.WUBRG.length; int cntColors = MagicColor.WUBRG.length;
final int[] map = new int[cntColors]; final int[] map = new int[cntColors];
for (int i = 0; i < cntColors; i++) {
map[i] = 0;
}
for (final Card crd : list) { for (final Card crd : list) {
ColorSet color = crd.getColor(); ColorSet color = crd.getColor();
@@ -339,10 +334,7 @@ public class CardFactoryUtil {
colorRestrictions.add(MagicColor.fromName(col)); colorRestrictions.add(MagicColor.fromName(col));
} }
int cntColors = colorRestrictions.size(); int cntColors = colorRestrictions.size();
final Integer[] map = new Integer[cntColors]; final int[] map = new int[cntColors];
for (int i = 0; i < cntColors; i++) {
map[i] = 0;
}
for (final Card crd : list) { for (final Card crd : list) {
ColorSet color = crd.getColor(); ColorSet color = crd.getColor();
@@ -927,7 +919,7 @@ public class CardFactoryUtil {
} else if (keyword.startsWith("Chapter")) { } else if (keyword.startsWith("Chapter")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
final String[] abs = k[2].split(","); final String[] abs = k[2].split(",");
if (abs.length != Integer.valueOf(k[1])) { if (abs.length != Integer.parseInt(k[1])) {
throw new RuntimeException("Saga max differ from Ability amount"); throw new RuntimeException("Saga max differ from Ability amount");
} }
@@ -2789,7 +2781,7 @@ public class CardFactoryUtil {
origSA.appendSubAbility(newSA); origSA.appendSubAbility(newSA);
} else if (keyword.startsWith("Class")) { } else if (keyword.startsWith("Class")) {
final String[] k = keyword.split(":"); final String[] k = keyword.split(":");
final int level = Integer.valueOf(k[1]); final int level = Integer.parseInt(k[1]);
final StringBuilder sbClass = new StringBuilder(); final StringBuilder sbClass = new StringBuilder();
sbClass.append("AB$ ClassLevelUp | Cost$ ").append(k[2]); sbClass.append("AB$ ClassLevelUp | Cost$ ").append(k[2]);

View File

@@ -1081,7 +1081,7 @@ public class CardView extends GameEntityView {
if (hiddenId == null) { if (hiddenId == null) {
return getId(); return getId();
} }
return hiddenId.intValue(); return hiddenId;
} }
void updateHiddenId(final int hiddenId) { void updateHiddenId(final int hiddenId) {
set(TrackableProperty.HiddenId, hiddenId); set(TrackableProperty.HiddenId, hiddenId);

View File

@@ -75,7 +75,7 @@ public class AttackConstraints {
final MapToAmount<Card> causesToAttack = new LinkedHashMapToAmount<>(); final MapToAmount<Card> causesToAttack = new LinkedHashMapToAmount<>();
for (final Entry<Card, Integer> entry : attacksIfOtherAttacks.entrySet()) { for (final Entry<Card, Integer> entry : attacksIfOtherAttacks.entrySet()) {
if (entry.getKey() != possibleAttacker) { if (entry.getKey() != possibleAttacker) {
causesToAttack.add(entry.getKey(), entry.getValue().intValue()); causesToAttack.add(entry.getKey(), entry.getValue());
} }
} }
@@ -121,7 +121,7 @@ public class AttackConstraints {
final int globalMax = globalRestrictions.getMax(); final int globalMax = globalRestrictions.getMax();
final int myMax = Ints.min(globalMax == -1 ? Integer.MAX_VALUE : globalMax, possibleAttackers.size()); final int myMax = Ints.min(globalMax == -1 ? Integer.MAX_VALUE : globalMax, possibleAttackers.size());
if (myMax == 0) { if (myMax == 0) {
return Pair.of(Collections.emptyMap(), Integer.valueOf(0)); return Pair.of(Collections.emptyMap(), 0);
} }
final MapToAmount<Map<Card, GameEntity>> possible = new LinkedHashMapToAmount<>(); final MapToAmount<Map<Card, GameEntity>> possible = new LinkedHashMapToAmount<>();
@@ -224,7 +224,7 @@ public class AttackConstraints {
} }
} }
final Integer defMax = globalRestrictions.getDefenderMax().get(req.defender); final Integer defMax = globalRestrictions.getDefenderMax().get(req.defender);
if (defMax != null && toDefender.count(req.defender) >= defMax.intValue()) { if (defMax != null && toDefender.count(req.defender) >= defMax) {
// too many to this defender already // too many to this defender already
skip = true; skip = true;
} else if (null != CombatUtil.getAttackCost(req.attacker.getGame(), req.attacker, req.defender)) { } else if (null != CombatUtil.getAttackCost(req.attacker.getGame(), req.attacker, req.defender)) {
@@ -254,7 +254,7 @@ public class AttackConstraints {
final List<Attack> clonedReqs = deepClone(reqs); final List<Attack> clonedReqs = deepClone(reqs);
for (final Entry<Card, Integer> causesToAttack : requirement.getCausesToAttack().entrySet()) { for (final Entry<Card, Integer> causesToAttack : requirement.getCausesToAttack().entrySet()) {
for (final Attack a : findAll(reqs, causesToAttack.getKey())) { for (final Attack a : findAll(reqs, causesToAttack.getKey())) {
a.requirements += causesToAttack.getValue().intValue(); a.requirements += causesToAttack.getValue();
} }
} }
// if maximum < no of possible attackers, try both with and without this creature // if maximum < no of possible attackers, try both with and without this creature
@@ -449,7 +449,7 @@ public class AttackConstraints {
private final Function<Map<Card, GameEntity>, Integer> FN_COUNT_VIOLATIONS = new Function<Map<Card,GameEntity>, Integer>() { private final Function<Map<Card, GameEntity>, Integer> FN_COUNT_VIOLATIONS = new Function<Map<Card,GameEntity>, Integer>() {
@Override @Override
public Integer apply(final Map<Card, GameEntity> input) { public Integer apply(final Map<Card, GameEntity> input) {
return Integer.valueOf(countViolations(input)); return countViolations(input);
} }
}; };
} }

View File

@@ -48,7 +48,7 @@ public class AttackRequirement {
for (final GameEntity defender : possibleDefenders) { for (final GameEntity defender : possibleDefenders) {
// use put here because we want to always put it, even if the value is 0 // use put here because we want to always put it, even if the value is 0
defenderSpecific.put(defender, Integer.valueOf(defenderSpecific.count(defender) + nAttackAnything)); defenderSpecific.put(defender, defenderSpecific.count(defender) + nAttackAnything);
} }
// Remove GameEntities that are no longer on an opposing battlefield or are // Remove GameEntities that are no longer on an opposing battlefield or are
@@ -107,7 +107,7 @@ public class AttackRequirement {
// only count violations if the forced creature can actually attack and has no cost incurred for doing so // only count violations if the forced creature can actually attack and has no cost incurred for doing so
if (attackers.size() < max && !attackers.containsKey(mustAttack.getKey()) && CombatUtil.canAttack(mustAttack.getKey()) && CombatUtil.getAttackCost(defender.getGame(), mustAttack.getKey(), defender) == null) { if (attackers.size() < max && !attackers.containsKey(mustAttack.getKey()) && CombatUtil.canAttack(mustAttack.getKey()) && CombatUtil.getAttackCost(defender.getGame(), mustAttack.getKey(), defender) == null) {
violations += mustAttack.getValue().intValue(); violations += mustAttack.getValue();
} }
} }
} }

View File

@@ -92,7 +92,7 @@ public class AttackingBand {
*/ */
@Override @Override
public String toString() { public String toString() {
return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked.booleanValue() ? ">||" : ">>>" ); return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked ? ">||" : ">>>" );
} }
} }

View File

@@ -92,7 +92,7 @@ public class CombatUtil {
return false; return false;
} }
final Pair<Map<Card, GameEntity>, Integer> bestAttack = constraints.getLegalAttackers(); final Pair<Map<Card, GameEntity>, Integer> bestAttack = constraints.getLegalAttackers();
return myViolations <= bestAttack.getRight().intValue(); return myViolations <= bestAttack.getRight();
} }
/** /**
@@ -122,7 +122,7 @@ public class CombatUtil {
if (myViolations == -1) { if (myViolations == -1) {
return false; return false;
} }
return myViolations <= bestAttack.getRight().intValue(); return myViolations <= bestAttack.getRight();
} }
}); });
} }

View File

@@ -50,7 +50,7 @@ public class GlobalAttackRestrictions {
if (max == null) { if (max == null) {
continue; continue;
} }
if (returnQuickly && max.intValue() == 0) { if (returnQuickly && max == 0) {
// there's at least one creature attacking this defender // there's at least one creature attacking this defender
defenderTooMany.put(defender, 1); defenderTooMany.put(defender, 1);
break; break;
@@ -59,13 +59,13 @@ public class GlobalAttackRestrictions {
for (final Entry<Card, GameEntity> attDef : attackers.entrySet()) { for (final Entry<Card, GameEntity> attDef : attackers.entrySet()) {
if (attDef.getValue() == defender) { if (attDef.getValue() == defender) {
count++; count++;
if (returnQuickly && count > max.intValue()) { if (returnQuickly && count > max) {
defenderTooMany.put(defender, count - max.intValue()); defenderTooMany.put(defender, count - max);
break outer; break outer;
} }
} }
} }
final int nDefTooMany = count - max.intValue(); final int nDefTooMany = count - max;
if (nDefTooMany > 0) { if (nDefTooMany > 0) {
// Too many attackers to one defender! // Too many attackers to one defender!
defenderTooMany.put(defender, nDefTooMany); defenderTooMany.put(defender, nDefTooMany);

View File

@@ -860,7 +860,7 @@ public class Cost implements Serializable {
return Cost.convertAmountTypeToWords(amount, type); return Cost.convertAmountTypeToWords(amount, type);
} }
return Cost.convertIntAndTypeToWords(i.intValue(), type); return Cost.convertIntAndTypeToWords(i, type);
} }
/** /**

View File

@@ -473,7 +473,7 @@ public class CostAdjustment {
if (!staticAbility.hasParam("Cost") && !staticAbility.hasParam("Color")) { if (!staticAbility.hasParam("Cost") && !staticAbility.hasParam("Color")) {
int minMana = 0; int minMana = 0;
if (staticAbility.hasParam("MinMana")) { if (staticAbility.hasParam("MinMana")) {
minMana = Integer.valueOf(staticAbility.getParam("MinMana")); minMana = Integer.parseInt(staticAbility.getParam("MinMana"));
} }
final int maxReduction = manaCost.getConvertedManaCost() - minMana - sumReduced; final int maxReduction = manaCost.getConvertedManaCost() - minMana - sumReduced;

View File

@@ -87,7 +87,7 @@ public class CostGainLife extends CostPart {
@Override @Override
public final boolean payAsDecided(final Player ai, final PaymentDecision decision, SpellAbility ability, final boolean effect) { public final boolean payAsDecided(final Player ai, final PaymentDecision decision, SpellAbility ability, final boolean effect) {
Integer c = this.getAbilityAmount(ability); int c = this.getAbilityAmount(ability);
int playersLeft = cntPlayers; int playersLeft = cntPlayers;
for (final Player opp : decision.players) { for (final Player opp : decision.players) {

View File

@@ -2,6 +2,8 @@ package forge.game.mana;
import forge.card.mana.ManaAtom; import forge.card.mana.ManaAtom;
import java.util.Arrays;
public class ManaConversionMatrix { public class ManaConversionMatrix {
static byte[] identityMatrix = { ManaAtom.WHITE, ManaAtom.BLUE, ManaAtom.BLACK, ManaAtom.RED, ManaAtom.GREEN, ManaAtom.COLORLESS }; static byte[] identityMatrix = { ManaAtom.WHITE, ManaAtom.BLUE, ManaAtom.BLACK, ManaAtom.RED, ManaAtom.GREEN, ManaAtom.COLORLESS };
@@ -54,13 +56,9 @@ public class ManaConversionMatrix {
public void restoreColorReplacements() { public void restoreColorReplacements() {
// By default each color can only be paid by itself ( {G} -> {G}, {C} -> {C} // By default each color can only be paid by itself ( {G} -> {G}, {C} -> {C}
for (int i = 0; i < colorConversionMatrix.length; i++) { System.arraycopy(identityMatrix, 0, colorConversionMatrix, 0, colorConversionMatrix.length);
colorConversionMatrix[i] = identityMatrix[i];
}
// By default all mana types are unrestricted // By default all mana types are unrestricted
for (int i = 0; i < colorRestrictionMatrix.length; i++) { Arrays.fill(colorRestrictionMatrix, ManaAtom.ALL_MANA_TYPES);
colorRestrictionMatrix[i] = ManaAtom.ALL_MANA_TYPES;
}
snowForColor = false; snowForColor = false;
} }
} }

View File

@@ -36,24 +36,24 @@ public class MulliganService {
boolean firstMullFree = game.getPlayers().size() > 2 || game.getRules().hasAppliedVariant(GameType.Brawl); boolean firstMullFree = game.getPlayers().size() > 2 || game.getRules().hasAppliedVariant(GameType.Brawl);
for (int i = 0; i < whoCanMulligan.size(); i++) { for (Player player : whoCanMulligan) {
MulliganDefs.MulliganRule rule = StaticData.instance().getMulliganRule(); MulliganDefs.MulliganRule rule = StaticData.instance().getMulliganRule();
switch (rule) { switch (rule) {
case Original: case Original:
mulligans.add(new OriginalMulligan(whoCanMulligan.get(i), firstMullFree)); mulligans.add(new OriginalMulligan(player, firstMullFree));
break; break;
case Paris: case Paris:
mulligans.add(new ParisMulligan(whoCanMulligan.get(i), firstMullFree)); mulligans.add(new ParisMulligan(player, firstMullFree));
break; break;
case Vancouver: case Vancouver:
mulligans.add(new VancouverMulligan(whoCanMulligan.get(i), firstMullFree)); mulligans.add(new VancouverMulligan(player, firstMullFree));
break; break;
case London: case London:
mulligans.add(new LondonMulligan(whoCanMulligan.get(i), firstMullFree)); mulligans.add(new LondonMulligan(player, firstMullFree));
break; break;
default: default:
// Default to Vancouver mulligan for now. Should ideally never get here. // Default to Vancouver mulligan for now. Should ideally never get here.
mulligans.add(new VancouverMulligan(whoCanMulligan.get(i), firstMullFree)); mulligans.add(new VancouverMulligan(player, firstMullFree));
break; break;
} }
} }

View File

@@ -209,7 +209,7 @@ public class Untap extends Phase {
if (chosen != null) { if (chosen != null) {
for (Entry<String, Integer> rest : restrictUntap.entrySet()) { for (Entry<String, Integer> rest : restrictUntap.entrySet()) {
if (chosen.isValid(rest.getKey(), player, null, null)) { if (chosen.isValid(rest.getKey(), player, null, null)) {
restrictUntap.put(rest.getKey(), rest.getValue().intValue() - 1); restrictUntap.put(rest.getKey(), rest.getValue() - 1);
} }
} }
restrictUntapped.add(chosen); restrictUntapped.add(chosen);

View File

@@ -940,7 +940,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
public void setCounters(final CounterType counterType, final Integer num, Player source, boolean fireEvents) { public void setCounters(final CounterType counterType, final Integer num, Player source, boolean fireEvents) {
Integer old = getCounters(counterType); int old = getCounters(counterType);
setCounters(counterType, num); setCounters(counterType, num);
view.updateCounters(this); view.updateCounters(this);
if (fireEvents) { if (fireEvents) {
@@ -2222,8 +2222,8 @@ public class Player extends GameEntity implements Comparable<Player> {
if (incR.length > 1) { if (incR.length > 1) {
final String excR = incR[1]; final String excR = incR[1];
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ... final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
for (int j = 0; j < exR.length; j++) { for (String s : exR) {
if (!hasProperty(exR[j], sourceController, source, spellAbility)) { if (!hasProperty(s, sourceController, source, spellAbility)) {
return false; return false;
} }
} }
@@ -2805,7 +2805,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
public int getCommanderDamage(Card commander) { public int getCommanderDamage(Card commander) {
Integer damage = commanderDamage.get(commander); Integer damage = commanderDamage.get(commander);
return damage == null ? 0 : damage.intValue(); return damage == null ? 0 : damage;
} }
public void addCommanderDamage(Card commander, int damage) { public void addCommanderDamage(Card commander, int damage) {
commanderDamage.merge(commander, damage, Integer::sum); commanderDamage.merge(commander, damage, Integer::sum);
@@ -2902,7 +2902,7 @@ public class Player extends GameEntity implements Comparable<Player> {
try { try {
if (keyword.startsWith("etbCounter")) { if (keyword.startsWith("etbCounter")) {
final String[] p = keyword.split(":"); final String[] p = keyword.split(":");
c.addCounterInternal(CounterType.getType(p[1]), Integer.valueOf(p[2]), null, false, null, null); c.addCounterInternal(CounterType.getType(p[1]), Integer.parseInt(p[2]), null, false, null, null);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -3054,7 +3054,7 @@ public class Player extends GameEntity implements Comparable<Player> {
} }
int generic = manaCost.getGenericCost(); int generic = manaCost.getGenericCost();
if (generic > 0 || manaCost.getCMC() == 0) { if (generic > 0 || manaCost.getCMC() == 0) {
if (!genericManaSymbols.add(Integer.valueOf(generic))) { if (!genericManaSymbols.add(generic)) {
return false; return false;
} }
} }
@@ -3544,11 +3544,11 @@ public class Player extends GameEntity implements Comparable<Player> {
public String trimKeywords(String keywordTexts) { public String trimKeywords(String keywordTexts) {
if (keywordTexts.contains("Protection:")) { if (keywordTexts.contains("Protection:")) {
List <String> lines = Arrays.asList(keywordTexts.split("\n")); List <String> lines = Arrays.asList(keywordTexts.split("\n"));
for (int i = 0; i < lines.size(); i++) { for (String line : lines) {
if (lines.get(i).startsWith("Protection:")) { if (line.startsWith("Protection:")) {
List<String> parts = Arrays.asList(lines.get(i).split(":")); List<String> parts = Arrays.asList(line.split(":"));
if (parts.size() > 2) { if (parts.size() > 2) {
keywordTexts = TextUtil.fastReplace(keywordTexts, lines.get(i), parts.get(2)); keywordTexts = TextUtil.fastReplace(keywordTexts, line, parts.get(2));
} }
} }
} }

View File

@@ -365,7 +365,7 @@ public class PlayerView extends GameEntityView {
Map<Integer, Integer> map = get(TrackableProperty.CommanderDamage); Map<Integer, Integer> map = get(TrackableProperty.CommanderDamage);
if (map == null) { return 0; } if (map == null) { return 0; }
Integer damage = map.get(commander.getId()); Integer damage = map.get(commander.getId());
return damage == null ? 0 : damage.intValue(); return damage == null ? 0 : damage;
} }
void updateCommanderDamage(Player p) { void updateCommanderDamage(Player p) {
Map<Integer, Integer> map = Maps.newHashMap(); Map<Integer, Integer> map = Maps.newHashMap();
@@ -388,7 +388,7 @@ public class PlayerView extends GameEntityView {
Map<Integer, Integer> map = get(TrackableProperty.CommanderCast); Map<Integer, Integer> map = get(TrackableProperty.CommanderCast);
if (map == null) { return 0; } if (map == null) { return 0; }
Integer damage = map.get(commander.getId()); Integer damage = map.get(commander.getId());
return damage == null ? 0 : damage.intValue(); return damage == null ? 0 : damage;
} }
void updateCommanderCast(Player p, Card c) { void updateCommanderCast(Player p, Card c) {
@@ -569,7 +569,7 @@ public class PlayerView extends GameEntityView {
e.printStackTrace(); e.printStackTrace();
count = null; count = null;
} }
return count != null ? count.intValue() : 0; return count != null ? count : 0;
} }
private Map<Byte, Integer> getMana() { private Map<Byte, Integer> getMana() {
return get(TrackableProperty.Mana); return get(TrackableProperty.Mana);

View File

@@ -81,16 +81,8 @@ public enum ReplacementType {
ReplacementEffect res = c.newInstance(mapParams, host, intrinsic); ReplacementEffect res = c.newInstance(mapParams, host, intrinsic);
res.setMode(this); res.setMode(this);
return res; return res;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | InstantiationException | IllegalAccessException |
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. InvocationTargetException e) {
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -203,7 +203,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
if (!source.isLKI()) { if (!source.isLKI()) {
source = CardCopyService.getLKICopy(source); source = CardCopyService.getLKICopy(source);
} }
Long next = source.getGame().getNextTimestamp(); long next = source.getGame().getNextTimestamp();
source.addCloneState(CardFactory.getCloneStates(source, source, this), next); source.addCloneState(CardFactory.getCloneStates(source, source, this), next);
lkicheck = true; lkicheck = true;
} }

View File

@@ -827,9 +827,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
} }
public void setTriggeringObjectsFrom(final Map<AbilityKey, Object> runParams, final AbilityKey... types) { public void setTriggeringObjectsFrom(final Map<AbilityKey, Object> runParams, final AbilityKey... types) {
int typesLength = types.length; for (AbilityKey type : types) {
for (int i = 0; i < typesLength; i += 1) {
AbilityKey type = types[i];
if (runParams.containsKey(type)) { if (runParams.containsKey(type)) {
triggeringObjects.put(type, runParams.get(type)); triggeringObjects.put(type, runParams.get(type));
} }
@@ -868,9 +866,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
replacingObjects = AbilityKey.newMap(repParams); replacingObjects = AbilityKey.newMap(repParams);
} }
public void setReplacingObjectsFrom(final Map<AbilityKey, Object> repParams, final AbilityKey... types) { public void setReplacingObjectsFrom(final Map<AbilityKey, Object> repParams, final AbilityKey... types) {
int typesLength = types.length; for (AbilityKey type : types) {
for (int i = 0; i < typesLength; i += 1) {
AbilityKey type = types[i];
if (repParams.containsKey(type)) { if (repParams.containsKey(type)) {
setReplacingObject(type, repParams.get(type)); setReplacingObject(type, repParams.get(type));
} }
@@ -2210,8 +2206,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (incR.length > 1) { if (incR.length > 1) {
final String excR = incR[1]; final String excR = incR[1];
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ... final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
for (int j = 0; j < exR.length; j++) { for (String s : exR) {
if (!hasProperty(exR[j], sourceController, source, spellAbility)) { if (!hasProperty(s, sourceController, source, spellAbility)) {
return testFailed; return testFailed;
} }
} }

View File

@@ -35,7 +35,7 @@ public class StaticAbilityCantDraw {
if (!stAb.matchesValidParam("ValidPlayer", player)) { if (!stAb.matchesValidParam("ValidPlayer", player)) {
return amount; return amount;
} }
int limit = Integer.valueOf(stAb.getParamOrDefault("DrawLimit", "0")); int limit = Integer.parseInt(stAb.getParamOrDefault("DrawLimit", "0"));
int drawn = player.getNumDrawnThisTurn(); int drawn = player.getNumDrawnThisTurn();
return Math.min(Math.max(limit - drawn, 0), amount); return Math.min(Math.max(limit - drawn, 0), amount);
} }

View File

@@ -76,7 +76,7 @@ public class TriggerCounterRemoved extends Trigger {
if (hasParam("NewCounterAmount")) { if (hasParam("NewCounterAmount")) {
final String amtString = getParam("NewCounterAmount"); final String amtString = getParam("NewCounterAmount");
int amt = Integer.parseInt(amtString); int amt = Integer.parseInt(amtString);
if(amt != addedNewCounterAmount.intValue()) { if(amt != addedNewCounterAmount) {
return false; return false;
} }
} }

View File

@@ -85,7 +85,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
add(c, index, latestState, false); add(c, index, latestState, false);
} }
public void add(final Card c, Integer index, final Card latestState, final boolean rollback) { public void add(final Card c, Integer index, final Card latestState, final boolean rollback) {
if (index != null && cardList.isEmpty() && index.intValue() > 0) { if (index != null && cardList.isEmpty() && index > 0) {
// something went wrong, most likely the method fired when the game was in an unexpected state // something went wrong, most likely the method fired when the game was in an unexpected state
// (e.g. conceding during the mana payment prompt) // (e.g. conceding during the mana payment prompt)
System.out.println("Warning: tried to add a card to zone with a specific non-zero index, but the zone was empty! Canceling Zone#add to avoid a crash."); System.out.println("Warning: tried to add a card to zone with a specific non-zero index, but the zone was empty! Canceling Zone#add to avoid a crash.");
@@ -133,7 +133,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
if (index == null) { if (index == null) {
cardList.add(c); cardList.add(c);
} else { } else {
cardList.add(index.intValue(), c); cardList.add(index, c);
} }
} }
onChanged(); onChanged();

View File

@@ -12,7 +12,7 @@ public class MessageUtil {
private MessageUtil() { } private MessageUtil() { }
public static String formatMessage(String message, Player player, Object related) { public static String formatMessage(String message, Player player, Object related) {
if (related instanceof Player && message.indexOf("{player") >= 0) { if (related instanceof Player && message.contains("{player")) {
String noun = mayBeYou(player, related); String noun = mayBeYou(player, related);
message = TextUtil.fastReplace(TextUtil.fastReplace(message, "{player}", noun),"{player's}", Lang.getInstance().getPossesive(noun)); message = TextUtil.fastReplace(TextUtil.fastReplace(message, "{player}", noun),"{player's}", Lang.getInstance().getPossesive(noun));
} }
@@ -20,7 +20,7 @@ public class MessageUtil {
} }
public static String formatMessage(String message, PlayerView player, Object related) { public static String formatMessage(String message, PlayerView player, Object related) {
if (related instanceof PlayerView && message.indexOf("{player") >= 0) { if (related instanceof PlayerView && message.contains("{player")) {
String noun = mayBeYou(player, related); String noun = mayBeYou(player, related);
message = TextUtil.fastReplace(TextUtil.fastReplace(message, "{player}", noun),"{player's}", Lang.getInstance().getPossesive(noun)); message = TextUtil.fastReplace(TextUtil.fastReplace(message, "{player}", noun),"{player's}", Lang.getInstance().getPossesive(noun));
} }

View File

@@ -108,10 +108,7 @@ public class GuiDesktop implements IGuiBase {
try { try {
SwingUtilities.invokeAndWait(proc); SwingUtilities.invokeAndWait(proc);
} }
catch (final InterruptedException exn) { catch (final InterruptedException | InvocationTargetException exn) {
throw new RuntimeException(exn);
}
catch (final InvocationTargetException exn) {
throw new RuntimeException(exn); throw new RuntimeException(exn);
} }
} }

View File

@@ -142,7 +142,7 @@ public class KeyboardShortcuts {
StackItemView si = matchUI.getGameView().peekStack(); StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) { if (si != null && si.isAbility()) {
matchUI.setShouldAutoYield(si.getKey(), true); matchUI.setShouldAutoYield(si.getKey(), true);
int triggerID = Integer.valueOf(si.getSourceTrigger()); int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) { if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.setShouldAlwaysAcceptTrigger(triggerID); matchUI.setShouldAlwaysAcceptTrigger(triggerID);
} }
@@ -160,7 +160,7 @@ public class KeyboardShortcuts {
StackItemView si = matchUI.getGameView().peekStack(); StackItemView si = matchUI.getGameView().peekStack();
if (si != null && si.isAbility()) { if (si != null && si.isAbility()) {
matchUI.setShouldAutoYield(si.getKey(), true); matchUI.setShouldAutoYield(si.getKey(), true);
int triggerID = Integer.valueOf(si.getSourceTrigger()); int triggerID = si.getSourceTrigger();
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) { if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
matchUI.setShouldAlwaysDeclineTrigger(triggerID); matchUI.setShouldAlwaysDeclineTrigger(triggerID);
} }
@@ -312,7 +312,7 @@ public class KeyboardShortcuts {
if (s.equals("16")) { inputEvents[0] = 16; } if (s.equals("16")) { inputEvents[0] = 16; }
else if (s.equals("17")) { inputEvents[1] = 17; } else if (s.equals("17")) { inputEvents[1] = 17; }
else { else {
keyEvent = Integer.valueOf(s); keyEvent = Integer.parseInt(s);
} }
} }

View File

@@ -170,7 +170,7 @@ public class FDeckViewer extends FDialog {
} }
private void copyToClipboard() { private void copyToClipboard() {
final String nl = System.getProperty("line.separator"); final String nl = System.lineSeparator();
final StringBuilder deckList = new StringBuilder(); final StringBuilder deckList = new StringBuilder();
String dName = deck.getName(); String dName = deck.getName();
//fix copying a commander netdeck then importing it again... //fix copying a commander netdeck then importing it again...

View File

@@ -78,7 +78,7 @@ public class GuiChoose {
final Integer[] choices = new Integer[count]; final Integer[] choices = new Integer[count];
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
choices[i] = Integer.valueOf(i + min); choices[i] = i + min;
} }
return GuiChoose.oneOrNone(message, choices); return GuiChoose.oneOrNone(message, choices);
} }
@@ -92,7 +92,7 @@ public class GuiChoose {
final List<Object> choices = new ArrayList<>(); final List<Object> choices = new ArrayList<>();
for (int i = min; i <= cutoff; i++) { for (int i = min; i <= cutoff; i++) {
choices.add(Integer.valueOf(i)); choices.add(i);
} }
choices.add(Localizer.getInstance().getMessage("lblOtherInteger")); choices.add(Localizer.getInstance().getMessage("lblOtherInteger"));
@@ -120,7 +120,7 @@ public class GuiChoose {
if (str == null) { return null; } // that is 'cancel' if (str == null) { return null; } // that is 'cancel'
if (StringUtils.isNumeric(str)) { if (StringUtils.isNumeric(str)) {
final Integer val = Integer.valueOf(str); final int val = Integer.parseInt(str);
if (val >= min && val <= max) { if (val >= min && val <= max) {
return val; return val;
} }

View File

@@ -31,13 +31,13 @@ public class GuiDialog {
final String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question; final String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
final List<String> opts = options == null ? defaultConfirmOptions : options; final List<String> opts = options == null ? defaultConfirmOptions : options;
final int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1); final int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
return Boolean.valueOf(answer == 0); return answer == 0;
}}; }};
final FutureTask<Boolean> future = new FutureTask<>(confirmTask); final FutureTask<Boolean> future = new FutureTask<>(confirmTask);
FThreads.invokeInEdtAndWait(future); FThreads.invokeInEdtAndWait(future);
try { try {
return future.get().booleanValue(); return future.get();
} catch (final InterruptedException | ExecutionException e) { // should be no exception here } catch (final InterruptedException | ExecutionException e) { // should be no exception here
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -131,10 +131,8 @@ public final class SLayoutIO {
final FileLocation file = ForgeConstants.WINDOW_LAYOUT_FILE; final FileLocation file = ForgeConstants.WINDOW_LAYOUT_FILE;
final String fWriteTo = file.userPrefLoc; final String fWriteTo = file.userPrefLoc;
final XMLOutputFactory out = XMLOutputFactory.newInstance(); final XMLOutputFactory out = XMLOutputFactory.newInstance();
FileOutputStream fos = null;
XMLEventWriter writer = null; XMLEventWriter writer = null;
try { try (FileOutputStream fos = new FileOutputStream(fWriteTo)) {
fos = new FileOutputStream(fWriteTo);
writer = out.createXMLEventWriter(fos); writer = out.createXMLEventWriter(fos);
writer.add(EF.createStartDocument()); writer.add(EF.createStartDocument());
@@ -149,18 +147,12 @@ public final class SLayoutIO {
writer.add(EF.createEndElement("", "", "layout")); writer.add(EF.createEndElement("", "", "layout"));
writer.flush(); writer.flush();
writer.add(EF.createEndDocument()); writer.add(EF.createEndDocument());
} catch (FileNotFoundException e) { } catch (XMLStreamException | IOException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace();
} catch (XMLStreamException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (writer != null ) { if (writer != null) {
try { writer.close(); } catch (XMLStreamException e) {} try { writer.close(); } catch (XMLStreamException ignored) {}
}
if ( fos != null ) {
try { fos.close(); } catch (IOException e) {}
} }
} }
} }
@@ -345,10 +337,7 @@ public final class SLayoutIO {
} }
writer.flush(); writer.flush();
writer.add(EF.createEndDocument()); writer.add(EF.createEndDocument());
} catch (FileNotFoundException e) { } catch (FileNotFoundException | XMLStreamException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace();
} catch (XMLStreamException e) {
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. // TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@@ -415,7 +404,7 @@ public final class SLayoutIO {
final FView view = FView.SINGLETON_INSTANCE; final FView view = FView.SINGLETON_INSTANCE;
String defaultLayoutSerial = ""; String defaultLayoutSerial = "";
String userLayoutSerial = ""; String userLayoutSerial = "";
Boolean resetLayout = false; boolean resetLayout = false;
FScreen screen = Singletons.getControl().getCurrentScreen(); FScreen screen = Singletons.getControl().getCurrentScreen();
FAbsolutePositioner.SINGLETON_INSTANCE.hideAll(); FAbsolutePositioner.SINGLETON_INSTANCE.hideAll();
view.getPnlInsets().removeAll(); view.getPnlInsets().removeAll();

View File

@@ -1,7 +1,6 @@
package forge.itemmanager.filters; package forge.itemmanager.filters;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -79,10 +78,8 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
btnPackOrDeck.setText(String.valueOf(count)); btnPackOrDeck.setText(String.valueOf(count));
} }
Iterator<StatTypes> buttonMapStatsIterator = buttonMap.keySet().iterator(); for (StatTypes statTypes : buttonMap.keySet()) {
while (buttonMapStatsIterator.hasNext()){ if (statTypes.predicate != null) {
StatTypes statTypes = buttonMapStatsIterator.next();
if (statTypes.predicate != null){
int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES), PaperCard.class); int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES), PaperCard.class);
buttonMap.get(statTypes).setText(String.valueOf(count)); buttonMap.get(statTypes).setText(String.valueOf(count));
} }

View File

@@ -38,6 +38,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.IntStream;
public class ImageView<T extends InventoryItem> extends ItemView<T> { public class ImageView<T extends InventoryItem> extends ItemView<T> {
private static final int PADDING = 5; private static final int PADDING = 5;
@@ -154,9 +155,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
SItemManagerUtil.populateImageViewOptions(itemManager0, cbGroupByOptions, cbPileByOptions); SItemManagerUtil.populateImageViewOptions(itemManager0, cbGroupByOptions, cbPileByOptions);
for (Integer i = MIN_COLUMN_COUNT; i <= MAX_COLUMN_COUNT; i++) { IntStream.rangeClosed(MIN_COLUMN_COUNT, MAX_COLUMN_COUNT).forEach(cbColumnCount::addItem);
cbColumnCount.addItem(i);
}
cbGroupByOptions.setMaximumRowCount(cbGroupByOptions.getItemCount()); cbGroupByOptions.setMaximumRowCount(cbGroupByOptions.getItemCount());
cbPileByOptions.setMaximumRowCount(cbPileByOptions.getItemCount()); cbPileByOptions.setMaximumRowCount(cbPileByOptions.getItemCount());
cbColumnCount.setMaximumRowCount(cbColumnCount.getItemCount()); cbColumnCount.setMaximumRowCount(cbColumnCount.getItemCount());
@@ -871,9 +870,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
public void selectAll() { public void selectAll() {
clearSelection(); clearSelection();
for (Integer i = 0; i < getCount(); i++) { IntStream.range(0, getCount()).forEach(selectedIndices::add);
selectedIndices.add(i);
}
updateSelection(); updateSelection();
} }

View File

@@ -273,8 +273,8 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
public Iterable<Integer> getSelectedIndices() { public Iterable<Integer> getSelectedIndices() {
final List<Integer> indices = new ArrayList<>(); final List<Integer> indices = new ArrayList<>();
final int[] selectedRows = this.table.getSelectedRows(); final int[] selectedRows = this.table.getSelectedRows();
for (int i = 0; i < selectedRows.length; i++) { for (int selectedRow : selectedRows) {
indices.add(selectedRows[i]); indices.add(selectedRow);
} }
return indices; return indices;
} }

View File

@@ -165,7 +165,7 @@ public final class CEditorQuest extends CDeckEditor<Deck> {
for (final Entry<PaperCard, Integer> e : deck.getMain()) { for (final Entry<PaperCard, Integer> e : deck.getMain()) {
final PaperCard card = e.getKey(); final PaperCard card = e.getKey();
final Integer amount = result.get(card); final Integer amount = result.get(card);
result.put(card, Integer.valueOf(amount == null ? 1 : 1 + amount.intValue())); result.put(card, amount == null ? 1 : 1 + amount);
} }
} }
return result; return result;

View File

@@ -138,7 +138,7 @@ public final class CEditorQuestLimited extends CDeckEditor<DeckGroup> {
for (final Entry<PaperCard, Integer> e : deck.getMain()) { for (final Entry<PaperCard, Integer> e : deck.getMain()) {
final PaperCard card = e.getKey(); final PaperCard card = e.getKey();
final Integer amount = result.get(card); final Integer amount = result.get(card);
result.put(card, Integer.valueOf(amount == null ? 1 : 1 + amount.intValue())); result.put(card, amount == null ? 1 : 1 + amount);
} }
} }
return result; return result;

View File

@@ -209,11 +209,11 @@ public class PlayerPanel extends FPanel {
void update() { void update() {
avatarLabel.setEnabled(mayEdit); avatarLabel.setEnabled(mayEdit);
avatarLabel.setIcon(FSkin.getAvatars().get(Integer.valueOf(type == LobbySlotType.OPEN ? -1 : avatarIndex))); avatarLabel.setIcon(FSkin.getAvatars().get(type == LobbySlotType.OPEN ? -1 : avatarIndex));
avatarLabel.repaintSelf(); avatarLabel.repaintSelf();
sleeveLabel.setEnabled(mayEdit); sleeveLabel.setEnabled(mayEdit);
sleeveLabel.setIcon(FSkin.getSleeves().get(Integer.valueOf(type == LobbySlotType.OPEN ? -1 : sleeveIndex))); sleeveLabel.setIcon(FSkin.getSleeves().get(type == LobbySlotType.OPEN ? -1 : sleeveIndex));
sleeveLabel.repaintSelf(); sleeveLabel.repaintSelf();
txtPlayerName.setEnabled(mayEdit); txtPlayerName.setEnabled(mayEdit);
@@ -312,7 +312,7 @@ public class PlayerPanel extends FPanel {
lbl.setCommand(new UiCommand() { lbl.setCommand(new UiCommand() {
@Override @Override
public void run() { public void run() {
setAvatarIndex(Integer.valueOf(lbl.getName().substring(11))); setAvatarIndex(Integer.parseInt(lbl.getName().substring(11)));
aSel.setVisible(false); aSel.setVisible(false);
} }
}); });
@@ -368,7 +368,7 @@ public class PlayerPanel extends FPanel {
lbl.setCommand(new UiCommand() { lbl.setCommand(new UiCommand() {
@Override @Override
public void run() { public void run() {
setSleeveIndex(Integer.valueOf(lbl.getName().substring(11))); setSleeveIndex(Integer.parseInt(lbl.getName().substring(11)));
sSel.setVisible(false); sSel.setVisible(false);
} }
}); });

View File

@@ -66,7 +66,7 @@ public enum CSubmenuQuestPrefs implements ICDoc {
validationError = val == null ? localizer.getMessage("lblEnteraDecimal") : null; validationError = val == null ? localizer.getMessage("lblEnteraDecimal") : null;
} else { } else {
final Integer val = Ints.tryParse(i0.getText()); final Integer val = Ints.tryParse(i0.getText());
validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val.intValue()); validationError = val == null ? localizer.getMessage("lblEnteraNumber") : prefs.validatePreference(i0.getQPref(), val);
} }
if (validationError != null) { if (validationError != null) {

View File

@@ -314,7 +314,7 @@ public class DialogChoosePoolDistribution {
public int getNumberOfBoosters() { public int getNumberOfBoosters() {
try { try {
return Integer.valueOf(numberOfBoostersField.getText()); return Integer.parseInt(numberOfBoostersField.getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return 0; return 0;
} }

View File

@@ -603,7 +603,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
for (final String s : codes) { for (final String s : codes) {
if (!s.isEmpty()) { if (!s.isEmpty()) {
displayText.add(KeyEvent.getKeyText(Integer.valueOf(s))); displayText.add(KeyEvent.getKeyText(Integer.parseInt(s)));
} }
} }

View File

@@ -459,12 +459,12 @@ public class VAssignCombatDamage {
} }
else if (defender instanceof CardView) { // planeswalker else if (defender instanceof CardView) { // planeswalker
final CardView pw = (CardView)defender; final CardView pw = (CardView)defender;
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty()); lethalDamage = Integer.parseInt(pw.getCurrentState().getLoyalty());
} }
} else { } else {
lethalDamage = Math.max(0, card.getLethalDamage()); lethalDamage = Math.max(0, card.getLethalDamage());
if (card.getCurrentState().isPlaneswalker()) { if (card.getCurrentState().isPlaneswalker()) {
lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty()); lethalDamage = Integer.parseInt(card.getCurrentState().getLoyalty());
} else if (attackerHasDeathtouch) { } else if (attackerHasDeathtouch) {
lethalDamage = Math.min(lethalDamage, 1); lethalDamage = Math.min(lethalDamage, 1);
} }

Some files were not shown because too many files have changed in this diff Show More