mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
replaced some instances of library.remove
This commit is contained in:
parent
53f2c0ee69
commit
3ea7f5df3b
12 changed files with 201 additions and 356 deletions
|
@ -78,7 +78,7 @@ class AchHansRunEffect extends OneShotEffect {
|
|||
if (!controller.searchLibrary(target, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class CongregationAtDawnEffect extends OneShotEffect {
|
|||
if (!target.getTargets().isEmpty()) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = controller.getLibrary().remove(cardId, game);
|
||||
Card card = controller.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
}
|
||||
controller.revealCards(sourceObject.getName(), revealed, game);
|
||||
|
|
|
@ -63,7 +63,7 @@ class DistantMemoriesEffect extends OneShotEffect {
|
|||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.moveCards(card, Zone.EXILED, source, game);
|
||||
controller.shuffleLibrary(source, game);
|
||||
|
|
|
@ -8,20 +8,20 @@ import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.hint.common.ProwlCostWasPaidHint;
|
||||
import mage.abilities.keyword.ProwlAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -41,11 +41,14 @@ public final class EarwigSquad extends CardImpl {
|
|||
this.addAbility(new ProwlAbility(this, "{2}{B}"));
|
||||
|
||||
// When Earwig Squad enters the battlefield, if its prowl cost was paid, search target opponent's library for three cards and exile them. Then that player shuffles their library.
|
||||
EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new EarwigSquadEffect(), false);
|
||||
Ability ability = new ConditionalInterveningIfTriggeredAbility(
|
||||
new EntersBattlefieldTriggeredAbility(new EarwigSquadEffect(), false),
|
||||
ProwlCostWasPaidCondition.instance, "When {this} enters the battlefield, " +
|
||||
"if its prowl cost was paid, search target opponent's library for three cards " +
|
||||
"and exile them. Then that player shuffles."
|
||||
);
|
||||
ability.addTarget(new TargetOpponent());
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, ProwlCostWasPaidCondition.instance,
|
||||
"When {this} enters the battlefield, if its prowl cost was paid, search target opponent's library for three cards and exile them. Then that player shuffles.")
|
||||
.addHint(ProwlCostWasPaidHint.instance));
|
||||
this.addAbility(ability.addHint(ProwlCostWasPaidHint.instance));
|
||||
|
||||
}
|
||||
|
||||
|
@ -79,20 +82,18 @@ class EarwigSquadEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && opponent != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 3, new FilterCard("cards from opponents library to exile"));
|
||||
if (player.searchLibrary(target, source, game, opponent.getId())) {
|
||||
List<UUID> targets = target.getTargets();
|
||||
for (UUID targetId : targets) {
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
opponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (player == null || opponent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(3, StaticFilters.FILTER_CARD_CARDS);
|
||||
player.searchLibrary(target, source, game, opponent.getId());
|
||||
Cards cards = new CardsImpl();
|
||||
target.getTargets()
|
||||
.stream()
|
||||
.map(uuid -> opponent.getLibrary().getCard(uuid, game))
|
||||
.forEach(cards::add);
|
||||
player.moveCards(cards, Zone.EXILED, source, game);
|
||||
opponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.e;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -10,26 +8,24 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cbt33, jeffwadsworth (Supreme Inquisitor)
|
||||
*/
|
||||
public final class Extract extends CardImpl {
|
||||
|
||||
public Extract(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}");
|
||||
|
||||
// Search target player's library for a card and exile it. Then that player shuffles their library.
|
||||
this.getSpellAbility().addEffect(new ExtractEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
|
||||
}
|
||||
|
||||
private Extract(final Extract card) {
|
||||
|
@ -44,8 +40,6 @@ public final class Extract extends CardImpl {
|
|||
|
||||
class ExtractEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
public ExtractEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "Search target player's library for a card and exile it. Then that player shuffles.";
|
||||
|
@ -64,17 +58,16 @@ class ExtractEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && targetPlayer != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, filter);
|
||||
if (player.searchLibrary(target, source, game, targetPlayer.getId())) {
|
||||
Card card = targetPlayer.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
|
||||
}
|
||||
}
|
||||
targetPlayer.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (player == null || targetPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
player.searchLibrary(target, source, game, targetPlayer.getId());
|
||||
Card card = targetPlayer.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.moveCards(card, Zone.EXILED, source, game);
|
||||
}
|
||||
targetPlayer.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ import mage.players.Player;
|
|||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -40,9 +42,13 @@ public final class GiftsUngiven extends CardImpl {
|
|||
|
||||
class GiftsUngivenEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("cards to put in graveyard");
|
||||
|
||||
public GiftsUngivenEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
this.staticText = "Search your library for up to four cards with different names and reveal them. Target opponent chooses two of those cards. Put the chosen cards into your graveyard and the rest into your hand. Then shuffle";
|
||||
this.staticText = "Search your library for up to four cards with different names and reveal them. " +
|
||||
"Target opponent chooses two of those cards. Put the chosen cards into your graveyard " +
|
||||
"and the rest into your hand. Then shuffle";
|
||||
}
|
||||
|
||||
public GiftsUngivenEffect(final GiftsUngivenEffect effect) {
|
||||
|
@ -57,54 +63,48 @@ class GiftsUngivenEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (player == null || sourceCard == null) {
|
||||
return false;
|
||||
}
|
||||
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (opponent == null) {
|
||||
if (player == null || opponent == null) {
|
||||
return false;
|
||||
}
|
||||
GiftsUngivenTarget target = new GiftsUngivenTarget();
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
player.revealCards(sourceCard.getIdName(), cards, game);
|
||||
|
||||
CardsImpl cardsToKeep = new CardsImpl();
|
||||
if (cards.size() > 2) {
|
||||
cardsToKeep.addAll(cards);
|
||||
TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, new FilterCard("cards to put in graveyard"));
|
||||
if (opponent.choose(Outcome.Discard, cards, targetDiscard, game)) {
|
||||
cardsToKeep.removeAll(targetDiscard.getTargets());
|
||||
cards.removeAll(cardsToKeep);
|
||||
}
|
||||
}
|
||||
|
||||
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
||||
player.moveCards(cardsToKeep, Zone.HAND, source, game);
|
||||
}
|
||||
player.searchLibrary(target, source, game);
|
||||
Cards cards = new CardsImpl();
|
||||
target.getTargets()
|
||||
.stream()
|
||||
.map(uuid -> player.getLibrary().getCard(uuid, game))
|
||||
.forEach(cards::add);
|
||||
if (cards.isEmpty()) {
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
player.revealCards(source, cards, game);
|
||||
|
||||
if (cards.size() > 2) {
|
||||
Cards cardsToKeep = new CardsImpl();
|
||||
cardsToKeep.addAll(cards);
|
||||
TargetCard targetDiscard = new TargetCard(2, Zone.LIBRARY, filter);
|
||||
if (opponent.choose(Outcome.Discard, cards, targetDiscard, game)) {
|
||||
cardsToKeep.removeIf(targetDiscard.getTargets()::contains);
|
||||
cards.removeAll(cardsToKeep);
|
||||
}
|
||||
player.moveCards(cardsToKeep, Zone.HAND, source, game);
|
||||
}
|
||||
|
||||
player.moveCards(cards, Zone.GRAVEYARD, source, game);
|
||||
player.shuffleLibrary(source, game);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class GiftsUngivenTarget extends TargetCardInLibrary {
|
||||
|
||||
public GiftsUngivenTarget() {
|
||||
super(0, 4, new FilterCard("cards with different names"));
|
||||
private static final FilterCard filter = new FilterCard("cards with different names");
|
||||
|
||||
GiftsUngivenTarget() {
|
||||
super(0, 4, filter);
|
||||
}
|
||||
|
||||
public GiftsUngivenTarget(final GiftsUngivenTarget target) {
|
||||
private GiftsUngivenTarget(final GiftsUngivenTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
|
@ -115,16 +115,16 @@ class GiftsUngivenTarget extends TargetCardInLibrary {
|
|||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) {
|
||||
Card card = cards.get(id, game);
|
||||
if (card != null) {
|
||||
for (UUID targetId : this.getTargets()) {
|
||||
Card iCard = game.getCard(targetId);
|
||||
if (iCard != null && iCard.getName().equals(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return filter.match(card, playerId, game);
|
||||
if (!super.canTarget(playerId, id, source, cards, game)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = cards.get(id, game);
|
||||
return card != null
|
||||
&& this
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.noneMatch(c -> CardUtil.haveSameNames(c, card));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -10,7 +7,6 @@ import mage.abilities.costs.common.SacrificeSourceCost;
|
|||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -19,26 +15,26 @@ import mage.constants.*;
|
|||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Quercitron
|
||||
*/
|
||||
public final class GrinningTotem extends CardImpl {
|
||||
|
||||
public GrinningTotem(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// {2}, {tap}, Sacrifice Grinning Totem: Search target opponent's library for a card and exile it. Then that player shuffles their library.
|
||||
// Until the beginning of your next upkeep, you may play that card.
|
||||
// At the beginning of your next upkeep, if you haven't played it, put it into its owner's graveyard.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GrinningTotemSearchAndExileEffect(), new ManaCostsImpl("{2}"));
|
||||
Ability ability = new SimpleActivatedAbility(new GrinningTotemSearchAndExileEffect(), new ManaCostsImpl<>("{2}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new TargetOpponent());
|
||||
|
@ -63,7 +59,7 @@ class GrinningTotemSearchAndExileEffect extends OneShotEffect {
|
|||
"Until the beginning of your next upkeep, you may play that card. " +
|
||||
"At the beginning of your next upkeep, if you haven't played it, put it into its owner's graveyard";
|
||||
}
|
||||
|
||||
|
||||
public GrinningTotemSearchAndExileEffect(final GrinningTotemSearchAndExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
@ -72,45 +68,38 @@ class GrinningTotemSearchAndExileEffect extends OneShotEffect {
|
|||
public GrinningTotemSearchAndExileEffect copy() {
|
||||
return new GrinningTotemSearchAndExileEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (you != null && targetOpponent != null && sourceObject != null) {
|
||||
if (targetOpponent.getLibrary().hasCards()) {
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
||||
if (you.searchLibrary(targetCard, source, game, targetOpponent.getId())) {
|
||||
Card card = targetOpponent.getLibrary().remove(targetCard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
|
||||
you.moveCardToExileWithInfo(card, exileZoneId, sourceObject.getIdName(), source, game, Zone.LIBRARY, true);
|
||||
ContinuousEffect effect = new GrinningTotemMayPlayEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
|
||||
game.addDelayedTriggeredAbility(new GrinningTotemDelayedTriggeredAbility(exileZoneId), source);
|
||||
}
|
||||
}
|
||||
}
|
||||
targetOpponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (you == null || targetOpponent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
||||
you.searchLibrary(targetCard, source, game, targetOpponent.getId());
|
||||
Card card = targetOpponent.getLibrary().remove(targetCard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
|
||||
you.moveCardsToExile(card, source, game, true, exileZoneId, CardUtil.getSourceName(game, source));
|
||||
game.addEffect(new GrinningTotemMayPlayEffect().setTargetPointer(new FixedTarget(card.getId())), source);
|
||||
game.addDelayedTriggeredAbility(new GrinningTotemDelayedTriggeredAbility(exileZoneId), source);
|
||||
}
|
||||
targetOpponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class GrinningTotemMayPlayEffect extends AsThoughEffectImpl {
|
||||
|
||||
|
||||
private boolean sameStep = true;
|
||||
|
||||
public GrinningTotemMayPlayEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit);
|
||||
this.staticText = "Until the beginning of your next upkeep, you may play that card.";
|
||||
}
|
||||
|
||||
|
||||
public GrinningTotemMayPlayEffect(final GrinningTotemMayPlayEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
@ -131,7 +120,7 @@ class GrinningTotemMayPlayEffect extends AsThoughEffectImpl {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
|
@ -142,7 +131,7 @@ class GrinningTotemMayPlayEffect extends AsThoughEffectImpl {
|
|||
return source.isControlledBy(affectedControllerId)
|
||||
&& sourceId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class GrinningTotemDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
@ -194,7 +183,7 @@ class GrinningTotemPutIntoGraveyardEffect extends OneShotEffect {
|
|||
super(Outcome.Detriment);
|
||||
this.exileZoneId = exileZoneId;
|
||||
}
|
||||
|
||||
|
||||
public GrinningTotemPutIntoGraveyardEffect(final GrinningTotemPutIntoGraveyardEffect effect) {
|
||||
super(effect);
|
||||
this.exileZoneId = effect.exileZoneId;
|
||||
|
@ -204,7 +193,7 @@ class GrinningTotemPutIntoGraveyardEffect extends OneShotEffect {
|
|||
public GrinningTotemPutIntoGraveyardEffect copy() {
|
||||
return new GrinningTotemPutIntoGraveyardEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
@ -214,5 +203,5 @@ class GrinningTotemPutIntoGraveyardEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,55 +1,57 @@
|
|||
|
||||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.SearchEffect;
|
||||
import mage.abilities.effects.common.continuous.LoseAbilitySourceEffect;
|
||||
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.abilities.keyword.TransmuteAbility;
|
||||
import mage.cards.*;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class Grozoth extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("cards that have mana value 9");
|
||||
|
||||
static {
|
||||
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, 9));
|
||||
}
|
||||
|
||||
public Grozoth(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}{U}{U}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{U}{U}{U}");
|
||||
this.subtype.add(SubType.LEVIATHAN);
|
||||
this.power = new MageInt(9);
|
||||
this.toughness = new MageInt(9);
|
||||
|
||||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
|
||||
|
||||
// When Grozoth enters the battlefield, you may search your library for any number of cards that have converted mana cost 9, reveal them, and put them into your hand. If you do, shuffle your library.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new GrozothEffect(), true));
|
||||
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInHandEffect(
|
||||
new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), true, true
|
||||
), true));
|
||||
|
||||
// {4}: Grozoth loses defender until end of turn.
|
||||
this.addAbility(new SimpleActivatedAbility(
|
||||
Zone.BATTLEFIELD,
|
||||
new LoseAbilitySourceEffect(DefenderAbility.getInstance(), Duration.EndOfTurn),
|
||||
new ManaCostsImpl("{4}")));
|
||||
|
||||
this.addAbility(new SimpleActivatedAbility(new LoseAbilitySourceEffect(
|
||||
DefenderAbility.getInstance(), Duration.EndOfTurn
|
||||
), new ManaCostsImpl<>("{4}")));
|
||||
|
||||
// Transmute {1}{U}{U}
|
||||
this.addAbility(new TransmuteAbility("{1}{U}{U}"));
|
||||
this.addAbility(new TransmuteAbility("{1}{U}{U}"));
|
||||
}
|
||||
|
||||
private Grozoth(final Grozoth card) {
|
||||
|
@ -61,48 +63,3 @@ public final class Grozoth extends CardImpl {
|
|||
return new Grozoth(this);
|
||||
}
|
||||
}
|
||||
|
||||
class GrozothEffect extends SearchEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
static {
|
||||
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, 9));
|
||||
}
|
||||
|
||||
public GrozothEffect() {
|
||||
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.DrawCard);
|
||||
staticText = "search your library for any number of cards that have mana value 9, reveal them, put them into your hand, then shuffle";
|
||||
}
|
||||
|
||||
public GrozothEffect(final GrozothEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrozothEffect copy() {
|
||||
return new GrozothEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null && player != null && player.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
player.revealCards(sourceCard.getIdName(), cards, game);
|
||||
player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.h;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -21,7 +20,6 @@ import mage.target.common.TargetOpponent;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class HideSeek extends SplitCard {
|
||||
|
@ -31,14 +29,13 @@ public final class HideSeek extends SplitCard {
|
|||
|
||||
// Hide
|
||||
// Put target artifact or enchantment on the bottom of its owner's library.
|
||||
getLeftHalfCard().getSpellAbility().addEffect(new PutOnLibraryTargetEffect(false));
|
||||
getLeftHalfCard().getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT));
|
||||
this.getLeftHalfCard().getSpellAbility().addEffect(new PutOnLibraryTargetEffect(false));
|
||||
this.getLeftHalfCard().getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT));
|
||||
|
||||
// Seek
|
||||
// Search target opponent's library for a card and exile it. You gain life equal to its converted mana cost. Then that player shuffles their library..
|
||||
getRightHalfCard().getSpellAbility().addEffect(new SeekEffect());
|
||||
getRightHalfCard().getSpellAbility().addTarget(new TargetOpponent());
|
||||
|
||||
this.getRightHalfCard().getSpellAbility().addEffect(new SeekEffect());
|
||||
this.getRightHalfCard().getSpellAbility().addTarget(new TargetOpponent());
|
||||
}
|
||||
|
||||
private HideSeek(final HideSeek card) {
|
||||
|
@ -71,24 +68,17 @@ class SeekEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null && opponent != null) {
|
||||
if (opponent.getLibrary().hasCards()) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (player.searchLibrary(target, source, game, opponent.getId())) {
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = opponent.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
player.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
|
||||
int cmc = card.getManaValue();
|
||||
if (cmc > 0) {
|
||||
player.gainLife(cmc, game, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (player == null || opponent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
player.searchLibrary(target, source, game, opponent.getId());
|
||||
Card card = opponent.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.moveCards(card, Zone.EXILED, source, game);
|
||||
player.gainLife(card.getManaValue(), game, source);
|
||||
}
|
||||
opponent.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.common.DiscardXTargetCost;
|
||||
import mage.abilities.dynamicvalue.common.GetXValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -26,11 +26,10 @@ public final class InsidiousDreams extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{B}");
|
||||
|
||||
// As an additional cost to cast Insidious Dreams, discard X cards.
|
||||
this.getSpellAbility().addCost(new DiscardXTargetCost(new FilterCard("cards"), true));
|
||||
this.getSpellAbility().addCost(new DiscardXTargetCost(StaticFilters.FILTER_CARD_CARDS, true));
|
||||
|
||||
// Search your library for X cards. Then shuffle your library and put those cards on top of it in any order.
|
||||
this.getSpellAbility().addEffect(new InsidiousDreamsEffect());
|
||||
|
||||
}
|
||||
|
||||
private InsidiousDreams(final InsidiousDreams card) {
|
||||
|
@ -45,8 +44,6 @@ public final class InsidiousDreams extends CardImpl {
|
|||
|
||||
class InsidiousDreamsEffect extends OneShotEffect {
|
||||
|
||||
static final private String textTop = "card to put on your library (last chosen will be on top)";
|
||||
|
||||
public InsidiousDreamsEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Search your library for up to X cards. Then shuffle and put those cards on top of it in any order";
|
||||
|
@ -64,39 +61,17 @@ class InsidiousDreamsEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
int amount = GetXValue.instance.calculate(game, source, this);
|
||||
|
||||
if (controller != null && sourceObject != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard());
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
Cards chosen = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = controller.getLibrary().remove(cardId, game);
|
||||
chosen.add(card);
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
|
||||
TargetCard targetToLib = new TargetCard(Zone.LIBRARY, new FilterCard(textTop));
|
||||
|
||||
while (chosen.size() > 1 && controller.canRespond()) {
|
||||
controller.choose(Outcome.Neutral, chosen, targetToLib, game);
|
||||
Card card = chosen.get(targetToLib.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
chosen.remove(card);
|
||||
controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, true, false);
|
||||
|
||||
}
|
||||
targetToLib.clearChosen();
|
||||
}
|
||||
|
||||
if (chosen.size() == 1) {
|
||||
Card card = chosen.get(chosen.iterator().next(), game);
|
||||
controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, true, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(
|
||||
0, GetXValue.instance.calculate(game, source, this), StaticFilters.FILTER_CARD_CARDS
|
||||
);
|
||||
controller.searchLibrary(target, source, game);
|
||||
Cards chosen = new CardsImpl();
|
||||
target.getTargets().stream().forEach(cardId -> controller.getLibrary().getCard(cardId, game));
|
||||
controller.shuffleLibrary(source, game);
|
||||
controller.putCardsOnTopOfLibrary(chosen, game, source, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,25 +8,19 @@ import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
|||
import mage.cards.*;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||
import mage.game.ExileZone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInExile;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.*;
|
||||
import mage.ApprovingObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
@ -50,7 +44,6 @@ public final class JaceArchitectOfThought extends CardImpl {
|
|||
// -8: For each player, search that player's library for a nonland card and exile it,
|
||||
// then that player shuffles their library. You may cast those cards without paying their mana costs.
|
||||
this.addAbility(new LoyaltyAbility(new JaceArchitectOfThoughtEffect3(), -8));
|
||||
|
||||
}
|
||||
|
||||
private JaceArchitectOfThought(final JaceArchitectOfThought card) {
|
||||
|
@ -90,7 +83,7 @@ class JaceArchitectOfThoughtStartEffect1 extends OneShotEffect {
|
|||
|
||||
class JaceArchitectOfThoughtDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
private int startingTurn;
|
||||
private final int startingTurn;
|
||||
|
||||
public JaceArchitectOfThoughtDelayedTriggeredAbility(int startingTurn) {
|
||||
super(new BoostTargetEffect(-1, 0, Duration.EndOfTurn), Duration.Custom, false);
|
||||
|
@ -228,83 +221,33 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller == null || sourcePermanent == null) {
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
if (controller.chooseUse(Outcome.Benefit, "Look at all players' libraries before card select?", null, game)) {
|
||||
if (controller.chooseUse(Outcome.Benefit, "Look at all players' libraries before card select?", source, game)) {
|
||||
game.informPlayers(controller.getLogName() + " is looking at all players' libraries.");
|
||||
controller.lookAtAllLibraries(source, game);
|
||||
}
|
||||
List<UUID> playerList = new ArrayList<>();
|
||||
playerList.addAll(game.getState().getPlayersInRange(controller.getId(), game));
|
||||
Set<UUID> checkList = new HashSet<>();
|
||||
while (!playerList.isEmpty()) {
|
||||
FilterPlayer filter = new FilterPlayer();
|
||||
List<PlayerIdPredicate> playerPredicates = new ArrayList<>();
|
||||
playerList.forEach((playerId) -> {
|
||||
playerPredicates.add(new PlayerIdPredicate(playerId));
|
||||
});
|
||||
filter.add(Predicates.or(playerPredicates));
|
||||
TargetPlayer targetPlayer = new TargetPlayer(1, 1, true, filter);
|
||||
targetPlayer.setRequired(!checkList.containsAll(playerList));
|
||||
if (controller.chooseTarget(outcome, targetPlayer, source, game)) {
|
||||
UUID playerId = targetPlayer.getFirstTarget();
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
String playerName = player.getLogName() + "'s";
|
||||
if (source.isControlledBy(player.getId())) {
|
||||
playerName = "your";
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard("nonland card from " + playerName + " library"));
|
||||
if (controller.searchLibrary(target, source, game, playerId)) {
|
||||
checkList.add(playerId);
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Card card = player.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
controller.moveCardsToExile(card, source, game, true, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getName());
|
||||
playerList.remove(playerId);
|
||||
}
|
||||
} else {
|
||||
playerList.remove(playerId);
|
||||
}
|
||||
} else {
|
||||
playerList.remove(playerId);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove disconnected or quit players
|
||||
playerList.removeIf(playerId -> game.getPlayer(playerId) == null || !game.getPlayer(playerId).canRespond());
|
||||
}
|
||||
checkList.stream().map((playerId) -> game.getPlayer(playerId)).filter((player) -> (player != null)).forEachOrdered((player) -> {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(
|
||||
0, 1, StaticFilters.FILTER_CARD_A_NON_LAND
|
||||
);
|
||||
controller.searchLibrary(target, source, game, playerId);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card == null) {
|
||||
continue;
|
||||
}
|
||||
cards.add(card);
|
||||
controller.moveCards(card, Zone.EXILED, source, game);
|
||||
player.shuffleLibrary(source, game);
|
||||
});
|
||||
ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
if (jaceExileZone == null) {
|
||||
return true;
|
||||
}
|
||||
FilterCard filter = new FilterCard("card to cast without mana costs");
|
||||
TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId());
|
||||
Cards cardsToChoose = new CardsImpl(jaceExileZone.getCards(game));
|
||||
while (controller.canRespond()
|
||||
&& cardsToChoose.count(filter, game) > 0
|
||||
&& controller.chooseUse(Outcome.Benefit, "Cast another spell from exile zone for free?", source, game)) {
|
||||
controller.choose(Outcome.PlayForFree, cardsToChoose, target, game);
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
|
||||
Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true),
|
||||
game, true, new ApprovingObject(source, game));
|
||||
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
|
||||
cardsToChoose.remove(card);
|
||||
if (cardWasCast) {
|
||||
game.getExile().removeCard(card, game);
|
||||
}
|
||||
}
|
||||
target.clearChosen();
|
||||
}
|
||||
cards.retainZone(Zone.EXILED, game);
|
||||
CardUtil.castMultipleWithAttributeForFree(controller, source, game, cards, StaticFilters.FILTER_CARD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.l;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -13,8 +11,9 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public final class LongTermPlans extends CardImpl {
|
||||
|
@ -55,18 +54,16 @@ class LongTermPlansEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.shuffleLibrary(source, game);
|
||||
// must hides the card name from other players
|
||||
player.putCardOnTopXOfLibrary(card, game, source, 3, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
player.searchLibrary(target, source, game);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
player.shuffleLibrary(source, game);
|
||||
if (card != null) {
|
||||
player.putCardOnTopXOfLibrary(card, game, source, 3, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue