public AnotherCreatureEntersTheBattlefield(GameState state) { super( state, "Whenever another creature enters the battlefield under your control, if you control both that creature and this one and both are unpaired, you may pair that creature with this creature for as long as both remain creatures on the battlefield under your control."); SetGenerator thisCreature = ABILITY_SOURCE_OF_THIS; SetGenerator otherCreatures = RelativeComplement.instance(CreaturePermanents.instance(), thisCreature); this.addPattern( new SimpleZoneChangePattern( null, Battlefield.instance(), otherCreatures, You.instance(), false)); SetGenerator thatCreature = NewObjectOf.instance(TriggerZoneChange.instance(This.instance())); SetGenerator youControl = ControlledBy.instance(You.instance()); SetGenerator youControlUnpairedThis = Intersect.instance(youControl, Unpaired.instance(), thisCreature); SetGenerator youControlUnpairedThat = Intersect.instance(youControl, Unpaired.instance(), thatCreature); this.interveningIf = Both.instance(youControlUnpairedThis, youControlUnpairedThat); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.PAIR); part.parameters.put( ContinuousEffectType.Parameter.OBJECT, Union.instance(thisCreature, thatCreature)); SetGenerator youControlCreatureThis = Intersect.instance(CREATURES_YOU_CONTROL, thisCreature); SetGenerator youControlCreatureThat = Intersect.instance(CREATURES_YOU_CONTROL, thatCreature); SetGenerator expires = Not.instance(Both.instance(youControlCreatureThis, youControlCreatureThat)); EventFactory floatingEffect = createFloatingEffect(expires, "Pair this creature with that creature", part); this.addEffect(youMay(floatingEffect)); }
public StreetSpasm(GameState state) { super(state); // Street Spasm deals X damage to target creature without flying you // don't control. SetGenerator creature = CreaturePermanents.instance(); SetGenerator creatureWithoutFlying = RelativeComplement.instance(creature, HasKeywordAbility.instance(Flying.class)); SetGenerator creatureWithoutFlyingYouDontControl = RelativeComplement.instance(creatureWithoutFlying, ControlledBy.instance(You.instance())); SetGenerator target = targetedBy( this.addTarget( creatureWithoutFlyingYouDontControl, "target creature without flying you don't control")); this.addEffect( spellDealDamage( ValueOfX.instance(This.instance()), target, "Street Spasm deals X damage to target creature without flying you don't control.")); // Overload (X)(X)(R)(R) (You may cast this spell for its overload cost. // If you do, change its text by replacing all instances of "target" // with "each.") this.addAbility(new Overload(state, "(X)(X)(R)(R)")); }
public MotherofRunesAbility0(GameState state) { super( state, "(T): Target creature you control gains protection from the color of your choice until end of turn."); this.costsTap = true; SetGenerator target = targetedBy( this.addTarget( Intersect.instance( CreaturePermanents.instance(), ControlledBy.instance(You.instance())), "target creature you control")); EventFactory chooseColor = playerChoose( You.instance(), 1, Identity.fromCollection(Color.allColors()), PlayerInterface.ChoiceType.COLOR, PlayerInterface.ChooseReason.CHOOSE_COLOR, ""); this.addEffect(chooseColor); SetGenerator color = EffectResult.instance(chooseColor); this.addEffect( addProtectionUntilEndOfTurn( target, color, "Target creature gains protection from the color of your choice until end of turn.")); }
public EveryoneTapsForTwoGreen(GameState state) { super(state, "Elves you control have \"(T): Add (G)(G) to your mana pool.\""); SetGenerator elvesYouControl = Intersect.instance( HasSubType.instance(SubType.ELF), ControlledBy.instance(You.instance())); this.addEffectPart(addAbilityToObject(elvesYouControl, TapForTwoGreen.class)); }
public FirstStrikeForAll(GameState state) { super(state, "Creatures you control have first strike."); SetGenerator creaturesYouControl = Intersect.instance( ControlledBy.instance(You.instance()), HasType.instance(Type.CREATURE)); this.addEffectPart(addAbilityToObject(creaturesYouControl, FirstStrike.class)); }
public PrizedElephantAbility0(GameState state) { super(state, "Prized Elephant gets +1/+1 as long as you control a Forest."); this.addEffectPart(modifyPowerAndToughness(This.instance(), +1, +1)); this.canApply = Both.instance( this.canApply, Intersect.instance( ControlledBy.instance(You.instance()), HasSubType.instance(SubType.FOREST))); }
public UntapLands(GameState state) { super(state, "Whenever this creature attacks, untap all lands you control."); this.addPattern(whenThisAttacks()); this.addEffect( untap( Intersect.instance( LandPermanents.instance(), ControlledBy.instance(You.instance())), "Untap all lands you control.")); }
public ManaDenial(GameState state) { super( state, "When a Faerie is championed with Mistbind Clique, tap all lands target player controls."); this.addPattern( whenSomethingIsChampioned(ABILITY_SOURCE_OF_THIS, HasSubType.instance(SubType.FAERIE))); Target target = this.addTarget(Players.instance(), "target player"); this.addEffect( tap( Intersect.instance( LandPermanents.instance(), ControlledBy.instance(targetedBy(target))), "Tap all lands target player controls.")); }
public DarksteelCDA(GameState state) { super( state, "Darksteel Juggernaut's power and toughness are each equal to the number of artifacts you control.", Characteristics.Characteristic.POWER, Characteristics.Characteristic.TOUGHNESS); SetGenerator count = Count.instance( Intersect.instance( ArtifactPermanents.instance(), ControlledBy.instance(You.instance()))); this.addEffectPart(setPowerAndToughness(This.instance(), count, count)); }
public OgreJailbreakerAbility1(GameState state) { super( state, "Ogre Jailbreaker can attack as though it didn't have defender as long as you control a Gate."); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.ATTACK_AS_THOUGH_DOESNT_HAVE_DEFENDER); part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance()); this.addEffectPart(part); SetGenerator youControlAGate = Intersect.instance( ControlledBy.instance(You.instance()), HasSubType.instance(SubType.GATE)); this.canApply = Intersect.instance(this.canApply, youControlAGate); }
@Override public boolean perform(Game game, Event event, Map<Parameter, MagicSet> parameters) { MagicSet cause = parameters.get(Parameter.CAUSE); event.setResult(Empty.set); Set<Color> choices = parameters.get(Parameter.CHOICE).getAll(Color.class); Player player = parameters.get(Parameter.PLAYER).getOne(Player.class); PlayerInterface.ChooseParameters<Color> chooseParameters = new PlayerInterface.ChooseParameters<Color>( 1, 1, new LinkedList<Color>(choices), PlayerInterface.ChoiceType.COLOR, PlayerInterface.ChooseReason.CHOOSE_COLOR); chooseParameters.thisID = cause.getOne(GameObject.class).ID; List<Color> chosenList = player.choose(chooseParameters); if (chosenList.isEmpty()) return false; Color color = chosenList.get(0); Class<? extends Protection> ability = Protection.from(color); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.ADD_ABILITY_TO_OBJECT); part.parameters.put( ContinuousEffectType.Parameter.OBJECT, Intersect.instance( HasColor.instance(Color.WHITE), Intersect.instance( HasType.instance(Type.CREATURE), ControlledBy.instance(You.instance())))); part.parameters.put( ContinuousEffectType.Parameter.ABILITY, Identity.instance(new SimpleAbilityFactory(ability))); Map<Parameter, MagicSet> fceParameters = new HashMap<Parameter, MagicSet>(); fceParameters.put(Parameter.CAUSE, cause); fceParameters.put(Parameter.EFFECT, new MagicSet(part)); Event protection = createEvent( game, "White creatures you control gain protection from the chosen color until end of turn.", EventType.CREATE_FLOATING_CONTINUOUS_EFFECT, fceParameters); protection.perform(event, false); return true; }
public Lavalanche(GameState state) { super(state); Target target = this.addTarget(Players.instance(), "target player"); SetGenerator victims = Union.instance( targetedBy(target), Intersect.instance( CreaturePermanents.instance(), ControlledBy.instance(targetedBy(target)))); this.addEffect( spellDealDamage( ValueOfX.instance(This.instance()), victims, "Lavalanche deals X damage to target player and each creature he or she controls.")); }
public Mutilate(GameState state) { super(state); // All creatures get -1/-1 until end of turn for each Swamp you control. SetGenerator count = Count.instance( Intersect.instance( ControlledBy.instance(You.instance()), HasSubType.instance(SubType.SWAMP))); SetGenerator amount = Subtract.instance(numberGenerator(0), count); this.addEffect( ptChangeUntilEndOfTurn( CreaturePermanents.instance(), amount, amount, "All creatures get -1/-1 until end of turn for each Swamp you control.")); }
public LensofClarityAbility0(GameState state) { super( state, "You may look at the top card of your library and at face-down creatures you don't control."); SetGenerator top = TopCards.instance(1, LibraryOf.instance(You.instance())); SetGenerator morphs = Intersect.instance(FaceDown.instance(), CreaturePermanents.instance()); SetGenerator otherPlayersMorphs = RelativeComplement.instance(morphs, ControlledBy.instance(You.instance())); ContinuousEffect.Part lookAtMorphs = new ContinuousEffect.Part(ContinuousEffectType.LOOK); lookAtMorphs.parameters.put(ContinuousEffectType.Parameter.PLAYER, You.instance()); lookAtMorphs.parameters.put( ContinuousEffectType.Parameter.OBJECT, Union.instance(top, otherPlayersMorphs)); this.addEffectPart(lookAtMorphs); }
public SigardaHostofHeronsAbility1(GameState state) { super( state, "Spells and abilities your opponents control can't cause you to sacrifice permanents."); SimpleEventPattern youSacrificePermanents = new SimpleEventPattern(EventType.SACRIFICE_ONE_PERMANENT); youSacrificePermanents.put( EventType.Parameter.CAUSE, ControlledBy.instance(OpponentsOf.instance(You.instance()), Stack.instance())); youSacrificePermanents.put(EventType.Parameter.PERMANENT, Permanents.instance()); youSacrificePermanents.put(EventType.Parameter.PLAYER, You.instance()); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.PROHIBIT); part.parameters.put( ContinuousEffectType.Parameter.PROHIBITION, Identity.instance(youSacrificePermanents)); this.addEffectPart(part); }
public KrakenoftheStraitsAbility0(GameState state) { super( state, "Creatures with power less than the number of Islands you control can't block Kraken of the Straits."); SetGenerator yourIslands = Intersect.instance( ControlledBy.instance(You.instance()), HasSubType.instance(SubType.ISLAND)); SetGenerator weak = HasPower.instance(Between.instance(numberGenerator(0), Count.instance(yourIslands))); SetGenerator restriction = Intersect.instance(weak, Blocking.instance(This.instance())); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.BLOCKING_RESTRICTION); part.parameters.put( ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(restriction)); this.addEffectPart(part); }
public LandfallShenanigans(GameState state) { super( state, "When Khalni Gem enters the battlefield, return two lands you control to their owner's hand."); this.addPattern(whenThisEntersTheBattlefield()); EventFactory factory = new EventFactory( EventType.PUT_INTO_HAND_CHOICE, "Return two lands you control to their owner's hand"); factory.parameters.put(EventType.Parameter.CAUSE, This.instance()); factory.parameters.put(EventType.Parameter.PLAYER, You.instance()); factory.parameters.put(EventType.Parameter.NUMBER, numberGenerator(2)); factory.parameters.put( EventType.Parameter.CHOICE, Intersect.instance(HasType.instance(Type.LAND), ControlledBy.instance(You.instance()))); this.addEffect(factory); }
public ThisEntersTheBattlefield(GameState state) { super( state, "When this creature enters the battlefield, if you control both this creature and another creature and both are unpaired, you may pair this creature with another unpaired creature you control for as long as both remain creatures on the battlefield under your control."); SetGenerator thisCreature = ABILITY_SOURCE_OF_THIS; this.addPattern( new SimpleZoneChangePattern(null, Battlefield.instance(), thisCreature, false)); SetGenerator otherCreaturesYouControl = RelativeComplement.instance(CREATURES_YOU_CONTROL, thisCreature); SetGenerator youControl = ControlledBy.instance(You.instance()); SetGenerator youControlUnpairedThis = Intersect.instance(youControl, Unpaired.instance(), thisCreature); SetGenerator youControlUnpairedOtherCreatures = Intersect.instance(Unpaired.instance(), otherCreaturesYouControl); this.interveningIf = Both.instance(youControlUnpairedThis, youControlUnpairedOtherCreatures); EventFactory choose = playerChoose( You.instance(), 1, youControlUnpairedOtherCreatures, PlayerInterface.ChoiceType.OBJECTS, REASON, "Choose another unpaired creature you control"); SetGenerator thatCreature = EffectResult.instance(choose); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.PAIR); part.parameters.put( ContinuousEffectType.Parameter.OBJECT, Union.instance(thisCreature, thatCreature)); SetGenerator youControlCreatureThis = Intersect.instance(CREATURES_YOU_CONTROL, thisCreature); SetGenerator youControlCreatureThat = Intersect.instance(CREATURES_YOU_CONTROL, thatCreature); SetGenerator expires = Not.instance(Both.instance(youControlCreatureThis, youControlCreatureThat)); EventFactory floatingEffect = createFloatingEffect(expires, "and pair this creature with the chosen creature.", part); this.addEffect( youMay( sequence(choose, floatingEffect), "You may pair this creature with another unpaired creature you control for as long as both remain creatures on the battlefield under your control.")); }
public DefenderMana(GameState state) { super(state, "(T): Add (G) to your mana pool for each creature with defender you control."); this.costsTap = true; SetGenerator hasDefender = HasKeywordAbility.instance(Defender.class); SetGenerator creaturesWithDefender = Intersect.instance(CreaturePermanents.instance(), hasDefender); SetGenerator youControl = ControlledBy.instance(You.instance()); SetGenerator creaturesWithDefenderYouControl = Intersect.instance(creaturesWithDefender, youControl); EventFactory factory = new EventFactory( EventType.ADD_MANA, "Add (G) to your mana pool for each creature with defender you control"); factory.parameters.put(EventType.Parameter.SOURCE, ABILITY_SOURCE_OF_THIS); factory.parameters.put(EventType.Parameter.MANA, Identity.instance(new ManaPool("G"))); factory.parameters.put( EventType.Parameter.NUMBER, Count.instance(creaturesWithDefenderYouControl)); factory.parameters.put(EventType.Parameter.PLAYER, You.instance()); this.addEffect(factory); }
public TezzeretAgentofBolasAbility2(GameState state) { super( state, -4, "Target player loses X life and you gain X life, where X is twice the number of artifacts you control."); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); SetGenerator X = Multiply.instance( numberGenerator(2), Count.instance( Intersect.instance( ArtifactPermanents.instance(), ControlledBy.instance(You.instance())))); EventFactory loseLife = loseLife(target, X, "Target player loses X life"); EventFactory gainLife = gainLife( You.instance(), X, "and you gain X life, where X is twice the number of artifacts you control."); this.addEffect(simultaneous(loseLife, gainLife)); }
public SylvanPrimordialAbility1(GameState state) { super( state, "When Sylvan Primordial enters the battlefield, for each opponent, destroy target noncreature permanent that player controls. For each permanent destroyed this way, search your library for a Forest card and put that card onto the battlefield tapped. Then shuffle your library."); this.addPattern(whenThisEntersTheBattlefield()); SetGenerator noncreaturePermanents = RelativeComplement.instance(Permanents.instance(), HasType.instance(Type.CREATURE)); SetGenerator legalTargets = Intersect.instance( noncreaturePermanents, ControlledBy.instance(OpponentsOf.instance(You.instance()))); Target t = new SylvanTarget(legalTargets, "target noncreature permanent each oppenent controls"); this.addTarget(t); EventFactory destroy = destroy( targetedBy(t), "For each opponent, destroy target noncreature permanent that player controls."); this.addEffect(destroy); SetGenerator X = Count.instance(NewObjectOf.instance(EffectResult.instance(destroy))); EventFactory search = new EventFactory( EventType.SEARCH_LIBRARY_AND_PUT_INTO, "For each permanent destroyed this way, search your library for a Forest card and put that card onto the battlefield tapped. Then shuffle your library."); search.parameters.put(EventType.Parameter.CAUSE, This.instance()); search.parameters.put(EventType.Parameter.CONTROLLER, You.instance()); search.parameters.put(EventType.Parameter.PLAYER, You.instance()); search.parameters.put(EventType.Parameter.NUMBER, X); search.parameters.put(EventType.Parameter.TAPPED, Empty.instance()); search.parameters.put(EventType.Parameter.TO, Battlefield.instance()); search.parameters.put( EventType.Parameter.TYPE, Identity.instance(HasSubType.instance(SubType.FOREST))); this.addEffect(search); }