From 8ef3ebfc3ce39fa26ffd132bb7cc32dbae41d6fc Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 19 Jun 2019 21:10:33 -0400 Subject: [PATCH] Implemented Ajani, Strength of the Pride --- .../mage/cards/a/AjaniStrengthOfThePride.java | 123 ++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2020.java | 1 + .../permanent/token/AjanisPridemateToken.java | 37 ++++++ 3 files changed, 161 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AjaniStrengthOfThePride.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/AjanisPridemateToken.java diff --git a/Mage.Sets/src/mage/cards/a/AjaniStrengthOfThePride.java b/Mage.Sets/src/mage/cards/a/AjaniStrengthOfThePride.java new file mode 100644 index 00000000000..aa8df094e4f --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AjaniStrengthOfThePride.java @@ -0,0 +1,123 @@ +package mage.cards.a; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.ExileAllEffect; +import mage.abilities.effects.common.ExileSourceEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; +import mage.game.permanent.token.AjanisPridemateToken; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class AjaniStrengthOfThePride extends CardImpl { + + public AjaniStrengthOfThePride(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{W}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.AJANI); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(5)); + + // +1: You gain life equal to the number of creatures you control plus the number of planeswalkers you control. + this.addAbility(new LoyaltyAbility(new GainLifeEffect( + AjaniStrengthOfThePrideValue.instance, "You gain life equal to " + + "the number of creatures you control plus the number of planeswalkers you control." + ), 1)); + + // −2: Create a 2/2 white Cat Soldier creature token named Ajani's Pridemate with "Whenever you gain life, put a +1/+1 counter on Ajani's Pridemate." + this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new AjanisPridemateToken()), -2)); + + // 0: If you have at least 15 life more than your starting life total, exile Ajani, Strength of the Pride and each artifact and creature your opponents control. + this.addAbility(new LoyaltyAbility(new AjaniStrengthOfThePrideEffect(), 0)); + } + + private AjaniStrengthOfThePride(final AjaniStrengthOfThePride card) { + super(card); + } + + @Override + public AjaniStrengthOfThePride copy() { + return new AjaniStrengthOfThePride(this); + } +} + +enum AjaniStrengthOfThePrideValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return game.getBattlefield().getAllActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, + sourceAbility.getControllerId(), game + ).size() + game.getBattlefield().getAllActivePermanents( + StaticFilters.FILTER_PERMANENT_PLANESWALKER, + sourceAbility.getControllerId(), game + ).size(); + } + + @Override + public DynamicValue copy() { + return instance; + } + + @Override + public String getMessage() { + return ""; + } +} + +class AjaniStrengthOfThePrideEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterPermanent(); + + static { + filter.add(new ControllerPredicate(TargetController.OPPONENT)); + filter.add(Predicates.or( + new CardTypePredicate(CardType.ARTIFACT), + new CardTypePredicate(CardType.CREATURE) + )); + } + + AjaniStrengthOfThePrideEffect() { + super(Outcome.Benefit); + staticText = "If you have at least 15 life more than your starting life total, " + + "exile {this} and each artifact and creature your opponents control."; + } + + private AjaniStrengthOfThePrideEffect(final AjaniStrengthOfThePrideEffect effect) { + super(effect); + } + + @Override + public AjaniStrengthOfThePrideEffect copy() { + return new AjaniStrengthOfThePrideEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || player.getLife() < game.getLife() + 15) { + return false; + } + new ExileSourceEffect().apply(game, source); + return new ExileAllEffect(filter).apply(game, source); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 72dc4734ad9..f02986d6112 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -27,6 +27,7 @@ public final class CoreSet2020 extends ExpansionSet { this.ratioBoosterMythic = 8; this.maxCardNumberInBooster = 280; + cards.add(new SetCardInfo("Ajani, Strength of the Pride", 2, Rarity.MYTHIC, mage.cards.a.AjaniStrengthOfThePride.class)); cards.add(new SetCardInfo("Angel of Vitality", 4, Rarity.UNCOMMON, mage.cards.a.AngelOfVitality.class)); cards.add(new SetCardInfo("Atemsis, All-Seeing", 46, Rarity.RARE, mage.cards.a.AtemsisAllSeeing.class)); cards.add(new SetCardInfo("Barkhide Troll", 165, Rarity.UNCOMMON, mage.cards.b.BarkhideTroll.class)); diff --git a/Mage/src/main/java/mage/game/permanent/token/AjanisPridemateToken.java b/Mage/src/main/java/mage/game/permanent/token/AjanisPridemateToken.java new file mode 100644 index 00000000000..4a4df6a1502 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/AjanisPridemateToken.java @@ -0,0 +1,37 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.common.GainLifeControllerTriggeredAbility; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; + +/** + * @author LoneFox + */ +public final class AjanisPridemateToken extends TokenImpl { + + public AjanisPridemateToken() { + super("Ajani's Pridemate", "2/2 white Cat Soldier creature token named Ajani's Pridemate with \"Whenever you gain life, put a +1/+1 counter on Ajani's Pridemate.\""); + cardType.add(CardType.CREATURE); + color.setWhite(true); + subtype.add(SubType.CAT); + subtype.add(SubType.SOLDIER); + power = new MageInt(2); + toughness = new MageInt(2); + + this.addAbility(new GainLifeControllerTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false + )); + } + + public AjanisPridemateToken(final AjanisPridemateToken token) { + super(token); + } + + public AjanisPridemateToken copy() { + return new AjanisPridemateToken(this); + } + +}