mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
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:
@@ -34,8 +34,7 @@ public class EditorMainWindow extends JFrame {
|
||||
Localizer.getInstance().initialize(FModel.getPreferences().getPref(ForgePreferences.FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
|
||||
int var2 = var1.length;
|
||||
|
||||
for(int var3 = 0; var3 < var2; ++var3) {
|
||||
UIManager.LookAndFeelInfo info = var1[var3];
|
||||
for (UIManager.LookAndFeelInfo info : var1) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(info.getClassName());
|
||||
|
||||
@@ -57,9 +57,9 @@ public class EffectEditor extends JComponent {
|
||||
|
||||
|
||||
currentData.name=name.getText();
|
||||
currentData.changeStartCards=((Integer)changeStartCards.getValue()).intValue();
|
||||
currentData.lifeModifier= ((Integer)lifeModifier.getValue()).intValue();
|
||||
currentData.moveSpeed= ((Float)moveSpeed.getValue()).floatValue();
|
||||
currentData.changeStartCards = (Integer) changeStartCards.getValue();
|
||||
currentData.lifeModifier = (Integer) lifeModifier.getValue();
|
||||
currentData.moveSpeed = (Float) moveSpeed.getValue();
|
||||
currentData.startBattleWithCard = startBattleWithCard.getList();
|
||||
currentData.colorView = colorView.isSelected();
|
||||
currentData.opponent = opponent.currentData;
|
||||
|
||||
@@ -14,6 +14,6 @@ public class FloatSpinner extends JSpinner{
|
||||
}
|
||||
public float floatValue()
|
||||
{
|
||||
return ((Float)getValue()).floatValue();
|
||||
return (Float) getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ public class IntSpinner extends JSpinner {
|
||||
}
|
||||
public int intValue()
|
||||
{
|
||||
return ((Integer)getValue()).intValue();
|
||||
return (Integer) getValue();
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class ItemEdit extends JComponent {
|
||||
currentData.description=description.getText();
|
||||
currentData.iconName=iconName.getText();
|
||||
currentData.questItem=questItem.isSelected();
|
||||
currentData.cost=((Integer) cost.getValue()).intValue();
|
||||
currentData.cost= (Integer) cost.getValue();
|
||||
}
|
||||
|
||||
public void setCurrentItem(ItemData data)
|
||||
|
||||
@@ -122,7 +122,7 @@ public class RewardEdit extends FormPanel {
|
||||
updating=true;
|
||||
typeField.setSelectedItem(currentData.type);
|
||||
|
||||
probability.setValue(new Double(currentData.probability));
|
||||
probability.setValue((double) currentData.probability);
|
||||
count.setValue(currentData.count);
|
||||
addMaxCount.setValue(currentData.addMaxCount);
|
||||
cardName.setText(currentData.cardName);
|
||||
|
||||
@@ -1173,8 +1173,8 @@ public class AiAttackController {
|
||||
while (!attritionalAttackers.isEmpty() && humanLife > 0 && attackRounds < 99) {
|
||||
// sum attacker damage
|
||||
int damageThisRound = 0;
|
||||
for (int y = 0; y < attritionalAttackers.size(); y++) {
|
||||
damageThisRound += attritionalAttackers.get(y).getNetCombatDamage();
|
||||
for (Card attritionalAttacker : attritionalAttackers) {
|
||||
damageThisRound += attritionalAttacker.getNetCombatDamage();
|
||||
}
|
||||
// remove from player life
|
||||
humanLife -= damageThisRound;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package forge.ai;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import forge.game.card.Card;
|
||||
@@ -164,10 +163,7 @@ public class AiCardMemory {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
Iterator<Card> it = memorySet.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName)) {
|
||||
return true;
|
||||
}
|
||||
@@ -191,10 +187,7 @@ public class AiCardMemory {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
Iterator<Card> it = memorySet.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
|
||||
return true;
|
||||
}
|
||||
@@ -259,10 +252,7 @@ public class AiCardMemory {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
Iterator<Card> it = memorySet.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName)) {
|
||||
return forgetCard(c, set);
|
||||
}
|
||||
@@ -284,10 +274,7 @@ public class AiCardMemory {
|
||||
Set<Card> memorySet = getMemorySet(set);
|
||||
|
||||
if (memorySet != null) {
|
||||
Iterator<Card> it = memorySet.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Card c = it.next();
|
||||
for (Card c : memorySet) {
|
||||
if (c.getName().equals(cardName) && c.getOwner().equals(owner)) {
|
||||
return forgetCard(c, set);
|
||||
}
|
||||
|
||||
@@ -1996,7 +1996,7 @@ public class AiController {
|
||||
break;
|
||||
case FlipOntoBattlefield:
|
||||
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>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
@@ -2112,9 +2112,9 @@ public class AiController {
|
||||
}
|
||||
|
||||
// add the rest of land to the end of the deck
|
||||
for (int i = 0; i < land.size(); i++) {
|
||||
if (!library.contains(land.get(i))) {
|
||||
library.add(land.get(i));
|
||||
for (Card card : land) {
|
||||
if (!library.contains(card)) {
|
||||
library.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,9 +147,9 @@ public class AiProfileUtil {
|
||||
if (children == null) {
|
||||
System.err.println("AIProfile > can't find AI profile directory!");
|
||||
} else {
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
if (children[i].endsWith(AI_PROFILE_EXT)) {
|
||||
availableProfiles.add(children[i].substring(0, children[i].length() - AI_PROFILE_EXT.length()));
|
||||
for (String child : children) {
|
||||
if (child.endsWith(AI_PROFILE_EXT)) {
|
||||
availableProfiles.add(child.substring(0, child.length() - AI_PROFILE_EXT.length()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -983,11 +983,11 @@ public class ComputerUtilCard {
|
||||
|
||||
for (final Card crd : list) {
|
||||
ColorSet color = crd.getColor();
|
||||
if (color.hasWhite()) map.get(0).setValue(Integer.valueOf(map.get(0).getValue() + 1));
|
||||
if (color.hasBlue()) map.get(1).setValue(Integer.valueOf(map.get(1).getValue() + 1));
|
||||
if (color.hasBlack()) map.get(2).setValue(Integer.valueOf(map.get(2).getValue() + 1));
|
||||
if (color.hasRed()) map.get(3).setValue(Integer.valueOf(map.get(3).getValue() + 1));
|
||||
if (color.hasGreen()) map.get(4).setValue(Integer.valueOf(map.get(4).getValue() + 1));
|
||||
if (color.hasWhite()) map.get(0).setValue(map.get(0).getValue() + 1);
|
||||
if (color.hasBlue()) map.get(1).setValue(map.get(1).getValue() + 1);
|
||||
if (color.hasBlack()) map.get(2).setValue(map.get(2).getValue() + 1);
|
||||
if (color.hasRed()) map.get(3).setValue(map.get(3).getValue() + 1);
|
||||
if (color.hasGreen()) map.get(4).setValue(map.get(4).getValue() + 1);
|
||||
}
|
||||
|
||||
Collections.sort(map, new Comparator<Pair<Byte, Integer>>() {
|
||||
|
||||
@@ -710,7 +710,7 @@ public class ComputerUtilCost {
|
||||
} else if ("LowPriority".equals(aiLogic) && MyRandom.getRandom().nextInt(100) < 67) {
|
||||
return false;
|
||||
} 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 (source.hasSVar("EndOfTurnLeavePlay") || ComputerUtilCard.isUselessCreature(payer, source)) {
|
||||
|
||||
@@ -222,8 +222,7 @@ public class ComputerUtilMana {
|
||||
for (int i = 0; i < preferredShardAmount && i < prefSortedAbilities.size(); i++) {
|
||||
finalAbilities.add(prefSortedAbilities.get(i));
|
||||
}
|
||||
for (int i = 0; i < otherSortedAbilities.size(); i++) {
|
||||
SpellAbility ab = otherSortedAbilities.get(i);
|
||||
for (SpellAbility ab : otherSortedAbilities) {
|
||||
if (!finalAbilities.contains(ab))
|
||||
finalAbilities.add(ab);
|
||||
}
|
||||
@@ -491,7 +490,7 @@ public class ComputerUtilMana {
|
||||
if (!replaceAmount.isEmpty()) {
|
||||
int totalAmount = 1;
|
||||
for (SpellAbility saMana : replaceAmount) {
|
||||
totalAmount *= Integer.valueOf(saMana.getParam("ReplaceAmount"));
|
||||
totalAmount *= Integer.parseInt(saMana.getParam("ReplaceAmount"));
|
||||
}
|
||||
manaProduced = StringUtils.repeat(manaProduced, " ", totalAmount);
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return defaultVal != null && defaultVal.booleanValue();
|
||||
return defaultVal != null && defaultVal;
|
||||
case UntapTimeVault: return false; // TODO Should AI skip his turn for time vault?
|
||||
case LeftOrRight: return brains.chooseDirection(sa);
|
||||
case OddsOrEvens: return brains.chooseEvenOdd(sa); // false is Odd, true is Even
|
||||
|
||||
@@ -18,7 +18,7 @@ public class AlterAttributeAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean checkApiLogic(Player aiPlayer, SpellAbility sa) {
|
||||
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(",");
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
@@ -91,7 +91,7 @@ public class AlterAttributeAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
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(",");
|
||||
|
||||
for (String attr : attributes) {
|
||||
|
||||
@@ -410,9 +410,7 @@ public class AttachAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
final Iterable<Card> auras = c.getEnchantedBy();
|
||||
final Iterator<Card> itr = auras.iterator();
|
||||
while (itr.hasNext()) {
|
||||
final Card aura = itr.next();
|
||||
for (Card aura : auras) {
|
||||
SpellAbility auraSA = aura.getSpells().get(0);
|
||||
if (auraSA.getApi() == ApiType.Attach) {
|
||||
if ("KeepTapped".equals(auraSA.getParam("AILogic"))) {
|
||||
|
||||
@@ -1390,7 +1390,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
aiPlaneswalkers.sort(CardPredicates.compareByCounterType(CounterEnumType.LOYALTY));
|
||||
for (Card pw : aiPlaneswalkers) {
|
||||
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) {
|
||||
return pw;
|
||||
}
|
||||
@@ -1748,7 +1748,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
}
|
||||
if (MyRandom.percentTrue(chance)) {
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ public class EffectAi extends SpellAbilityAi {
|
||||
}
|
||||
if (logic.contains(":")) {
|
||||
String[] k = logic.split(":");
|
||||
Integer i = Integer.valueOf(k[1]);
|
||||
int i = Integer.parseInt(k[1]);
|
||||
return ai.getCreaturesInPlay().size() >= i;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FlipOntoBattlefieldAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
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>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
|
||||
@@ -169,7 +169,7 @@ public class ManaAi extends SpellAbilityAi {
|
||||
numCounters = host.getCounters(ctrType);
|
||||
manaReceived = numCounters;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
String logic = sa.getParam("AILogic");
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -421,24 +421,11 @@ public class CardStorageReader {
|
||||
* @return a new Card instance
|
||||
*/
|
||||
protected final CardRules loadCard(final CardRules.Reader rulesReader, final ZipEntry entry) {
|
||||
InputStream zipInputStream = null;
|
||||
try {
|
||||
zipInputStream = this.zip.getInputStream(entry);
|
||||
try (InputStream zipInputStream = this.zip.getInputStream(entry)) {
|
||||
rulesReader.reset();
|
||||
|
||||
return rulesReader.readCard(readScript(zipInputStream), Files.getNameWithoutExtension(entry.getName()));
|
||||
} catch (final IOException exn) {
|
||||
throw new RuntimeException(exn);
|
||||
// PM
|
||||
} finally {
|
||||
try {
|
||||
if (zipInputStream != null) {
|
||||
zipInputStream.close();
|
||||
}
|
||||
} catch (final IOException ignored) {
|
||||
// 11:08
|
||||
// PM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,13 +78,13 @@ public class CardAiHints {
|
||||
*/
|
||||
public Integer getAiStatusComparable() {
|
||||
if (this.isRemovedFromAIDecks && this.isRemovedFromRandomDecks) {
|
||||
return Integer.valueOf(3);
|
||||
return 3;
|
||||
} else if (this.isRemovedFromAIDecks) {
|
||||
return Integer.valueOf(4);
|
||||
return 4;
|
||||
} else if (this.isRemovedFromRandomDecks) {
|
||||
return Integer.valueOf(2);
|
||||
return 2;
|
||||
} else {
|
||||
return Integer.valueOf(1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
||||
if (this.hasNoCost) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -468,9 +468,7 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
*/
|
||||
public CardPool getFilteredPool(Predicate<PaperCard> predicate) {
|
||||
CardPool filteredPool = new CardPool();
|
||||
Iterator<PaperCard> cardsInPool = this.items.keySet().iterator();
|
||||
while (cardsInPool.hasNext()) {
|
||||
PaperCard c = cardsInPool.next();
|
||||
for (PaperCard c : this.items.keySet()) {
|
||||
if (predicate.apply(c))
|
||||
filteredPool.add(c, this.items.get(c));
|
||||
}
|
||||
|
||||
@@ -100,8 +100,7 @@ public class DeckGroup extends DeckBase {
|
||||
DeckGroup myClone = (DeckGroup) clone;
|
||||
myClone.setHumanDeck((Deck) humanDeck.copyTo(getName())); //human deck name should always match DeckGroup name
|
||||
|
||||
for (int i = 0; i < aiDecks.size(); i++) {
|
||||
Deck src = aiDecks.get(i);
|
||||
for (Deck src : aiDecks) {
|
||||
myClone.addAiDeck((Deck) src.copyTo(src.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,9 +267,9 @@ public abstract class DeckGeneratorBase {
|
||||
|
||||
for (ImmutablePair<FilterCMC, Integer> pair : cmcLevels) {
|
||||
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));
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
@@ -213,9 +213,9 @@ public class Aggregates {
|
||||
U k = fnGetField.apply(kv.getKey());
|
||||
Integer v = kv.getValue();
|
||||
Integer sum = result.get(k);
|
||||
int n = v == null ? 0 : v.intValue();
|
||||
int s = sum == null ? 0 : sum.intValue();
|
||||
result.put(k, Integer.valueOf(s + n));
|
||||
int n = v == null ? 0 : v;
|
||||
int s = sum == null ? 0 : sum;
|
||||
result.put(k, s + n);
|
||||
}
|
||||
return result.entrySet();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
package forge.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
@@ -63,7 +64,7 @@ public final class Base64Coder {
|
||||
* Constant.
|
||||
* <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.
|
||||
/** Constant <code>map1=new char[64]</code>. */
|
||||
@@ -89,9 +90,7 @@ public final class Base64Coder {
|
||||
private static byte[] map2 = new byte[128];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < Base64Coder.map2.length; i++) {
|
||||
Base64Coder.map2[i] = -1;
|
||||
}
|
||||
Arrays.fill(Base64Coder.map2, (byte) -1);
|
||||
for (int i = 0; i < 64; i++) {
|
||||
Base64Coder.map2[Base64Coder.map1[i]] = (byte) i;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ItemPool<T extends InventoryItem> implements Iterable<Entry<T, Inte
|
||||
if (from != null) {
|
||||
for (final Tin srcKey : from) {
|
||||
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;
|
||||
}
|
||||
final Integer boxed = items.get(item);
|
||||
return boxed == null ? 0 : boxed.intValue();
|
||||
return boxed == null ? 0 : boxed;
|
||||
}
|
||||
|
||||
public final int countAll() {
|
||||
|
||||
@@ -355,9 +355,7 @@ public class TextUtil {
|
||||
* @return The sort-friendly name of the card. Example: "The Hive" becomes "Hive The".
|
||||
*/
|
||||
public static String moveArticleToEnd(String str) {
|
||||
String articleWord;
|
||||
for (int i = 0; i < ARTICLE_WORDS.length; i++) {
|
||||
articleWord = ARTICLE_WORDS[i];
|
||||
for (String articleWord : ARTICLE_WORDS) {
|
||||
if (str.startsWith(articleWord + " ")) {
|
||||
str = str.substring(articleWord.length() + 1) + " " + articleWord;
|
||||
return str;
|
||||
|
||||
@@ -32,8 +32,8 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
|
||||
public void add(T item, int amount) {
|
||||
if (amount <= 0) { return; } // throw an exception maybe?
|
||||
Integer cur = get(item);
|
||||
int newVal = cur == null ? amount : amount + cur.intValue();
|
||||
put(item, Integer.valueOf(newVal));
|
||||
int newVal = cur == null ? amount : amount + cur;
|
||||
put(item, newVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,9 +52,9 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
|
||||
public boolean substract(T item, int amount) {
|
||||
Integer cur = get(item);
|
||||
if (cur == null) { return false; }
|
||||
int newVal = cur.intValue() - amount;
|
||||
int newVal = cur - amount;
|
||||
if (newVal > 0) {
|
||||
put(item, Integer.valueOf(newVal));
|
||||
put(item, newVal);
|
||||
}
|
||||
else {
|
||||
remove(item);
|
||||
@@ -73,7 +73,7 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
|
||||
public int countAll() {
|
||||
int c = 0;
|
||||
for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) {
|
||||
c += kv.getValue().intValue();
|
||||
c += kv.getValue();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -81,6 +81,6 @@ public class EnumMapToAmount<T extends Enum<T>> extends EnumMap<T, Integer> impl
|
||||
@Override
|
||||
public int count(T item) {
|
||||
Integer cur = get(item);
|
||||
return cur == null ? 0 : cur.intValue();
|
||||
return cur == null ? 0 : cur;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
public void add(final T item, final int amount) {
|
||||
if (amount <= 0) { return; } // throw an exception maybe?
|
||||
Integer cur = get(item);
|
||||
int newVal = cur == null ? amount : amount + cur.intValue();
|
||||
put(item, Integer.valueOf(newVal));
|
||||
int newVal = cur == null ? amount : amount + cur;
|
||||
put(item, newVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,9 +75,9 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
public boolean substract(final T item, final int amount) {
|
||||
Integer cur = get(item);
|
||||
if (cur == null) { return false; }
|
||||
int newVal = cur.intValue() - amount;
|
||||
int newVal = cur - amount;
|
||||
if (newVal > 0) {
|
||||
put(item, Integer.valueOf(newVal));
|
||||
put(item, newVal);
|
||||
} else {
|
||||
remove(item);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
public int countAll() {
|
||||
int c = 0;
|
||||
for (java.util.Map.Entry<T, Integer> kv : this.entrySet()) {
|
||||
c += kv.getValue().intValue();
|
||||
c += kv.getValue();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class LinkedHashMapToAmount<T> extends LinkedHashMap<T, Integer> implemen
|
||||
@Override
|
||||
public int count(final T item) {
|
||||
Integer cur = get(item);
|
||||
return cur == null ? 0 : cur.intValue();
|
||||
return cur == null ? 0 : cur;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ public final class MapToAmountUtil {
|
||||
int max = Integer.MIN_VALUE;
|
||||
T maxElement = null;
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() > max) {
|
||||
max = entry.getValue().intValue();
|
||||
if (entry.getValue() > max) {
|
||||
max = entry.getValue();
|
||||
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 FCollection<T> set = new FCollection<>();
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() == max) {
|
||||
if (entry.getValue() == max) {
|
||||
set.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
@@ -93,12 +93,12 @@ public final class MapToAmountUtil {
|
||||
int min = Integer.MAX_VALUE;
|
||||
T minElement = null;
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() < min) {
|
||||
min = entry.getValue().intValue();
|
||||
if (entry.getValue() < min) {
|
||||
min = entry.getValue();
|
||||
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 FCollection<T> set = new FCollection<>();
|
||||
for (final Entry<T, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue().intValue() == min) {
|
||||
if (entry.getValue() == min) {
|
||||
set.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ public class Game {
|
||||
|
||||
|
||||
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
|
||||
@@ -1320,7 +1320,7 @@ public class Game {
|
||||
}
|
||||
}
|
||||
public void addFacedownWhileCasting(Card c, int numDrawn) {
|
||||
facedownWhileCasting.put(c, Integer.valueOf(numDrawn));
|
||||
facedownWhileCasting.put(c, numDrawn);
|
||||
}
|
||||
|
||||
public boolean isDay() {
|
||||
|
||||
@@ -2065,7 +2065,7 @@ public class GameAction {
|
||||
if (landCount == 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) {
|
||||
@@ -2514,7 +2514,7 @@ public class GameAction {
|
||||
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();
|
||||
|
||||
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) {
|
||||
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.removeChangedCardTypes(unanimateTimestamp, 0);
|
||||
c.removeChangedName(unanimateTimestamp, 0);
|
||||
|
||||
@@ -211,8 +211,8 @@ public final class GameActionUtil {
|
||||
&& source.isForetold() && !source.enteredThisTurn() && !source.getManaCost().isNoCost()) {
|
||||
// Its foretell cost is equal to its mana cost reduced by {2}.
|
||||
final SpellAbility foretold = sa.copy(activator);
|
||||
Integer reduced = Math.min(2, sa.getPayCosts().getCostMana().getMana().getGenericCost());
|
||||
foretold.putParam("ReduceCost", reduced.toString());
|
||||
int reduced = Math.min(2, sa.getPayCosts().getCostMana().getMana().getGenericCost());
|
||||
foretold.putParam("ReduceCost", Integer.toString(reduced));
|
||||
foretold.setAlternativeCost(AlternativeCost.Foretold);
|
||||
foretold.getRestrictions().setZone(ZoneType.Exile);
|
||||
foretold.putParam("AfterDescription", "(Foretold)");
|
||||
@@ -887,7 +887,7 @@ public final class GameActionUtil {
|
||||
// skip GameAction
|
||||
oldCard.getZone().remove(oldCard);
|
||||
// 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);
|
||||
ability.setHostCard(oldCard);
|
||||
ability.setXManaCostPaid(null);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GameEntityCounterTable extends ForwardingTable<Optional<Player>, Ga
|
||||
}
|
||||
Map<CounterType, Integer> alreadyRemoved = column(ge).get(Optional.absent());
|
||||
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) {
|
||||
result.put(e.getKey(), rest);
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
} catch (Exception e) {
|
||||
formatsubType = FormatSubType.CUSTOM;
|
||||
}
|
||||
Integer idx = section.getInt("order");
|
||||
int idx = section.getInt("order");
|
||||
String dateStr = section.get("effective");
|
||||
if (dateStr == null){
|
||||
dateStr = DEFAULTDATE;
|
||||
|
||||
@@ -7,7 +7,7 @@ public interface IIdentifiable {
|
||||
Function<IIdentifiable, Integer> FN_GET_ID = new Function<IIdentifiable, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final IIdentifiable input) {
|
||||
return Integer.valueOf(input.getId());
|
||||
return input.getId();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public class AbilityUtils {
|
||||
} else if (defined.startsWith("CardUID_")) {
|
||||
String idString = defined.substring(8);
|
||||
for (final Card cardByID : game.getCardsInGame()) {
|
||||
if (cardByID.getId() == Integer.valueOf(idString)) {
|
||||
if (cardByID.getId() == Integer.parseInt(idString)) {
|
||||
cards.add(game.getCardState(cardByID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import forge.util.TextUtil;
|
||||
public class AlterAttributeEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
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(",");
|
||||
CardCollection defined = getDefinedCardsOrTargeted(sa, "Defined");
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class CamouflageEffect extends SpellAbilityEffect {
|
||||
// Remove chosen creatures, unless it can block additional attackers
|
||||
for (final Card blocker : blockers) {
|
||||
int index = pool.indexOf(blocker);
|
||||
Integer blockedCount = blockedSoFar.get(index) + 1;
|
||||
int blockedCount = blockedSoFar.get(index) + 1;
|
||||
if (!blocker.canBlockAny() && blocker.canBlockAdditional() < blockedCount) {
|
||||
pool.remove(index);
|
||||
blockedSoFar.remove(index);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
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 String changedColorWordOriginal, changedColorWordNew;
|
||||
|
||||
@@ -142,7 +142,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
|
||||
game.getTriggerHandler().clearActiveTriggers(tgtCard, null);
|
||||
|
||||
final Long ts = game.getNextTimestamp();
|
||||
final long ts = game.getNextTimestamp();
|
||||
tgtCard.addCloneState(CardFactory.getCloneStates(cardToCopy, tgtCard, sa), ts);
|
||||
|
||||
// set ETB tapped of clone
|
||||
|
||||
@@ -228,7 +228,7 @@ public class CopyPermanentEffect extends TokenEffectBase {
|
||||
}
|
||||
} else if (chosenMap) {
|
||||
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;
|
||||
tgtCards.add(host.getChosenMap().get(controller).get(index));
|
||||
} else tgtCards = host.getChosenMap().get(controller);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CounterEffect extends SpellAbilityEffect {
|
||||
// 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)
|
||||
if (sa.hasParam("RememberCounteredCMC")) {
|
||||
sa.getHostCard().addRemembered(Integer.valueOf(tgtSACard.getCMC()));
|
||||
sa.getHostCard().addRemembered(tgtSACard.getCMC());
|
||||
}
|
||||
if (sa.hasParam("RememberForCounter")) {
|
||||
sa.getHostCard().addRemembered(tgtSACard);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CountersMultiplyEffect extends SpellAbilityEffect {
|
||||
final Player player = sa.getActivatingPlayer();
|
||||
|
||||
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();
|
||||
for (final Card tgtCard : getTargetCards(sa)) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
if (sa.hasParam("AmountByChosenMap")) {
|
||||
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;
|
||||
final Card chosen = host.getChosenMap().get(placer).get(index);
|
||||
counterAmount = AbilityUtils.xCount(chosen, parse[0], sa);
|
||||
|
||||
@@ -634,7 +634,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
int totalAdded = table.totalValues();
|
||||
if (totalAdded > 0 && rememberAmount) {
|
||||
// TODO use SpellAbility Remember later
|
||||
card.addRemembered(Integer.valueOf(totalAdded));
|
||||
card.addRemembered(totalAdded);
|
||||
}
|
||||
|
||||
if (sa.hasParam("RemovePhase")) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CountersRemoveAllEffect extends SpellAbilityEffect {
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("RememberAmount")) {
|
||||
sa.getHostCard().addRemembered(Integer.valueOf(numberRemoved));
|
||||
sa.getHostCard().addRemembered(numberRemoved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
|
||||
if (totalRemoved > 0 && rememberAmount) {
|
||||
// TODO use SpellAbility Remember later
|
||||
card.addRemembered(Integer.valueOf(totalRemoved));
|
||||
card.addRemembered(totalRemoved);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,8 +172,7 @@ public class DigMultipleEffect extends SpellAbilityEffect {
|
||||
}
|
||||
} else {
|
||||
// just move them randomly
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
Card c = rest.get(i);
|
||||
for (Card c : rest) {
|
||||
final ZoneType origin = c.getZone().getZoneType();
|
||||
final PlayerZone toZone = c.getOwner().getZone(destZone2);
|
||||
c = game.getAction().moveTo(toZone, c, sa);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DrainManaEffect extends SpellAbilityEffect {
|
||||
sa.getActivatingPlayer().getManaPool().add(drained);
|
||||
}
|
||||
if (sa.hasParam("RememberDrainedMana")) {
|
||||
sa.getHostCard().addRemembered(Integer.valueOf(drained.size()));
|
||||
sa.getHostCard().addRemembered(drained.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class MutateEffect extends SpellAbilityEffect {
|
||||
// First remove current mutated states
|
||||
target.removeMutatedStates();
|
||||
// Now add all abilities from bottom cards
|
||||
final Long ts = game.getNextTimestamp();
|
||||
final long ts = game.getNextTimestamp();
|
||||
target.setMutatedTimestamp(ts);
|
||||
|
||||
target.addCloneState(CardFactory.getMutatedCloneStates(target, sa), ts);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
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 List<String> choices = ProtectEffect.getProtectionList(sa);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class RepeatEffect extends SpellAbilityEffect {
|
||||
Integer maxRepeat = null;
|
||||
if (sa.hasParam("MaxRepeat")) {
|
||||
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
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ReplaceManaEffect extends SpellAbilityEffect {
|
||||
}
|
||||
} else if (sa.hasParam("ReplaceAmount")) {
|
||||
// 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);
|
||||
// effect was updated
|
||||
|
||||
@@ -307,9 +307,9 @@ public class RollDiceEffect extends SpellAbilityEffect {
|
||||
}
|
||||
if (rememberHighest) {
|
||||
int highest = 0;
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
if (highest < results.get(i)) {
|
||||
highest = results.get(i);
|
||||
for (Integer result : results) {
|
||||
if (highest < result) {
|
||||
highest = result;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < results.size(); ++i) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StoreSVarEffect extends SpellAbilityEffect {
|
||||
value = AbilityUtils.xCount(source, expr, sa);
|
||||
}
|
||||
else if (type.equals("Number")) {
|
||||
value = Integer.valueOf(expr);
|
||||
value = Integer.parseInt(expr);
|
||||
}
|
||||
else if (type.equals("CountSVar")) {
|
||||
if (expr.contains("/")) {
|
||||
|
||||
@@ -7370,7 +7370,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
incrementTransformedTimestamp();
|
||||
}
|
||||
if (sa.hasParam("Prototype") && prototypeTimestamp == -1) {
|
||||
Long next = game.getNextTimestamp();
|
||||
long next = game.getNextTimestamp();
|
||||
addCloneState(CardFactory.getCloneStates(this, this, sa), next);
|
||||
prototypeTimestamp = next;
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ public final class CardChangedWords extends ForwardingMap<String, String> {
|
||||
}
|
||||
|
||||
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
|
||||
isDirty = true;
|
||||
return stamp;
|
||||
}
|
||||
|
||||
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));
|
||||
isDirty = true;
|
||||
return stamp;
|
||||
|
||||
@@ -271,9 +271,7 @@ public class CardFactoryUtil {
|
||||
public static byte getMostProminentColors(final Iterable<Card> list) {
|
||||
int cntColors = MagicColor.WUBRG.length;
|
||||
final Integer[] map = new Integer[cntColors];
|
||||
for (int i = 0; i < cntColors; i++) {
|
||||
map[i] = 0;
|
||||
}
|
||||
Arrays.fill(map, 0);
|
||||
|
||||
for (final Card crd : list) {
|
||||
ColorSet color = crd.getColor();
|
||||
@@ -309,9 +307,6 @@ public class CardFactoryUtil {
|
||||
public static int[] SortColorsFromList(final CardCollection list) {
|
||||
int cntColors = MagicColor.WUBRG.length;
|
||||
final int[] map = new int[cntColors];
|
||||
for (int i = 0; i < cntColors; i++) {
|
||||
map[i] = 0;
|
||||
}
|
||||
|
||||
for (final Card crd : list) {
|
||||
ColorSet color = crd.getColor();
|
||||
@@ -339,10 +334,7 @@ public class CardFactoryUtil {
|
||||
colorRestrictions.add(MagicColor.fromName(col));
|
||||
}
|
||||
int cntColors = colorRestrictions.size();
|
||||
final Integer[] map = new Integer[cntColors];
|
||||
for (int i = 0; i < cntColors; i++) {
|
||||
map[i] = 0;
|
||||
}
|
||||
final int[] map = new int[cntColors];
|
||||
|
||||
for (final Card crd : list) {
|
||||
ColorSet color = crd.getColor();
|
||||
@@ -927,7 +919,7 @@ public class CardFactoryUtil {
|
||||
} else if (keyword.startsWith("Chapter")) {
|
||||
final String[] k = keyword.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");
|
||||
}
|
||||
|
||||
@@ -2789,7 +2781,7 @@ public class CardFactoryUtil {
|
||||
origSA.appendSubAbility(newSA);
|
||||
} else if (keyword.startsWith("Class")) {
|
||||
final String[] k = keyword.split(":");
|
||||
final int level = Integer.valueOf(k[1]);
|
||||
final int level = Integer.parseInt(k[1]);
|
||||
|
||||
final StringBuilder sbClass = new StringBuilder();
|
||||
sbClass.append("AB$ ClassLevelUp | Cost$ ").append(k[2]);
|
||||
|
||||
@@ -1081,7 +1081,7 @@ public class CardView extends GameEntityView {
|
||||
if (hiddenId == null) {
|
||||
return getId();
|
||||
}
|
||||
return hiddenId.intValue();
|
||||
return hiddenId;
|
||||
}
|
||||
void updateHiddenId(final int hiddenId) {
|
||||
set(TrackableProperty.HiddenId, hiddenId);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AttackConstraints {
|
||||
final MapToAmount<Card> causesToAttack = new LinkedHashMapToAmount<>();
|
||||
for (final Entry<Card, Integer> entry : attacksIfOtherAttacks.entrySet()) {
|
||||
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 myMax = Ints.min(globalMax == -1 ? Integer.MAX_VALUE : globalMax, possibleAttackers.size());
|
||||
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<>();
|
||||
@@ -224,7 +224,7 @@ public class AttackConstraints {
|
||||
}
|
||||
}
|
||||
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
|
||||
skip = true;
|
||||
} 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);
|
||||
for (final Entry<Card, Integer> causesToAttack : requirement.getCausesToAttack().entrySet()) {
|
||||
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
|
||||
@@ -449,7 +449,7 @@ public class AttackConstraints {
|
||||
private final Function<Map<Card, GameEntity>, Integer> FN_COUNT_VIOLATIONS = new Function<Map<Card,GameEntity>, Integer>() {
|
||||
@Override
|
||||
public Integer apply(final Map<Card, GameEntity> input) {
|
||||
return Integer.valueOf(countViolations(input));
|
||||
return countViolations(input);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class AttackRequirement {
|
||||
|
||||
for (final GameEntity defender : possibleDefenders) {
|
||||
// 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
|
||||
@@ -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
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class AttackingBand {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked.booleanValue() ? ">||" : ">>>" );
|
||||
return String.format("%s %s", attackers.toString(), blocked == null ? " ? " : blocked ? ">||" : ">>>" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CombatUtil {
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
return myViolations <= bestAttack.getRight().intValue();
|
||||
return myViolations <= bestAttack.getRight();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GlobalAttackRestrictions {
|
||||
if (max == null) {
|
||||
continue;
|
||||
}
|
||||
if (returnQuickly && max.intValue() == 0) {
|
||||
if (returnQuickly && max == 0) {
|
||||
// there's at least one creature attacking this defender
|
||||
defenderTooMany.put(defender, 1);
|
||||
break;
|
||||
@@ -59,13 +59,13 @@ public class GlobalAttackRestrictions {
|
||||
for (final Entry<Card, GameEntity> attDef : attackers.entrySet()) {
|
||||
if (attDef.getValue() == defender) {
|
||||
count++;
|
||||
if (returnQuickly && count > max.intValue()) {
|
||||
defenderTooMany.put(defender, count - max.intValue());
|
||||
if (returnQuickly && count > max) {
|
||||
defenderTooMany.put(defender, count - max);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
final int nDefTooMany = count - max.intValue();
|
||||
final int nDefTooMany = count - max;
|
||||
if (nDefTooMany > 0) {
|
||||
// Too many attackers to one defender!
|
||||
defenderTooMany.put(defender, nDefTooMany);
|
||||
|
||||
@@ -860,7 +860,7 @@ public class Cost implements Serializable {
|
||||
return Cost.convertAmountTypeToWords(amount, type);
|
||||
}
|
||||
|
||||
return Cost.convertIntAndTypeToWords(i.intValue(), type);
|
||||
return Cost.convertIntAndTypeToWords(i, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -473,7 +473,7 @@ public class CostAdjustment {
|
||||
if (!staticAbility.hasParam("Cost") && !staticAbility.hasParam("Color")) {
|
||||
int minMana = 0;
|
||||
if (staticAbility.hasParam("MinMana")) {
|
||||
minMana = Integer.valueOf(staticAbility.getParam("MinMana"));
|
||||
minMana = Integer.parseInt(staticAbility.getParam("MinMana"));
|
||||
}
|
||||
|
||||
final int maxReduction = manaCost.getConvertedManaCost() - minMana - sumReduced;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CostGainLife extends CostPart {
|
||||
|
||||
@Override
|
||||
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;
|
||||
for (final Player opp : decision.players) {
|
||||
|
||||
@@ -2,6 +2,8 @@ package forge.game.mana;
|
||||
|
||||
import forge.card.mana.ManaAtom;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ManaConversionMatrix {
|
||||
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() {
|
||||
// By default each color can only be paid by itself ( {G} -> {G}, {C} -> {C}
|
||||
for (int i = 0; i < colorConversionMatrix.length; i++) {
|
||||
colorConversionMatrix[i] = identityMatrix[i];
|
||||
}
|
||||
System.arraycopy(identityMatrix, 0, colorConversionMatrix, 0, colorConversionMatrix.length);
|
||||
// By default all mana types are unrestricted
|
||||
for (int i = 0; i < colorRestrictionMatrix.length; i++) {
|
||||
colorRestrictionMatrix[i] = ManaAtom.ALL_MANA_TYPES;
|
||||
}
|
||||
Arrays.fill(colorRestrictionMatrix, ManaAtom.ALL_MANA_TYPES);
|
||||
snowForColor = false;
|
||||
}
|
||||
}
|
||||
@@ -36,24 +36,24 @@ public class MulliganService {
|
||||
|
||||
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();
|
||||
switch (rule) {
|
||||
case Original:
|
||||
mulligans.add(new OriginalMulligan(whoCanMulligan.get(i), firstMullFree));
|
||||
mulligans.add(new OriginalMulligan(player, firstMullFree));
|
||||
break;
|
||||
case Paris:
|
||||
mulligans.add(new ParisMulligan(whoCanMulligan.get(i), firstMullFree));
|
||||
mulligans.add(new ParisMulligan(player, firstMullFree));
|
||||
break;
|
||||
case Vancouver:
|
||||
mulligans.add(new VancouverMulligan(whoCanMulligan.get(i), firstMullFree));
|
||||
mulligans.add(new VancouverMulligan(player, firstMullFree));
|
||||
break;
|
||||
case London:
|
||||
mulligans.add(new LondonMulligan(whoCanMulligan.get(i), firstMullFree));
|
||||
mulligans.add(new LondonMulligan(player, firstMullFree));
|
||||
break;
|
||||
default:
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class Untap extends Phase {
|
||||
if (chosen != null) {
|
||||
for (Entry<String, Integer> rest : restrictUntap.entrySet()) {
|
||||
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);
|
||||
|
||||
@@ -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) {
|
||||
Integer old = getCounters(counterType);
|
||||
int old = getCounters(counterType);
|
||||
setCounters(counterType, num);
|
||||
view.updateCounters(this);
|
||||
if (fireEvents) {
|
||||
@@ -2222,8 +2222,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
if (incR.length > 1) {
|
||||
final String excR = incR[1];
|
||||
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
|
||||
for (int j = 0; j < exR.length; j++) {
|
||||
if (!hasProperty(exR[j], sourceController, source, spellAbility)) {
|
||||
for (String s : exR) {
|
||||
if (!hasProperty(s, sourceController, source, spellAbility)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2805,7 +2805,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
public int getCommanderDamage(Card commander) {
|
||||
Integer damage = commanderDamage.get(commander);
|
||||
return damage == null ? 0 : damage.intValue();
|
||||
return damage == null ? 0 : damage;
|
||||
}
|
||||
public void addCommanderDamage(Card commander, int damage) {
|
||||
commanderDamage.merge(commander, damage, Integer::sum);
|
||||
@@ -2902,7 +2902,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
try {
|
||||
if (keyword.startsWith("etbCounter")) {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
@@ -3054,7 +3054,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
int generic = manaCost.getGenericCost();
|
||||
if (generic > 0 || manaCost.getCMC() == 0) {
|
||||
if (!genericManaSymbols.add(Integer.valueOf(generic))) {
|
||||
if (!genericManaSymbols.add(generic)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3544,11 +3544,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
public String trimKeywords(String keywordTexts) {
|
||||
if (keywordTexts.contains("Protection:")) {
|
||||
List <String> lines = Arrays.asList(keywordTexts.split("\n"));
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (lines.get(i).startsWith("Protection:")) {
|
||||
List<String> parts = Arrays.asList(lines.get(i).split(":"));
|
||||
for (String line : lines) {
|
||||
if (line.startsWith("Protection:")) {
|
||||
List<String> parts = Arrays.asList(line.split(":"));
|
||||
if (parts.size() > 2) {
|
||||
keywordTexts = TextUtil.fastReplace(keywordTexts, lines.get(i), parts.get(2));
|
||||
keywordTexts = TextUtil.fastReplace(keywordTexts, line, parts.get(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ public class PlayerView extends GameEntityView {
|
||||
Map<Integer, Integer> map = get(TrackableProperty.CommanderDamage);
|
||||
if (map == null) { return 0; }
|
||||
Integer damage = map.get(commander.getId());
|
||||
return damage == null ? 0 : damage.intValue();
|
||||
return damage == null ? 0 : damage;
|
||||
}
|
||||
void updateCommanderDamage(Player p) {
|
||||
Map<Integer, Integer> map = Maps.newHashMap();
|
||||
@@ -388,7 +388,7 @@ public class PlayerView extends GameEntityView {
|
||||
Map<Integer, Integer> map = get(TrackableProperty.CommanderCast);
|
||||
if (map == null) { return 0; }
|
||||
Integer damage = map.get(commander.getId());
|
||||
return damage == null ? 0 : damage.intValue();
|
||||
return damage == null ? 0 : damage;
|
||||
}
|
||||
|
||||
void updateCommanderCast(Player p, Card c) {
|
||||
@@ -569,7 +569,7 @@ public class PlayerView extends GameEntityView {
|
||||
e.printStackTrace();
|
||||
count = null;
|
||||
}
|
||||
return count != null ? count.intValue() : 0;
|
||||
return count != null ? count : 0;
|
||||
}
|
||||
private Map<Byte, Integer> getMana() {
|
||||
return get(TrackableProperty.Mana);
|
||||
|
||||
@@ -81,16 +81,8 @@ public enum ReplacementType {
|
||||
ReplacementEffect res = c.newInstance(mapParams, host, intrinsic);
|
||||
res.setMode(this);
|
||||
return res;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
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) {
|
||||
} catch (IllegalArgumentException | InstantiationException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
||||
if (!source.isLKI()) {
|
||||
source = CardCopyService.getLKICopy(source);
|
||||
}
|
||||
Long next = source.getGame().getNextTimestamp();
|
||||
long next = source.getGame().getNextTimestamp();
|
||||
source.addCloneState(CardFactory.getCloneStates(source, source, this), next);
|
||||
lkicheck = true;
|
||||
}
|
||||
|
||||
@@ -827,9 +827,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
|
||||
public void setTriggeringObjectsFrom(final Map<AbilityKey, Object> runParams, final AbilityKey... types) {
|
||||
int typesLength = types.length;
|
||||
for (int i = 0; i < typesLength; i += 1) {
|
||||
AbilityKey type = types[i];
|
||||
for (AbilityKey type : types) {
|
||||
if (runParams.containsKey(type)) {
|
||||
triggeringObjects.put(type, runParams.get(type));
|
||||
}
|
||||
@@ -868,9 +866,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
replacingObjects = AbilityKey.newMap(repParams);
|
||||
}
|
||||
public void setReplacingObjectsFrom(final Map<AbilityKey, Object> repParams, final AbilityKey... types) {
|
||||
int typesLength = types.length;
|
||||
for (int i = 0; i < typesLength; i += 1) {
|
||||
AbilityKey type = types[i];
|
||||
for (AbilityKey type : types) {
|
||||
if (repParams.containsKey(type)) {
|
||||
setReplacingObject(type, repParams.get(type));
|
||||
}
|
||||
@@ -2210,8 +2206,8 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
if (incR.length > 1) {
|
||||
final String excR = incR[1];
|
||||
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
|
||||
for (int j = 0; j < exR.length; j++) {
|
||||
if (!hasProperty(exR[j], sourceController, source, spellAbility)) {
|
||||
for (String s : exR) {
|
||||
if (!hasProperty(s, sourceController, source, spellAbility)) {
|
||||
return testFailed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class StaticAbilityCantDraw {
|
||||
if (!stAb.matchesValidParam("ValidPlayer", player)) {
|
||||
return amount;
|
||||
}
|
||||
int limit = Integer.valueOf(stAb.getParamOrDefault("DrawLimit", "0"));
|
||||
int limit = Integer.parseInt(stAb.getParamOrDefault("DrawLimit", "0"));
|
||||
int drawn = player.getNumDrawnThisTurn();
|
||||
return Math.min(Math.max(limit - drawn, 0), amount);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class TriggerCounterRemoved extends Trigger {
|
||||
if (hasParam("NewCounterAmount")) {
|
||||
final String amtString = getParam("NewCounterAmount");
|
||||
int amt = Integer.parseInt(amtString);
|
||||
if(amt != addedNewCounterAmount.intValue()) {
|
||||
if(amt != addedNewCounterAmount) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
add(c, index, latestState, false);
|
||||
}
|
||||
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
|
||||
// (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.");
|
||||
@@ -133,7 +133,7 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
if (index == null) {
|
||||
cardList.add(c);
|
||||
} else {
|
||||
cardList.add(index.intValue(), c);
|
||||
cardList.add(index, c);
|
||||
}
|
||||
}
|
||||
onChanged();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class MessageUtil {
|
||||
private MessageUtil() { }
|
||||
|
||||
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);
|
||||
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) {
|
||||
if (related instanceof PlayerView && message.indexOf("{player") >= 0) {
|
||||
if (related instanceof PlayerView && message.contains("{player")) {
|
||||
String noun = mayBeYou(player, related);
|
||||
message = TextUtil.fastReplace(TextUtil.fastReplace(message, "{player}", noun),"{player's}", Lang.getInstance().getPossesive(noun));
|
||||
}
|
||||
|
||||
@@ -108,10 +108,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(proc);
|
||||
}
|
||||
catch (final InterruptedException exn) {
|
||||
throw new RuntimeException(exn);
|
||||
}
|
||||
catch (final InvocationTargetException exn) {
|
||||
catch (final InterruptedException | InvocationTargetException exn) {
|
||||
throw new RuntimeException(exn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class KeyboardShortcuts {
|
||||
StackItemView si = matchUI.getGameView().peekStack();
|
||||
if (si != null && si.isAbility()) {
|
||||
matchUI.setShouldAutoYield(si.getKey(), true);
|
||||
int triggerID = Integer.valueOf(si.getSourceTrigger());
|
||||
int triggerID = si.getSourceTrigger();
|
||||
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
|
||||
matchUI.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class KeyboardShortcuts {
|
||||
StackItemView si = matchUI.getGameView().peekStack();
|
||||
if (si != null && si.isAbility()) {
|
||||
matchUI.setShouldAutoYield(si.getKey(), true);
|
||||
int triggerID = Integer.valueOf(si.getSourceTrigger());
|
||||
int triggerID = si.getSourceTrigger();
|
||||
if (si.isOptionalTrigger() && matchUI.isLocalPlayer(si.getActivatingPlayer())) {
|
||||
matchUI.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class KeyboardShortcuts {
|
||||
if (s.equals("16")) { inputEvents[0] = 16; }
|
||||
else if (s.equals("17")) { inputEvents[1] = 17; }
|
||||
else {
|
||||
keyEvent = Integer.valueOf(s);
|
||||
keyEvent = Integer.parseInt(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ public class FDeckViewer extends FDialog {
|
||||
}
|
||||
|
||||
private void copyToClipboard() {
|
||||
final String nl = System.getProperty("line.separator");
|
||||
final String nl = System.lineSeparator();
|
||||
final StringBuilder deckList = new StringBuilder();
|
||||
String dName = deck.getName();
|
||||
//fix copying a commander netdeck then importing it again...
|
||||
|
||||
@@ -78,7 +78,7 @@ public class GuiChoose {
|
||||
|
||||
final Integer[] choices = new Integer[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
choices[i] = Integer.valueOf(i + min);
|
||||
choices[i] = i + min;
|
||||
}
|
||||
return GuiChoose.oneOrNone(message, choices);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class GuiChoose {
|
||||
|
||||
final List<Object> choices = new ArrayList<>();
|
||||
for (int i = min; i <= cutoff; i++) {
|
||||
choices.add(Integer.valueOf(i));
|
||||
choices.add(i);
|
||||
}
|
||||
choices.add(Localizer.getInstance().getMessage("lblOtherInteger"));
|
||||
|
||||
@@ -120,7 +120,7 @@ public class GuiChoose {
|
||||
if (str == null) { return null; } // that is 'cancel'
|
||||
|
||||
if (StringUtils.isNumeric(str)) {
|
||||
final Integer val = Integer.valueOf(str);
|
||||
final int val = Integer.parseInt(str);
|
||||
if (val >= min && val <= max) {
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ public class GuiDialog {
|
||||
final String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||
final List<String> opts = options == null ? defaultConfirmOptions : options;
|
||||
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);
|
||||
FThreads.invokeInEdtAndWait(future);
|
||||
try {
|
||||
return future.get().booleanValue();
|
||||
return future.get();
|
||||
} catch (final InterruptedException | ExecutionException e) { // should be no exception here
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -131,10 +131,8 @@ public final class SLayoutIO {
|
||||
final FileLocation file = ForgeConstants.WINDOW_LAYOUT_FILE;
|
||||
final String fWriteTo = file.userPrefLoc;
|
||||
final XMLOutputFactory out = XMLOutputFactory.newInstance();
|
||||
FileOutputStream fos = null;
|
||||
XMLEventWriter writer = null;
|
||||
try {
|
||||
fos = new FileOutputStream(fWriteTo);
|
||||
try (FileOutputStream fos = new FileOutputStream(fWriteTo)) {
|
||||
writer = out.createXMLEventWriter(fos);
|
||||
|
||||
writer.add(EF.createStartDocument());
|
||||
@@ -147,20 +145,14 @@ public final class SLayoutIO {
|
||||
writer.add(EF.createAttribute(Property.max, window.isMaximized() ? "1" : "0"));
|
||||
writer.add(EF.createAttribute(Property.fs, window.isFullScreen() ? "1" : "0"));
|
||||
writer.add(EF.createEndElement("", "", "layout"));
|
||||
writer.flush();
|
||||
writer.flush();
|
||||
writer.add(EF.createEndDocument());
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
} catch (XMLStreamException 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();
|
||||
} finally {
|
||||
if (writer != null ) {
|
||||
try { writer.close(); } catch (XMLStreamException e) {}
|
||||
}
|
||||
if ( fos != null ) {
|
||||
try { fos.close(); } catch (IOException e) {}
|
||||
if (writer != null) {
|
||||
try { writer.close(); } catch (XMLStreamException ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,10 +337,7 @@ public final class SLayoutIO {
|
||||
}
|
||||
writer.flush();
|
||||
writer.add(EF.createEndDocument());
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
} catch (XMLStreamException 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();
|
||||
} finally {
|
||||
@@ -415,7 +404,7 @@ public final class SLayoutIO {
|
||||
final FView view = FView.SINGLETON_INSTANCE;
|
||||
String defaultLayoutSerial = "";
|
||||
String userLayoutSerial = "";
|
||||
Boolean resetLayout = false;
|
||||
boolean resetLayout = false;
|
||||
FScreen screen = Singletons.getControl().getCurrentScreen();
|
||||
FAbsolutePositioner.SINGLETON_INSTANCE.hideAll();
|
||||
view.getPnlInsets().removeAll();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.itemmanager.filters;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
@@ -79,10 +78,8 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
|
||||
btnPackOrDeck.setText(String.valueOf(count));
|
||||
}
|
||||
|
||||
Iterator<StatTypes> buttonMapStatsIterator = buttonMap.keySet().iterator();
|
||||
while (buttonMapStatsIterator.hasNext()){
|
||||
StatTypes statTypes = buttonMapStatsIterator.next();
|
||||
if (statTypes.predicate != null){
|
||||
for (StatTypes statTypes : buttonMap.keySet()) {
|
||||
if (statTypes.predicate != null) {
|
||||
int count = items.countAll(Predicates.compose(statTypes.predicate, PaperCard.FN_GET_RULES), PaperCard.class);
|
||||
buttonMap.get(statTypes).setText(String.valueOf(count));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private static final int PADDING = 5;
|
||||
@@ -154,9 +155,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
|
||||
SItemManagerUtil.populateImageViewOptions(itemManager0, cbGroupByOptions, cbPileByOptions);
|
||||
|
||||
for (Integer i = MIN_COLUMN_COUNT; i <= MAX_COLUMN_COUNT; i++) {
|
||||
cbColumnCount.addItem(i);
|
||||
}
|
||||
IntStream.rangeClosed(MIN_COLUMN_COUNT, MAX_COLUMN_COUNT).forEach(cbColumnCount::addItem);
|
||||
cbGroupByOptions.setMaximumRowCount(cbGroupByOptions.getItemCount());
|
||||
cbPileByOptions.setMaximumRowCount(cbPileByOptions.getItemCount());
|
||||
cbColumnCount.setMaximumRowCount(cbColumnCount.getItemCount());
|
||||
@@ -871,9 +870,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
@Override
|
||||
public void selectAll() {
|
||||
clearSelection();
|
||||
for (Integer i = 0; i < getCount(); i++) {
|
||||
selectedIndices.add(i);
|
||||
}
|
||||
IntStream.range(0, getCount()).forEach(selectedIndices::add);
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
|
||||
@@ -273,8 +273,8 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
|
||||
public Iterable<Integer> getSelectedIndices() {
|
||||
final List<Integer> indices = new ArrayList<>();
|
||||
final int[] selectedRows = this.table.getSelectedRows();
|
||||
for (int i = 0; i < selectedRows.length; i++) {
|
||||
indices.add(selectedRows[i]);
|
||||
for (int selectedRow : selectedRows) {
|
||||
indices.add(selectedRow);
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public final class CEditorQuest extends CDeckEditor<Deck> {
|
||||
for (final Entry<PaperCard, Integer> e : deck.getMain()) {
|
||||
final PaperCard card = e.getKey();
|
||||
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;
|
||||
|
||||
@@ -138,7 +138,7 @@ public final class CEditorQuestLimited extends CDeckEditor<DeckGroup> {
|
||||
for (final Entry<PaperCard, Integer> e : deck.getMain()) {
|
||||
final PaperCard card = e.getKey();
|
||||
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;
|
||||
|
||||
@@ -209,11 +209,11 @@ public class PlayerPanel extends FPanel {
|
||||
|
||||
void update() {
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
txtPlayerName.setEnabled(mayEdit);
|
||||
@@ -312,7 +312,7 @@ public class PlayerPanel extends FPanel {
|
||||
lbl.setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
setAvatarIndex(Integer.valueOf(lbl.getName().substring(11)));
|
||||
setAvatarIndex(Integer.parseInt(lbl.getName().substring(11)));
|
||||
aSel.setVisible(false);
|
||||
}
|
||||
});
|
||||
@@ -368,7 +368,7 @@ public class PlayerPanel extends FPanel {
|
||||
lbl.setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
setSleeveIndex(Integer.valueOf(lbl.getName().substring(11)));
|
||||
setSleeveIndex(Integer.parseInt(lbl.getName().substring(11)));
|
||||
sSel.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ public enum CSubmenuQuestPrefs implements ICDoc {
|
||||
validationError = val == null ? localizer.getMessage("lblEnteraDecimal") : null;
|
||||
} else {
|
||||
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) {
|
||||
|
||||
@@ -314,7 +314,7 @@ public class DialogChoosePoolDistribution {
|
||||
|
||||
public int getNumberOfBoosters() {
|
||||
try {
|
||||
return Integer.valueOf(numberOfBoostersField.getText());
|
||||
return Integer.parseInt(numberOfBoostersField.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
|
||||
for (final String s : codes) {
|
||||
if (!s.isEmpty()) {
|
||||
displayText.add(KeyEvent.getKeyText(Integer.valueOf(s)));
|
||||
displayText.add(KeyEvent.getKeyText(Integer.parseInt(s)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -459,12 +459,12 @@ public class VAssignCombatDamage {
|
||||
}
|
||||
else if (defender instanceof CardView) { // planeswalker
|
||||
final CardView pw = (CardView)defender;
|
||||
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty());
|
||||
lethalDamage = Integer.parseInt(pw.getCurrentState().getLoyalty());
|
||||
}
|
||||
} else {
|
||||
lethalDamage = Math.max(0, card.getLethalDamage());
|
||||
if (card.getCurrentState().isPlaneswalker()) {
|
||||
lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty());
|
||||
lethalDamage = Integer.parseInt(card.getCurrentState().getLoyalty());
|
||||
} else if (attackerHasDeathtouch) {
|
||||
lethalDamage = Math.min(lethalDamage, 1);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user