diff --git a/Mage.Sets/src/mage/cards/m/MagnusTheRed.java b/Mage.Sets/src/mage/cards/m/MagnusTheRed.java new file mode 100644 index 0000000000..1b7e680c3b --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MagnusTheRed.java @@ -0,0 +1,107 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.token.SpawnToken; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MagnusTheRed extends CardImpl { + + public MagnusTheRed(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.DEMON); + this.subtype.add(SubType.PRIMARCH); + this.power = new MageInt(4); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Unearthly Power -- Instant and sorcery spells you cast cost {1} less to cast for each creature token you control. + this.addAbility(new SimpleStaticAbility(new MagnusTheRedEffect()) + .withFlavorWord("Unearthly Power") + .addHint(MagnusTheRedEffect.getHint())); + + // Blade of Magnus -- Whenever Magnus the Red deals combat damage to a player, create a 3/3 red Spawn creature token. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility( + new CreateTokenEffect(new SpawnToken()), false + ).withFlavorWord("Blade of Magnus")); + } + + private MagnusTheRed(final MagnusTheRed card) { + super(card); + } + + @Override + public MagnusTheRed copy() { + return new MagnusTheRed(this); + } +} + +class MagnusTheRedEffect extends CostModificationEffectImpl { + + private static final FilterPermanent filter = new FilterControlledCreaturePermanent(); + + static { + filter.add(TokenPredicate.TRUE); + } + + private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter); + private static final Hint hint = new ValueHint("Creature tokens you control", xValue); + + MagnusTheRedEffect() { + super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "instant and sorcery spells you cast cost {1} less to cast for each creature token you control"; + } + + private MagnusTheRedEffect(final MagnusTheRedEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.reduceCost(abilityToModify, xValue.calculate(game, source, this)); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + return abilityToModify instanceof SpellAbility + && abilityToModify.isControlledBy(source.getControllerId()) + && ((SpellAbility) abilityToModify).getCharacteristics(game).isInstantOrSorcery(game) + && game.getCard(abilityToModify.getSourceId()) != null; + } + + @Override + public MagnusTheRedEffect copy() { + return new MagnusTheRedEffect(this); + } + + public static Hint getHint() { + return hint; + } +} diff --git a/Mage.Sets/src/mage/sets/Warhammer40000.java b/Mage.Sets/src/mage/sets/Warhammer40000.java index c19ee7bace..36c047e2ce 100644 --- a/Mage.Sets/src/mage/sets/Warhammer40000.java +++ b/Mage.Sets/src/mage/sets/Warhammer40000.java @@ -149,6 +149,7 @@ public final class Warhammer40000 extends ExpansionSet { cards.add(new SetCardInfo("Lokhust Heavy Destroyer", 38, Rarity.RARE, mage.cards.l.LokhustHeavyDestroyer.class)); cards.add(new SetCardInfo("Lord of Change", 24, Rarity.RARE, mage.cards.l.LordOfChange.class)); cards.add(new SetCardInfo("Lychguard", 39, Rarity.RARE, mage.cards.l.Lychguard.class)); + cards.add(new SetCardInfo("Magnus the Red", 131, Rarity.RARE, mage.cards.m.MagnusTheRed.class)); cards.add(new SetCardInfo("Malanthrope", 132, Rarity.RARE, mage.cards.m.Malanthrope.class)); cards.add(new SetCardInfo("Mandate of Abaddon", 40, Rarity.RARE, mage.cards.m.MandateOfAbaddon.class)); cards.add(new SetCardInfo("Martial Coup", 189, Rarity.RARE, mage.cards.m.MartialCoup.class)); diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index 379eb292bc..0f6f93b69e 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -295,6 +295,7 @@ public enum SubType { PIRATE("Pirate", SubTypeSet.CreatureType), PLANT("Plant", SubTypeSet.CreatureType), PRAETOR("Praetor", SubTypeSet.CreatureType), + PRIMARCH("Primarch", SubTypeSet.CreatureType), PRISM("Prism", SubTypeSet.CreatureType), PROCESSOR("Processor", SubTypeSet.CreatureType), PUREBLOOD("Pureblood", SubTypeSet.CreatureType, true), diff --git a/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java b/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java new file mode 100644 index 0000000000..4811018d8b --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/SpawnToken.java @@ -0,0 +1,27 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * @author TheElk801 + */ +public final class SpawnToken extends TokenImpl { + + public SpawnToken() { + super("Spawn Token", "3/3 red Spawn creature token"); + cardType.add(CardType.CREATURE); + this.subtype.add(SubType.SPAWN); + power = new MageInt(3); + toughness = new MageInt(3); + } + + public SpawnToken(final SpawnToken token) { + super(token); + } + + public SpawnToken copy() { + return new SpawnToken(this); + } +}