mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Make CreatureEvaluator implement Function, so that a separate class isn't needed for that.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -235,7 +234,7 @@ public class ComputerUtilCard {
|
||||
* @return the card
|
||||
*/
|
||||
public static Card getBestCreatureAI(final Iterable<Card> list) {
|
||||
return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.fnEvaluateCreature);
|
||||
return Aggregates.itemWithMax(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.creatureEvaluator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +247,7 @@ public class ComputerUtilCard {
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static Card getWorstCreatureAI(final Iterable<Card> list) {
|
||||
return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.fnEvaluateCreature);
|
||||
return Aggregates.itemWithMin(Iterables.filter(list, CardPredicates.Presets.CREATURES), ComputerUtilCard.creatureEvaluator);
|
||||
}
|
||||
|
||||
// This selection rates tokens higher
|
||||
@@ -352,12 +351,6 @@ public class ComputerUtilCard {
|
||||
return getCheapestPermanentAI(list, null, false);
|
||||
}
|
||||
|
||||
public static final Function<Card, Integer> fnEvaluateCreature = new Function<Card, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Card a) {
|
||||
return ComputerUtilCard.evaluateCreature(a);
|
||||
}
|
||||
};
|
||||
public static final Comparator<Card> EvaluateCreatureComparator = new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card a, final Card b) {
|
||||
@@ -389,7 +382,7 @@ public class ComputerUtilCard {
|
||||
}
|
||||
|
||||
public static int evaluateCreatureList(final CardCollectionView list) {
|
||||
return Aggregates.sum(list, fnEvaluateCreature);
|
||||
return Aggregates.sum(list, creatureEvaluator);
|
||||
}
|
||||
|
||||
public static boolean doesCreatureAttackAI(final Player ai, final Card card) {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package forge.ai;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
public class CreatureEvaluator {
|
||||
public class CreatureEvaluator implements Function<Card, Integer> {
|
||||
protected int getEffectivePower(final Card c) {
|
||||
return c.getNetCombatDamage();
|
||||
}
|
||||
@@ -11,6 +13,11 @@ public class CreatureEvaluator {
|
||||
return c.getNetToughness();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(Card c) {
|
||||
return evaluateCreature(c);
|
||||
}
|
||||
|
||||
public int evaluateCreature(final Card c) {
|
||||
int value = 80;
|
||||
if (!c.isToken()) {
|
||||
|
||||
Reference in New Issue
Block a user