diff --git a/Mage.Sets/src/mage/cards/m/MythUnbound.java b/Mage.Sets/src/mage/cards/m/MythUnbound.java new file mode 100644 index 00000000000..28924a6075f --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MythUnbound.java @@ -0,0 +1,113 @@ +package mage.cards.m; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.common.ZoneChangeAllTriggeredAbility; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.CostModificationType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.predicate.other.OwnerPredicate; +import mage.filter.predicate.permanent.CommanderPredicate; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author TheElk801 + */ +public final class MythUnbound extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent(); + + static { + filter.add(new CommanderPredicate()); + filter.add(new OwnerPredicate(TargetController.YOU)); + } + + public MythUnbound(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); + + // Your commander costs {1} less to cast for each time it's been cast from the command zone this game. + this.addAbility(new SimpleStaticAbility( + Zone.BATTLEFIELD, + new MythUnboundCostReductionEffect() + )); + + // Whenever your commander is put into the command zone from anywhere, draw a card. + this.addAbility(new ZoneChangeAllTriggeredAbility( + Zone.BATTLEFIELD, Zone.ALL, Zone.COMMAND, + new DrawCardSourceControllerEffect(1), filter, + "Whenever your commander is put into " + + "the command zone from anywhere, ", false + )); + } + + public MythUnbound(final MythUnbound card) { + super(card); + } + + @Override + public MythUnbound copy() { + return new MythUnbound(this); + } +} + +class MythUnboundCostReductionEffect extends CostModificationEffectImpl { + + MythUnboundCostReductionEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "your commander costs {1} less to cast for each time " + + "it's been cast from the command zone this game"; + } + + MythUnboundCostReductionEffect(MythUnboundCostReductionEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + Ability spellAbility = (SpellAbility) abilityToModify; + if (spellAbility != null) { + Integer amount = (Integer) game.getState().getValue(abilityToModify.getControllerId() + "_castCount"); + if (amount != null && amount > 0) { + CardUtil.reduceCost(spellAbility, amount); + return true; + } + } + return false; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + if (abilityToModify instanceof SpellAbility) { + if (abilityToModify.isControlledBy(source.getControllerId())) { + Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); + if (spell != null) { + return player.getCommandersIds().contains(spell.getId()); + } + } + } + return false; + } + + @Override + public MythUnboundCostReductionEffect copy() { + return new MythUnboundCostReductionEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index c9e1253121f..c090a960a95 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -195,6 +195,7 @@ public final class Commander2018 extends ExpansionSet { cards.add(new SetCardInfo("Mulldrifter", 94, Rarity.UNCOMMON, mage.cards.m.Mulldrifter.class)); cards.add(new SetCardInfo("Myr Battlesphere", 212, Rarity.RARE, mage.cards.m.MyrBattlesphere.class)); cards.add(new SetCardInfo("Myriad Landscape", 269, Rarity.UNCOMMON, mage.cards.m.MyriadLandscape.class)); + cards.add(new SetCardInfo("Myth Unbound", 32, Rarity.RARE, mage.cards.m.MythUnbound.class)); cards.add(new SetCardInfo("Nesting Dragon", 24, Rarity.RARE, mage.cards.n.NestingDragon.class)); cards.add(new SetCardInfo("New Benalia", 270, Rarity.UNCOMMON, mage.cards.n.NewBenalia.class)); cards.add(new SetCardInfo("Night Incarnate", 17, Rarity.RARE, mage.cards.n.NightIncarnate.class));