diff --git a/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java new file mode 100644 index 0000000000..ce86f7e659 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java @@ -0,0 +1,106 @@ +package mage.cards.s; + +import mage.MageObject; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.UntapTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterEquipmentPermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ShacklesOfTreachery extends CardImpl { + + public ShacklesOfTreachery(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}"); + + // Gain control of target creature until end of turn. Untap that creature. Until end of turn, it gains haste and "Whenever this creature deals damage, destroy target Equipment attached to it." + this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn)); + this.getSpellAbility().addEffect(new UntapTargetEffect().setText("Untap that creature")); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect( + HasteAbility.getInstance(), Duration.EndOfTurn + ).setText("Until end of turn, it gains haste")); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect( + new ShacklesOfTreacheryTriggeredAbility(), Duration.EndOfTurn + ).setText("and \"Whenever this creature deals damage, destroy target Equipment attached to it.\"")); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + private ShacklesOfTreachery(final ShacklesOfTreachery card) { + super(card); + } + + @Override + public ShacklesOfTreachery copy() { + return new ShacklesOfTreachery(this); + } +} + +class ShacklesOfTreacheryTriggeredAbility extends TriggeredAbilityImpl { + + private enum ShacklesOfTreacheryPredicate implements ObjectSourcePlayerPredicate> { + instance; + + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Permanent permanent = game.getPermanent(input.getSourceId()); + return permanent != null && permanent.getAttachments().contains(input.getObject().getId()); + } + } + + private static final FilterPermanent filter + = new FilterEquipmentPermanent("Equipment attached to this creature"); + + static { + filter.add(ShacklesOfTreacheryPredicate.instance); + } + + ShacklesOfTreacheryTriggeredAbility() { + super(Zone.BATTLEFIELD, new DestroyTargetEffect(), false); + this.addTarget(new TargetPermanent(filter)); + } + + private ShacklesOfTreacheryTriggeredAbility(final ShacklesOfTreacheryTriggeredAbility ability) { + super(ability); + } + + @Override + public ShacklesOfTreacheryTriggeredAbility copy() { + return new ShacklesOfTreacheryTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_CREATURE + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER + || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getSourceId().equals(this.getSourceId()); + } + + @Override + public String getRule() { + return "Whenever this creature deals damage, destroy target Equipment attached to it."; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index cd9d8301e4..d36d58d182 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -250,6 +250,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Scorn Effigy", 246, Rarity.COMMON, mage.cards.s.ScornEffigy.class)); cards.add(new SetCardInfo("Sculptor of Winter", 193, Rarity.COMMON, mage.cards.s.SculptorOfWinter.class)); cards.add(new SetCardInfo("Seize the Spoils", 149, Rarity.COMMON, mage.cards.s.SeizeTheSpoils.class)); + cards.add(new SetCardInfo("Shackles of Treachery", 150, Rarity.COMMON, mage.cards.s.ShacklesOfTreachery.class)); cards.add(new SetCardInfo("Shepherd of the Cosmos", 28, Rarity.UNCOMMON, mage.cards.s.ShepherdOfTheCosmos.class)); cards.add(new SetCardInfo("Shimmerdrift Vale", 267, Rarity.COMMON, mage.cards.s.ShimmerdriftVale.class)); cards.add(new SetCardInfo("Showdown of the Skalds", 229, Rarity.RARE, mage.cards.s.ShowdownOfTheSkalds.class));