From 6aeedac387b395da00f0eaaa8b403fed6c47e09a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 9 Jan 2019 12:43:15 -0500 Subject: [PATCH] Implemented Font of Agonies --- Mage.Sets/src/mage/cards/f/FontOfAgonies.java | 81 +++++++++++++++++++ .../src/mage/sets/RavnicaAllegiance.java | 1 + .../abilities/costs/common/PayLifeCost.java | 8 +- .../main/java/mage/game/events/GameEvent.java | 1 + 4 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/f/FontOfAgonies.java diff --git a/Mage.Sets/src/mage/cards/f/FontOfAgonies.java b/Mage.Sets/src/mage/cards/f/FontOfAgonies.java new file mode 100644 index 0000000000..984192d846 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FontOfAgonies.java @@ -0,0 +1,81 @@ +package mage.cards.f; + +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.RemoveCountersSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FontOfAgonies extends CardImpl { + + public FontOfAgonies(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}"); + + // Whenever you pay life, put that many blood counters on Font of Agonies. + this.addAbility(new FontOfAgoniesTriggeredAbility()); + + // {1}{B}, Remove four blood counters from Font of Agonies: Destroy target creature. + Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new ManaCostsImpl("{1}{B}")); + ability.addCost(new RemoveCountersSourceCost(CounterType.BLOOD.createInstance(4))); + this.addAbility(ability); + } + + private FontOfAgonies(final FontOfAgonies card) { + super(card); + } + + @Override + public FontOfAgonies copy() { + return new FontOfAgonies(this); + } +} + +class FontOfAgoniesTriggeredAbility extends TriggeredAbilityImpl { + + FontOfAgoniesTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.BLOOD.createInstance()), false); + } + + private FontOfAgoniesTriggeredAbility(final FontOfAgoniesTriggeredAbility ability) { + super(ability); + } + + @Override + public FontOfAgoniesTriggeredAbility copy() { + return new FontOfAgoniesTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType().equals(GameEvent.EventType.LIFE_PAID); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getPlayerId().equals(controllerId) && event.getAmount() > 0) { + this.getEffects().clear(); + this.addEffect(new AddCountersSourceEffect(CounterType.BLOOD.createInstance(event.getAmount()))); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever you pay life, put that many blood counters on {this}."; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index e03072c9e9..aa6abe937f 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -74,6 +74,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("End-Raze Forerunners", 124, Rarity.RARE, mage.cards.e.EndRazeForerunners.class)); cards.add(new SetCardInfo("Essence Capture", 37, Rarity.UNCOMMON, mage.cards.e.EssenceCapture.class)); cards.add(new SetCardInfo("Ethereal Absolution", 170, Rarity.RARE, mage.cards.e.EtherealAbsolution.class)); + cards.add(new SetCardInfo("Font of Agonies", 74, Rarity.RARE, mage.cards.f.FontOfAgonies.class)); cards.add(new SetCardInfo("Frenzied Arynx", 173, Rarity.COMMON, mage.cards.f.FrenziedArynx.class)); cards.add(new SetCardInfo("Frilled Mystic", 174, Rarity.UNCOMMON, mage.cards.f.FrilledMystic.class)); cards.add(new SetCardInfo("Gate Colossus", 232, Rarity.UNCOMMON, mage.cards.g.GateColossus.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/PayLifeCost.java b/Mage/src/main/java/mage/abilities/costs/common/PayLifeCost.java index e35de153b5..a2905ea831 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/PayLifeCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/PayLifeCost.java @@ -1,15 +1,16 @@ package mage.abilities.costs.common; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.costs.Cost; import mage.abilities.costs.CostImpl; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.game.Game; +import mage.game.events.GameEvent; + +import java.util.UUID; /** - * * @author BetaSteward_at_googlemail.com */ public class PayLifeCost extends CostImpl { @@ -49,6 +50,9 @@ public class PayLifeCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { int lifeToPayAmount = amount.calculate(game, ability, null); this.paid = game.getPlayer(controllerId).loseLife(lifeToPayAmount, game, false) == lifeToPayAmount; + if (paid) { + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIFE_PAID, controllerId, sourceId, controllerId, lifeToPayAmount)); + } return paid; } diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 622ee3eadd..edff7314ab 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -221,6 +221,7 @@ public class GameEvent implements Serializable { PLANESWALK, PLANESWALKED, PAID_CUMULATIVE_UPKEEP, DIDNT_PAY_CUMULATIVE_UPKEEP, + LIFE_PAID, //permanent events ENTERS_THE_BATTLEFIELD_SELF, /* 616.1a If any of the replacement and/or prevention effects are self-replacement effects (see rule 614.15), one of them must be chosen. If not, proceed to rule 616.1b. */