mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 01:38:13 +00:00
Revert Android 8 codes to support older Android phones.
Hope I didn't miss any. :) (tested with Android Marshmallow phone with 2gb RAM and mediatek cpu)
This commit is contained in:
@@ -124,7 +124,7 @@ public class AiBlockController {
|
||||
ComputerUtilCard.sortByEvaluateCreature(attackers);
|
||||
CardLists.sortByPowerDesc(attackers);
|
||||
//move cards like Phage the Untouchable to the front
|
||||
attackers.sort(new Comparator<Card>() {
|
||||
Collections.sort(attackers, new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card o1, final Card o2) {
|
||||
if (o1.hasSVar("MustBeBlocked") && !o2.hasSVar("MustBeBlocked")) {
|
||||
|
||||
@@ -608,7 +608,7 @@ public class AiController {
|
||||
ComputerUtilAbility.getAvailableCards(game, player);
|
||||
|
||||
List<SpellAbility> all = ComputerUtilAbility.getSpellAbilities(cards, player);
|
||||
all.sort(saComparator); // put best spells first
|
||||
Collections.sort(all, saComparator); // put best spells first
|
||||
|
||||
for (final SpellAbility sa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, player)) {
|
||||
ApiType saApi = sa.getApi();
|
||||
@@ -1571,7 +1571,7 @@ public class AiController {
|
||||
if (all == null || all.isEmpty())
|
||||
return null;
|
||||
|
||||
all.sort(saComparator); // put best spells first
|
||||
Collections.sort(all, saComparator); // put best spells first
|
||||
|
||||
for (final SpellAbility sa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, player)) {
|
||||
// Don't add Counterspells to the "normal" playcard lookups
|
||||
|
||||
@@ -631,7 +631,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
CardPredicates.hasKeyword("Undying"));
|
||||
|
||||
if (!prefs.isEmpty()) {
|
||||
prefs.sort(CardPredicates.compareByCounterType(CounterType.P1P1));
|
||||
Collections.sort(prefs, CardPredicates.compareByCounterType(CounterType.P1P1));
|
||||
PaymentDecision result = PaymentDecision.card(prefs);
|
||||
result.ct = CounterType.P1P1;
|
||||
return result;
|
||||
@@ -642,7 +642,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
CardPredicates.hasKeyword("Persist"));
|
||||
|
||||
if (!prefs.isEmpty()) {
|
||||
prefs.sort(CardPredicates.compareByCounterType(CounterType.M1M1));
|
||||
Collections.sort(prefs, CardPredicates.compareByCounterType(CounterType.M1M1));
|
||||
PaymentDecision result = PaymentDecision.card(prefs);
|
||||
result.ct = CounterType.M1M1;
|
||||
return result;
|
||||
@@ -653,7 +653,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
CardPredicates.nameEquals("Chronozoa"));
|
||||
|
||||
if (!prefs.isEmpty()) {
|
||||
prefs.sort(CardPredicates.compareByCounterType(CounterType.TIME));
|
||||
Collections.sort(prefs, CardPredicates.compareByCounterType(CounterType.TIME));
|
||||
PaymentDecision result = PaymentDecision.card(prefs);
|
||||
result.ct = CounterType.TIME;
|
||||
return result;
|
||||
@@ -676,7 +676,7 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
||||
return crd.getCounters(CounterType.QUEST) >= e + c;
|
||||
}
|
||||
});
|
||||
prefs.sort(Collections.reverseOrder(CardPredicates.compareByCounterType(CounterType.QUEST)));
|
||||
Collections.sort(prefs, Collections.reverseOrder(CardPredicates.compareByCounterType(CounterType.QUEST)));
|
||||
PaymentDecision result = PaymentDecision.card(prefs);
|
||||
result.ct = CounterType.QUEST;
|
||||
return result;
|
||||
|
||||
@@ -2197,7 +2197,7 @@ public class ComputerUtil {
|
||||
}
|
||||
}
|
||||
|
||||
goodChoices.sort(CardLists.TextLenComparator);
|
||||
Collections.sort(goodChoices, CardLists.TextLenComparator);
|
||||
|
||||
CardLists.sortByCmcDesc(goodChoices);
|
||||
dChoices.add(goodChoices.get(0));
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ComputerUtilCard {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByEvaluateCreature(final CardCollection list) {
|
||||
list.sort(ComputerUtilCard.EvaluateCreatureComparator);
|
||||
Collections.sort(list, ComputerUtilCard.EvaluateCreatureComparator);
|
||||
} // sortByEvaluateCreature()
|
||||
|
||||
// The AI doesn't really pick the best artifact, just the most expensive.
|
||||
@@ -390,7 +390,7 @@ public class ComputerUtilCard {
|
||||
if (!Iterables.isEmpty(list)) {
|
||||
CardCollection cc = CardLists.filter(new CardCollection(list),
|
||||
Predicates.or(CardPredicates.isType("Instant"), CardPredicates.isType("Sorcery")));
|
||||
cc.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(cc, CardLists.CmcComparatorInv);
|
||||
|
||||
if (cc.isEmpty()) {
|
||||
return null;
|
||||
@@ -802,9 +802,8 @@ public class ComputerUtilCard {
|
||||
if (color.hasGreen()) map.get(4).setValue(Integer.valueOf(map.get(4).getValue()+1));
|
||||
} // for
|
||||
|
||||
map.sort(new Comparator<Pair<Byte, Integer>>() {
|
||||
@Override
|
||||
public int compare(Pair<Byte, Integer> o1, Pair<Byte, Integer> o2) {
|
||||
Collections.sort(map, new Comparator<Pair<Byte,Integer>>() {
|
||||
@Override public int compare(Pair<Byte, Integer> o1, Pair<Byte, Integer> o2) {
|
||||
return o2.getValue() - o1.getValue();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ComputerUtilMana {
|
||||
}
|
||||
}
|
||||
}
|
||||
orderedCards.sort(new Comparator<Card>() {
|
||||
Collections.sort(orderedCards, new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card card1, final Card card2) {
|
||||
return Integer.compare(manaCardMap.get(card1), manaCardMap.get(card2));
|
||||
@@ -151,7 +151,7 @@ public class ComputerUtilMana {
|
||||
System.out.println("Unsorted Abilities: " + newAbilities);
|
||||
}
|
||||
|
||||
newAbilities.sort(new Comparator<SpellAbility>() {
|
||||
Collections.sort(newAbilities, new Comparator<SpellAbility>() {
|
||||
@Override
|
||||
public int compare(final SpellAbility ability1, final SpellAbility ability2) {
|
||||
int preOrder = orderedCards.indexOf(ability1.getHostCard()) - orderedCards.indexOf(ability2.getHostCard());
|
||||
|
||||
@@ -579,7 +579,7 @@ public class SpecialCardAi {
|
||||
int changeNum = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("ChangeNum"), sa);
|
||||
CardCollection lib = CardLists.filter(ai.getCardsIn(ZoneType.Library),
|
||||
Predicates.not(CardPredicates.nameEquals(sa.getHostCard().getName())));
|
||||
lib.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(lib, CardLists.CmcComparatorInv);
|
||||
|
||||
// Additional cards which are difficult to auto-classify but which are generally good to Intuition for
|
||||
List<String> highPriorityNamedCards = Lists.newArrayList("Accumulated Knowledge", "Take Inventory");
|
||||
@@ -679,7 +679,7 @@ public class SpecialCardAi {
|
||||
// If we're playing Reanimator, we're really interested just in the highest CMC spells, not the
|
||||
// ones we necessarily have multiples of
|
||||
if (ComputerUtil.isPlayingReanimator(ai)) {
|
||||
libHighPriorityList.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(libHighPriorityList, CardLists.CmcComparatorInv);
|
||||
}
|
||||
|
||||
// Otherwise, try to grab something that is hopefully decent to grab, in priority order
|
||||
@@ -1173,7 +1173,7 @@ public class SpecialCardAi {
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
atTargetCMCInLib = CardLists.filter(creatsInLib, CardPredicates.greaterCMC(numManaSrcs));
|
||||
}
|
||||
atTargetCMCInLib.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(atTargetCMCInLib, CardLists.CmcComparatorInv);
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
// Nothing to aim for?
|
||||
return null;
|
||||
@@ -1181,11 +1181,11 @@ public class SpecialCardAi {
|
||||
|
||||
// Cards in hand that are below the max CMC affordable by the AI
|
||||
CardCollection belowMaxCMC = CardLists.filter(creatsInHand, CardPredicates.lessCMC(numManaSrcs - 1));
|
||||
belowMaxCMC.sort(Collections.reverseOrder(CardLists.CmcComparatorInv));
|
||||
Collections.sort(belowMaxCMC, Collections.reverseOrder(CardLists.CmcComparatorInv));
|
||||
|
||||
// Cards in hand that are above the max CMC affordable by the AI
|
||||
CardCollection aboveMaxCMC = CardLists.filter(creatsInHand, CardPredicates.greaterCMC(numManaSrcs + 1));
|
||||
aboveMaxCMC.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(aboveMaxCMC, CardLists.CmcComparatorInv);
|
||||
|
||||
Card maxCMC = !aboveMaxCMC.isEmpty() ? aboveMaxCMC.getFirst() : null;
|
||||
Card minCMC = !belowMaxCMC.isEmpty() ? belowMaxCMC.getFirst() : null;
|
||||
@@ -1218,7 +1218,7 @@ public class SpecialCardAi {
|
||||
// worth to fill the graveyard now
|
||||
if (ComputerUtil.isPlayingReanimator(ai) && !creatsInLib.isEmpty()) {
|
||||
CardCollection creatsInHandByCMC = new CardCollection(creatsInHand);
|
||||
creatsInHandByCMC.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(creatsInHandByCMC, CardLists.CmcComparatorInv);
|
||||
return creatsInHandByCMC.getFirst();
|
||||
}
|
||||
|
||||
@@ -1243,14 +1243,14 @@ public class SpecialCardAi {
|
||||
if (atTargetCMCInLib.isEmpty()) {
|
||||
atTargetCMCInLib = CardLists.filter(creatsInLib, CardPredicates.greaterCMC(numManaSrcs));
|
||||
}
|
||||
atTargetCMCInLib.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(atTargetCMCInLib, CardLists.CmcComparatorInv);
|
||||
|
||||
Card bestInLib = atTargetCMCInLib != null ? atTargetCMCInLib.getFirst() : null;
|
||||
|
||||
if (bestInLib == null && ComputerUtil.isPlayingReanimator(ai)) {
|
||||
// For Reanimator, we don't mind grabbing the biggest thing possible to recycle it again with SotF later.
|
||||
CardCollection creatsInLibByCMC = new CardCollection(creatsInLib);
|
||||
creatsInLibByCMC.sort(CardLists.CmcComparatorInv);
|
||||
Collections.sort(creatsInLibByCMC, CardLists.CmcComparatorInv);
|
||||
return creatsInLibByCMC.getFirst();
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,7 +1321,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
chance = aic.getIntProperty(AiProps.BLINK_RELOAD_PLANESWALKER_CHANCE);
|
||||
}
|
||||
if (MyRandom.percentTrue(chance)) {
|
||||
aiPlaneswalkers.sort(new Comparator<Card>() {
|
||||
Collections.sort(aiPlaneswalkers, new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
return a.getCounters(CounterType.LOYALTY) - b.getCounters(CounterType.LOYALTY);
|
||||
|
||||
@@ -547,7 +547,7 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView {
|
||||
Map<String, String> result = Maps.newHashMap(output);
|
||||
for (Map.Entry<String, String> e : input.entrySet()) {
|
||||
String value = e.getValue();
|
||||
result.put(e.getKey(), output.getOrDefault(value, value));
|
||||
result.put(e.getKey(), output.containsKey(value) ? output.get(value) : value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class Game {
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
return changeZoneLKIInfo.getOrDefault(c.getId(), c);
|
||||
return changeZoneLKIInfo.containsKey(c.getId()) ? changeZoneLKIInfo.get(c.getId()) : c;
|
||||
}
|
||||
public final void clearChangeZoneLKIInfo() {
|
||||
changeZoneLKIInfo.clear();
|
||||
|
||||
@@ -824,7 +824,7 @@ public class GameAction {
|
||||
.result();
|
||||
}
|
||||
};
|
||||
staticAbilities.sort(comp);
|
||||
Collections.sort(staticAbilities, comp);
|
||||
|
||||
final Map<StaticAbility, CardCollectionView> affectedPerAbility = Maps.newHashMap();
|
||||
for (final StaticAbilityLayer layer : StaticAbilityLayer.CONTINUOUS_LAYERS) {
|
||||
|
||||
@@ -403,7 +403,8 @@ public class GameFormat implements Comparable<GameFormat> {
|
||||
naturallyOrdered = reader.naturallyOrdered;
|
||||
reverseDateOrdered = new ArrayList<>(naturallyOrdered);
|
||||
Collections.sort(naturallyOrdered);
|
||||
reverseDateOrdered.sort(new InverseDateComparator());
|
||||
//Why this refactor doesnt work on some android phones? -> reverseDateOrdered.sort(new InverseDateComparator());
|
||||
Collections.sort(reverseDateOrdered, new InverseDateComparator());
|
||||
}
|
||||
|
||||
public Iterable<GameFormat> getOrderedList() {
|
||||
|
||||
@@ -136,13 +136,13 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
|
||||
for (final GameOutcome game : gamesPlayed) {
|
||||
RegisteredPlayer player = game.getWinningPlayer();
|
||||
|
||||
int amount = winCount.getOrDefault(player, 0);
|
||||
int amount = winCount.containsKey(player) ? winCount.get(player) : 0;
|
||||
winCount.put(player, amount + 1);
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (Entry<RegisteredPlayer, String> entry : players.entrySet()) {
|
||||
int amount = winCount.getOrDefault(entry.getKey(), 0);
|
||||
int amount = winCount.containsKey(entry.getKey()) ? winCount.get(entry.getKey()) : 0;
|
||||
|
||||
sb.append(entry.getValue()).append(": ").append(amount).append(" ");
|
||||
}
|
||||
|
||||
@@ -311,8 +311,8 @@ public final class AbilityFactory {
|
||||
}
|
||||
|
||||
private static final TargetRestrictions readTarget(Map<String, String> mapParams) {
|
||||
final String min = mapParams.getOrDefault("TargetMin", "1");
|
||||
final String max = mapParams.getOrDefault("TargetMax", "1");
|
||||
final String min = mapParams.containsKey("TargetMin") ? mapParams.get("TargetMin") : "1";
|
||||
final String max = mapParams.containsKey("TargetMax") ? mapParams.get("TargetMax") : "1";
|
||||
|
||||
|
||||
// TgtPrompt now optional
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.game.spellability.SpellAbility;
|
||||
import forge.util.Lang;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -190,7 +191,7 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// Sort Chosen by SA order
|
||||
chosen.sort(new Comparator<AbilitySub>() {
|
||||
Collections.sort(chosen, new Comparator<AbilitySub>() {
|
||||
@Override
|
||||
public int compare(AbilitySub o1, AbilitySub o2) {
|
||||
return Integer.compare(o1.getSVarInt("CharmOrder"), o2.getSVarInt("CharmOrder"));
|
||||
|
||||
@@ -1330,7 +1330,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
int counterAmount = 0;
|
||||
if (countersAddedBy.containsKey(source)) {
|
||||
final Map<CounterType, Integer> counterMap = countersAddedBy.get(source);
|
||||
counterAmount = counterMap.getOrDefault(counterType, 0);
|
||||
counterAmount = counterMap.containsKey(counterType) ? counterMap.get(counterType) : 0;
|
||||
countersAddedBy.remove(source);
|
||||
}
|
||||
return counterAmount;
|
||||
@@ -6188,7 +6188,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return numberTurnActivations.getOrDefault(original, 0);
|
||||
return numberTurnActivations.containsKey(original) ? numberTurnActivations.get(original) : 0;
|
||||
}
|
||||
|
||||
public int getAbilityActivatedThisGame(SpellAbility ability) {
|
||||
@@ -6203,7 +6203,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return numberGameActivations.getOrDefault(original, 0);
|
||||
return numberGameActivations.containsKey(original) ? numberGameActivations.get(original) : 0;
|
||||
}
|
||||
|
||||
public void resetTurnActivations() {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByCmcDesc(final List<Card> list) {
|
||||
list.sort(CmcComparatorInv);
|
||||
Collections.sort(list, CmcComparatorInv);
|
||||
} // sortByCmcDesc
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByToughnessAsc(final List<Card> list) {
|
||||
list.sort(ToughnessComparator);
|
||||
Collections.sort(list, ToughnessComparator);
|
||||
} // sortByToughnessAsc()
|
||||
|
||||
/**
|
||||
@@ -141,7 +141,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByToughnessDesc(final List<Card> list) {
|
||||
list.sort(ToughnessComparatorInv);
|
||||
Collections.sort(list, ToughnessComparatorInv);
|
||||
} // sortByToughnessDesc()
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByPowerAsc(final List<Card> list) {
|
||||
list.sort(PowerComparator);
|
||||
Collections.sort(list, PowerComparator);
|
||||
} // sortAttackLowFirst()
|
||||
|
||||
// the higher the attack the better
|
||||
@@ -164,7 +164,7 @@ public class CardLists {
|
||||
* @param list
|
||||
*/
|
||||
public static void sortByPowerDesc(final List<Card> list) {
|
||||
list.sort(Collections.reverseOrder(PowerComparator));
|
||||
Collections.sort(list, Collections.reverseOrder(PowerComparator));
|
||||
} // sortAttack()
|
||||
|
||||
|
||||
|
||||
@@ -449,7 +449,11 @@ public class CardState extends GameObject {
|
||||
return sVars;
|
||||
}
|
||||
public final String getSVar(final String var) {
|
||||
return sVars.getOrDefault(var, "");
|
||||
if (sVars.containsKey(var)) {
|
||||
return sVars.get(var);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public final boolean hasSVar(final String var) {
|
||||
if (var == null) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.game.cost;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -125,7 +126,7 @@ public class Cost implements Serializable {
|
||||
// Things that are pretty much happen at the end (Untap) 16+
|
||||
// Things that NEED to happen last 100+
|
||||
|
||||
this.costParts.sort(new Comparator<CostPart>() {
|
||||
Collections.sort(this.costParts, new Comparator<CostPart>() {
|
||||
@Override
|
||||
public int compare(CostPart o1, CostPart o2) {
|
||||
return o1.paymentOrder() - o2.paymentOrder();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CostAdjustment {
|
||||
return;
|
||||
}
|
||||
|
||||
final String scost = params.getOrDefault("Cost", "1");
|
||||
final String scost = params.containsKey("Cost") ? params.get("Cost") : "1";
|
||||
Cost part = new Cost(scost, sa.isAbility());
|
||||
int count = 0;
|
||||
|
||||
|
||||
@@ -598,12 +598,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
view.updateCommanderDamage(this);
|
||||
}
|
||||
|
||||
int old = assignedDamage.getOrDefault(source, 0);
|
||||
int old = assignedDamage.containsKey(source) ? assignedDamage.get(source) : 0;
|
||||
assignedDamage.put(source, old + amount);
|
||||
source.getDamageHistory().registerDamage(this);
|
||||
|
||||
if (isCombat) {
|
||||
old = assignedCombatDamage.getOrDefault(source, 0);
|
||||
old = assignedCombatDamage.containsKey(source) ? assignedCombatDamage.get(source) : 0;
|
||||
assignedCombatDamage.put(source, old + amount);
|
||||
for (final String type : source.getType().getCreatureTypes()) {
|
||||
source.getController().addProwlType(type);
|
||||
|
||||
@@ -89,8 +89,8 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
public AbilityManaPart(final Card sourceCard, final Map<String, String> params) {
|
||||
this.sourceCard = sourceCard;
|
||||
|
||||
origProduced = params.getOrDefault("Produced", "1");
|
||||
this.manaRestrictions = params.getOrDefault("RestrictValid", "");
|
||||
origProduced = params.containsKey("Produced") ? params.get("Produced") : "1";
|
||||
this.manaRestrictions = params.containsKey("RestrictValid") ? params.get("RestrictValid") : "";
|
||||
this.cannotCounterSpell = params.get("AddsNoCounter");
|
||||
this.addsKeywords = params.get("AddsKeywords");
|
||||
this.addsKeywordsType = params.get("AddsKeywordsType");
|
||||
@@ -98,7 +98,7 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
this.addsCounters = params.get("AddsCounters");
|
||||
this.triggersWhenSpent = params.get("TriggersWhenSpent");
|
||||
this.persistentMana = (null != params.get("PersistentMana")) && "True".equalsIgnoreCase(params.get("PersistentMana"));
|
||||
this.manaReplaceType = params.getOrDefault("ManaReplaceType", "");
|
||||
this.manaReplaceType = params.containsKey("ManaReplaceType") ? params.get("ManaReplaceType") : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,7 +81,7 @@ public class StaticAbilityCantBeCast {
|
||||
|
||||
if (params.containsKey("NumLimitEachTurn") && activator != null) {
|
||||
int limit = Integer.parseInt(params.get("NumLimitEachTurn"));
|
||||
String valid = params.getOrDefault("ValidCard", "Card");
|
||||
String valid = params.containsKey("ValidCard") ? params.get("ValidCard") : "Card";
|
||||
List<Card> thisTurnCast = CardUtil.getThisTurnCast(valid, card);
|
||||
if (CardLists.filterControlledBy(thisTurnCast, activator).size() < limit) {
|
||||
return false;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class StaticAbilityPreventDamage {
|
||||
|
||||
if (params.containsKey("Optional")) { //Assume if param is present it should be optional
|
||||
if (!isTest) {
|
||||
final String logic = params.getOrDefault("AILogic", "");
|
||||
final String logic = params.containsKey("AILogic") ? params.get("AILogic") : "";
|
||||
final String message = "Apply the effect of " + hostCard + "? (Affected: " + target + ")";
|
||||
boolean confirmed = hostCard.getController().getController().confirmStaticApplication(hostCard, target, logic, message);
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -446,7 +446,7 @@ public class ImportSourceAnalyzer {
|
||||
analyzeListedDir(root, ForgeConstants.CACHE_ICON_PICS_DIR, new ListedAnalyzer() {
|
||||
@Override
|
||||
public String map(final String filename) {
|
||||
return iconFileNames.getOrDefault(filename, null);
|
||||
return iconFileNames.containsKey(filename) ? iconFileNames.get(filename) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -618,7 +618,7 @@ public class ImportSourceAnalyzer {
|
||||
analyzeListedDir(root, targetDir, new ListedAnalyzer() {
|
||||
@Override
|
||||
public String map(final String filename) {
|
||||
return fileDb.getOrDefault(filename, null);
|
||||
return fileDb.containsKey(filename) ? fileDb.get(filename) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -857,7 +857,11 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addFilter(final ItemFilter<? extends T> filter) {
|
||||
final Class<? extends ItemFilter<? extends T>> filterClass = (Class<? extends ItemFilter<? extends T>>) filter.getClass();
|
||||
List<ItemFilter<? extends T>> classFilters = this.filters.computeIfAbsent(filterClass, k -> new ArrayList<>());
|
||||
List<ItemFilter<? extends T>> classFilters = this.filters.get(filterClass);
|
||||
if (classFilters == null) {
|
||||
classFilters = new ArrayList<>();
|
||||
this.filters.put(filterClass, classFilters);
|
||||
}
|
||||
if (classFilters.size() > 0) {
|
||||
//if filter with the same class already exists, try to merge if allowed
|
||||
//NOTE: can always use first filter for these checks since if
|
||||
|
||||
@@ -36,7 +36,7 @@ class AsyncSoundRegistry {
|
||||
}
|
||||
|
||||
public synchronized static int getNumIterations(String soundName) {
|
||||
return soundsPlayed.getOrDefault(soundName, 0);
|
||||
return soundsPlayed.containsKey(soundName) ? soundsPlayed.get(soundName) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,11 @@ public class QuestEventDraft implements IQuestEvent {
|
||||
int value;
|
||||
final String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
|
||||
|
||||
value = MAP_PRICES.getOrDefault(boosterName, 395);
|
||||
if (MAP_PRICES.containsKey(boosterName)) {
|
||||
value = MAP_PRICES.get(boosterName);
|
||||
} else {
|
||||
value = 395;
|
||||
}
|
||||
|
||||
boosterPrices += value;
|
||||
|
||||
@@ -514,7 +518,11 @@ public class QuestEventDraft implements IQuestEvent {
|
||||
|
||||
final String boosterName = booster.getName();
|
||||
|
||||
value = MAP_PRICES.getOrDefault(boosterName, 395);
|
||||
if (MAP_PRICES.containsKey(boosterName)) {
|
||||
value = MAP_PRICES.get(boosterName);
|
||||
} else {
|
||||
value = 395;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -941,7 +949,11 @@ public class QuestEventDraft implements IQuestEvent {
|
||||
int value;
|
||||
final String boosterName = FModel.getMagicDb().getEditions().get(boosterSet).getName() + " Booster Pack";
|
||||
|
||||
value = MAP_PRICES.getOrDefault(boosterName, 395);
|
||||
if (MAP_PRICES.containsKey(boosterName)) {
|
||||
value = MAP_PRICES.get(boosterName);
|
||||
} else {
|
||||
value = 395;
|
||||
}
|
||||
|
||||
entryFee += value;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user