mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
CardLists: removed duplicate sortByMostExpensive, gave propper names to methods of CardLists
This commit is contained in:
@@ -62,26 +62,26 @@ public class CardLists {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Comparator<Card> DefenseComparator = new Comparator<Card>() {
|
public static final Comparator<Card> ToughnessComparator = new Comparator<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Card a, final Card b) {
|
public int compare(final Card a, final Card b) {
|
||||||
return b.getNetDefense() - a.getNetDefense();
|
return a.getNetDefense() - b.getNetDefense();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Comparator<Card> AttackComparator = new Comparator<Card>() {
|
public static final Comparator<Card> PowerComparator = new Comparator<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Card a, final Card b) {
|
public int compare(final Card a, final Card b) {
|
||||||
return b.getNetCombatDamage() - a.getNetCombatDamage();
|
return a.getNetCombatDamage() - b.getNetCombatDamage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Comparator<Card> CmcComparator = new Comparator<Card>() {
|
public static final Comparator<Card> CmcComparatorInv = new Comparator<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Card a, final Card b) {
|
public int compare(final Card a, final Card b) {
|
||||||
return b.getCMC() - a.getCMC();
|
return b.getCMC() - a.getCMC();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Comparator<Card> TextLenReverseComparator = new Comparator<Card>() {
|
public static final Comparator<Card> TextLenComparator = new Comparator<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Card a, final Card b) {
|
public int compare(final Card a, final Card b) {
|
||||||
final int aLen = a.getText().length();
|
final int aLen = a.getText().length();
|
||||||
@@ -90,30 +90,6 @@ public class CardLists {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final Comparator<Card> getKeywordComparator(final String kw) {
|
|
||||||
return new Comparator<Card>() {
|
|
||||||
@Override
|
|
||||||
public int compare(final Card a, final Card b) {
|
|
||||||
int aV = a.hasKeyword(kw) ? 1 : 0;
|
|
||||||
int bV = b.hasKeyword(kw) ? 1 : 0;
|
|
||||||
return bV - aV;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// the higher the attack the better
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* sortAttack.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* a {@link forge.CardList} object.
|
|
||||||
*/
|
|
||||||
public static void sortAttack(final List<Card> list) {
|
|
||||||
Collections.sort(list, AttackComparator);
|
|
||||||
} // sortAttack()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Sorts a List<Card> by "best" using the EvaluateCreature function.
|
* Sorts a List<Card> by "best" using the EvaluateCreature function.
|
||||||
@@ -129,17 +105,16 @@ public class CardLists {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Sorts a List<Card> by converted mana cost, putting highest first.
|
* Sorts a List<Card> from highest converted mana cost to lowest.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* a {@link forge.CardList} object.
|
* a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static void sortByMostExpensive(final List<Card> list) {
|
public static void sortByCmcDesc(final List<Card> list) {
|
||||||
Collections.sort(list, CmcComparator);
|
Collections.sort(list, CmcComparatorInv);
|
||||||
} // sortByMostExpensive()
|
} // sortCMC
|
||||||
|
|
||||||
// the lower the attack the better
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* sortAttackLowFirst.
|
* sortAttackLowFirst.
|
||||||
@@ -148,46 +123,24 @@ public class CardLists {
|
|||||||
* @param list
|
* @param list
|
||||||
* a {@link forge.CardList} object.
|
* a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static void sortAttackLowFirst(final List<Card> list) {
|
public static void sortByPowerAsc(final List<Card> list) {
|
||||||
Collections.sort(list, Collections.reverseOrder(AttackComparator));
|
Collections.sort(list, PowerComparator);
|
||||||
} // sortAttackLowFirst()
|
} // sortAttackLowFirst()
|
||||||
|
|
||||||
|
// the higher the attack the better
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Sorts a CardList, putting creatures without Flying first.
|
* sortAttack.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param list
|
* @param list
|
||||||
* a {@link forge.CardList} object.
|
* a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static void sortNonFlyingFirst(final List<Card> list) {
|
public static void sortByPowerDesc(final List<Card> list) {
|
||||||
CardLists.sortFlying(list);
|
Collections.sort(list, Collections.reverseOrder(PowerComparator));
|
||||||
Collections.reverse(list);
|
} // sortAttack()
|
||||||
} // sortNonFlyingFirst
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Sorts a CardList, putting creatures with Flying first.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* a {@link forge.CardList} object.
|
|
||||||
*/
|
|
||||||
public static void sortFlying(final List<Card> list) {
|
|
||||||
Collections.sort(list, getKeywordComparator("Flying"));
|
|
||||||
} // sortFlying()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Sorts a List<Card> from highest converted mana cost to lowest.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* a {@link forge.CardList} object.
|
|
||||||
*/
|
|
||||||
public static void sortCMC(final List<Card> list) {
|
|
||||||
Collections.sort(list, CmcComparator);
|
|
||||||
} // sortCMC
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -860,7 +860,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
if (ai.getLife() <= 5) { // Desperate?
|
if (ai.getLife() <= 5) { // Desperate?
|
||||||
// Get something AI can cast soon.
|
// Get something AI can cast soon.
|
||||||
System.out.println("5 Life or less, trying to find something castable.");
|
System.out.println("5 Life or less, trying to find something castable.");
|
||||||
CardLists.sortByMostExpensive(nonLands);
|
CardLists.sortByCmcDesc(nonLands);
|
||||||
for (Card potentialCard : nonLands) {
|
for (Card potentialCard : nonLands) {
|
||||||
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
||||||
choice = potentialCard;
|
choice = potentialCard;
|
||||||
@@ -971,7 +971,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
if (ai.getLife() <= 5) { // Desperate?
|
if (ai.getLife() <= 5) { // Desperate?
|
||||||
// Get something AI can cast soon.
|
// Get something AI can cast soon.
|
||||||
System.out.println("5 Life or less, trying to find something castable.");
|
System.out.println("5 Life or less, trying to find something castable.");
|
||||||
CardLists.sortByMostExpensive(nonLands);
|
CardLists.sortByCmcDesc(nonLands);
|
||||||
for (Card potentialCard : nonLands) {
|
for (Card potentialCard : nonLands) {
|
||||||
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
||||||
choice = potentialCard;
|
choice = potentialCard;
|
||||||
@@ -1212,7 +1212,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
if (ai.getLife() <= 5) { // Desperate?
|
if (ai.getLife() <= 5) { // Desperate?
|
||||||
// Get something AI can cast soon.
|
// Get something AI can cast soon.
|
||||||
System.out.println("5 Life or less, trying to find something castable.");
|
System.out.println("5 Life or less, trying to find something castable.");
|
||||||
CardLists.sortByMostExpensive(fetchList);
|
CardLists.sortByCmcDesc(fetchList);
|
||||||
for (Card potentialCard : fetchList) {
|
for (Card potentialCard : fetchList) {
|
||||||
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
if (ComputerUtilMana.payManaCost(potentialCard.getFirstSpellAbility(), ai, true, 0, false)) {
|
||||||
c = potentialCard;
|
c = potentialCard;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class PumpAi extends PumpAiBase {
|
|||||||
if (sa.getParam("AILogic").equals("HighestPower")) {
|
if (sa.getParam("AILogic").equals("HighestPower")) {
|
||||||
list = CardLists.getValidCards(CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
list = CardLists.getValidCards(CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard());
|
||||||
list = CardLists.getTargetableCards(list, sa);
|
list = CardLists.getTargetableCards(list, sa);
|
||||||
CardLists.sortAttack(list);
|
CardLists.sortByPowerDesc(list);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
tgt.addTarget(list.get(0));
|
tgt.addTarget(list.get(0));
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
|||||||
tgt.addTarget(combatants.get(0));
|
tgt.addTarget(combatants.get(0));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
CardLists.sortByMostExpensive(compTargetables);
|
CardLists.sortByCmcDesc(compTargetables);
|
||||||
for (final Card c : compTargetables) {
|
for (final Card c : compTargetables) {
|
||||||
if (c.getShield() == 0) {
|
if (c.getShield() == 0) {
|
||||||
tgt.addTarget(c);
|
tgt.addTarget(c);
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ public class DiscardEffect extends RevealEffectBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(goodChoices, CardLists.TextLenReverseComparator);
|
Collections.sort(goodChoices, CardLists.TextLenComparator);
|
||||||
|
|
||||||
CardLists.sortCMC(goodChoices);
|
CardLists.sortByCmcDesc(goodChoices);
|
||||||
dChoices.add(goodChoices.get(0));
|
dChoices.add(goodChoices.get(0));
|
||||||
|
|
||||||
return Aggregates.random(goodChoices);
|
return Aggregates.random(goodChoices);
|
||||||
|
|||||||
@@ -505,8 +505,8 @@ public class CardFactorySorceries {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p.isComputer()) {
|
if (p.isComputer()) {
|
||||||
CardLists.sortAttackLowFirst(c);
|
CardLists.sortByPowerAsc(c);
|
||||||
CardLists.sortCMC(c);
|
CardLists.sortByCmcDesc(c);
|
||||||
Collections.reverse(c);
|
Collections.reverse(c);
|
||||||
for (int i = 0; i < sac; i++) {
|
for (int i = 0; i < sac; i++) {
|
||||||
Singletons.getModel().getGame().getAction().sacrifice(c.get(i), card);
|
Singletons.getModel().getGame().getAction().sacrifice(c.get(i), card);
|
||||||
|
|||||||
@@ -1237,7 +1237,7 @@ public class GameAction {
|
|||||||
return crd.hasKeyword("Totem armor");
|
return crd.hasKeyword("Totem armor");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CardLists.sortCMC(list);
|
CardLists.sortByCmcDesc(list);
|
||||||
|
|
||||||
if (list.size() != 0) {
|
if (list.size() != 0) {
|
||||||
final Card crd;
|
final Card crd;
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CardLists.sortAttackLowFirst(attackers);
|
CardLists.sortByPowerAsc(attackers);
|
||||||
int blockersNeeded = this.oppList.size();
|
int blockersNeeded = this.oppList.size();
|
||||||
|
|
||||||
// don't hold back creatures that can't block any of the human creatures
|
// don't hold back creatures that can't block any of the human creatures
|
||||||
@@ -382,7 +382,7 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttack(this.attackers);
|
CardLists.sortByPowerDesc(this.attackers);
|
||||||
|
|
||||||
final List<Card> unblockedAttackers = new ArrayList<Card>();
|
final List<Card> unblockedAttackers = new ArrayList<Card>();
|
||||||
final List<Card> remainingAttackers = new ArrayList<Card>(this.attackers);
|
final List<Card> remainingAttackers = new ArrayList<Card>(this.attackers);
|
||||||
@@ -531,7 +531,7 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
if (bAssault) {
|
if (bAssault) {
|
||||||
System.out.println("Assault");
|
System.out.println("Assault");
|
||||||
CardLists.sortAttack(attackersLeft);
|
CardLists.sortByPowerDesc(attackersLeft);
|
||||||
for (Card attacker : attackersLeft) {
|
for (Card attacker : attackersLeft) {
|
||||||
if (CombatUtil.canAttack(attacker, combat) && this.isEffectiveAttacker(ai, attacker, combat)) {
|
if (CombatUtil.canAttack(attacker, combat) && this.isEffectiveAttacker(ai, attacker, combat)) {
|
||||||
combat.addAttacker(attacker);
|
combat.addAttacker(attacker);
|
||||||
@@ -563,7 +563,7 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exalted) {
|
if (exalted) {
|
||||||
CardLists.sortAttack(this.attackers);
|
CardLists.sortByPowerDesc(this.attackers);
|
||||||
System.out.println("Exalted");
|
System.out.println("Exalted");
|
||||||
this.aiAggression = 6;
|
this.aiAggression = 6;
|
||||||
for (Card attacker : this.attackers) {
|
for (Card attacker : this.attackers) {
|
||||||
@@ -663,7 +663,7 @@ public class AiAttackController {
|
|||||||
// *********************
|
// *********************
|
||||||
boolean doAttritionalAttack = false;
|
boolean doAttritionalAttack = false;
|
||||||
// get list of attackers ordered from low power to high
|
// get list of attackers ordered from low power to high
|
||||||
CardLists.sortAttackLowFirst(this.attackers);
|
CardLists.sortByPowerAsc(this.attackers);
|
||||||
// get player life total
|
// get player life total
|
||||||
int humanLife = opp.getLife();
|
int humanLife = opp.getLife();
|
||||||
// get the list of attackers up to the first blocked one
|
// get the list of attackers up to the first blocked one
|
||||||
@@ -799,7 +799,7 @@ public class AiAttackController {
|
|||||||
int attackNum = 0;
|
int attackNum = 0;
|
||||||
int damage = 0;
|
int damage = 0;
|
||||||
List<Card> attacking = combat.getAttackersByDefenderSlot(combat.getCurrentDefenderNumber());
|
List<Card> attacking = combat.getAttackersByDefenderSlot(combat.getCurrentDefenderNumber());
|
||||||
CardLists.sortAttackLowFirst(attacking);
|
CardLists.sortByPowerAsc(attacking);
|
||||||
for (Card atta : attacking) {
|
for (Card atta : attacking) {
|
||||||
if (attackNum >= blockNum || !CombatUtil.canBeBlocked(attacker, this.blockers)) {
|
if (attackNum >= blockNum || !CombatUtil.canBeBlocked(attacker, this.blockers)) {
|
||||||
damage += ComputerUtilCombat.damageIfUnblocked(atta, opp, null);
|
damage += ComputerUtilCombat.damageIfUnblocked(atta, opp, null);
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ public class AiController {
|
|||||||
discardList.add(landsInHand.get(0));
|
discardList.add(landsInHand.get(0));
|
||||||
hand.remove(landsInHand.get(0));
|
hand.remove(landsInHand.get(0));
|
||||||
} else { // Discard other stuff
|
} else { // Discard other stuff
|
||||||
CardLists.sortCMC(hand);
|
CardLists.sortByCmcDesc(hand);
|
||||||
int numLandsAvailable = numLandsInPlay;
|
int numLandsAvailable = numLandsInPlay;
|
||||||
if (numLandsInHand > 0) {
|
if (numLandsInHand > 0) {
|
||||||
numLandsAvailable++;
|
numLandsAvailable++;
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ public class ComputerUtil {
|
|||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
* @param activate
|
* @param source
|
||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
* @param target
|
* @param target
|
||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
@@ -407,10 +407,8 @@ public class ComputerUtil {
|
|||||||
* a int.
|
* a int.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static List<Card> chooseSacrificeType(final Player ai, final String type, final Card activate, final Card target,
|
public static List<Card> chooseSacrificeType(final Player ai, final String type, final Card source, final Card target, final int amount) {
|
||||||
final int amount) {
|
List<Card> typeList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), source.getController(), source);
|
||||||
List<Card> typeList =
|
|
||||||
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), type.split(";"), activate.getController(), activate);
|
|
||||||
if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
if (ai.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) {
|
||||||
typeList = CardLists.getNotType(typeList, "Creature");
|
typeList = CardLists.getNotType(typeList, "Creature");
|
||||||
}
|
}
|
||||||
@@ -427,7 +425,7 @@ public class ComputerUtil {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (count < amount) {
|
while (count < amount) {
|
||||||
final Card prefCard = ComputerUtil.getCardPreference(ai, activate, "SacCost", typeList);
|
final Card prefCard = ComputerUtil.getCardPreference(ai, source, "SacCost", typeList);
|
||||||
if (prefCard != null) {
|
if (prefCard != null) {
|
||||||
sacList.add(prefCard);
|
sacList.add(prefCard);
|
||||||
typeList.remove(prefCard);
|
typeList.remove(prefCard);
|
||||||
@@ -437,7 +435,7 @@ public class ComputerUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttackLowFirst(typeList);
|
CardLists.sortByPowerAsc(typeList);
|
||||||
|
|
||||||
for (int i = count; i < amount; i++) {
|
for (int i = count; i < amount; i++) {
|
||||||
sacList.add(typeList.get(i));
|
sacList.add(typeList.get(i));
|
||||||
@@ -481,7 +479,7 @@ public class ComputerUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttackLowFirst(typeList);
|
CardLists.sortByPowerAsc(typeList);
|
||||||
final List<Card> exileList = new ArrayList<Card>();
|
final List<Card> exileList = new ArrayList<Card>();
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
@@ -520,7 +518,7 @@ public class ComputerUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttackLowFirst(typeList);
|
CardLists.sortByPowerAsc(typeList);
|
||||||
|
|
||||||
final List<Card> tapList = new ArrayList<Card>();
|
final List<Card> tapList = new ArrayList<Card>();
|
||||||
|
|
||||||
@@ -560,7 +558,7 @@ public class ComputerUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttack(typeList);
|
CardLists.sortByPowerDesc(typeList);
|
||||||
|
|
||||||
final List<Card> untapList = new ArrayList<Card>();
|
final List<Card> untapList = new ArrayList<Card>();
|
||||||
|
|
||||||
@@ -597,7 +595,7 @@ public class ComputerUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortAttackLowFirst(typeList);
|
CardLists.sortByPowerAsc(typeList);
|
||||||
final List<Card> returnList = new ArrayList<Card>();
|
final List<Card> returnList = new ArrayList<Card>();
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
@@ -645,7 +643,7 @@ public class ComputerUtil {
|
|||||||
return sacrificed; // sacrifice none
|
return sacrificed; // sacrifice none
|
||||||
}
|
}
|
||||||
|
|
||||||
CardLists.sortCMC(remaining);
|
CardLists.sortByCmcDesc(remaining);
|
||||||
Collections.reverse(remaining);
|
Collections.reverse(remaining);
|
||||||
|
|
||||||
final int max = Math.min(remaining.size(), amount);
|
final int max = Math.min(remaining.size(), amount);
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ public class ComputerUtilBlock {
|
|||||||
|
|
||||||
// Begin with the attackers that pose the biggest threat
|
// Begin with the attackers that pose the biggest threat
|
||||||
CardLists.sortByEvaluateCreature(firstAttacker);
|
CardLists.sortByEvaluateCreature(firstAttacker);
|
||||||
CardLists.sortAttack(firstAttacker);
|
CardLists.sortByPowerDesc(firstAttacker);
|
||||||
|
|
||||||
// If I don't have any planeswalkers than sorting doesn't really matter
|
// If I don't have any planeswalkers than sorting doesn't really matter
|
||||||
if (defenders.size() == 1) {
|
if (defenders.size() == 1) {
|
||||||
@@ -301,7 +301,7 @@ public class ComputerUtilBlock {
|
|||||||
// if planeswalker will be too difficult to defend don't even bother
|
// if planeswalker will be too difficult to defend don't even bother
|
||||||
for (List<Card> attacker : attackerLists) {
|
for (List<Card> attacker : attackerLists) {
|
||||||
// Begin with the attackers that pose the biggest threat
|
// Begin with the attackers that pose the biggest threat
|
||||||
CardLists.sortAttack(attacker);
|
CardLists.sortByPowerDesc(attacker);
|
||||||
for (final Card c : attacker) {
|
for (final Card c : attacker) {
|
||||||
sortedAttackers.add(c);
|
sortedAttackers.add(c);
|
||||||
}
|
}
|
||||||
@@ -423,7 +423,7 @@ public class ComputerUtilBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (firstStrikeBlockers.size() > 1) {
|
if (firstStrikeBlockers.size() > 1) {
|
||||||
CardLists.sortAttack(firstStrikeBlockers);
|
CardLists.sortByPowerDesc(firstStrikeBlockers);
|
||||||
for (final Card blocker : firstStrikeBlockers) {
|
for (final Card blocker : firstStrikeBlockers) {
|
||||||
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
final int damageNeeded = ComputerUtilCombat.getDamageToKill(attacker)
|
||||||
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
+ ComputerUtilCombat.predictToughnessBonusOfAttacker(attacker, blocker, combat, false);
|
||||||
@@ -803,7 +803,7 @@ public class ComputerUtilBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Begin with the weakest blockers
|
// Begin with the weakest blockers
|
||||||
CardLists.sortAttackLowFirst(ComputerUtilBlock.getBlockersLeft());
|
CardLists.sortByPowerAsc(ComputerUtilBlock.getBlockersLeft());
|
||||||
|
|
||||||
// == 1. choose best blocks first ==
|
// == 1. choose best blocks first ==
|
||||||
combat = ComputerUtilBlock.makeGoodBlocks(ai, combat);
|
combat = ComputerUtilBlock.makeGoodBlocks(ai, combat);
|
||||||
@@ -919,7 +919,7 @@ public class ComputerUtilBlock {
|
|||||||
// very very simple ordering of blockers, sort by evaluate, then sort by attack
|
// very very simple ordering of blockers, sort by evaluate, then sort by attack
|
||||||
//final int damage = attacker.getNetCombatDamage();
|
//final int damage = attacker.getNetCombatDamage();
|
||||||
CardLists.sortByEvaluateCreature(blockers);
|
CardLists.sortByEvaluateCreature(blockers);
|
||||||
CardLists.sortAttack(blockers);
|
CardLists.sortByPowerDesc(blockers);
|
||||||
|
|
||||||
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
|
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
|
||||||
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
|
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
|
||||||
@@ -932,7 +932,7 @@ public class ComputerUtilBlock {
|
|||||||
// very very simple ordering of attackers, sort by evaluate, then sort by attack
|
// very very simple ordering of attackers, sort by evaluate, then sort by attack
|
||||||
//final int damage = attacker.getNetCombatDamage();
|
//final int damage = attacker.getNetCombatDamage();
|
||||||
CardLists.sortByEvaluateCreature(blockers);
|
CardLists.sortByEvaluateCreature(blockers);
|
||||||
CardLists.sortAttack(blockers);
|
CardLists.sortByPowerDesc(blockers);
|
||||||
|
|
||||||
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
|
// TODO: Take total damage, and attempt to maximize killing the greatest evaluation of creatures
|
||||||
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
|
// It's probably generally better to kill the largest creature, but sometimes its better to kill a few smaller ones
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ public class Upkeep extends Phase {
|
|||||||
public void resolve() {
|
public void resolve() {
|
||||||
final List<Card> creatures = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
final List<Card> creatures = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
|
||||||
if (creatures.size() > 0) {
|
if (creatures.size() > 0) {
|
||||||
CardLists.sortAttackLowFirst(creatures);
|
CardLists.sortByPowerAsc(creatures);
|
||||||
final int power = creatures.get(0).getNetAttack();
|
final int power = creatures.get(0).getNetAttack();
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
Singletons.getModel().getMatch().getInput().setInput(
|
Singletons.getModel().getMatch().getInput().setInput(
|
||||||
|
|||||||
@@ -419,7 +419,6 @@ public class DeckLister extends JPanel implements ILocalRepaint {
|
|||||||
this.cmdRowSelect.execute();
|
this.cmdRowSelect.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T extends DeckBase> void editDeck(final Deck d0) {
|
private <T extends DeckBase> void editDeck(final Deck d0) {
|
||||||
switch (this.gametype) {
|
switch (this.gametype) {
|
||||||
case Quest:
|
case Quest:
|
||||||
|
|||||||
Reference in New Issue
Block a user