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 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 TidehollowScullerAbility0(GameState state) { super( state, "When Tidehollow Sculler enters the battlefield, target opponent reveals his or her hand and you choose a nonland card from it. Exile that card."); this.addPattern(whenThisEntersTheBattlefield()); SetGenerator target = targetedBy(this.addTarget(OpponentsOf.instance(You.instance()), "target opponent")); SetGenerator inTargetsHand = InZone.instance(HandOf.instance(target)); EventFactory reveal = new EventFactory(EventType.REVEAL, "Target opponent reveals his or her hand"); reveal.parameters.put(EventType.Parameter.CAUSE, This.instance()); reveal.parameters.put(EventType.Parameter.OBJECT, inTargetsHand); this.addEffect(reveal); EventFactory exile = new EventFactory( EventType.EXILE_CHOICE, "and you choose a nonland card from it. Exile that card."); exile.parameters.put(EventType.Parameter.CAUSE, This.instance()); exile.parameters.put( EventType.Parameter.OBJECT, RelativeComplement.instance(inTargetsHand, HasType.instance(Type.LAND))); exile.parameters.put(EventType.Parameter.PLAYER, You.instance()); exile.setLink(this); this.addEffect(exile); this.getLinkManager().addLinkClass(TidehollowScullerAbility1.class); }
public SurgicalExtraction(GameState state) { super(state); // Choose target card in a graveyard other than a basic land card. SetGenerator inGraveyards = InZone.instance(GraveyardOf.instance(Players.instance())); SetGenerator basicLands = Intersect.instance(HasSuperType.instance(SuperType.BASIC), HasType.instance(Type.LAND)); SetGenerator legalTargets = RelativeComplement.instance(inGraveyards, basicLands); Target t = this.addTarget(legalTargets, "target card in a graveyard other than a basic land card"); // Search its owner's graveyard, hand, and library for all cards with // the same name as that card and exile them. SetGenerator itsOwner = OwnerOf.instance(targetedBy(t)); SetGenerator graveyard = GraveyardOf.instance(itsOwner); SetGenerator hand = HandOf.instance(itsOwner); SetGenerator library = LibraryOf.instance(itsOwner); SetGenerator zones = Union.instance(graveyard, hand, library); EventFactory effect = new EventFactory( EventType.SEARCH_FOR_ALL_AND_PUT_INTO, "Choose target card in a graveyard other than a basic land card. Search its owner's graveyard, hand, and library for all cards with the same name as that card and exile them."); effect.parameters.put(EventType.Parameter.CAUSE, This.instance()); effect.parameters.put(EventType.Parameter.PLAYER, You.instance()); effect.parameters.put(EventType.Parameter.ZONE, zones); effect.parameters.put( EventType.Parameter.TYPE, Identity.instance(HasName.instance(NameOf.instance(targetedBy(t))))); effect.parameters.put(EventType.Parameter.TO, ExileZone.instance()); this.addEffect(effect); // Then that player shuffles his or her library. this.addEffect(shuffleLibrary(targetedBy(t), "Then that player shuffles his or her library.")); }
public MysticRemoraAbility1(GameState state) { super( state, "Whenever an opponent casts a noncreature spell, you may draw a card unless that player pays (4)."); SimpleEventPattern pattern = new SimpleEventPattern(EventType.BECOMES_PLAYED); pattern.put(EventType.Parameter.PLAYER, OpponentsOf.instance(You.instance())); pattern.put( EventType.Parameter.OBJECT, RelativeComplement.instance(Spells.instance(), HasType.instance(Type.CREATURE))); this.addPattern(pattern); SetGenerator thatPlayer = EventParameter.instance( TriggerEvent.instance(This.instance()), EventType.Parameter.PLAYER); EventFactory mayDraw = youMay(drawCards(You.instance(), 1, "Draw a card"), "You may draw a card"); EventFactory pay = new EventFactory(EventType.PAY_MANA, "Pay (4)"); pay.parameters.put(EventType.Parameter.CAUSE, This.instance()); pay.parameters.put(EventType.Parameter.PLAYER, thatPlayer); pay.parameters.put(EventType.Parameter.MANA, Identity.instance(new ManaPool("4"))); this.addEffect( unless(thatPlayer, mayDraw, pay, "You may draw a card unless that player pays (4).")); }
public Breakthrough(GameState state) { super(state); // Draw four cards, then choose X cards in your hand and discard the // rest. this.addEffect(drawCards(You.instance(), 4, "Draw four cards,")); SetGenerator inYourHand = InZone.instance(HandOf.instance(You.instance())); EventFactory choose = playerChoose( You.instance(), ValueOfX.instance(This.instance()), inYourHand, PlayerInterface.ChoiceType.OBJECTS, REASON, "then choose X cards in your hand"); EventFactory discard = new EventFactory(EventType.DISCARD_CARDS, "and discard the rest."); discard.parameters.put(EventType.Parameter.CAUSE, This.instance()); discard.parameters.put( EventType.Parameter.CARD, RelativeComplement.instance(inYourHand, EffectResult.instance(choose))); this.addEffect(sequence(choose, discard)); }
public CountrysideCrusherAbility0(GameState state) { super( state, "At the beginning of your upkeep, reveal the top card of your library. If it's a land card, put it into your graveyard and repeat this process."); this.addPattern(atTheBeginningOfYourUpkeep()); SetGenerator yourLibrary = LibraryOf.instance(You.instance()); SetGenerator toReveal = TopMost.instance( yourLibrary, numberGenerator(1), RelativeComplement.instance( InZone.instance(yourLibrary), HasType.instance(Type.LAND))); EventFactory reveal = new EventFactory( EventType.REVEAL, "Reveal cards from the top of your library until you reveal a nonland card."); reveal.parameters.put(EventType.Parameter.CAUSE, This.instance()); reveal.parameters.put(EventType.Parameter.OBJECT, toReveal); this.addEffect(reveal); SetGenerator landsRevealed = Intersect.instance(toReveal, HasType.instance(Type.LAND)); EventFactory pitch = new EventFactory( EventType.PUT_INTO_GRAVEYARD, "Put all revealed nonland cards into your graveyard."); pitch.parameters.put(EventType.Parameter.CAUSE, This.instance()); pitch.parameters.put(EventType.Parameter.OBJECT, landsRevealed); this.addEffect(pitch); }
public ElspethTirelAbility2(GameState state) { super(state, -5, "Destroy all other permanents except for lands and tokens."); SetGenerator destroy = RelativeComplement.instance( Permanents.instance(), Union.instance(ABILITY_SOURCE_OF_THIS, LandPermanents.instance(), Tokens.instance())); this.addEffect(destroy(destroy, "Destroy all other permanents except for lands and tokens.")); }
public GrantShroud(GameState state) { super(state, "Other Faeries you control have shroud."); SetGenerator faeries = Intersect.instance(HasSubType.instance(SubType.FAERIE), CREATURES_YOU_CONTROL); SetGenerator who = RelativeComplement.instance(faeries, This.instance()); this.addEffectPart(addAbilityToObject(who, org.rnd.jmagic.abilities.keywords.Shroud.class)); }
public Deluge(GameState state) { super(state); SetGenerator affectedCreatures = RelativeComplement.instance( CreaturePermanents.instance(), HasKeywordAbility.instance(Flying.class)); this.addEffect(tap(affectedCreatures, "Tap all creatures without flying.")); }
public DoomBlade(GameState state) { super(state); // Destroy target nonblack creature. SetGenerator nonblackCreatures = RelativeComplement.instance(CreaturePermanents.instance(), HasColor.instance(Color.BLACK)); Target target = this.addTarget(nonblackCreatures, "target nonblack creature"); this.addEffect(destroy(targetedBy(target), "Destroy target nonblack creature.")); }
public EntomberExarchAbility0(GameState state) { super( state, "When Entomber Exarch enters the battlefield, choose one \u2014\n\u2022 Return target creature card from your graveyard to your hand.\n\u2022 Target opponent reveals his or her hand, you choose a noncreature card from it, then that player discards that card."); this.addPattern(whenThisEntersTheBattlefield()); // Return target creature card from your graveyard to your hand { SetGenerator yourYard = GraveyardOf.instance(You.instance()); SetGenerator target = targetedBy( this.addTarget( 1, Intersect.instance(HasType.instance(Type.CREATURE), InZone.instance(yourYard)), "target creature card in your graveyard")); EventFactory move = new EventFactory( EventType.MOVE_OBJECTS, "Return target creature card from your graveyard to your hand"); move.parameters.put(EventType.Parameter.CAUSE, This.instance()); move.parameters.put(EventType.Parameter.TO, HandOf.instance(You.instance())); move.parameters.put(EventType.Parameter.OBJECT, target); this.addEffect(1, move); } // target opponent reveals his or her hand, you choose a noncreature // card from it, then that player discards that card { SetGenerator target = targetedBy(this.addTarget(2, OpponentsOf.instance(You.instance()), "target opponent")); SetGenerator cards = InZone.instance(HandOf.instance(target)); EventType.ParameterMap revealParameters = new EventType.ParameterMap(); revealParameters.put(EventType.Parameter.CAUSE, This.instance()); revealParameters.put(EventType.Parameter.OBJECT, cards); this.addEffect( 2, new EventFactory( EventType.REVEAL, revealParameters, "Target opponent reveals his or her hand.")); SetGenerator choices = RelativeComplement.instance(cards, HasType.instance(Type.CREATURE)); EventType.ParameterMap parameters = new EventType.ParameterMap(); parameters.put(EventType.Parameter.CAUSE, This.instance()); parameters.put(EventType.Parameter.PLAYER, You.instance()); parameters.put(EventType.Parameter.TARGET, target); parameters.put(EventType.Parameter.CHOICE, Identity.instance(choices)); this.addEffect( 2, new EventFactory( EventType.DISCARD_FORCE, parameters, "You choose a noncreature card from it, then that player discards that card.")); } }
public BellowingTanglewurmAbility1(GameState state) { super(state, "Other green creatures you control have intimidate."); SetGenerator otherGreenCreaturesYouControl = RelativeComplement.instance( Intersect.instance(HasColor.instance(Color.GREEN), CREATURES_YOU_CONTROL), This.instance()); this.addEffectPart(addAbilityToObject(otherGreenCreaturesYouControl, Intimidate.class)); }
public MasterofthePearlTridentAbility0(GameState state) { super(state, "Other Merfolk creatures you control get +1/+1 and have islandwalk."); SetGenerator fish = Intersect.instance(HasSubType.instance(SubType.MERFOLK), CREATURES_YOU_CONTROL); SetGenerator otherFish = RelativeComplement.instance(fish, This.instance()); this.addEffectPart(modifyPowerAndToughness(otherFish, +1, +1)); this.addEffectPart( addAbilityToObject( otherFish, org.rnd.jmagic.abilities.keywords.Landwalk.Islandwalk.class)); }
public Mirrorweave(GameState state) { super(state); Target target = this.addTarget( RelativeComplement.instance( CreaturePermanents.instance(), HasSuperType.instance(SuperType.LEGENDARY)), "target nonlegendary creature"); // Each other creature becomes a copy of target nonlegendary creature // until end of turn. ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.COPY_OBJECT); part.parameters.put(ContinuousEffectType.Parameter.ORIGINAL, targetedBy(target)); part.parameters.put( ContinuousEffectType.Parameter.OBJECT, RelativeComplement.instance(CreaturePermanents.instance(), targetedBy(target))); this.addEffect( createFloatingEffect( "Each other creature becomes a copy of target nonlegendary creature until end of turn.", part)); }
public VeteranSwordsmith(GameState state) { super(state); this.setPower(3); this.setToughness(2); SetGenerator soldiers = Intersect.instance(HasSubType.instance(SubType.SOLDIER), CREATURES_YOU_CONTROL); SetGenerator others = RelativeComplement.instance(soldiers, This.instance()); this.addAbility( new org.rnd.jmagic.abilities.StaticPTChange( state, others, "Other Soldier creatures you control", +1, +0, true)); }
public Execute(GameState state) { super( state, "(1)(B), (T), Sacrifice Executioner's Capsule: Destroy target nonblack creature."); this.setManaCost(new ManaPool("1B")); this.costsTap = true; this.addCost(sacrificeThis("Executioner's Capsule")); Target target = this.addTarget( RelativeComplement.instance( CreaturePermanents.instance(), HasColor.instance(Color.BLACK)), "target nonblack creature"); this.addEffect(destroy(targetedBy(target), "Destroy target nonblack creature.")); }
public Glass(GameState state) { super( state, "Whenever this creature becomes the target of a spell or ability for the first time in a turn, counter that spell or ability."); SimpleEventPattern pattern = new SimpleEventPattern(EventType.BECOMES_TARGET); pattern.put( EventType.Parameter.TARGET, RelativeComplement.instance(ABILITY_SOURCE_OF_THIS, TargetedThisTurn.instance())); state.ensureTracker(new TargetedThisTurn.Tracker()); SetGenerator thatSpell = EventParameter.instance( TriggerEvent.instance(This.instance()), EventType.Parameter.OBJECT); this.addEffect(counter(thatSpell, "Counter that spell or ability.")); }
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 DiscipleofBolasAbility0(GameState state) { super( state, "When Disciple of Bolas enters the battlefield, sacrifice another creature. You gain X life and draw X cards, where X is that creature's power."); this.addPattern(whenThisEntersTheBattlefield()); EventFactory sacrifice = sacrifice( You.instance(), 1, RelativeComplement.instance(CREATURES_YOU_CONTROL, ABILITY_SOURCE_OF_THIS), "Sacrifice another creature"); this.addEffect(sacrifice); SetGenerator X = PowerOf.instance(OldObjectOf.instance(EffectResult.instance(sacrifice))); this.addEffect(gainLife(You.instance(), X, "You gain X life")); this.addEffect(drawCards(You.instance(), X, "and draw X cards")); }
public Vendetta(GameState state) { super(state); // Destroy target nonblack creature. It can't be regenerated. SetGenerator target = targetedBy( this.addTarget( RelativeComplement.instance( CreaturePermanents.instance(), HasColor.instance(Color.BLACK)), "target nonblack creature")); this.addEffects( bury(this, target, "Destroy target nonblack creature. It can't be regenerated.")); // You lose life equal to that creature's toughness. this.addEffect( loseLife( You.instance(), ToughnessOf.instance(target), "You lose life equal to that creature's toughness.")); }
public StubbornDenial(GameState state) { super(state); // Counter target noncreature spell unless its controller pays (1). SetGenerator noncreatureSpells = RelativeComplement.instance(Spells.instance(), HasType.instance(Type.CREATURE)); Target target = this.addTarget(noncreatureSpells, "target noncreature spell"); EventFactory softCounter = counterTargetUnlessControllerPays("(1)", target); // Ferocious \u2014 If you control a creature with power 4 or greater, // counter that spell instead. EventFactory hardCounter = counter(targetedBy(target), "Counter target noncreature spell."); this.addEffect( ifThenElse( Ferocious.instance(), hardCounter, softCounter, "Counter target noncreature spell unless its controller pays (1).\n\nFerocious \u2014 If you control a creature with power 4 or greater, counter that spell instead.")); }
public ScionofOona(GameState state) { super(state); this.setPower(1); this.setToughness(1); // Flash this.addAbility(new org.rnd.jmagic.abilities.keywords.Flash(state)); // Flying this.addAbility(new org.rnd.jmagic.abilities.keywords.Flying(state)); // Other Faerie creatures you control get +1/+1. SetGenerator faeries = Intersect.instance(HasSubType.instance(SubType.FAERIE), CREATURES_YOU_CONTROL); SetGenerator who = RelativeComplement.instance(faeries, This.instance()); this.addAbility( new org.rnd.jmagic.abilities.StaticPTChange( state, who, "Other Faerie creatures you control", +1, +1, true)); // Other Faeries you control have shroud. this.addAbility(new GrantShroud(state)); }
public GlintHawkIdolAbility0(GameState state) { super( state, "Whenever another artifact enters the battlefield under your control, you may have Glint Hawk Idol become a 2/2 Bird artifact creature with flying until end of turn."); this.addPattern( new SimpleZoneChangePattern( null, Battlefield.instance(), RelativeComplement.instance(HasType.instance(Type.ARTIFACT), ABILITY_SOURCE_OF_THIS), You.instance(), false)); Animator animate = new Animator(ABILITY_SOURCE_OF_THIS, 2, 2); animate.addSubType(SubType.BIRD); animate.addType(Type.ARTIFACT); animate.addType(Type.CREATURE); animate.addAbility(org.rnd.jmagic.abilities.keywords.Flying.class); this.addEffect( youMay( createFloatingEffect( "Glint Hawk Idol becomes a 2/2 Bird artifact creature with flying until end of turn.", animate.getParts()), "You may have Glint Hawk Idol become a 2/2 Bird artifact creature with flying until end of turn.")); }
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); }