From ce9ac8665cf868add07b7b82629e1eea9df067e0 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 9 Nov 2022 09:37:20 -0500 Subject: [PATCH] [BRO] Implement Razorlash Transmogrant --- .../mage/cards/r/RazorlashTransmogrant.java | 110 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RazorlashTransmogrant.java diff --git a/Mage.Sets/src/mage/cards/r/RazorlashTransmogrant.java b/Mage.Sets/src/mage/cards/r/RazorlashTransmogrant.java new file mode 100644 index 0000000000..f6d80ba8df --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RazorlashTransmogrant.java @@ -0,0 +1,110 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.CantBlockAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.CostAdjuster; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.InfoEffect; +import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldWithCounterEffect; +import mage.abilities.hint.Hint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.Predicates; +import mage.game.Controllable; +import mage.game.Game; +import mage.util.CardUtil; + +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class RazorlashTransmogrant extends CardImpl { + + public RazorlashTransmogrant(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}"); + + this.subtype.add(SubType.ZOMBIE); + this.power = new MageInt(3); + this.toughness = new MageInt(1); + + // Razorlash Transmogrant can't block. + this.addAbility(new CantBlockAbility()); + + // {4}{B}{B}: Return Razorlash Transmogrant from your graveyard to the battlefield with a +1/+1 counter on it. This ability costs {4} less to activate if an opponent controls four or more nonbasic lands. + Ability ability = new SimpleActivatedAbility( + new ReturnSourceFromGraveyardToBattlefieldWithCounterEffect( + CounterType.P1P1.createInstance(), false + ), new ManaCostsImpl<>("{4}{B}{B}") + ); + ability.addEffect(new InfoEffect("This ability costs {4} less to activate if an opponent controls four or more nonbasic lands")); + this.addAbility(ability.setCostAdjuster(RazorlashTransmograntAdjuster.instance).addHint(RazorlashTransmograntHint.instance)); + } + + private RazorlashTransmogrant(final RazorlashTransmogrant card) { + super(card); + } + + @Override + public RazorlashTransmogrant copy() { + return new RazorlashTransmogrant(this); + } +} + +enum RazorlashTransmograntAdjuster implements CostAdjuster { + instance; + private static final FilterPermanent filter = new FilterLandPermanent(); + + static { + filter.add(TargetController.OPPONENT.getControllerPredicate()); + filter.add(Predicates.not(SuperType.BASIC.getPredicate())); + } + + @Override + public void adjustCosts(Ability ability, Game game) { + if (makeMap(game, ability).values().stream().anyMatch(x -> x >= 4)) { + CardUtil.reduceCost(ability, 4); + } + } + + static Map makeMap(Game game, Ability ability) { + return game + .getBattlefield() + .getActivePermanents(filter, ability.getControllerId(), ability, game) + .stream() + .collect(Collectors.toMap( + Controllable::getControllerId, + x -> 1, Integer::sum + )); + } +} + +enum RazorlashTransmograntHint implements Hint { + instance; + + @Override + public String getText(Game game, Ability ability) { + return RazorlashTransmograntAdjuster + .makeMap(game, ability) + .entrySet() + .stream() + .map(entry -> game.getPlayer(entry.getKey()).getLogName() + ": " + entry.getValue() + " nonbasic lands") + .collect(Collectors.joining("
")); + } + + @Override + public RazorlashTransmograntHint copy() { + return this; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 16c354177c..36e48be237 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -208,6 +208,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Queen Kayla bin-Kroog", 218, Rarity.RARE, mage.cards.q.QueenKaylaBinKroog.class)); cards.add(new SetCardInfo("Ravenous Gigamole", 113, Rarity.COMMON, mage.cards.r.RavenousGigamole.class)); cards.add(new SetCardInfo("Raze to the Ground", 149, Rarity.COMMON, mage.cards.r.RazeToTheGround.class)); + cards.add(new SetCardInfo("Razorlash Transmogrant", 122, Rarity.RARE, mage.cards.r.RazorlashTransmogrant.class)); cards.add(new SetCardInfo("Reconstructed Thopter", 242, Rarity.UNCOMMON, mage.cards.r.ReconstructedThopter.class)); cards.add(new SetCardInfo("Recruitment Officer", 23, Rarity.UNCOMMON, mage.cards.r.RecruitmentOfficer.class)); cards.add(new SetCardInfo("Repair and Recharge", 24, Rarity.UNCOMMON, mage.cards.r.RepairAndRecharge.class));