Merge branch 'master' of https://github.com/magefree/mage into copy_constructor_watchers

This commit is contained in:
Ingmar Goudt 2019-12-29 21:05:37 +01:00
commit 998c3be2a5
4 changed files with 266 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -0,0 +1,144 @@
package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.common.SagaAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect;
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.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
import static mage.constants.Outcome.Benefit;
/**
* @author TheElk801
*/
public final class TymaretCallsTheDead extends CardImpl {
public TymaretCallsTheDead(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
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, II Put the top three cards of your library into your graveyard. Then you may exile a creature or enchantment card from your graveyard. If you do, create a 2/2 black Zombie creature token.
sagaAbility.addChapterEffect(
this, SagaChapter.CHAPTER_I, SagaChapter.CHAPTER_II, new TymaretCallsTheDeadFirstEffect()
);
// III You gain X life and scry X, where X is the number of Zombies you control.
sagaAbility.addChapterEffect(this, SagaChapter.CHAPTER_III, new TymaretCallsTheDeadLastEffect());
this.addAbility(sagaAbility);
}
private TymaretCallsTheDead(final TymaretCallsTheDead card) {
super(card);
}
@Override
public TymaretCallsTheDead copy() {
return new TymaretCallsTheDead(this);
}
}
class TymaretCallsTheDeadFirstEffect extends OneShotEffect {
private static final Effect millEffect = new PutTopCardOfLibraryIntoGraveControllerEffect(3);
private static final Effect tokenEffect = new CreateTokenEffect(new ZombieToken());
private static final FilterCard filter = new FilterCard("creature or enchantment card from your graveyard");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.ENCHANTMENT)
));
}
TymaretCallsTheDeadFirstEffect() {
super(Benefit);
staticText = "put the top three cards of your library into your graveyard. " +
"Then you may exile a creature or enchantment card from your graveyard. " +
"If you do, create a 2/2 black Zombie creature token";
}
private TymaretCallsTheDeadFirstEffect(final TymaretCallsTheDeadFirstEffect effect) {
super(effect);
}
@Override
public TymaretCallsTheDeadFirstEffect copy() {
return new TymaretCallsTheDeadFirstEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
millEffect.apply(game, source);
if (player.getGraveyard().count(filter, game) == 0
|| !player.chooseUse(outcome, "Exile a creature or enchantment card from your graveyard?", source, game)) {
return true;
}
TargetCard target = new TargetCardInYourGraveyard(filter);
target.setNotTarget(true);
if (!player.choose(outcome, player.getGraveyard(), target, game)) {
return false;
}
return player.moveCards(game.getCard(target.getFirstTarget()), Zone.EXILED, source, game)
&& tokenEffect.apply(game, source);
}
}
class TymaretCallsTheDeadLastEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent(SubType.ZOMBIE, "");
TymaretCallsTheDeadLastEffect() {
super(Benefit);
staticText = "You gain X life and scry X, where X is the number of Zombies you control.";
}
private TymaretCallsTheDeadLastEffect(final TymaretCallsTheDeadLastEffect effect) {
super(effect);
}
@Override
public TymaretCallsTheDeadLastEffect copy() {
return new TymaretCallsTheDeadLastEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int zombieCount = game.getBattlefield().countAll(filter, source.getControllerId(), game);
if (zombieCount <= 0) {
return true;
}
player.gainLife(zombieCount, game, source);
return player.scry(zombieCount, source, game);
}
}

View file

@ -62,7 +62,9 @@ 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("Tymaret Calls the Dead", 118, Rarity.RARE, mage.cards.t.TymaretCallsTheDead.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));
cards.add(new SetCardInfo("Victory's Envoy", 289, Rarity.RARE, mage.cards.v.VictorysEnvoy.class));

View file

@ -86,7 +86,7 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect {
}
sb.append(target.getTargetName()).append(" and put them onto the battlefield");
} else {
sb.append(target.getTargetName().startsWith("a ") || target.getTargetName().startsWith("an ") ? "" : sb.append("a "))
sb.append(target.getTargetName().startsWith("a ") || target.getTargetName().startsWith("an ") ? "" : "a ")
.append(target.getTargetName())
.append(" and put it onto the battlefield");
}