- Fixed the AI not using ETB counters.

This commit is contained in:
Sloth
2012-02-19 08:44:05 +00:00
parent cf5372543b
commit 00af08fc16
6 changed files with 37 additions and 5 deletions

View File

@@ -10,6 +10,8 @@ SVar:DBBodySnatcherCleanup:DB$ Cleanup | ClearRemembered$ True
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Graveyard | Execute$ TrigBodySnatcherExileMe | TriggerDescription$ When CARDNAME dies, exile CARDNAME and return target creature card from your graveyard to the battlefield.
SVar:TrigBodySnatcherExileMe:AB$ ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Exile | SubAbility$ DBBodySnatcherReturnCreature
SVar:DBBodySnatcherReturnCreature:DB$ ChangeZone | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature from your graveyard | Origin$ Graveyard | Destination$ Battlefield
SVar:NeedsToPlayVar:Y GE2
SVar:Y:Count$TypeInYourHand.Creature
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/body_snatcher.jpg
End

View File

@@ -8,6 +8,7 @@ T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ Opponent | CheckSVar$ OppCast
SVar:TrigDamageOpp:AB$ DealDamage | Cost$ 0 | Defined$ Opponent | NumDmg$ 2
SVar:YouCast:Count$ThisTurnCast_Card.YouCtrl
SVar:OppCast:Count$ThisTurnCast_Card.YouDontCtrl
SVar:RemRandomDeck:True
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/impatience.jpg
End

View File

@@ -5,8 +5,7 @@ Text:no text
PT:2/2
K:Flash
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigCounter | TriggerDescription$ When CARDNAME enters the battlefield, counter target spell.
SVar:TrigCounter:AB$Counter | Cost$ 0 | TargetType$ Spell | ValidTgts$ Card | TgtPrompt$ Select target spell
SVar:RemAIDeck:True
SVar:TrigCounter:DB$Counter | Cost$ 0 | TargetType$ Spell | ValidTgts$ Card | TgtPrompt$ Select target spell
SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/mystic_snake.jpg
SetInfo:APC|Rare|http://magiccards.info/scans/en/ap/112.jpg

View File

@@ -7,7 +7,6 @@ SVar:DBScentOfNightshadePump:DB$ Pump | ValidTgts$ Creature | TgtPrompt$ Select
SVar:DBScentOfNightshadeCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:ScentOfNightshadeX:Remembered$Amount.Negative
SVar:RemAIDeck:True
SVar:RemRandomDeck:True
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/scent_of_nightshade.jpg
End

View File

@@ -6,7 +6,7 @@ PT:2/2
K:Flash
T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigCounter | TriggerDescription$ When CARDNAME enters the battlefield, counter target activated ability.
T:Mode$ SpellCast | ValidCard$ Card.YouCtrl | Execute$ TrigBounce | TriggerZones$ Battlefield | OptionalDecider$ You | TriggerDescription$ Whenever you cast a spell, you may return CARDNAME to its owner's hand.
SVar:TrigCounter:AB$Counter | Cost$ 0 | TargetType$ Activated | TgtPrompt$ Select target ability | ValidTgts$ Permanent
SVar:TrigCounter:DB$Counter | Cost$ 0 | TargetType$ Activated | TgtPrompt$ Select target ability | ValidTgts$ Permanent
SVar:TrigBounce:AB$ChangeZone | Cost$ 0 | Origin$ Battlefield | Destination$ Hand
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/voidmage_husher.jpg

View File

@@ -27,6 +27,7 @@ import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.card.trigger.Trigger;
/**
* <p>
@@ -110,7 +111,7 @@ public class ComputerAIGeneral implements Computer {
final boolean hasACardGivingHaste = this.hasACardGivingHaste();
// Why is the computer checking if their mana pool is empty?
// If mana pool is not empty try to play anything
if (AllZone.getComputerPlayer().getManaPool().isEmpty()) {
hand = hand.filter(new CardListFilter() {
@Override
@@ -299,6 +300,7 @@ public class ComputerAIGeneral implements Computer {
public boolean addCard(final Card c) {
if (c.isPermanent()
&& c.hasKeyword("Flash")
&& !hasETBTrigger(c)
&& (AllZone.getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer()) || AllZone.getPhaseHandler()
.isBefore(Constant.Phase.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY))) {
return false;
@@ -320,6 +322,35 @@ public class ComputerAIGeneral implements Computer {
return all;
}
/**
* <p>
* hasETBTrigger.
* </p>
*
* @param card
* a {@link forge.Card} object.
* @return a boolean.
*/
public boolean hasETBTrigger(final Card card) {
final ArrayList<Trigger> triggers = card.getTriggers();
for (final Trigger tr : triggers) {
final HashMap<String, String> params = tr.getMapParams();
if (!params.get("Mode").equals("ChangesZone")) {
continue;
}
if (!params.get("Destination").equals("Battlefield")) {
continue;
}
if (params.containsKey("ValidCard") && !params.get("ValidCard").contains("Self")) {
continue;
}
return true;
}
return false;
}
/**
* <p>
* getOtherPhases.