From 6d5e2d929700e1cffb7bb6a06de8333b76f2330b Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 7 Apr 2022 19:42:45 -0400 Subject: [PATCH] [SNC] Implemented Cut of the Profits --- .../src/mage/cards/c/CutOfTheProfits.java | 37 ++++++++ .../src/mage/sets/StreetsOfNewCapenna.java | 1 + .../abilities/keyword/CasualtyAbility.java | 86 +++++++++++++++++++ Utils/keywords.txt | 1 + 4 files changed, 125 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CutOfTheProfits.java create mode 100644 Mage/src/main/java/mage/abilities/keyword/CasualtyAbility.java diff --git a/Mage.Sets/src/mage/cards/c/CutOfTheProfits.java b/Mage.Sets/src/mage/cards/c/CutOfTheProfits.java new file mode 100644 index 0000000000..7d8eba2b48 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CutOfTheProfits.java @@ -0,0 +1,37 @@ +package mage.cards.c; + +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.LoseLifeSourceControllerEffect; +import mage.abilities.keyword.CasualtyAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CutOfTheProfits extends CardImpl { + + public CutOfTheProfits(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}{B}"); + + // Casualty 3 + this.addAbility(new CasualtyAbility(this, 3)); + + // You draw X cards and you lose X life. + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR, "you")); + this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(ManacostVariableValue.REGULAR).concatBy("and")); + } + + private CutOfTheProfits(final CutOfTheProfits card) { + super(card); + } + + @Override + public CutOfTheProfits copy() { + return new CutOfTheProfits(this); + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index ef0b20fabb..f54bf910d6 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -24,6 +24,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Brokers Ascendancy", 170, Rarity.RARE, mage.cards.b.BrokersAscendancy.class)); cards.add(new SetCardInfo("Brokers Charm", 171, Rarity.UNCOMMON, mage.cards.b.BrokersCharm.class)); cards.add(new SetCardInfo("Cabaretti Charm", 173, Rarity.UNCOMMON, mage.cards.c.CabarettiCharm.class)); + cards.add(new SetCardInfo("Cut of the Profits", 72, Rarity.RARE, mage.cards.c.CutOfTheProfits.class)); cards.add(new SetCardInfo("Forest", 270, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 264, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Jetmir's Garden", 250, Rarity.RARE, mage.cards.j.JetmirsGarden.class)); diff --git a/Mage/src/main/java/mage/abilities/keyword/CasualtyAbility.java b/Mage/src/main/java/mage/abilities/keyword/CasualtyAbility.java new file mode 100644 index 0000000000..9132893f7d --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/CasualtyAbility.java @@ -0,0 +1,86 @@ +package mage.abilities.keyword; + +import mage.abilities.Ability; +import mage.abilities.StaticAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.effects.common.CopySourceSpellEffect; +import mage.abilities.effects.common.InfoEffect; +import mage.cards.Card; +import mage.constants.ComparisonType; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.PowerPredicate; +import mage.game.Game; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class CasualtyAbility extends StaticAbility { + + public CasualtyAbility(Card card, int number) { + super(Zone.ALL, new InfoEffect( + "Casualty " + number + " (As you cast this spell, " + + "you may sacrifice a creature with power " + number + + " or greater. When you do, copy this spell.)" + )); + card.getSpellAbility().addCost(new CasualtyCost(number)); + } + + private CasualtyAbility(final CasualtyAbility ability) { + super(ability); + } + + @Override + public CasualtyAbility copy() { + return new CasualtyAbility(this); + } +} + +class CasualtyCost extends SacrificeTargetCost { + + CasualtyCost(int number) { + super(new TargetControlledPermanent(0, 1, makeFilter(number), true)); + this.text = ""; + } + + private CasualtyCost(final CasualtyCost cost) { + super(cost); + } + + @Override + public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) { + if (!super.pay(ability, game, source, controllerId, noMana, costToPay)) { + return false; + } + if (!getPermanents().isEmpty()) { + game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility( + new CopySourceSpellEffect(), false, "when you do, copy this spell" + ), source); + } + return true; + } + + @Override + public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) { + return true; + } + + @Override + public CasualtyCost copy() { + return new CasualtyCost(this); + } + + private static FilterControlledPermanent makeFilter(int number) { + FilterControlledPermanent filter = new FilterControlledCreaturePermanent( + "creature with power " + number + " or greater" + ); + filter.add(new PowerPredicate(ComparisonType.MORE_THAN, number - 1)); + return filter; + } +} diff --git a/Utils/keywords.txt b/Utils/keywords.txt index e752919eeb..2e4e79b1d8 100644 --- a/Utils/keywords.txt +++ b/Utils/keywords.txt @@ -10,6 +10,7 @@ Bloodthirst|number| Bushido|number| Buyback|manaString| Cascade|new| +Casualty|card, number| Changeling|new| Cleave|card, manaString| Compleated|instance|