diff --git a/Mage.Sets/src/mage/cards/t/TheEverChangingDane.java b/Mage.Sets/src/mage/cards/t/TheEverChangingDane.java new file mode 100644 index 0000000000..73584199f5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheEverChangingDane.java @@ -0,0 +1,103 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; +import mage.util.functions.CopyApplier; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TheEverChangingDane extends CardImpl { + + public TheEverChangingDane(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.SHAPESHIFTER); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // {1}, Sacrifice another creature: The Ever-Changing 'Dane becomes a copy of the sacrificed creature, except it has this ability. + this.addAbility(makeAbility()); + } + + private TheEverChangingDane(final TheEverChangingDane card) { + super(card); + } + + @Override + public TheEverChangingDane copy() { + return new TheEverChangingDane(this); + } + + static Ability makeAbility() { + Ability ability = new SimpleActivatedAbility(new TheEverChangingDaneEffect(), new GenericManaCost(1)); + ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE)); + return ability; + } +} + +class TheEverChangingDaneEffect extends OneShotEffect { + + TheEverChangingDaneEffect() { + super(Outcome.Benefit); + staticText = "{this} becomes a copy of the sacrificed creature, except it has this ability"; + } + + private TheEverChangingDaneEffect(final TheEverChangingDaneEffect effect) { + super(effect); + } + + @Override + public TheEverChangingDaneEffect copy() { + return new TheEverChangingDaneEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent == null) { + return false; + } + Permanent sacrificedPermanent = CardUtil + .castStream(source.getCosts().stream(), SacrificeTargetCost.class) + .filter(Objects::nonNull) + .map(SacrificeTargetCost::getPermanents) + .flatMap(Collection::stream) + .findAny() + .orElse(null); + if (sacrificedPermanent == null) { + return false; + } + game.copyPermanent(sacrificedPermanent, permanent.getId(), source, new TheEverChangingDaneCopyApplier()); + return true; + } +} + +class TheEverChangingDaneCopyApplier extends CopyApplier { + + @Override + public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) { + blueprint.getAbilities().add(TheEverChangingDane.makeAbility()); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java index 72c12a9f9b..a1058de953 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java +++ b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java @@ -187,6 +187,7 @@ public final class DominariaUnitedCommander extends ExpansionSet { cards.add(new SetCardInfo("Terramorphic Expanse", 239, Rarity.COMMON, mage.cards.t.TerramorphicExpanse.class)); cards.add(new SetCardInfo("Teshar, Ancestor's Apostle", 105, Rarity.RARE, mage.cards.t.TesharAncestorsApostle.class)); cards.add(new SetCardInfo("The Circle of Loyalty", 98, Rarity.MYTHIC, mage.cards.t.TheCircleOfLoyalty.class)); + cards.add(new SetCardInfo("The Ever-Changing 'Dane", 30, Rarity.RARE, mage.cards.t.TheEverChangingDane.class)); cards.add(new SetCardInfo("The Mana Rig", 28, Rarity.MYTHIC, mage.cards.t.TheManaRig.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("The Mana Rig", 80, Rarity.MYTHIC, mage.cards.t.TheManaRig.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("The Reaver Cleaver", 8, Rarity.RARE, mage.cards.t.TheReaverCleaver.class, NON_FULL_USE_VARIOUS));