From b9afbb92096a143bb34de5b64512545f919483ee Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 29 Dec 2019 14:30:34 -0500 Subject: [PATCH] Implemented The Binding of the Titans --- .../mage/cards/t/TheBindingOfTheTitans.java | 119 ++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + 2 files changed, 120 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TheBindingOfTheTitans.java diff --git a/Mage.Sets/src/mage/cards/t/TheBindingOfTheTitans.java b/Mage.Sets/src/mage/cards/t/TheBindingOfTheTitans.java new file mode 100644 index 0000000000..a6c8366987 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheBindingOfTheTitans.java @@ -0,0 +1,119 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.common.SagaAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveEachPlayerEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; +import mage.cards.*; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.Collection; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class TheBindingOfTheTitans extends CardImpl { + + private static final FilterCard filter = new FilterCard("creature or land card from your graveyard"); + + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.CREATURE), + new CardTypePredicate(CardType.LAND) + )); + } + + public TheBindingOfTheTitans(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); + + this.subtype.add(SubType.SAGA); + + // (As this Saga enters and after your draw step, add a lore counter. Sacrifice after III.) + SagaAbility sagaAbility = new SagaAbility(this, SagaChapter.CHAPTER_III); + + // I — Each player puts the top three cards of their library into their graveyard. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_I, new PutTopCardOfLibraryIntoGraveEachPlayerEffect( + 3, TargetController.ANY + ) + ); + + // II — Exile up to two target cards from graveyards. For each creature card exiled this way, you gain 1 life. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_II, SagaChapter.CHAPTER_II, new TheBindingOfTheTitansEffect(), + new TargetCardInGraveyard(0, 2, StaticFilters.FILTER_CARD) + ); + + // III — Return target creature or land card from your graveyard to your hand. + sagaAbility.addChapterEffect( + this, SagaChapter.CHAPTER_III, SagaChapter.CHAPTER_III, + new ReturnFromGraveyardToHandTargetEffect(), new TargetCardInYourGraveyard(filter) + ); + this.addAbility(sagaAbility); + } + + private TheBindingOfTheTitans(final TheBindingOfTheTitans card) { + super(card); + } + + @Override + public TheBindingOfTheTitans copy() { + return new TheBindingOfTheTitans(this); + } +} + +class TheBindingOfTheTitansEffect extends OneShotEffect { + + TheBindingOfTheTitansEffect() { + super(Outcome.Benefit); + staticText = "Exile up to two target cards from graveyards. " + + "For each creature card exiled this way, you gain 1 life."; + } + + private TheBindingOfTheTitansEffect(final TheBindingOfTheTitansEffect effect) { + super(effect); + } + + @Override + public TheBindingOfTheTitansEffect copy() { + return new TheBindingOfTheTitansEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl( + source.getTargets() + .stream() + .map(Target::getTargets) + .flatMap(Collection::stream) + .collect(Collectors.toList()) + ); + player.moveCards(cards, Zone.EXILED, source, game); + int lifeToGain = cards + .getCards(game) + .stream() + .filter(Card::isCreature) + .map(Card::getId) + .map(game.getState()::getZone) + .map(Zone.EXILED::equals) + .mapToInt(b -> b ? 1 : 0) + .sum(); + return player.gainLife(lifeToGain, game, source) > 0; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index aa1d8e6b50..6e68e5ba5c 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -62,6 +62,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Swamp", 252, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Terror of Mount Velus", 295, Rarity.RARE, mage.cards.t.TerrorOfMountVelus.class)); cards.add(new SetCardInfo("The Akroan War", 124, Rarity.RARE, mage.cards.t.TheAkroanWar.class)); + cards.add(new SetCardInfo("The Binding of the Titans", 166, Rarity.UNCOMMON, mage.cards.t.TheBindingOfTheTitans.class)); cards.add(new SetCardInfo("Treeshaker Chimera", 297, Rarity.RARE, mage.cards.t.TreeshakerChimera.class)); cards.add(new SetCardInfo("Underworld Rage-Hound", 163, Rarity.COMMON, mage.cards.u.UnderworldRageHound.class)); cards.add(new SetCardInfo("Underworld Sentinel", 293, Rarity.RARE, mage.cards.u.UnderworldSentinel.class));