From af8ae39f77941341355ee05b82a96454021bbe98 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 27 Jan 2021 11:26:00 -0500 Subject: [PATCH] [KHC] Implemented Tales of the Ancestors --- .../src/mage/cards/t/TalesOfTheAncestors.java | 79 +++++++++++++++++++ .../src/mage/sets/KaldheimCommander.java | 1 + 2 files changed, 80 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TalesOfTheAncestors.java diff --git a/Mage.Sets/src/mage/cards/t/TalesOfTheAncestors.java b/Mage.Sets/src/mage/cards/t/TalesOfTheAncestors.java new file mode 100644 index 0000000000..b75bfa2213 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TalesOfTheAncestors.java @@ -0,0 +1,79 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.ForetellAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TalesOfTheAncestors extends CardImpl { + + public TalesOfTheAncestors(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); + + // Each player with fewer cards in hand than the player with the most cards in hand draws cards equal to the difference. + this.getSpellAbility().addEffect(new TalesOfTheAncestorsEffect()); + + // Foretell {1}{U} + this.addAbility(new ForetellAbility(this, "{1}{U}")); + } + + private TalesOfTheAncestors(final TalesOfTheAncestors card) { + super(card); + } + + @Override + public TalesOfTheAncestors copy() { + return new TalesOfTheAncestors(this); + } +} + +class TalesOfTheAncestorsEffect extends OneShotEffect { + + TalesOfTheAncestorsEffect() { + super(Outcome.Benefit); + staticText = "each player with fewer cards in hand than the player " + + "with the most cards in hand draws cards equal to the difference"; + } + + private TalesOfTheAncestorsEffect(final TalesOfTheAncestorsEffect effect) { + super(effect); + } + + @Override + public TalesOfTheAncestorsEffect copy() { + return new TalesOfTheAncestorsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int cardCount = 0; + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + cardCount = Math.max(cardCount, player.getHand().size()); + } + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + int diff = cardCount - player.getHand().size(); + if (diff > 0) { + player.drawCards(diff, source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/KaldheimCommander.java b/Mage.Sets/src/mage/sets/KaldheimCommander.java index b7af1c5bad..90705eec3b 100644 --- a/Mage.Sets/src/mage/sets/KaldheimCommander.java +++ b/Mage.Sets/src/mage/sets/KaldheimCommander.java @@ -28,6 +28,7 @@ public final class KaldheimCommander extends ExpansionSet { cards.add(new SetCardInfo("Sage of the Beyond", 6, Rarity.RARE, mage.cards.s.SageOfTheBeyond.class)); cards.add(new SetCardInfo("Spectral Deluge", 7, Rarity.RARE, mage.cards.s.SpectralDeluge.class)); cards.add(new SetCardInfo("Stoic Farmer", 5, Rarity.RARE, mage.cards.s.StoicFarmer.class)); + cards.add(new SetCardInfo("Tales of the Ancestors", 8, Rarity.RARE, mage.cards.t.TalesOfTheAncestors.class)); cards.add(new SetCardInfo("Wolverine Riders", 14, Rarity.RARE, mage.cards.w.WolverineRiders.class)); } }