mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
Add description parameter to BecomesTappedAttachedTriggeredAbility. Use it and DestroyAttachedEffect for some existing cards. Fix several issues with Brink of Disaster. Implement card: Uncontrolled Infestation
This commit is contained in:
parent
05e7eedb65
commit
a6aa484ea0
9 changed files with 118 additions and 168 deletions
|
@ -29,23 +29,16 @@ package mage.sets.fifthedition;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.effects.common.DestroyAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,9 +58,9 @@ public class Blight extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
||||
// When enchanted land becomes tapped, destroy it.
|
||||
this.addAbility(new BlightTriggeredAbility());
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DestroyAttachedEffect("it"), "enchanted land"));
|
||||
}
|
||||
|
||||
public Blight(final Blight card) {
|
||||
|
@ -79,43 +72,3 @@ public class Blight extends CardImpl {
|
|||
return new Blight(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BlightTriggeredAbility extends TriggeredAbilityImpl {
|
||||
BlightTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new DestroyTargetEffect());
|
||||
}
|
||||
|
||||
BlightTriggeredAbility(final BlightTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.TAPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchantment = game.getPermanent(this.sourceId);
|
||||
if (enchantment != null && enchantment.getAttachedTo().equals(event.getTargetId())) {
|
||||
Permanent attached = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (attached != null) {
|
||||
for (Effect e : getEffects()) {
|
||||
e.setTargetPointer(new FixedTarget(attached.getId()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlightTriggeredAbility copy() {
|
||||
return new BlightTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When enchanted land becomes tapped, destroy it.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class Seizures extends CardImpl {
|
|||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// Whenever enchanted creature becomes tapped, Seizures deals 3 damage to that creature's controller unless that player pays {3}.
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new SeizuresEffect(), false));
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new SeizuresEffect(), "enchanted creature"));
|
||||
}
|
||||
|
||||
public Seizures(final Seizures card) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class Insolence extends CardImpl {
|
|||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// Whenever enchanted creature becomes tapped, Insolence deals 2 damage to that creature's controller.
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DamageAttachedControllerEffect(2), false));
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DamageAttachedControllerEffect(2), "enchanted creature"));
|
||||
}
|
||||
|
||||
public Insolence(final Insolence card) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LustForWar extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Whenever enchanted creature becomes tapped, Lust for War deals 3 damage to that creature's controller.
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DamageAttachedControllerEffect(3), false));
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DamageAttachedControllerEffect(3), "enchanted creature"));
|
||||
|
||||
// Enchanted creature attacks each turn if able.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
||||
|
|
81
Mage.Sets/src/mage/sets/scourge/UncontrolledInfestation.java
Normal file
81
Mage.Sets/src/mage/sets/scourge/UncontrolledInfestation.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.scourge;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DestroyAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class UncontrolledInfestation extends CardImpl {
|
||||
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("nonbasic land");
|
||||
|
||||
static{
|
||||
filter.add(Predicates.not(new SupertypePredicate("Basic")));
|
||||
}
|
||||
|
||||
public UncontrolledInfestation(UUID ownerId) {
|
||||
super(ownerId, 108, "Uncontrolled Infestation", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
|
||||
this.expansionSetCode = "SCG";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
// Enchant nonbasic land
|
||||
TargetPermanent auraTarget = new TargetLandPermanent(filter);
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// When enchanted land becomes tapped, destroy it.
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DestroyAttachedEffect("it"), "enchanted land"));
|
||||
}
|
||||
|
||||
public UncontrolledInfestation(final UncontrolledInfestation card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UncontrolledInfestation copy() {
|
||||
return new UncontrolledInfestation(this);
|
||||
}
|
||||
}
|
|
@ -29,11 +29,10 @@ package mage.sets.urzassaga;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||
import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.effects.common.DestroyAttachedEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSourceEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -41,15 +40,9 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,29 +50,29 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public class SpreadingAlgae extends CardImpl {
|
||||
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Swamp");
|
||||
private static final FilterPermanent filter = new FilterPermanent("Swamp");
|
||||
|
||||
static{
|
||||
filter.add(new SubtypePredicate("Swamp"));
|
||||
}
|
||||
|
||||
public SpreadingAlgae(UUID ownerId) {
|
||||
super(ownerId, 274, "Spreading Algae", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{G}");
|
||||
this.expansionSetCode = "USG";
|
||||
this.subtype.add("Aura");
|
||||
|
||||
|
||||
// Enchant Swamp
|
||||
|
||||
TargetPermanent auraTarget = new TargetLandPermanent();
|
||||
TargetPermanent auraTarget = new TargetPermanent(filter);
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// When enchanted land becomes tapped, destroy it.
|
||||
this.addAbility(new SpreadingAlgaeTriggeredAbility(new DestroyTargetEffect()));
|
||||
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DestroyAttachedEffect("it"), "enchanted land"));
|
||||
|
||||
// When Spreading Algae is put into a graveyard from the battlefield, return Spreading Algae to its owner's hand.
|
||||
this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public SpreadingAlgae(final SpreadingAlgae card) {
|
||||
|
@ -91,43 +84,3 @@ public class SpreadingAlgae extends CardImpl {
|
|||
return new SpreadingAlgae(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SpreadingAlgaeTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public SpreadingAlgaeTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
public SpreadingAlgaeTriggeredAbility(final SpreadingAlgaeTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpreadingAlgaeTriggeredAbility copy() {
|
||||
return new SpreadingAlgaeTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.TAPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchant = game.getPermanent(sourceId);
|
||||
if (enchant != null && enchant.getAttachedTo() != null) {
|
||||
if (event.getTargetId().equals(enchant.getAttachedTo())) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(enchant.getAttachedTo()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When enchanted permanent becomes tapped, destroy it.";
|
||||
}
|
||||
|
||||
}
|
|
@ -67,7 +67,7 @@ public class Betrayal extends CardImpl {
|
|||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
// Whenever enchanted creature becomes tapped, you draw a card.
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DrawCardSourceControllerEffect(1), false));
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DrawCardSourceControllerEffect(1), "enchanted creature"));
|
||||
}
|
||||
|
||||
public Betrayal(final Betrayal card) {
|
||||
|
|
|
@ -28,24 +28,19 @@
|
|||
package mage.sets.worldwake;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.effects.common.DestroyAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,7 +48,7 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public class BrinkOfDisaster extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent();
|
||||
private static final FilterPermanent filter = new FilterPermanent("creature or land");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
|
@ -68,12 +63,14 @@ public class BrinkOfDisaster extends CardImpl {
|
|||
|
||||
|
||||
// Enchant creature or land
|
||||
TargetPermanent auraTarget = new TargetPermanent();
|
||||
TargetPermanent auraTarget = new TargetPermanent(filter);
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// When enchanted permanent becomes tapped, destroy it.
|
||||
this.addAbility(new EnchantedBecomesTappedTriggeredAbility(new DestroyTargetEffect()));
|
||||
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new DestroyAttachedEffect("it"), "enchanted permanent"));
|
||||
}
|
||||
|
||||
public BrinkOfDisaster(final BrinkOfDisaster card) {
|
||||
|
@ -85,41 +82,3 @@ public class BrinkOfDisaster extends CardImpl {
|
|||
return new BrinkOfDisaster(this);
|
||||
}
|
||||
}
|
||||
|
||||
class EnchantedBecomesTappedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public EnchantedBecomesTappedTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
public EnchantedBecomesTappedTriggeredAbility(final EnchantedBecomesTappedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnchantedBecomesTappedTriggeredAbility copy() {
|
||||
return new EnchantedBecomesTappedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.TAPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent enchant = game.getPermanent(sourceId);
|
||||
if (enchant != null && enchant.getAttachedTo() != null) {
|
||||
if (event.getTargetId().equals(enchant.getAttachedTo())) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(enchant.getAttachedTo()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When enchanted permanent becomes tapped, destroy it.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,16 +41,20 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class BecomesTappedAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public BecomesTappedAttachedTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
private final String description;
|
||||
|
||||
public BecomesTappedAttachedTriggeredAbility(Effect effect, String description) {
|
||||
this(effect, description, false);
|
||||
}
|
||||
|
||||
public BecomesTappedAttachedTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
public BecomesTappedAttachedTriggeredAbility(Effect effect, String description, boolean isOptional) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public BecomesTappedAttachedTriggeredAbility(final BecomesTappedAttachedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.description = ability.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,6 +79,6 @@ public class BecomesTappedAttachedTriggeredAbility extends TriggeredAbilityImpl
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever enchanted creature becomes tapped, " + super.getRule();
|
||||
return "Whenever " + description + " becomes tapped, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue