From 5160922af6ddf39d89fbef13d33ce47cb4dca009 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 14 Oct 2022 09:26:54 -0400 Subject: [PATCH] [DMC] Implemented Historian's Boon --- .../src/mage/cards/h/HistoriansBoon.java | 102 ++++++++++++++++++ .../mage/sets/DominariaUnitedCommander.java | 1 + .../mage/abilities/common/SagaAbility.java | 5 + 3 files changed, 108 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/h/HistoriansBoon.java diff --git a/Mage.Sets/src/mage/cards/h/HistoriansBoon.java b/Mage.Sets/src/mage/cards/h/HistoriansBoon.java new file mode 100644 index 0000000000..6237f6d37c --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HistoriansBoon.java @@ -0,0 +1,102 @@ +package mage.cards.h; + +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility; +import mage.abilities.common.SagaAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SagaChapter; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledEnchantmentPermanent; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.AngelVigilanceToken; +import mage.game.permanent.token.SoldierToken; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class HistoriansBoon extends CardImpl { + + private static final FilterPermanent filter + = new FilterControlledEnchantmentPermanent("another nontoken enchantment"); + + static { + filter.add(TokenPredicate.FALSE); + } + + public HistoriansBoon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}"); + + // Whenever Historian's Boon or another nontoken enchantment enters the battlefield under your control, create a 1/1 white Soldier creature token. + this.addAbility(new EntersBattlefieldThisOrAnotherTriggeredAbility( + new CreateTokenEffect(new SoldierToken()), filter, false, true + )); + + // Whenever the final chapter of a Saga you control triggers, create a 4/4 white Angel creature token with flying and vigilance. + this.addAbility(new HistoriansBoonTriggeredAbility()); + } + + private HistoriansBoon(final HistoriansBoon card) { + super(card); + } + + @Override + public HistoriansBoon copy() { + return new HistoriansBoon(this); + } +} + +class HistoriansBoonTriggeredAbility extends TriggeredAbilityImpl { + + HistoriansBoonTriggeredAbility() { + super(Zone.BATTLEFIELD, new CreateTokenEffect(new AngelVigilanceToken())); + } + + private HistoriansBoonTriggeredAbility(final HistoriansBoonTriggeredAbility ability) { + super(ability); + } + + @Override + public HistoriansBoonTriggeredAbility copy() { + return new HistoriansBoonTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ABILITY_TRIGGERED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent == null + || !permanent.isControlledBy(getControllerId()) + || !permanent.hasSubtype(SubType.SAGA, game)) { + return false; + } + int maxChapter = CardUtil + .castStream(permanent.getAbilities(game).stream(), SagaAbility.class) + .map(SagaAbility::getMaxChapter) + .mapToInt(SagaChapter::getNumber) + .sum(); + Ability ability = game.getAbility(event.getTargetId(), event.getSourceId()).orElse(null); + return SagaAbility.isFinalAbility(ability, maxChapter); + } + + @Override + public String getRule() { + return "Whenever the final chapter of a Saga you control triggers, " + + "create a 4/4 white Angel creature token with flying and vigilance."; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java index 3cb10eedc9..35399c9e80 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java +++ b/Mage.Sets/src/mage/sets/DominariaUnitedCommander.java @@ -99,6 +99,7 @@ public final class DominariaUnitedCommander extends ExpansionSet { cards.add(new SetCardInfo("Hero's Blade", 186, Rarity.UNCOMMON, mage.cards.h.HerosBlade.class)); cards.add(new SetCardInfo("Hero's Downfall", 112, Rarity.UNCOMMON, mage.cards.h.HerosDownfall.class)); cards.add(new SetCardInfo("Heroes' Podium", 185, Rarity.RARE, mage.cards.h.HeroesPodium.class)); + cards.add(new SetCardInfo("Historian's Boon", 21, Rarity.RARE, mage.cards.h.HistoriansBoon.class)); cards.add(new SetCardInfo("Honor-Worn Shaku", 187, Rarity.UNCOMMON, mage.cards.h.HonorWornShaku.class)); cards.add(new SetCardInfo("Illuna, Apex of Wishes", 154, Rarity.MYTHIC, mage.cards.i.IllunaApexOfWishes.class)); cards.add(new SetCardInfo("Iridian Maelstrom", 12, Rarity.RARE, mage.cards.i.IridianMaelstrom.class)); diff --git a/Mage/src/main/java/mage/abilities/common/SagaAbility.java b/Mage/src/main/java/mage/abilities/common/SagaAbility.java index e520484348..08a06bc651 100644 --- a/Mage/src/main/java/mage/abilities/common/SagaAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SagaAbility.java @@ -139,6 +139,11 @@ public class SagaAbility extends SimpleStaticAbility { public static boolean isChapterAbility(TriggeredAbility ability) { return ability instanceof ChapterTriggeredAbility; } + + public static boolean isFinalAbility(Ability ability, int maxChapter) { + return ability instanceof ChapterTriggeredAbility + && ((ChapterTriggeredAbility) ability).getChapterFrom().getNumber() == maxChapter; + } } class SagaLoreCountersEffect extends OneShotEffect {