mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Make AILogic BirthingPod obey card restrictions specified in AIPreference SacCost (for the purpose of being flexible for not only Birthing Pod but Natural Order and potentially other cards). Now this AI Logic probably needs a better name.
This commit is contained in:
@@ -47,6 +47,7 @@ import forge.game.player.PlayerPredicates;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special logic for individual cards
|
* Special logic for individual cards
|
||||||
@@ -80,20 +81,24 @@ public class SpecialCardAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardCollection listToSac = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES);
|
String definedPref = StringUtils.split(source.getSVar("AIPreference"), "$")[1];
|
||||||
|
String overridePrefix = definedPref.contains(".") ? definedPref + "+" : definedPref + ".";
|
||||||
|
|
||||||
|
CardCollection listToSac = CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), CardPredicates.restriction(definedPref.split(","), ai, source, sa));
|
||||||
listToSac.sort(!sacWorst ? CardLists.CmcComparatorInv : Collections.reverseOrder(CardLists.CmcComparatorInv));
|
listToSac.sort(!sacWorst ? CardLists.CmcComparatorInv : Collections.reverseOrder(CardLists.CmcComparatorInv));
|
||||||
|
|
||||||
for (Card sacCandidate : listToSac) {
|
for (Card sacCandidate : listToSac) {
|
||||||
int sacCMC = sacCandidate.getCMC();
|
int sacCMC = sacCandidate.getCMC();
|
||||||
int goalCMC = sacCMC + 1;
|
int goalCMC = sacCMC + 1;
|
||||||
|
|
||||||
CardCollection listGoal = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES);
|
CardCollection listGoal = CardLists.filter(ai.getCardsIn(ZoneType.Library), CardPredicates.restriction(definedPref.split(","), ai, source, sa));
|
||||||
|
|
||||||
if (!anyCMC) {
|
if (!anyCMC) {
|
||||||
// e.g. Birthing Pod - ensure we have a valid card to upgrade to
|
// e.g. Birthing Pod - ensure we have a valid card to upgrade to
|
||||||
listGoal = CardLists.getValidCards(listGoal, "Creature.cmcEQ" + goalCMC, source.getController(), source);
|
listGoal = CardLists.getValidCards(listGoal, overridePrefix + "cmcEQ" + goalCMC, source.getController(), source);
|
||||||
} else {
|
} else {
|
||||||
// e.g. Natural Order - ensure we're upgrading to something better
|
// e.g. Natural Order - ensure we're upgrading to something better
|
||||||
listGoal = CardLists.getValidCards(listGoal, "Creature.cmcGE" + goalCMC, source.getController(), source);
|
listGoal = CardLists.getValidCards(listGoal, overridePrefix + "cmcGE" + goalCMC, source.getController(), source);
|
||||||
}
|
}
|
||||||
listGoal = CardLists.filter(listGoal, new Predicate<Card>() {
|
listGoal = CardLists.filter(listGoal, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ ManaCost:2 G G
|
|||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
A:SP$ ChangeZone | Cost$ 2 G G Sac<1/Creature.Green/green creature> | Origin$ Library | Destination$ Battlefield | ChangeType$ Creature.Green | ChangeNum$ 1 | AILogic$ BirthingPod.SacWorst+AnyCMCGoal | SpellDescription$ Search your library for a green creature card and put it onto the battlefield. Then shuffle your library.
|
A:SP$ ChangeZone | Cost$ 2 G G Sac<1/Creature.Green/green creature> | Origin$ Library | Destination$ Battlefield | ChangeType$ Creature.Green | ChangeNum$ 1 | AILogic$ BirthingPod.SacWorst+AnyCMCGoal | SpellDescription$ Search your library for a green creature card and put it onto the battlefield. Then shuffle your library.
|
||||||
# AI Preference is needed to make the AI consider the ability. Further constraints are defined by AILogic BirthingPod.
|
# AI Preference is needed to make the AI consider the ability. Further constraints are defined by AILogic BirthingPod.
|
||||||
SVar:AIPreference:SacCost$Creature
|
SVar:AIPreference:SacCost$Creature.Green
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/natural_order.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/natural_order.jpg
|
||||||
Oracle:As an additional cost to cast Natural Order, sacrifice a green creature.\nSearch your library for a green creature card and put it onto the battlefield. Then shuffle your library.
|
Oracle:As an additional cost to cast Natural Order, sacrifice a green creature.\nSearch your library for a green creature card and put it onto the battlefield. Then shuffle your library.
|
||||||
|
|||||||
Reference in New Issue
Block a user