diff --git a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java index 3b3236043c4..7117e94d616 100644 --- a/forge-ai/src/main/java/forge/ai/ability/EffectAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/EffectAi.java @@ -3,6 +3,7 @@ package forge.ai.ability; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; +import forge.ai.ComputerUtil; import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCombat; import forge.ai.SpellAbilityAi; @@ -27,7 +28,7 @@ import java.util.Random; public class EffectAi extends SpellAbilityAi { @Override - protected boolean canPlayAI(Player ai, SpellAbility sa) { + protected boolean canPlayAI(final Player ai, SpellAbility sa) { final Game game = ai.getGame(); final Random r = MyRandom.getRandom(); boolean randomReturn = r.nextFloat() <= .6667; @@ -89,6 +90,26 @@ public class EffectAi extends SpellAbilityAi { || CardLists.getType(ai.getCardsIn(ZoneType.Battlefield), "Planeswalker").isEmpty()) { return false; } + randomReturn = true; + } else if (logic.equals("NarsetRebound")) { + // should be done in Main2, but it might broke for other cards + //if (phase.getPhase().isBefore(PhaseType.MAIN2)) { + // return false; + //} + + // fetch Instant or Sorcery without Rebound and AI has reason to play this turn + // only need count, not the list + final int count = CardLists.count(ai.getCardsIn(ZoneType.Hand), new Predicate() { + @Override + public boolean apply(final Card c) { + return (c.isInstant() || c.isSorcery()) && !c.hasKeyword("Rebound") && ComputerUtil.hasReasonToPlayCardThisTurn(ai, c); + } + }); + + if(count == 0) { + return false; + } + randomReturn = true; } else if (logic.equals("Always")) { randomReturn = true; diff --git a/forge-gui/res/cardsfolder/n/narset_transcendent.txt b/forge-gui/res/cardsfolder/n/narset_transcendent.txt index aed7080cde2..5afd2e81be3 100644 --- a/forge-gui/res/cardsfolder/n/narset_transcendent.txt +++ b/forge-gui/res/cardsfolder/n/narset_transcendent.txt @@ -5,12 +5,11 @@ Loyalty:6 A:AB$ PeekAndReveal | Cost$ AddCounter<1/LOYALTY> | Planeswalker$ True | AILogic$ Main2 | PeekAmount$ 1 | RevealValid$ Card.nonCreature+nonLand | RevealOptional$ True | RememberRevealed$ True | SubAbility$ DBChangeZone | SpellDescription$ Look at the top card of your library. If it's a noncreature, nonland card, you may reveal it and put it into your hand. SVar:DBChangeZone:DB$ ChangeZone | Defined$ TopOfLibrary | Origin$ Library | Destination$ Hand | ConditionDefined$ Remembered | ConditionPresent$ Card.nonCreature+nonLand | ConditionCompare$ EQ1 | SubAbility$ DBCleanupOne SVar:DBCleanupOne:DB$ Cleanup | ClearRemembered$ True -A:AB$Effect | Cost$ SubCounter<2/LOYALTY> | Planeswalker$ True | Name$ Narset Transcendent effect. | Triggers$ AddRebound | SVars$ AddReboundMain,DBCleanupTwo | SpellDescription$ When you cast your next instant or sorcery spell from your hand this turn, it gains rebound. +A:AB$Effect | Cost$ SubCounter<2/LOYALTY> | Planeswalker$ True | AILogic$ NarsetRebound | Stackable$ False | Name$ Narset Transcendent effect. | Triggers$ AddRebound | SVars$ AddReboundMain,DBCleanupTwo | SpellDescription$ When you cast your next instant or sorcery spell from your hand this turn, it gains rebound. SVar:AddRebound:Mode$ SpellCast | ValidCard$ Instant.wasCastFromHand,Sorcery.wasCastFromHand | ValidActivatingPlayer$ You | OneOff$ True | Execute$ AddReboundMain | TriggerZones$ Command | TriggerDescription$ When you cast your next instant or sorcery spell from your hand this turn, it gains rebound. SVar:AddReboundMain:AB$ Pump | Cost$ 0 | Defined$ TriggeredCard| KW$ Rebound | PumpZone$ Stack | SubAbility$ DBCleanupTwo SVar:DBCleanupTwo:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile A:AB$ Effect | Cost$ SubCounter<9/LOYALTY> | Name$ Narset Transcendent emblem | StaticAbilities$ STNarset | Planeswalker$ True | Ultimate$ True | Stackable$ False | Duration$ Permanent | AILogic$ Always | SpellDescription$ You get an emblem with "Your opponents can't cast noncreature spells." SVar:STNarset:Mode$ CantBeCast | ValidCard$ Card.nonCreature | Caster$ Opponent | EffectZone$ Command | Description$ Your opponents can't cast noncreature spells. SVar:Picture:http://www.wizards.com/global/images/magic/general/narset_transcendent.jpg -SVar:RemAIDeck:True Oracle:[+1] Look at the top card of your library. If it's a noncreature, nonland card, you may reveal it and put it into your hand.\n[-2] When you cast your next instant or sorcery spell from your hand this turn, it gains rebound.\n[-9] You get an emblem with "Your opponents can't cast noncreature spells."