mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +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;
|
||||
|
||||
@@ -2196,8 +2196,8 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user