diff --git a/Mage.Sets/src/mage/cards/a/AshnodTheUncaring.java b/Mage.Sets/src/mage/cards/a/AshnodTheUncaring.java new file mode 100644 index 0000000000..1bc871a5bf --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AshnodTheUncaring.java @@ -0,0 +1,102 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.SacrificeCost; +import mage.abilities.effects.common.CopyStackObjectEffect; +import mage.abilities.keyword.DeathtouchAbility; +import mage.abilities.mana.ActivatedManaAbilityImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.StackAbility; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AshnodTheUncaring extends CardImpl { + + public AshnodTheUncaring(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{B}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ARTIFICER); + this.power = new MageInt(1); + this.toughness = new MageInt(4); + + // Deathtouch + this.addAbility(DeathtouchAbility.getInstance()); + + // Whenever you activate an ability of an artifact or creature that isn't a mana ability, if one or more permanents were sacrificed to activate it, you may copy that ability. You may choose new targets for the copy. + this.addAbility(new AshnodTheUncaringTriggeredAbility()); + } + + private AshnodTheUncaring(final AshnodTheUncaring card) { + super(card); + } + + @Override + public AshnodTheUncaring copy() { + return new AshnodTheUncaring(this); + } +} + +class AshnodTheUncaringTriggeredAbility extends TriggeredAbilityImpl { + + AshnodTheUncaringTriggeredAbility() { + super(Zone.BATTLEFIELD, new CopyStackObjectEffect(), true); + } + + private AshnodTheUncaringTriggeredAbility(final AshnodTheUncaringTriggeredAbility ability) { + super(ability); + } + + @Override + public AshnodTheUncaringTriggeredAbility copy() { + return new AshnodTheUncaringTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ACTIVATED_ABILITY; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!isControlledBy(event.getPlayerId())) { + return false; + } + StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId()); + if (stackAbility == null + || stackAbility.getStackAbility() instanceof ActivatedManaAbilityImpl + || stackAbility + .getStackAbility() + .getCosts() + .stream() + .noneMatch(SacrificeCost.class::isInstance)) { + return false; + } + Permanent permanent = game.getPermanent(stackAbility.getSourceId()); + if (permanent == null || (!permanent.isArtifact(game) && !permanent.isCreature(game))) { + return false; + } + this.getEffects().setValue("stackObject", stackAbility); + return true; + } + + @Override + public String getRule() { + return "Whenever you activate an ability of an artifact or creature that isn't a mana ability, " + + "if one or more permanents were sacrificed to activate it, " + + "you may copy that ability. You may choose new targets for the copy."; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java b/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java index a557cebb3b..95bd3ad46b 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWarCommander.java @@ -26,6 +26,7 @@ public final class TheBrothersWarCommander extends ExpansionSet { cards.add(new SetCardInfo("Arcane Signet", 132, Rarity.COMMON, mage.cards.a.ArcaneSignet.class)); cards.add(new SetCardInfo("Armix, Filigree Thrasher", 103, Rarity.UNCOMMON, mage.cards.a.ArmixFiligreeThrasher.class)); cards.add(new SetCardInfo("Ash Barrens", 174, Rarity.COMMON, mage.cards.a.AshBarrens.class)); + cards.add(new SetCardInfo("Ashnod the Uncaring", 4, Rarity.MYTHIC, mage.cards.a.AshnodTheUncaring.class)); cards.add(new SetCardInfo("Audacious Reshapers", 112, Rarity.RARE, mage.cards.a.AudaciousReshapers.class)); cards.add(new SetCardInfo("Austere Command", 69, Rarity.RARE, mage.cards.a.AustereCommand.class)); cards.add(new SetCardInfo("Azorius Chancery", 175, Rarity.UNCOMMON, mage.cards.a.AzoriusChancery.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/SacrificeCost.java b/Mage/src/main/java/mage/abilities/costs/SacrificeCost.java new file mode 100644 index 0000000000..ba91d5244f --- /dev/null +++ b/Mage/src/main/java/mage/abilities/costs/SacrificeCost.java @@ -0,0 +1,9 @@ +package mage.abilities.costs; + +/** + * An interface to identify costs that sacrifice permanents + * + * @author TheElk801 + */ +public interface SacrificeCost extends Cost { +} diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java index 31632393a0..4d18521048 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAllCost.java @@ -1,23 +1,23 @@ - package mage.abilities.costs.common; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.Cost; import mage.abilities.costs.CostImpl; +import mage.abilities.costs.SacrificeCost; import mage.constants.AbilityType; import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** - * * @author LevelX2 */ -public class SacrificeAllCost extends CostImpl { +public class SacrificeAllCost extends CostImpl implements SacrificeCost { private final FilterPermanent filter; private final List permanents = new ArrayList<>(); diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachedCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachedCost.java index 6deb5b7e04..fb04bb46fb 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachedCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachedCost.java @@ -1,18 +1,18 @@ - package mage.abilities.costs.common; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; import mage.abilities.costs.CostImpl; +import mage.abilities.costs.SacrificeCost; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author L_J (based on BetaSteward_at_googlemail.com) */ -public class SacrificeAttachedCost extends CostImpl { +public class SacrificeAttachedCost extends CostImpl implements SacrificeCost { public SacrificeAttachedCost() { this.text = "Sacrifice enchanted creature"; diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachmentCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachmentCost.java index c037e07f24..2f2ddd697d 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachmentCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeAttachmentCost.java @@ -2,6 +2,7 @@ package mage.abilities.costs.common; import mage.abilities.Ability; import mage.abilities.costs.Cost; +import mage.abilities.costs.SacrificeCost; import mage.abilities.costs.UseAttachedCost; import mage.game.Game; import mage.game.permanent.Permanent; @@ -11,7 +12,7 @@ import java.util.UUID; /** * @author TheElk801 */ -public class SacrificeAttachmentCost extends UseAttachedCost { +public class SacrificeAttachmentCost extends UseAttachedCost implements SacrificeCost { public SacrificeAttachmentCost() { super(); diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeSourceCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeSourceCost.java index 7c3439808a..a3d6d8b811 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeSourceCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeSourceCost.java @@ -1,18 +1,19 @@ package mage.abilities.costs.common; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; import mage.abilities.costs.CostImpl; +import mage.abilities.costs.SacrificeCost; import mage.game.Game; import mage.game.permanent.Permanent; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ -public class SacrificeSourceCost extends CostImpl { +public class SacrificeSourceCost extends CostImpl implements SacrificeCost { public SacrificeSourceCost() { this.text = "sacrifice {this}"; diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java index 8f790667d9..e98e42ed53 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeTargetCost.java @@ -4,6 +4,7 @@ import mage.abilities.Ability; import mage.abilities.ActivatedAbilityImpl; import mage.abilities.costs.Cost; import mage.abilities.costs.CostImpl; +import mage.abilities.costs.SacrificeCost; import mage.constants.AbilityType; import mage.constants.Outcome; import mage.filter.common.FilterControlledPermanent; @@ -19,7 +20,7 @@ import java.util.UUID; /** * @author BetaSteward_at_googlemail.com */ -public class SacrificeTargetCost extends CostImpl { +public class SacrificeTargetCost extends CostImpl implements SacrificeCost { private final List permanents = new ArrayList<>(); diff --git a/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java b/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java index 26839ceb90..41e341bcd6 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/SacrificeXTargetCost.java @@ -2,6 +2,7 @@ package mage.abilities.costs.common; import mage.abilities.Ability; import mage.abilities.costs.Cost; +import mage.abilities.costs.SacrificeCost; import mage.abilities.costs.VariableCostImpl; import mage.abilities.costs.VariableCostType; import mage.filter.Filter; @@ -12,7 +13,7 @@ import mage.target.common.TargetControlledPermanent; /** * @author LevelX2 */ -public class SacrificeXTargetCost extends VariableCostImpl { +public class SacrificeXTargetCost extends VariableCostImpl implements SacrificeCost { protected final FilterControlledPermanent filter; private final int minValue;