public ArrowVolleyTrap(GameState state) { super(state); SetGenerator trapCondition = Intersect.instance(Between.instance(4, null), Count.instance(Attacking.instance())); this.addAbility( new org.rnd.jmagic.abilities.Trap( state, this.getName(), trapCondition, "If four or more creatures are attacking", "(1)(W)")); Target target = this.addTarget(Attacking.instance(), "up to five target attacking creatures"); target.setNumber(1, 5); this.setDivision(Union.instance(numberGenerator(5), Identity.instance("damage"))); EventType.ParameterMap damageParameters = new EventType.ParameterMap(); damageParameters.put(EventType.Parameter.SOURCE, This.instance()); damageParameters.put( EventType.Parameter.TAKER, ChosenTargetsFor.instance(Identity.instance(target), This.instance())); this.addEffect( new EventFactory( EventType.DISTRIBUTE_DAMAGE, damageParameters, "Arrow Volley Trap deals 5 damage divided as you choose among any number of target attacking creatures.")); }
public AgadeemOccultistAbility0(GameState state) { super( state, "(T): Put target creature card from an opponent's graveyard onto the battlefield under your control if its converted mana cost is less than or equal to the number of Allies you control."); this.costsTap = true; SetGenerator creatureCards = HasType.instance(Type.CREATURE); SetGenerator inOpponentsYard = InZone.instance(GraveyardOf.instance(OpponentsOf.instance(You.instance()))); Target t = this.addTarget( Intersect.instance(creatureCards, inOpponentsYard), "target creature card from an opponent's graveyard"); EventFactory move = new EventFactory( EventType.PUT_ONTO_BATTLEFIELD, "Put target creature card from an opponent's graveyard onto the battlefield under your control"); move.parameters.put(EventType.Parameter.CAUSE, This.instance()); move.parameters.put(EventType.Parameter.CONTROLLER, You.instance()); move.parameters.put(EventType.Parameter.OBJECT, targetedBy(t)); SetGenerator lessThanOrEqualNumAllies = Between.instance(null, Count.instance(ALLIES_YOU_CONTROL)); SetGenerator condition = Intersect.instance(ConvertedManaCostOf.instance(targetedBy(t)), lessThanOrEqualNumAllies); EventFactory effect = new EventFactory( EventType.IF_CONDITION_THEN_ELSE, "Put target creature card from an opponent's graveyard onto the battlefield under your control if its converted mana cost is less than or equal to the number of Allies you control."); effect.parameters.put(EventType.Parameter.IF, condition); effect.parameters.put(EventType.Parameter.THEN, Identity.instance(move)); this.addEffect(effect); }
public RuneflareTrap(GameState state) { super(state); // If an opponent drew three or more cards this turn, you may pay (R) // rather than pay Runeflare Trap's mana cost. state.ensureTracker(new CardsDrawn()); SetGenerator opponents = OpponentsOf.instance(You.instance()); SetGenerator cardsDrawn = MaximumPerPlayer.instance(CardsDrawn.class, opponents); SetGenerator trapCondition = Intersect.instance(cardsDrawn, Between.instance(3, null)); this.addAbility( new Trap( state, this.getName(), trapCondition, "If an opponent drew three or more cards this turn", "(R)")); // Runeflare Trap deals damage to target player equal to the number of // cards in that player's hand. Target target = this.addTarget(Players.instance(), "target player"); SetGenerator amount = Count.instance(InZone.instance(HandOf.instance(targetedBy(target)))); this.addEffect( spellDealDamage( amount, targetedBy(target), "Runeflare Trap deals damage to target player equal to the number of cards in that player's hand.")); }
public ElspethTirelAbility0(GameState state) { super(state, +2, "You gain 1 life for each creature you control."); this.addEffect( gainLife( You.instance(), Count.instance(CREATURES_YOU_CONTROL), "You gain 1 life for each creature you control.")); }
public PsychosisCrawlerAbility0(GameState state) { super( state, "Psychosis Crawler's power and toughness are each equal to the number of cards in your hand.", Characteristics.Characteristic.POWER, Characteristics.Characteristic.TOUGHNESS); SetGenerator number = Count.instance(InZone.instance(HandOf.instance(You.instance()))); this.addEffectPart(setPowerAndToughness(This.instance(), number, number)); }
public ConsumingAberrationAbility0(GameState state) { super( state, "Consuming Aberration's power and toughness are each equal to the number of cards in your opponents' graveyards.", Characteristics.Characteristic.POWER, Characteristics.Characteristic.TOUGHNESS); SetGenerator number = Count.instance( InZone.instance(GraveyardOf.instance(OpponentsOf.instance(You.instance())))); this.addEffectPart(setPowerAndToughness(This.instance(), number, number)); }
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 ScrapyardSalvo(GameState state) { super(state); // Scrapyard Salvo deals damage to target player equal to the number of // artifact cards in your graveyard. SetGenerator artifacts = HasType.instance(Type.ARTIFACT); SetGenerator inYourYard = InZone.instance(GraveyardOf.instance(You.instance())); SetGenerator amount = Count.instance(Intersect.instance(artifacts, inYourYard)); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( spellDealDamage( amount, target, "Scrapyard Salvo deals damage to target player equal to the number of artifact cards in your graveyard.")); }
public KembasLegionAbility1(GameState state) { super( state, "Kemba's Legion can block an additional creature for each Equipment attached to Kemba's Legion."); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.CAN_BLOCK_AN_ADDITIONAL_CREATURE); part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance()); part.parameters.put( ContinuousEffectType.Parameter.NUMBER, Count.instance( Intersect.instance( HasSubType.instance(SubType.EQUIPMENT), AttachedTo.instance(This.instance())))); this.addEffectPart(part); }
public DamageTrigger(GameState state) { super( state, "At the beginning of each opponent's upkeep, if that player has two or fewer cards in hand, Hellfire Mongrel deals 2 damage to him or her."); this.addPattern(atTheBeginningOfEachOpponentsUpkeeps()); SetGenerator twoOrFewer = Between.instance(null, 2); SetGenerator upkeep = EventParameter.instance(TriggerEvent.instance(This.instance()), EventType.Parameter.STEP); SetGenerator thatPlayer = OwnerOf.instance(upkeep); SetGenerator cardsInHand = Count.instance(InZone.instance(HandOf.instance(thatPlayer))); this.interveningIf = Intersect.instance(twoOrFewer, cardsInHand); this.addEffect( permanentDealDamage(2, thatPlayer, "Hellfire Mongrel deals 2 damage to that player.")); }
public BlasphemousActAbility0(GameState state) { super(state, "Blasphemous Act costs (1) less to cast for each creature on the battlefield."); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.MANA_COST_REDUCTION); part.parameters.put(ContinuousEffectType.Parameter.OBJECT, This.instance()); part.parameters.put( ContinuousEffectType.Parameter.NUMBER, Count.instance(CreaturePermanents.instance())); part.parameters.put( ContinuousEffectType.Parameter.COST, Identity.instance(new ManaPool("(1)"))); this.addEffectPart(part); // doesn't union with this.canApply since it completely changes when // it applies this.canApply = NonEmpty.instance(); }
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 ZombiePT(GameState state) { super( state, "Soulless One's power and toughness are each equal to the number of Zombies on the battlefield plus the number of Zombie cards in all graveyards.", Characteristics.Characteristic.POWER, Characteristics.Characteristic.TOUGHNESS); SetGenerator aliveAndDead = InZone.instance( Union.instance(Battlefield.instance(), GraveyardOf.instance(Players.instance()))); SetGenerator zombiesAndDeadZombies = Intersect.instance(HasSubType.instance(SubType.ZOMBIE), aliveAndDead); SetGenerator number = Count.instance(zombiesAndDeadZombies); this.addEffectPart(setPowerAndToughness(This.instance(), number, number)); }
public GyreSageAbility1(GameState state) { super(state, "(T): Add (G) to your mana pool for each +1/+1 counter on Gyre Sage."); this.costsTap = true; SetGenerator count = Count.instance( CountersOn.instance(ABILITY_SOURCE_OF_THIS, Counter.CounterType.PLUS_ONE_PLUS_ONE)); EventFactory addMana = new EventFactory( EventType.ADD_MANA, "Add (G) to your mana pool for each +1/+1 counter on Gyre Sage."); addMana.parameters.put(EventType.Parameter.SOURCE, ABILITY_SOURCE_OF_THIS); addMana.parameters.put(EventType.Parameter.MANA, Identity.instance(new ManaPool("(G)"))); addMana.parameters.put(EventType.Parameter.MULTIPLY, count); addMana.parameters.put(EventType.Parameter.PLAYER, You.instance()); this.addEffect(addMana); }
public FinishHim(GameState state) { super( state, "At the beginning of your upkeep, if twenty or more creature cards are in your graveyard, you win the game."); SetGenerator numCreatures = Count.instance( Intersect.instance( HasType.instance(Type.CREATURE), InZone.instance( GraveyardOf.instance(ControllerOf.instance(ABILITY_SOURCE_OF_THIS))))); this.addPattern(atTheBeginningOfYourUpkeep()); this.interveningIf = Intersect.instance(numCreatures, Between.instance(20, null)); this.addEffect(youWinTheGame()); }
public VentSentinelAbility1(GameState state) { super( state, "(1)(R), (T): Vent Sentinel deals damage to target player equal to the number of creatures with defender you control."); this.setManaCost(new ManaPool("(1)(R)")); this.costsTap = true; SetGenerator amount = Count.instance( Intersect.instance( CREATURES_YOU_CONTROL, HasKeywordAbility.instance(Defender.class))); SetGenerator target = targetedBy(this.addTarget(Players.instance(), "target player")); this.addEffect( permanentDealDamage( amount, target, "Vent Sentinel deals damage to target player equal to the number of creatures with defender you control.")); }
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 MadcapSkillsAbility1(GameState state) { super( state, "Enchanted creature gets +3/+0 and can't be blocked except by two or more creatures."); SetGenerator enchantedCreature = EnchantedBy.instance(This.instance()); this.addEffectPart(modifyPowerAndToughness(enchantedCreature, +3, +0)); SetGenerator restriction = Intersect.instance( Count.instance(Blocking.instance(enchantedCreature)), numberGenerator(1)); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.BLOCKING_RESTRICTION); part.parameters.put( ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(restriction)); this.addEffectPart(part); }
public AllyLife(GameState state) { super( state, "Whenever Hagra Diabolist or another Ally enters the battlefield under your control, you may have target player lose life equal to the number of Allies you control."); this.addPattern(allyTrigger()); Target target = this.addTarget(Players.instance(), "target player"); EventFactory lifeFactory = loseLife( targetedBy(target), Count.instance(ALLIES_YOU_CONTROL), "Target player loses life equal to the number of Allies you control"); this.addEffect( youMay( lifeFactory, "You may have target player lose life equal to the number of Allies you control.")); }
public FracturingGust(GameState state) { super(state); // Destroy all artifacts and enchantments. EventFactory destroy = destroy( Union.instance(ArtifactPermanents.instance(), EnchantmentPermanents.instance()), "Destroy artifacts and enchantments."); this.addEffect(destroy); // You gain 2 life for each permanent destroyed this way. SetGenerator X = Count.instance(NewObjectOf.instance(EffectResult.instance(destroy))); this.addEffect( gainLife( You.instance(), Multiply.instance(numberGenerator(2), X), "You gain 2 life for each permanent destroyed this way.")); }
public ShrineofBoundlessGrowthAbility1(GameState state) { super( state, "(T), Sacrifice Shrine of Boundless Growth: Add (1) to your mana pool for each charge counter on Shrine of Boundless Growth."); this.costsTap = true; this.addCost(sacrificeThis("Shrine of Boundless Growth")); SetGenerator counters = Count.instance(CountersOn.instance(ABILITY_SOURCE_OF_THIS, Counter.CounterType.CHARGE)); EventFactory addMana = new EventFactory( EventType.ADD_MANA, "Add (1) to your mana pool for each charge counter on Shrine of Boundless Growth."); addMana.parameters.put(EventType.Parameter.SOURCE, ABILITY_SOURCE_OF_THIS); addMana.parameters.put(EventType.Parameter.MANA, Identity.instance(new ManaPool("(1)"))); addMana.parameters.put(EventType.Parameter.NUMBER, counters); addMana.parameters.put(EventType.Parameter.PLAYER, You.instance()); this.addEffect(addMana); }
public EnsnaringBridgeAbility0(GameState state) { super( state, "Creatures with power greater than the number of cards in your hand can't attack."); SetGenerator numberOfCardsInYourHand = Count.instance(InZone.instance(HandOf.instance(You.instance()))); SetGenerator hasPowerGreater = HasPower.instance( Between.instance( Sum.instance(Union.instance(numberGenerator(1), numberOfCardsInYourHand)), Empty.instance())); SetGenerator restriction = Intersect.instance(Attacking.instance(), hasPowerGreater); ContinuousEffect.Part part = new ContinuousEffect.Part(ContinuousEffectType.ATTACKING_RESTRICTION); part.parameters.put( ContinuousEffectType.Parameter.RESTRICTION, Identity.instance(restriction)); this.addEffectPart(part); }
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); }
public CumulativeUpkeepAbility(GameState state, CumulativeUpkeep parent) { super( state, "At the beginning of your upkeep, if this permanent is on the battlefield, put an age counter on this permanent. Then you may pay its cumulative upkeep cost for each age counter on it. If you don't, sacrifice it."); this.parent = parent; SetGenerator thisCard = ABILITY_SOURCE_OF_THIS; EventFactory cost = parent.getFactory(This.instance()); this.addPattern(atTheBeginningOfYourUpkeep()); this.interveningIf = Intersect.instance(ABILITY_SOURCE_OF_THIS, Permanents.instance()); this.addEffect(putCountersOnThis(1, Counter.CounterType.AGE, "this permanent")); EventFactory payFactory = new EventFactory( EventType.PAY_CUMULATIVE_UPKEEP, (cost.name + " for each age counter on it.")); payFactory.parameters.put(EventType.Parameter.CAUSE, This.instance()); payFactory.parameters.put(EventType.Parameter.EVENT, Identity.instance(cost)); payFactory.parameters.put( EventType.Parameter.NUMBER, Count.instance(CountersOn.instance(thisCard, Counter.CounterType.AGE))); EventFactory mayFactory = youMay(payFactory, "You may " + cost.name + " for each age counter on it."); EventFactory sacFactory = sacrificeThis("it"); EventFactory mainFactory = new EventFactory( EventType.IF_EVENT_THEN_ELSE, ("You may " + cost.name + " for each age counter on it. If you don't, sacrifice it.")); mainFactory.parameters.put(EventType.Parameter.IF, Identity.instance(mayFactory)); mainFactory.parameters.put(EventType.Parameter.ELSE, Identity.instance(sacFactory)); this.addEffect(mainFactory); }