* Some more fixed/reworked card movement handling.

This commit is contained in:
LevelX2 2018-05-11 00:52:09 +02:00
parent 7d7b13d5dd
commit 75c8ee35f6
95 changed files with 969 additions and 2192 deletions

View file

@ -29,12 +29,15 @@ package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.cards.*;
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;
@ -49,7 +52,8 @@ public class AncestralMemories extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}{U}{U}");
// Look at the top seven cards of your library. Put two of them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new AncestralMemoriesEffect());
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(7), false, new StaticValue(2),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false));
}
public AncestralMemories(final AncestralMemories card) {

View file

@ -28,17 +28,13 @@
package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.*;
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.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -50,7 +46,8 @@ public class BitterRevelation extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}");
// Look at the top four cards of your library. Put two of them into your hand and the rest into your graveyard. You lose 2 life.
this.getSpellAbility().addEffect(new BitterRevelationEffect());
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(2),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(2));
}
@ -63,40 +60,3 @@ public class BitterRevelation extends CardImpl {
return new BitterRevelation(this);
}
}
class BitterRevelationEffect extends OneShotEffect {
BitterRevelationEffect() {
super(Outcome.Benefit);
this.staticText = "Look at the top four cards of your library. Put two of them into your hand and the rest into your graveyard";
}
BitterRevelationEffect(final BitterRevelationEffect effect) {
super(effect);
}
@Override
public BitterRevelationEffect copy() {
return new BitterRevelationEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
controller.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Math.min(2, cards.size()), Zone.LIBRARY, new FilterCard("two cards to put in your hand"));
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Cards toHand = new CardsImpl(target.getTargets());
controller.moveCards(toHand, Zone.HAND, source, game);
cards.removeAll(toHand);
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -40,6 +40,7 @@ import mage.abilities.effects.common.continuous.PlayWithTheTopCardRevealedEffect
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -138,11 +139,11 @@ class CrownOfConvergenceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
Card card = you.getLibrary().removeFromTop(game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
controller.putCardsOnBottomOfLibrary(new CardsImpl(card), game, source, true);
}
return true;
}

View file

@ -28,19 +28,15 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -49,11 +45,12 @@ import mage.target.TargetCard;
public class ForbiddenAlchemy extends CardImpl {
public ForbiddenAlchemy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new ForbiddenAlchemyEffect());
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false));
// Flashback {6}{B}
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{6}{B}"), TimingRule.INSTANT));
}
@ -67,55 +64,3 @@ public class ForbiddenAlchemy extends CardImpl {
return new ForbiddenAlchemy(this);
}
}
class ForbiddenAlchemyEffect extends OneShotEffect {
public ForbiddenAlchemyEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public ForbiddenAlchemyEffect(final ForbiddenAlchemyEffect effect) {
super(effect);
}
@Override
public ForbiddenAlchemyEffect copy() {
return new ForbiddenAlchemyEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cards cards = new CardsImpl();
int cardsCount = Math.min(4, player.getLibrary().size());
for (int i = 0; i < cardsCount; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
if (!cards.isEmpty()) {
player.lookAtCards("Forbidden Alchemy", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (player.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
cards.remove(card);
}
}
for (Card card : cards.getCards(game)) {
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
}
}
return true;
}
return false;
}
}

View file

@ -37,7 +37,6 @@ import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -47,7 +46,7 @@ import mage.players.Player;
public class ForceMastery extends CardImpl {
public ForceMastery(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}{U}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{U}{W}");
// At the beggining of your upkeep, reveal the top card of your library and put that card into your hand. You gain life equal to its converted mana cost.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new ForceMasteryEffect(), TargetController.YOU, false));
@ -78,18 +77,14 @@ class ForceMasteryEffect 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.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controller.revealCards(sourcePermanent.getIdName(), cards, game);
controller.moveCards(card, Zone.HAND, source, game);
controller.gainLife(card.getConvertedManaCost(), game, source);
}
return true;
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.revealCards(source, new CardsImpl(card), game);
controller.moveCards(card, Zone.HAND, source, game);
controller.gainLife(card.getConvertedManaCost(), game, source);
}
return true;
}
return false;
}

View file

@ -34,8 +34,8 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import mage.players.Player;
@ -80,16 +80,14 @@ class GalvanothEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.getLibrary().hasCards()) {
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card);
controller.lookAtCards("Galvanoth", cards, game);
if (card.isInstant() || card.isSorcery()) {
StringBuilder message = new StringBuilder("Cast ").append(card.getName()).append(" without paying its mana cost?");
if (controller.chooseUse(Outcome.PlayForFree, message.toString(), source, game)) {
controller.getLibrary().removeFromTop(game);
controller.cast(card.getSpellAbility(), game, true);
if (card != null) {
controller.lookAtCards(source, null, new CardsImpl(card), game);
if (card.isInstant() || card.isSorcery()) {
if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
controller.cast(card.getSpellAbility(), game, true);
}
}
}
return true;

View file

@ -41,7 +41,6 @@ import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -85,29 +84,29 @@ class DuskmarEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourceCard = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourceCard == null) {
return false;
}
boolean putToPlay = true;
Cards cards = new CardsImpl();
for (Player player : game.getPlayers().values()) {
if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (!card.isCreature()) {
putToPlay = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean putToPlay = true;
Cards cards = new CardsImpl();
for (Player player : game.getPlayers().values()) {
if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (!card.isCreature()) {
putToPlay = false;
}
player.revealCards(source, "- Revealed by " + player.getName(), cards, game);
}
player.revealCards(sourceCard.getName() + ": Revealed by " + player.getName(), cards, game);
} else {
putToPlay = false;
}
} else {
putToPlay = false;
}
if (putToPlay) {
controller.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
return true;
}
if (putToPlay) {
game.getPlayers().values().iterator().next().moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
return true;
return false;
}
}

View file

@ -37,9 +37,9 @@ import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterCard;
@ -58,7 +58,7 @@ import mage.target.TargetCard;
public class GenesisHydra extends CardImpl {
public GenesisHydra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{X}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}{G}");
this.subtype.add(SubType.PLANT);
this.subtype.add(SubType.HYDRA);
@ -96,49 +96,39 @@ class GenesisHydraPutOntoBattlefieldEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY);
int count = 0;
if (obj != null && obj instanceof SpellAbility) {
count = ((SpellAbility) obj).getManaCostsToPay().getX();
// using other var because of tooltip
int size = Math.min(controller.getLibrary().size(), count);
for (int i = 0; i < size; i++) {
Card card = controller.getLibrary().removeFromTop(game);
cards.add(card);
}
}
if (!cards.isEmpty()) {
controller.revealCards("Genesis Hydra", cards, game);
}
FilterCard filter = new FilterPermanentCard("a nonland permanent card with converted mana cost " + count + " or less to put onto the battlefield");
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, count + 1));
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter);
target1.setRequired(false);
if (cards.count(filter, controller.getId(), source.getSourceId(), game) > 0) {
if (controller.choose(Outcome.PutCardInPlay, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (controller != null && obj != null && obj instanceof SpellAbility) {
int count = ((SpellAbility) obj).getManaCostsToPay().getX();
if (count > 0) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count));
controller.revealCards(source, cards, game);
FilterCard filter = new FilterPermanentCard("a nonland permanent card with converted mana cost " + count + " or less to put onto the battlefield");
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, count + 1));
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter);
target1.setRequired(false);
if (cards.count(filter, controller.getId(), source.getSourceId(), game) > 0) {
if (controller.choose(Outcome.PutCardInPlay, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
target1.clearChosen();
} else {
game.informPlayers(controller.getLogName() + " didn't choose anything");
}
} else {
game.informPlayers("No nonland permanent card with converted mana cost " + count + " or less to choose.");
}
if (!cards.isEmpty()) {
controller.moveCards(cards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
}
target1.clearChosen();
} else {
game.informPlayers(controller.getLogName() + " didn't choose anything");
}
} else {
game.informPlayers("No nonland permanent card with converted mana cost " + count + " or less to choose.");
return true;
}
controller.moveCards(cards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
return true;
return false;
}
@Override

View file

@ -25,14 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.g;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
@ -86,35 +82,21 @@ class GenesisWaveEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
int xValue = source.getManaCostsToPay().getX();
int numberCards = Math.min(controller.getLibrary().size(), xValue);
for (int i = 0; i < numberCards; i++) {
Card card = controller.getLibrary().removeFromTop(game);
cards.add(card);
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.revealCards(source, cards, game);
FilterCard filter = new FilterPermanentCard("cards with converted mana cost " + xValue + " or less to put onto the battlefield");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
target1.setRequired(false);
target1.setNotTarget(true);
controller.choose(Outcome.PutCardInPlay, cards, target1, game);
Set<Card> toBattlefield = new LinkedHashSet<>();
for (UUID cardId : target1.getTargets()) {
Card card = cards.get(cardId, game);
if (card != null) {
cards.remove(card);
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, false, null);
Cards toBattlefield = new CardsImpl(target1.getTargets());
cards.removeAll(toBattlefield);
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;

View file

@ -27,7 +27,6 @@
*/
package mage.cards.g;
import java.util.Collection;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -49,9 +48,9 @@ import mage.players.Player;
public class GhoulcallersBell extends CardImpl {
public GhoulcallersBell(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {tap}: Each player puts the top card of their library into their graveyard.
// {T}: Each player puts the top card of their library into their graveyard.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GhoulcallersBellEffect(), new TapSourceCost()));
}
@ -83,10 +82,10 @@ class GhoulcallersBellEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Collection<Player> players = game.getPlayers().values();
for (Player player : players) {
if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCards(card, Zone.GRAVEYARD, source, game);
}

View file

@ -47,8 +47,7 @@ import mage.target.TargetCard;
public class GiftOfTheGargantuan extends CardImpl {
public GiftOfTheGargantuan(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Look at the top four cards of your library. You may reveal a creature card and/or a land card from among them and put the revealed cards into your hand. Put the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new GiftOfTheGargantuanEffect());
@ -86,52 +85,32 @@ class GiftOfTheGargantuanEffect extends OneShotEffect {
if (player == null) {
return false;
}
Cards cards = new CardsImpl();
boolean creatureCardFound = false;
boolean landCardFound = false;
int count = Math.min(player.getLibrary().size(), 4);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 4));
player.lookAtCards(source, null, cards, game);
Cards revealedCards = new CardsImpl();
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to reveal and put into your hand"));
if (target.canChoose(source.getControllerId(), game)
&& player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.add(card);
if (card.isCreature()) {
creatureCardFound = true;
}
if (card.isLand()) {
landCardFound = true;
}
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
revealedCards.add(card);
}
}
player.lookAtCards("Gift of the Gargantuan", cards, game);
if ((creatureCardFound || landCardFound) && player.chooseUse(Outcome.DrawCard, "Do you wish to reveal a creature card and/or a land card and put them into your hand?", source, game)) {
Cards revealedCards = new CardsImpl();
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to reveal and put into your hand"));
if (creatureCardFound && player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
revealedCards.add(card);
}
}
target = new TargetCard(Zone.LIBRARY, new FilterLandCard("land card to reveal and put into your hand"));
if (landCardFound && player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
revealedCards.add(card);
}
}
if (!revealedCards.isEmpty()) {
player.revealCards("Gift of the Gargantuan", revealedCards, game);
target = new TargetCard(Zone.LIBRARY, new FilterLandCard("land card to reveal and put into your hand"));
if (target.canChoose(source.getControllerId(), game)
&& player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
revealedCards.add(card);
}
}
if (!revealedCards.isEmpty()) {
player.revealCards(source, revealedCards, game);
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}

View file

@ -27,18 +27,14 @@
*/
package mage.cards.g;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
@ -94,12 +90,6 @@ public class GishathSunsAvatar extends CardImpl {
class GishathSunsAvatarEffect extends OneShotEffect {
private static final FilterCreatureCard filter = new FilterCreatureCard("Dinosaur creature cards");
static {
filter.add(new SubtypePredicate(SubType.DINOSAUR));
}
GishathSunsAvatarEffect() {
super(Outcome.Benefit);
this.staticText = "reveal that many cards from the top of your library. Put any number of Dinosaur creature cards from among them onto the battlefield and the rest on the bottom of your library in a random order";
@ -117,31 +107,21 @@ class GishathSunsAvatarEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
int xValue = (Integer) getValue("damage");
int numberCards = Math.min(controller.getLibrary().size(), xValue);
for (int i = 0; i < numberCards; i++) {
Card card = controller.getLibrary().removeFromTop(game);
cards.add(card);
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.revealCards(source, cards, game);
FilterCreatureCard filter = new FilterCreatureCard("Dinosaur creature cards");
filter.add(new SubtypePredicate(SubType.DINOSAUR));
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
target1.setRequired(false);
target1.setNotTarget(true);
controller.choose(Outcome.PutCardInPlay, cards, target1, game);
Set<Card> toBattlefield = new LinkedHashSet<>();
for (UUID cardId : target1.getTargets()) {
Card card = cards.get(cardId, game);
if (card != null) {
cards.remove(card);
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, false, null);
Cards toBattlefield = new CardsImpl(target1.getTargets());
cards.removeAll(toBattlefield);
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
}
return true;

View file

@ -28,16 +28,12 @@
package mage.cards.g;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.cards.*;
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.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -46,11 +42,11 @@ import mage.target.TargetCard;
public class GlimpseTheFuture extends CardImpl {
public GlimpseTheFuture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}");
// Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new GlimpseTheFutureEffect());
// Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(3), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false));
}
@ -63,51 +59,3 @@ public class GlimpseTheFuture extends CardImpl {
return new GlimpseTheFuture(this);
}
}
class GlimpseTheFutureEffect extends OneShotEffect {
public GlimpseTheFutureEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public GlimpseTheFutureEffect(final GlimpseTheFutureEffect effect) {
super(effect);
}
@Override
public GlimpseTheFutureEffect copy() {
return new GlimpseTheFutureEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
int cardsCount = Math.min(3, controller.getLibrary().size());
for (int i = 0; i < cardsCount; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
if (!cards.isEmpty()) {
controller.lookAtCards("Glimpse the Future", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -29,22 +29,20 @@ package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.Card;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
/**
@ -93,27 +91,20 @@ class GoblinMachinistEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (controller.getLibrary().hasCards()) {
CardsImpl cards = new CardsImpl();
Library library = controller.getLibrary();
Card card = null;
do {
card = library.removeFromTop(game);
if (card != null) {
cards.add(card);
}
} while (library.hasCards() && card != null && card.isLand());
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
}
boolean retVal = false;
if (controller != null) {
CardsImpl cards = new CardsImpl();
for (Card card : controller.getLibrary().getCards(game)) {
if (card != null) {
retVal = new BoostSourceEffect(card.getConvertedManaCost(), 0, Duration.EndOfTurn).apply(game, source);
cards.add(card);
if (!card.isLand()) {
if (card.getConvertedManaCost() > 0) {
game.addEffect(new BoostSourceEffect(card.getConvertedManaCost(), 0, Duration.EndOfTurn), source);
}
break;
}
}
return controller.putCardsOnBottomOfLibrary(cards, game, source, true) && retVal;
controller.revealCards(source, cards, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}

View file

@ -48,7 +48,7 @@ import mage.target.TargetPlayer;
public class Grindstone extends CardImpl {
public Grindstone(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {3}, {T}: Target player puts the top two cards of their library into their graveyard. If both cards share a color, repeat this process.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GrindstoneEffect(), new ManaCostsImpl("{3}"));
@ -87,10 +87,11 @@ class GrindstoneEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
boolean colorShared;
if (targetPlayer != null) {
int possibleIterations = targetPlayer.getLibrary().size() / 2;
int iteration = 0;
boolean colorShared;
do {
iteration++;
if (iteration > possibleIterations + 20) {
@ -102,16 +103,19 @@ class GrindstoneEffect extends OneShotEffect {
return true;
}
colorShared = false;
Cards cards = new CardsImpl();
cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) {
Card card1 = targetPlayer.getLibrary().removeFromTop(game);
if (targetPlayer.getLibrary().hasCards()) {
colorShared = card1.getColor(game).shares(targetPlayer.getLibrary().removeFromTop(game).getColor(game));
Card card1 = null;
Cards toGraveyard = new CardsImpl();
for (Card card : targetPlayer.getLibrary().getCards(game)) {
toGraveyard.add(card);
if (card1 == null) {
card1 = card;
} else {
colorShared = card1.getColor(game).shares(card.getColor(game));
break;
}
}
targetPlayer.moveCards(cards, Zone.GRAVEYARD, source, game);
} while (colorShared && targetPlayer.canRespond());
targetPlayer.moveCards(toGraveyard, Zone.GRAVEYARD, source, game);
} while (colorShared);
return true;
}
return false;

View file

@ -28,7 +28,6 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
@ -49,7 +48,7 @@ import mage.target.TargetCard;
public class GrislySalvage extends CardImpl {
public GrislySalvage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}{G}");
// Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard.
this.getSpellAbility().addEffect(new GrislySalvageEffect());
@ -68,6 +67,7 @@ public class GrislySalvage extends CardImpl {
class GrislySalvageEffect extends OneShotEffect {
private static final FilterCard filterPutInHand = new FilterCard("creature or land card to put in hand");
static {
filterPutInHand.add(Predicates.or(new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND)));
}
@ -89,22 +89,14 @@ class GrislySalvageEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 5));
boolean properCardFound = false;
for (Card card: cards.getCards(game)) {
if (filterPutInHand.match(card, source.getSourceId(), source.getControllerId(), game)) {
properCardFound = true;
}
}
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
boolean properCardFound = cards.count(filterPutInHand, game) > 0;
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
if (properCardFound && controller.chooseUse(outcome, "Put a creature or land card from the revealed cards into your hand?", source, game) &&
controller.choose(Outcome.DrawCard, cards, target, game)) {
if (properCardFound && controller.chooseUse(outcome, "Put a creature or land card from the revealed cards into your hand?", source, game)
&& controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);

View file

@ -29,20 +29,15 @@ package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.ExploitCreatureTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.keyword.ExploitAbility;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -51,7 +46,7 @@ import mage.target.TargetCard;
public class GurmagDrowner extends CardImpl {
public GurmagDrowner(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.subtype.add(SubType.NAGA);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(2);
@ -59,9 +54,10 @@ public class GurmagDrowner extends CardImpl {
// Exploit
this.addAbility(new ExploitAbility());
// When Gurmag Drowner exploits a creature, look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard.
this.addAbility(new ExploitCreatureTriggeredAbility(new GurmagDrownerEffect(), false));
this.addAbility(new ExploitCreatureTriggeredAbility(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false), false));
}
public GurmagDrowner(final GurmagDrowner card) {
@ -73,44 +69,3 @@ public class GurmagDrowner extends CardImpl {
return new GurmagDrowner(this);
}
}
class GurmagDrownerEffect extends OneShotEffect {
public GurmagDrownerEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public GurmagDrownerEffect(final GurmagDrownerEffect effect) {
super(effect);
}
@Override
public GurmagDrownerEffect copy() {
return new GurmagDrownerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
controller.lookAtCards(sourceObject.getName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -34,8 +34,8 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -47,10 +47,9 @@ import mage.players.Player;
public class HeedTheMists extends CardImpl {
public HeedTheMists(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
this.subtype.add(SubType.ARCANE);
// Put the top card of your library into your graveyard, then draw cards equal to that card's converted mana cost.
this.getSpellAbility().addEffect(new HeedTheMistsEffect());
}
@ -80,7 +79,7 @@ public class HeedTheMists extends CardImpl {
boolean result = false;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().removeFromTop(game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
int cmc = card.getConvertedManaCost();
controller.moveCards(card, Zone.GRAVEYARD, source, game);

View file

@ -52,7 +52,7 @@ import mage.target.common.TargetOpponent;
public class HelmOfObedience extends CardImpl {
public HelmOfObedience(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
// {X}, {T}: Target opponent puts cards from the top of their library into their graveyard until a creature card or X cards are put into that graveyard this way, whichever comes first. If a creature card is put into that graveyard this way, sacrifice Helm of Obedience and put that card onto the battlefield under your control. X can't be 0.
VariableManaCost xCosts = new VariableManaCost();
@ -73,22 +73,19 @@ public class HelmOfObedience extends CardImpl {
}
}
class HelmOfObedienceEffect extends OneShotEffect {
private static final ManacostVariableValue amount = new ManacostVariableValue();
public HelmOfObedienceEffect() {
super(Outcome.Detriment);
staticText = "Target opponent puts cards from the top of their library into their graveyard until a creature card or X cards are put into that graveyard this way, whichever comes first. If a creature card is put into that graveyard this way, sacrifice Helm of Obedience and put that card onto the battlefield under your control. X can't be 0";
staticText = "Target opponent puts cards from the top of their library into their graveyard until a creature card or X cards are put into that graveyard this way, whichever comes first. If a creature card is put into that graveyard this way, sacrifice {this} and put that card onto the battlefield under your control. X can't be 0";
}
public HelmOfObedienceEffect(final HelmOfObedienceEffect effect) {
super(effect);
}
@Override
public HelmOfObedienceEffect copy() {
return new HelmOfObedienceEffect(this);
@ -96,36 +93,29 @@ class HelmOfObedienceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
int max = amount.calculate(game, source, this);
if(max != 0){
int numberOfCard = 0;
while(targetOpponent.getLibrary().hasCards()) {
Card card = targetOpponent.getLibrary().removeFromTop(game);
if (card != null){
if (targetOpponent.moveCards(card, Zone.GRAVEYARD, source, game)) {
if(card.isCreature()){
// If a creature card is put into that graveyard this way, sacrifice Helm of Obedience
// and put that card onto the battlefield under your control.
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
sourcePermanent.sacrifice(source.getSourceId(), game);
}
if (game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
}
int max = amount.calculate(game, source, this);
if (targetOpponent != null && controller != null && max > 0) {
int numberOfCard = 0;
for (Card card : targetOpponent.getLibrary().getCards(game)) {
if (card != null) {
if (targetOpponent.moveCards(card, Zone.GRAVEYARD, source, game)) {
if (card.isCreature()) {
// If a creature card is put into that graveyard this way, sacrifice Helm of Obedience
// and put that card onto the battlefield under your control.
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent != null) {
sourcePermanent.sacrifice(source.getSourceId(), game);
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
} else {
numberOfCard++;
if (numberOfCard >= max) {
break;
} else{
numberOfCard++;
if(numberOfCard >= max){
break;
}
}
}
} else{
return false;
}
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.i;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect;
@ -104,8 +103,7 @@ class IndomitableCreativityEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (controller != null) {
List<Permanent> destroyedPermanents = new ArrayList<>();
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent target = game.getPermanent(targetId);
@ -115,47 +113,25 @@ class IndomitableCreativityEffect extends OneShotEffect {
}
}
}
Map<Player, Cards> cardsToReveal = new HashMap<>();
for (Permanent permanent : destroyedPermanents) {
Player controllerOfDestroyedCreature = game.getPlayer(permanent.getControllerId());
if (controllerOfDestroyedCreature != null) {
Library library = controllerOfDestroyedCreature.getLibrary();
if (library.hasCards()) {
Cards cards = new CardsImpl();
Cards revealCards;
if (cardsToReveal.containsKey(controllerOfDestroyedCreature)) {
revealCards = cardsToReveal.get(controllerOfDestroyedCreature);
} else {
revealCards = new CardsImpl();
cardsToReveal.put(controllerOfDestroyedCreature, revealCards);
}
Card card = library.removeFromTop(game);
cards.add(card);
while (!card.isCreature() && !card.isArtifact() && library.hasCards()) {
card = library.removeFromTop(game);
cards.add(card);
}
if (!cards.isEmpty()) {
revealCards.addAll(cards);
Cards cardsToReaveal = new CardsImpl();
for (Card card : library.getCards(game)) {
cardsToReaveal.add(card);
if (card.isCreature() || card.isArtifact()) {
controllerOfDestroyedCreature.moveCards(card, Zone.EXILED, source, game);
controllerOfDestroyedCreature.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
Set<Card> cardsToShuffle = cards.getCards(game);
cardsToShuffle.remove(card);
library.addAll(cardsToShuffle, game);
}
controllerOfDestroyedCreature.revealCards(source, " for destroyed " + permanent.getIdName(), cardsToReaveal, game);
controllerOfDestroyedCreature.shuffleLibrary(source, game);
}
}
}
// reveal cards at the end (because a player can have x permanents to be destroyed
for (Player player : cardsToReveal.keySet()) {
player.revealCards(sourceObject.getIdName(), cardsToReveal.get(player), game);
}
return true;
}
return false;

View file

@ -28,7 +28,6 @@
package mage.cards.j;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
@ -72,7 +71,7 @@ import mage.util.CardUtil;
public class JaceArchitectOfThought extends CardImpl {
public JaceArchitectOfThought(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{U}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.JACE);
@ -192,16 +191,8 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.revealCards("Jace, Architect of Thought", cards, game);
Cards allCards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
player.revealCards(source, allCards, game);
Set<UUID> opponents = game.getOpponents(source.getControllerId());
if (!opponents.isEmpty()) {
Player opponent = null;
@ -215,50 +206,24 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
opponent = game.getPlayer(opponents.iterator().next());
}
TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile"));
target.setRequired(false);
Cards pile1 = new CardsImpl();
if (opponent.choose(Outcome.Neutral, cards, target, game)) {
for (UUID targetId : (List<UUID>) target.getTargets()) {
Card card = cards.get(targetId, game);
if (card != null) {
pile1.add(card);
cards.remove(card);
}
}
}
player.revealCards("Pile 1 (Jace, Architect of Thought)", pile1, game);
player.revealCards("Pile 2 (Jace, Architect of Thought)", cards, game);
TargetCard target = new TargetCard(0, allCards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile"));
target.setNotTarget(true);
opponent.choose(Outcome.Neutral, allCards, target, game);
Cards pile1 = new CardsImpl(target.getTargets());
Cards pile2 = new CardsImpl(allCards);
pile2.removeAll(pile1);
player.revealCards(source, "Pile 1", pile1, game);
player.revealCards(source, "Pile 2", pile2, game);
postPileToLog("Pile 1", pile1.getCards(game), game);
postPileToLog("Pile 2", cards.getCards(game), game);
postPileToLog("Pile 2", pile2.getCards(game), game);
Cards cardsToHand = cards;
Cards cardsToLibrary = pile1;
List<Card> cardPile1 = new ArrayList<>();
List<Card> cardPile2 = new ArrayList<>();
for (UUID cardId : pile1) {
cardPile1.add(game.getCard(cardId));
}
for (UUID cardId : cards) {
cardPile2.add(game.getCard(cardId));
}
boolean pileChoice = player.choosePile(Outcome.Neutral, "Choose a pile to to put into your hand.", cardPile1, cardPile2, game);
if (pileChoice) {
cardsToHand = pile1;
cardsToLibrary = cards;
}
boolean pileChoice = player.choosePile(Outcome.Neutral, "Choose a pile to to put into your hand.",
new ArrayList<>(pile1.getCards(game)),
new ArrayList<>(allCards.getCards(game)), game);
game.informPlayers(player.getLogName() + " chose pile" + (pileChoice ? "1" : "2"));
for (UUID cardUuid : cardsToHand) {
Card card = cardsToHand.get(cardUuid, game);
if (card != null) {
player.moveCards(card, Zone.HAND, source, game);
}
}
player.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, true);
player.moveCards(pileChoice ? pile1 : pile2, Zone.HAND, source, game);
player.putCardsOnBottomOfLibrary(pileChoice ? pile2 : pile1, game, source, true);
return true;
}
return false;

View file

@ -40,8 +40,8 @@ import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
@ -55,7 +55,7 @@ import mage.target.common.TargetCreaturePermanent;
public class JaceTheMindSculptor extends CardImpl {
public JaceTheMindSculptor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{U}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.JACE);
@ -150,21 +150,12 @@ class JaceTheMindSculptorEffect2 extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
while (true) {
if (player.getLibrary().getFromTop(game) == null) {
break;
}
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToExile(null, "", source.getSourceId(), game);
}
}
for (Card card : player.getHand().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
player.shuffleLibrary(source, game);
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (controller != null && targetPlayer != null) {
controller.moveCards(targetPlayer.getLibrary().getTopCards(game, targetPlayer.getLibrary().size()), Zone.EXILED, source, game);
targetPlayer.moveCards(targetPlayer.getHand(), Zone.LIBRARY, source, game);
targetPlayer.shuffleLibrary(source, game);
return true;
}
return false;

View file

@ -37,7 +37,6 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
@ -62,7 +61,7 @@ import mage.target.TargetCard;
public class JarOfEyeballs extends CardImpl {
public JarOfEyeballs(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Whenever a creature you control dies, put two eyeball counters on Jar of Eyeballs.
this.addAbility(new JarOfEyeballsTriggeredAbility());
@ -184,37 +183,25 @@ class JarOfEyeballsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int countersRemoved = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof JarOfEyeballsCost) {
countersRemoved = ((JarOfEyeballsCost) cost).getRemovedCounters();
}
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), countersRemoved);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Jar of Eyeballs", cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, countersRemoved));
controller.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Cards targetCards = new CardsImpl(target.getTargets());
controller.moveCards(targetCards, Zone.HAND, source, game);
cards.removeAll(targetCards);
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -27,11 +27,7 @@
*/
package mage.cards.j;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
@ -51,13 +47,13 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -67,7 +63,7 @@ import mage.players.Player;
public class JeskaiInfiltrator extends CardImpl {
public JeskaiInfiltrator(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.MONK);
this.power = new MageInt(2);
@ -112,23 +108,21 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Card> cardsToManifest = new ArrayList<>(2);
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Card sourceCard = game.getCard(source.getSourceId());
if (sourcePermanent != null && sourceCard != null) {
controller.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
cardsToManifest.add(sourceCard);
HashSet<Card> cardsToManifest = new HashSet<>();
cardsToManifest.add(source.getSourcePermanentIfItStillExists(game));
cardsToManifest.add(controller.getLibrary().getFromTop(game));
UUID exileId = UUID.randomUUID();
controller.moveCardsToExile(cardsToManifest, source, game, false, exileId, "");
ExileZone exileZone = game.getExile().getExileZone(exileId);
for (Card card : exileZone.getCards(game)) {
card.setFaceDown(true, game);
}
if (sourcePermanent != null && controller.getLibrary().hasCards()) {
Card cardFromLibrary = controller.getLibrary().removeFromTop(game);
controller.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
cardsToManifest.add(cardFromLibrary);
}
Collections.shuffle(cardsToManifest);
game.fireUpdatePlayersEvent(); // removes Jeskai from Battlefield, so he returns as a fresh permanent to the battlefield with new position
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
for (Card card : cardsToManifest) {
while (!exileZone.isEmpty()) {
Card card = exileZone.getRandom(game);
ManaCosts manaCosts = null;
if (card.isCreature()) {
manaCosts = card.getSpellAbility().getManaCosts();
@ -139,9 +133,7 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
Set<Card> toBattlefield = new LinkedHashSet();
toBattlefield.addAll(cardsToManifest);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;

View file

@ -1,14 +1,9 @@
package mage.cards.k;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.LegendarySpellAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
@ -29,8 +24,7 @@ import mage.players.Player;
import mage.target.TargetCard;
/**
* @author JRHerlehy
* Created on 4/8/18.
* @author JRHerlehy Created on 4/8/18.
*/
public class KamahlsDruidicVow extends CardImpl {
@ -72,18 +66,12 @@ class KamahlsDruidicVowEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
int xValue = source.getManaCostsToPay().getX();
int numCards = Math.min(controller.getLibrary().size(), xValue);
for (int i = 0; i < numCards; i++) {
Card card = controller.getLibrary().removeFromTop(game);
cards.add(card);
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
controller.lookAtCards(source, null, cards, game);
if (!cards.isEmpty()) {
FilterCard filter = new FilterPermanentCard("land and/or legendary permanent cards with converted mana cost " + xValue + " or less to put onto the battlefield");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1));
@ -93,18 +81,11 @@ class KamahlsDruidicVowEffect extends OneShotEffect {
new SupertypePredicate(SuperType.LEGENDARY)
));
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter);
target1.setRequired(false);
target1.setNotTarget(true);
controller.choose(Outcome.PutCardInPlay, cards, target1, game);
Set<Card> toBattlefield = new LinkedHashSet<>();
for (UUID cardId : target1.getTargets()) {
Card card = cards.get(cardId, game);
if (card != null) {
cards.remove(card);
toBattlefield.add(card);
}
}
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, false, false, null);
Cards toBattlefield = new CardsImpl(target1.getTargets());
cards.removeAll(toBattlefield);
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;

View file

@ -30,7 +30,6 @@ package mage.cards.k;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
@ -96,8 +95,7 @@ class KindredSummonsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (controller != null) {
SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game);
if (subType == null) {
return false;
@ -110,19 +108,23 @@ class KindredSummonsEffect extends OneShotEffect {
Cards otherCards = new CardsImpl();
FilterCreatureCard filterCard = new FilterCreatureCard("creature card of the chosen type");
filterCard.add(new SubtypePredicate(subType));
while (chosenSubtypeCreatureCards.size() < numberOfCards && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
for (Card card : controller.getLibrary().getCards(game)) {
revealed.add(card);
if (card != null && filterCard.match(card, game)) {
chosenSubtypeCreatureCards.add(card);
if (chosenSubtypeCreatureCards.size() == numberOfCards) {
break;
}
} else {
otherCards.add(card);
}
}
controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.revealCards(source, revealed, game);
controller.moveCards(chosenSubtypeCreatureCards, Zone.BATTLEFIELD, source, game);
controller.putCardsOnTopOfLibrary(otherCards, game, source, false);
controller.shuffleLibrary(source, game);
if (!otherCards.isEmpty()) {
controller.putCardsOnTopOfLibrary(otherCards, game, source, false);
controller.shuffleLibrary(source, game);
}
return true;
}
return false;

View file

@ -30,18 +30,14 @@ package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
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.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
@ -50,8 +46,7 @@ import mage.target.TargetCard;
public class LimDulsVault extends CardImpl {
public LimDulsVault(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}{B}");
// Look at the top five cards of your library. As many times as you choose, you may pay 1 life, put those cards on the bottom of your library in any order, then look at the top five cards of your library. Then shuffle your library and put the last cards you looked at this way on top of it in any order.
this.getSpellAbility().addEffect(new LimDulsVaultEffect());
@ -68,12 +63,12 @@ public class LimDulsVault extends CardImpl {
}
class LimDulsVaultEffect extends OneShotEffect {
static final private String textTop = "card to put on your library (last chosen will be on top)";
static final private String textBottom = "card to put on bottom of your library (last chosen will be on bottom)";
public LimDulsVaultEffect() {
super(Outcome.Benefit);
this.staticText = "Look at the top five cards of your library. As many times as you choose, you may pay 1 life, put those cards on the bottom of your library in any order, then look at the top five cards of your library. Then shuffle your library and put the last cards you looked at this way on top of it in any order";
this.staticText = "Look at the top five cards of your library. As many times as you choose, "
+ "you may pay 1 life, put those cards on the bottom of your library in any order, then look at the top five cards of your library. "
+ "Then shuffle your library and put the last cards you looked at this way on top of it in any order";
}
public LimDulsVaultEffect(final LimDulsVaultEffect effect) {
@ -93,38 +88,17 @@ class LimDulsVaultEffect extends OneShotEffect {
}
boolean doAgain;
do {
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 5);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Lim-Dul's Vault", cards, game);
do {
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 5));
player.lookAtCards(source, null, cards, game);
doAgain = player.chooseUse(outcome, "Pay 1 life and look at the next 5 cards?", source, game);
if (doAgain) {
player.loseLife(1, game, false);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
} else {
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(cards, game, source, true);
}
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard(doAgain ? textBottom : textTop));
while (player.canRespond() && cards.size() > 1) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, !doAgain);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, !doAgain);
}
} while (doAgain);
return true;

View file

@ -33,13 +33,11 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -52,7 +50,7 @@ import mage.target.TargetPlayer;
public class LostHours extends CardImpl {
public LostHours(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Target player reveals their hand. You choose a nonland card from it. That player puts that card into their library third from the top.
this.getSpellAbility().addEffect(new LostHoursEffect());
@ -71,17 +69,11 @@ public class LostHours extends CardImpl {
class LostHoursEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("nonland card");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
}
public LostHoursEffect() {
super(Outcome.Discard);
this.staticText = "Target player reveals their hand. You choose a nonland card from it. That player puts that card into their library third from the top.";
this.staticText = "Target player reveals their hand. You choose a nonland card from it. That player puts that card into their library third from the top";
}
public LostHoursEffect(final LostHoursEffect effect) {
super(effect);
}
@ -90,38 +82,19 @@ class LostHoursEffect extends OneShotEffect {
public LostHoursEffect copy() {
return new LostHoursEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (player != null && controller != null) {
player.revealCards("Lost Hours", player.getHand(), game);
if (player.getHand().size() > 0) {
TargetCard target = new TargetCard(Zone.HAND, new FilterCard(filter));
if (controller.choose(Outcome.Discard, player.getHand(), target, game)) {
if (targetPlayer != null && controller != null) {
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
if (targetPlayer.getHand().size() > 0) {
TargetCard target = new TargetCard(Zone.HAND, new FilterCard(StaticFilters.FILTER_CARD_A_NON_LAND));
if (controller.choose(Outcome.Discard, targetPlayer.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
// Move card to third position
CardsImpl cards = new CardsImpl();
cards.add(card);
Card cardTop = null;
Card cardSecond = null;
if (player.getLibrary().hasCards()) {
cardTop = player.getLibrary().removeFromTop(game);
}
if (player.getLibrary().hasCards()) {
cardSecond = player.getLibrary().removeFromTop(game);
}
player.putCardsOnTopOfLibrary(cards, game, source, true);
if (cardSecond != null) {
player.getLibrary().putOnTop(cardSecond, game);
}
if (cardTop != null) {
player.getLibrary().putOnTop(cardTop, game);
}
game.informPlayers(card.getLogName() + " is put into " + player.getLogName() +"'s library " + (cardTop != null ? (cardSecond != null ? "third" : "second") : "first") + " from the top");
targetPlayer.putCardOnTopXOfLibrary(card, game, source, 3);
}
}
}
@ -129,5 +102,5 @@ class LostHoursEffect extends OneShotEffect {
}
return false;
}
}

View file

@ -28,7 +28,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -39,7 +38,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
/**
@ -84,31 +82,25 @@ class MadcapExperimentEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && controller.getLibrary().hasCards()) {
CardsImpl cards = new CardsImpl();
Library library = controller.getLibrary();
Card card = null;
do {
card = library.removeFromTop(game);
if (card != null) {
cards.add(card);
if (controller != null) {
CardsImpl toReveal = new CardsImpl();
Card toBattlefield = null;
for (Card card : controller.getLibrary().getCards(game)) {
toReveal.add(card);
game.fireUpdatePlayersEvent();
if (card.isArtifact()) {
toBattlefield = card;
break;
}
} while (library.hasCards() && card != null && !card.isArtifact());
// reveal cards
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
}
int revealed = cards.size();
if (card != null && card.isArtifact()) {
// put artifact card to battlefield
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
// remove it from revealed card list
cards.remove(card);
}
// Put the rest on the bottom of your library in a random order
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
controller.damage(revealed, source.getSourceId(), game, false, true);
controller.revealCards(source, toReveal, game);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
int damage = toReveal.size();
toReveal.remove(toBattlefield);
controller.putCardsOnBottomOfLibrary(toReveal, game, source, false);
controller.damage(damage, source.getSourceId(), game, false, true);
return true;
}
return false;

View file

@ -29,10 +29,8 @@ package mage.cards.m;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -45,7 +43,6 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -86,31 +83,25 @@ class MassPolymorphEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
int count;
if (controller != null) {
// Cards creatures = new CardsImpl();
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game);
Set<Card> creaturesToExile = new HashSet<>();
creaturesToExile.addAll(creatures);
count = creatures.size();
Set<Card> creaturesToExile = new HashSet<>(game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game));
int count = creaturesToExile.size();
controller.moveCards(creaturesToExile, Zone.EXILED, source, game);
Cards revealed = new CardsImpl();
Set<Card> creatureCards = new LinkedHashSet<>();
Cards nonCreatureCards = new CardsImpl();
while (creatureCards.size() < count && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
for (Card card : controller.getLibrary().getCards(game)) {
revealed.add(card);
if (card.isCreature()) {
creatureCards.add(card);
} else {
nonCreatureCards.add(card);
if (creatureCards.size() == count) {
break;
}
}
}
controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.revealCards(source, revealed, game);
controller.moveCards(creatureCards, Zone.BATTLEFIELD, source, game, false, false, true, null);
controller.putCardsOnTopOfLibrary(nonCreatureCards, game, source, false);
controller.shuffleLibrary(source, game);
return true;
}

View file

@ -49,15 +49,12 @@ import mage.target.common.TargetOpponent;
public class MindFuneral extends CardImpl {
public MindFuneral(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}{B}");
// Target opponent reveals cards from the top of their library until four land cards are revealed. That player puts all cards revealed this way into their graveyard.
this.getSpellAbility().addEffect(new MindFuneralEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
}
public MindFuneral(final MindFuneral card) {
@ -92,17 +89,13 @@ class MindFuneralEffect extends OneShotEffect {
if (opponent != null) {
Cards cards = new CardsImpl();
int landsFound = 0;
while (landsFound < 4 && opponent.getLibrary().hasCards()) {
Card card = opponent.getLibrary().removeFromTop(game);
if (card == null) {
for (Card card : opponent.getLibrary().getCards(game)) {
cards.add(card);
if (card.isLand() && ++landsFound == 4) {
break;
}
if (card.isLand()) {
landsFound++;
}
cards.add(card);
}
opponent.revealCards("Mind Funeral", cards, game);
opponent.revealCards(source, cards, game);
opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}

View file

@ -50,18 +50,17 @@ import mage.players.Player;
public class MindGrind extends CardImpl {
public MindGrind(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}{B}");
// Each opponent reveals cards from the top of their library until he or she reveals X land cards, then puts all cards revealed this way into their graveyard. X can't be 0.
this.getSpellAbility().addEffect(new MindGrindEffect());
for (VariableCost cost: this.getSpellAbility().getManaCosts().getVariableCosts()) {
for (VariableCost cost : this.getSpellAbility().getManaCosts().getVariableCosts()) {
if (cost instanceof VariableManaCost) {
((VariableManaCost) cost).setMinX(1);
break;
}
}
}
}
public MindGrind(final MindGrind card) {
super(card);
@ -92,8 +91,7 @@ class MindGrindEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX();
Card sourceCard = game.getCard(source.getSourceId());
if (xValue < 1 || sourceCard == null) {
if (xValue < 1) {
return false;
}
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
@ -103,19 +101,13 @@ class MindGrindEffect extends OneShotEffect {
}
int landsToReveal = xValue;
Cards cards = new CardsImpl();
while(player.getLibrary().hasCards()){
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if(card.isLand()){
--landsToReveal;
if (landsToReveal < 1) {
break;
}
}
for (Card card : player.getLibrary().getCards(game)) {
cards.add(card);
if (card.isLand() && --landsToReveal == 0) {
break;
}
}
player.revealCards("by " + sourceCard.getName() + " from " + player.getName(), cards, game);
player.revealCards(source, "from " + player.getName(), cards, game);
player.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;

View file

@ -28,7 +28,6 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
@ -41,10 +40,10 @@ import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil;
/**
*
@ -91,17 +90,15 @@ class MindsDesireEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (controller != null) {
controller.shuffleLibrary(source, game);
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
ContinuousEffect effect = new MindsDesireCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
UUID exileId = UUID.randomUUID();
controller.moveCardsToExile(card, source, game, true, exileId, CardUtil.createObjectRealtedWindowTitle(source, game, null));
ContinuousEffect effect = new MindsDesireCastFromExileEffect();
effect.setTargetPointer(new FixedTargets(game.getExile().getExileZone(exileId).getCards(game), game));
game.addEffect(effect, source);
}
return true;
}
@ -132,19 +129,15 @@ class MindsDesireCastFromExileEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (objectId != null && objectId.equals(getTargetPointer().getFirst(game, source))) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
if (card != null && game.getState().getZone(objectId) == Zone.EXILED) {
if (!card.isLand() && card.getSpellAbility().getCosts() != null) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts());
}
}
return true;
if (affectedControllerId.equals(source.getControllerId()) && getTargetPointer().getTargets(game, source).contains(objectId)) {
Card card = game.getCard(objectId);
if (card != null && !card.isLand() && card.getSpellAbility().getCosts() != null) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
player.setCastSourceIdWithAlternateMana(objectId, null, card.getSpellAbility().getCosts());
}
}
return true;
}
return false;
}

View file

@ -39,9 +39,9 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -54,7 +54,7 @@ import mage.target.TargetPlayer;
public class Mindshrieker extends CardImpl {
public Mindshrieker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.SPIRIT);
this.subtype.add(SubType.BIRD);
@ -95,7 +95,7 @@ class MindshriekerEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
if (targetPlayer.getLibrary().hasCards()) {
Card card = targetPlayer.getLibrary().removeFromTop(game);
Card card = targetPlayer.getLibrary().getFromTop(game);
if (card != null) {
targetPlayer.moveCards(card, Zone.GRAVEYARD, source, game);
int amount = card.getConvertedManaCost();
@ -114,4 +114,4 @@ class MindshriekerEffect extends OneShotEffect {
return new MindshriekerEffect(this);
}
}
}

View file

@ -25,20 +25,18 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
@ -48,16 +46,13 @@ import mage.players.Player;
*
* @author LevelX2
*/
public class MirkoVoskMindDrinker extends CardImpl {
public MirkoVoskMindDrinker (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{B}");
public MirkoVoskMindDrinker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{B}");
this.subtype.add(SubType.VAMPIRE);
addSuperType(SuperType.LEGENDARY);
this.power = new MageInt(2);
this.toughness = new MageInt(4);
@ -67,7 +62,7 @@ public class MirkoVoskMindDrinker extends CardImpl {
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new MirkoVoskMindDrinkerEffect(), false, true));
}
public MirkoVoskMindDrinker (final MirkoVoskMindDrinker card) {
public MirkoVoskMindDrinker(final MirkoVoskMindDrinker card) {
super(card);
}
@ -97,25 +92,20 @@ class MirkoVoskMindDrinkerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
if (player == null) {
return false;
}
int landsToReveal = 4;
Cards cards = new CardsImpl();
while(player.getLibrary().hasCards()){
Card card = player.getLibrary().removeFromTop(game);
for (Card card : player.getLibrary().getCards(game)) {
if (card != null) {
cards.add(card);
if(card.isLand()){
--landsToReveal;
if (landsToReveal < 1) {
break;
}
if (card.isLand() && --landsToReveal < 1) {
break;
}
}
}
player.revealCards("by " + sourceObject.getName() + " from " + player.getName(), cards, game);
player.revealCards(source, "from " + player.getName(), cards, game);
player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}

View file

@ -89,32 +89,34 @@ class MirrorMadPhantasmEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent perm = game.getPermanent(source.getSourceId());
Permanent perm = source.getSourcePermanentIfItStillExists(game);
if (perm != null) {
Player player = game.getPlayer(perm.getOwnerId());
if (player != null) {
Player owner = game.getPlayer(perm.getOwnerId());
if (owner == null) {
return false;
}
if (owner.moveCards(perm, Zone.LIBRARY, source, game)) {
owner.shuffleLibrary(source, game);
perm.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
player.shuffleLibrary(source, game);
owner.shuffleLibrary(source, game);
Cards cards = new CardsImpl();
while (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
if (card == null) {
break;
}
if (card.getName().equals("Mirror-Mad Phantasm")) {
player.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
Card phantasmCard = null;
for (Card card : owner.getLibrary().getCards(game)) {
cards.add(card);
if (card.getName().equals("Mirror-Mad Phantasm")) {
phantasmCard = card;
break;
}
}
if (!cards.isEmpty()) {
player.revealCards("Mirror-Mad Phantasm", cards, game);
player.moveCards(cards, Zone.GRAVEYARD, source, game);
owner.revealCards(source, cards, game);
if (phantasmCard != null) {
owner.moveCards(phantasmCard, Zone.BATTLEFIELD, source, game);
cards.remove(phantasmCard);
}
return true;
owner.moveCards(cards, Zone.GRAVEYARD, source, game);
}
}
return false;
return true;
}
@Override

View file

@ -37,8 +37,8 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactCard;
@ -55,7 +55,7 @@ import mage.target.TargetCard;
public class MuzzioVisionaryArchitect extends CardImpl {
public MuzzioVisionaryArchitect(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ARTIFICER);
@ -97,8 +97,7 @@ class MuzzioVisionaryArchitectEffect 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;
}
@ -113,28 +112,19 @@ class MuzzioVisionaryArchitectEffect extends OneShotEffect {
}
}
Cards cards = new CardsImpl();
for (int i = 0; i < highCMC; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
controller.lookAtCards(sourcePermanent.getIdName(), cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, highCMC));
controller.lookAtCards(source, null, cards, game);
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield"));
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
controller.revealCards(source, new CardsImpl(card), game);
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}

View file

@ -30,30 +30,25 @@ package mage.cards.n;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
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.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer;
/**
*
* @author KholdFuzion
*
*/
public class NaturalSelection extends CardImpl {
public NaturalSelection(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}");
// Look at the top three cards of target player's library, then put them back in any order. You may have that player shuffle their library.
this.getSpellAbility().addEffect(new NaturalSelectionEffect());
@ -70,57 +65,35 @@ public class NaturalSelection extends CardImpl {
}
}
class NaturalSelectionEffect extends OneShotEffect {
class NaturalSelectionEffect extends OneShotEffect {
public NaturalSelectionEffect() {
public NaturalSelectionEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top three cards of target player's library, then put them back in any order. You may have that player shuffle their library.";
}
public NaturalSelectionEffect(final NaturalSelectionEffect effect) {
public NaturalSelectionEffect(final NaturalSelectionEffect effect) {
super(effect);
}
@Override
public NaturalSelectionEffect copy() {
return new NaturalSelectionEffect(this);
public NaturalSelectionEffect copy() {
return new NaturalSelectionEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || you == null) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null || controller == null) {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
you.lookAtCards("Natural Selection", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of target player's library"));
while (player.canRespond() && cards.size() > 1) {
you.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
if (you.chooseUse(Outcome.Neutral, "You may have that player shuffle their library", source, game)){
player.shuffleLibrary(source, game);
Cards cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3));
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
if (controller.chooseUse(Outcome.Neutral, "You may have that player shuffle their library", source, game)) {
targetPlayer.shuffleLibrary(source, game);
}
return true;
}
}
}

View file

@ -51,6 +51,7 @@ import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -59,7 +60,7 @@ import mage.target.targetpointer.FixedTarget;
public class Necropotence extends CardImpl {
public Necropotence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{B}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}{B}{B}");
// Skip your draw step.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect()));
@ -137,17 +138,16 @@ class NecropotenceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, false)) {
card.setFaceDown(true, game);
Effect returnToHandEffect = new ReturnToHandTargetEffect();
returnToHandEffect.setText("put that face down card into your hand");
returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source);
return true;
}
return false;
Card card = controller.getLibrary().getFromTop(game);
if (card != null && controller.moveCardsToExile(card, source, game, false,
CardUtil.getCardExileZoneId(game, source),
CardUtil.createObjectRealtedWindowTitle(source, game, null))) {
card.setFaceDown(true, game);
Effect returnToHandEffect = new ReturnToHandTargetEffect();
returnToHandEffect.setText("put that face down card into your hand");
returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source);
return true;
}
return true;
}

View file

@ -27,7 +27,9 @@
*/
package mage.cards.n;
import mage.MageObject;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
@ -46,15 +48,11 @@ import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
*
* @author Will
@ -172,22 +170,21 @@ class NicolBolasGodPharaohPlusTwoEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (opponent != null && opponent.getLibrary().hasCards() && sourceObject != null) {
if (opponent != null) {
Library library = opponent.getLibrary();
Card card;
do {
card = library.removeFromTop(game);
card = library.getFromTop(game);
if (card != null) {
opponent.moveCards(card, Zone.EXILED, source, game);
if (!card.isLand()) {
ContinuousEffect effect = new NicolBolasGodPharaohFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
game.addEffect(effect, source);
break;
}
}
} while (library.hasCards() && card != null && card.isLand());
if (card != null) {
ContinuousEffect effect = new NicolBolasGodPharaohFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
game.addEffect(effect, source);
}
} while (library.hasCards() && card != null);
return true;
}
return false;

View file

@ -29,7 +29,6 @@ package mage.cards.n;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -108,10 +107,9 @@ class NightveilSpecterExileEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
Card card = player.getLibrary().removeFromTop(game);
MageObject sourceObject = game.getObject(source.getSourceId());
if (card != null && sourceObject != null) {
player.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCardsToExile(card, source, game, true, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, null));
return true;
}
}
@ -147,10 +145,9 @@ class NightveilSpecterEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(objectId);
if (affectedControllerId.equals(source.getControllerId()) && card != null && game.getState().getZone(card.getId()) == Zone.EXILED) {
if (affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
return zone != null && zone.contains(card.getId());
return zone != null && zone.contains(objectId);
}
return false;
}

View file

@ -48,6 +48,7 @@ import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -56,11 +57,11 @@ import mage.target.targetpointer.FixedTarget;
public class NivixAerieOfTheFiremind extends CardImpl {
public NivixAerieOfTheFiremind(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.LAND},"");
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
// {tap}: Add {C}.
this.addAbility(new ColorlessManaAbility());
// {2}{U}{R}, {tap}: Exile the top card of your library. Until your next turn, you may cast that card if it's an instant or sorcery card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NivixAerieOfTheFiremindEffect(), new ManaCostsImpl<>("{2}{U}{R}"));
ability.addCost(new TapSourceCost());
@ -78,30 +79,30 @@ public class NivixAerieOfTheFiremind extends CardImpl {
}
class NivixAerieOfTheFiremindEffect extends OneShotEffect {
NivixAerieOfTheFiremindEffect() {
super(Outcome.Benefit);
this.staticText = "Exile the top card of your library. Until your next turn, you may cast that card if it's an instant or sorcery card";
}
NivixAerieOfTheFiremindEffect(final NivixAerieOfTheFiremindEffect effect) {
super(effect);
}
@Override
public NivixAerieOfTheFiremindEffect copy() {
return new NivixAerieOfTheFiremindEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Library library = controller.getLibrary();
if (library.hasCards()) {
Card card = library.removeFromTop(game);
Card card = library.getFromTop(game);
if (card != null
&& controller.moveCardsToExile(card, source, game, true, source.getSourceId(), "Nivix, Aerie of the Firemind")
&& controller.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null))
&& (card.isInstant() || card.isSorcery())) {
ContinuousEffect effect = new NivixAerieOfTheFiremindCanCastEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
@ -136,10 +137,8 @@ class NivixAerieOfTheFiremindCanCastEffect extends AsThoughEffectImpl {
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
return this.getTargetPointer().getFirst(game, source) != null
&& this.getTargetPointer().getFirst(game, source).equals(sourceId)
&& source.getControllerId().equals(affectedControllerId)
&& game.getState().getZone(sourceId) == Zone.EXILED;
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
return source.getControllerId().equals(affectedControllerId)
&& objectId.equals(this.getTargetPointer().getFirst(game, source));
}
}

View file

@ -120,9 +120,9 @@ class OmenMachineEffect2 extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
Card card = player.getLibrary().removeFromTop(game);
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
player.moveCards(card, Zone.EXILED, source, game);
if (card.isLand()) {
player.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {

View file

@ -52,6 +52,7 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -77,7 +78,7 @@ public class OraclesVault extends CardImpl {
this.addAbility(new ConditionalActivatedAbility(Zone.BATTLEFIELD,
new OraclesVaultFreeEffect(), new TapSourceCost(), new SourceHasCounterCondition(CounterType.BRICK, 3, Integer.MAX_VALUE),
"{T}: Exile the top card of your library. Until end of turn, you may play that card without paying its mana cost. "
+ "Activate this ability only if there are three or more brick counters on {this}"));
+ "Activate this ability only if there are three or more brick counters on {this}"));
}
public OraclesVault(final OraclesVault card) {
@ -108,12 +109,11 @@ class OraclesVaultEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.removeFromTop(game);
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true);
controller.moveCardsToExile(card, source, game, true, source.getSourceId(),
CardUtil.createObjectRealtedWindowTitle(source, game, "<this card may be played the turn it was exiled>"));
game.addEffect(new OraclesVaultPlayEffect(new MageObjectReference(card, game)), source);
}
return true;
@ -121,6 +121,7 @@ class OraclesVaultEffect extends OneShotEffect {
return false;
}
}
class OraclesVaultFreeEffect extends OneShotEffect {
public OraclesVaultFreeEffect() {
@ -142,9 +143,10 @@ class OraclesVaultFreeEffect extends OneShotEffect {
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.removeFromTop(game);
Card card = library.getFromTop(game);
if (card != null) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true);
controller.moveCardsToExile(card, source, game, true, source.getSourceId(),
CardUtil.createObjectRealtedWindowTitle(source, game, " <this card may be played the turn it was exiled>"));
game.addEffect(new OraclesVaultPlayForFreeEffect(new MageObjectReference(card, game)), source);
}
return true;
@ -191,6 +193,7 @@ class OraclesVaultPlayEffect extends AsThoughEffectImpl {
return false;
}
}
class OraclesVaultPlayForFreeEffect extends AsThoughEffectImpl {
private final MageObjectReference objectReference;
@ -229,4 +232,4 @@ class OraclesVaultPlayForFreeEffect extends AsThoughEffectImpl {
}
return false;
}
}
}

View file

@ -45,10 +45,8 @@ import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
@ -83,7 +81,7 @@ class OrcishLibrarianEffect extends OneShotEffect {
public OrcishLibrarianEffect() {
super(Outcome.Neutral);
this.staticText = "Look at the top eight cards of your library. Exile four of them at random, then put the rest on top of your library in any order.";
this.staticText = "Look at the top eight cards of your library. Exile four of them at random, then put the rest on top of your library in any order";
}
public OrcishLibrarianEffect(final OrcishLibrarianEffect effect) {
@ -100,34 +98,21 @@ class OrcishLibrarianEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
int cardsCount = Math.min(8, controller.getLibrary().size());
for (int i = 0; i < cardsCount; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 8));
if (!cards.isEmpty()) {
Cards randomExit = new CardsImpl();
for (int i = 0; i < 4; i++) {
if (!cards.isEmpty()) {
Card card = cards.getRandom(game);
controller.moveCardToExileWithInfo(card, null, null, source.getId(), game, Zone.LIBRARY, true);
cards.remove(card);
if (card != null) {
randomExit.add(card);
cards.remove(card);
}
}
}
controller.lookAtCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of target player's library"));
while (controller.canRespond() && !cards.isEmpty()) {
controller.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
target.clearChosen();
}
controller.moveCards(randomExit, Zone.EXILED, source, game);
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
}
return true;
}

View file

@ -30,12 +30,10 @@ package mage.cards.o;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -48,8 +46,7 @@ import mage.target.common.TargetCreaturePermanent;
public class Oust extends CardImpl {
public Oust(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}");
// Put target creature into its owner's library second from the top. Its controller gains 3 life.
this.getSpellAbility().addEffect(new OustEffect());
@ -84,27 +81,16 @@ class OustEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player owner = game.getPlayer(permanent.getOwnerId());
Player controller = game.getPlayer(permanent.getControllerId());
if (owner == null || controller == null) {
return false;
}
Card card = null;
if (owner.getLibrary().hasCards()) {
card = owner.getLibrary().removeFromTop(game);
}
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
if (card != null) {
owner.getLibrary().putOnTop(card, game);
}
owner.getLibrary().putCardToTopXPos(permanent, 2, game);
controller.gainLife(3, game, source);
return true;
}
return false;
return true;
}
}

View file

@ -29,7 +29,6 @@ package mage.cards.p;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -45,6 +44,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
/**
*
@ -89,11 +89,9 @@ class PetraSphinxEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && sourceObject != null && player != null) {
if (controller != null && player != null) {
if (player.getLibrary().hasCards()) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames());
@ -102,11 +100,11 @@ class PetraSphinxEffect extends OneShotEffect {
return false;
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().removeFromTop(game);
game.informPlayers(CardUtil.createObjectRealtedWindowTitle(source, game, null) + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(sourceObject.getIdName(), cards, game);
player.revealCards(source, cards, game);
if (card.getName().equals(cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {

View file

@ -58,10 +58,9 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class PlungeIntoDarkness extends CardImpl {
public PlungeIntoDarkness(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{B}");
// Choose one -
// Choose one -
this.getSpellAbility().getModes().setMinModes(1);
this.getSpellAbility().getModes().setMaxModes(1);
// Sacrifice any number of creatures, then you gain 3 life for each sacrificed creature;
@ -70,7 +69,7 @@ public class PlungeIntoDarkness extends CardImpl {
Mode mode = new Mode();
mode.getEffects().add(new PlungeIntoDarknessSearchEffect());
this.getSpellAbility().getModes().addMode(mode);
// Entwine {B}
this.addAbility(new EntwineAbility("{B}"));
}
@ -86,21 +85,21 @@ public class PlungeIntoDarkness extends CardImpl {
}
class PlungeIntoDarknessLifeEffect extends OneShotEffect {
PlungeIntoDarknessLifeEffect() {
super(Outcome.GainLife);
this.staticText = "Sacrifice any number of creatures, then you gain 3 life for each sacrificed creature";
}
PlungeIntoDarknessLifeEffect(final PlungeIntoDarknessLifeEffect effect) {
super(effect);
}
@Override
public PlungeIntoDarknessLifeEffect copy() {
return new PlungeIntoDarknessLifeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
@ -126,52 +125,40 @@ class PlungeIntoDarknessLifeEffect extends OneShotEffect {
}
class PlungeIntoDarknessSearchEffect extends OneShotEffect {
PlungeIntoDarknessSearchEffect() {
super(Outcome.Benefit);
this.staticText = "pay X life, then look at the top X cards of your library, put one of those cards into your hand, and exile the rest.";
}
PlungeIntoDarknessSearchEffect(final PlungeIntoDarknessSearchEffect effect) {
super(effect);
}
@Override
public PlungeIntoDarknessSearchEffect copy() {
return new PlungeIntoDarknessSearchEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
VariableCost cost = new PayVariableLifeCost();
int xValue = cost.announceXValue(source, game);
cost.getFixedCostsFromAnnouncedValue(xValue).pay(source, game, source.getSourceId(), source.getControllerId(), false, null);
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), xValue);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Plunge into Darkness", cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
controller.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
game.informPlayers("Plunge into Darkness: " + player.getLogName() + " puts a card into their hand");
controller.moveCards(card, Zone.HAND, source, game);
}
}
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
card.moveToExile(null, "", source.getSourceId(), game);
}
controller.moveCards(cards, Zone.EXILED, source, game);
return true;
}
return false;

View file

@ -27,7 +27,6 @@
*/
package mage.cards.p;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -53,7 +52,7 @@ import mage.target.common.TargetCreaturePermanent;
public class Polymorph extends CardImpl {
public Polymorph(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Destroy target creature. It can't be regenerated.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -98,22 +97,21 @@ class PolymorphEffect extends OneShotEffect {
Library library = player.getLibrary();
if (library.hasCards()) {
Cards cards = new CardsImpl();
Card card = library.removeFromTop(game);
cards.add(card);
while (!card.isCreature() && library.hasCards()) {
card = library.removeFromTop(game);
Card toBattlefield = null;
for (Card card : library.getCards(game)) {
cards.add(card);
if (card.isCreature()) {
toBattlefield = card;
break;
}
}
if (card.isCreature()) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), player.getId());
if (toBattlefield != null) {
player.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
}
player.revealCards(source, cards, game);
cards.remove(toBattlefield);
if (!cards.isEmpty()) {
player.revealCards("Polymorph", cards, game);
Set<Card> cardsToShuffle = cards.getCards(game);
cardsToShuffle.remove(card);
library.addAll(cardsToShuffle, game);
player.shuffleLibrary(source, game);
}
}
return true;

View file

@ -33,18 +33,14 @@ import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbili
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
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.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer;
/**
@ -54,7 +50,7 @@ import mage.target.TargetPlayer;
public class Portent extends CardImpl {
public Portent(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}");
// Look at the top three cards of target player's library, then put them back in any order. You may have that player shuffle their library.
this.getSpellAbility().addEffect(new PortentEffect());
@ -73,57 +69,35 @@ public class Portent extends CardImpl {
}
}
class PortentEffect extends OneShotEffect {
class PortentEffect extends OneShotEffect {
public PortentEffect() {
public PortentEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top three cards of target player's library, then put them back in any order. You may have that player shuffle their library.";
}
public PortentEffect(final PortentEffect effect) {
public PortentEffect(final PortentEffect effect) {
super(effect);
}
@Override
public PortentEffect copy() {
return new PortentEffect(this);
public PortentEffect copy() {
return new PortentEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || you == null) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player == null || controller == null) {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
you.lookAtCards("Portent", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of target player's library"));
while (player.canRespond() && cards.size() > 1) {
you.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
if (you.chooseUse(Outcome.Neutral, "You may have that player shuffle their library", source, game)){
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
if (controller.chooseUse(Outcome.Neutral, "You may have that player shuffle their library", source, game)) {
player.shuffleLibrary(source, game);
}
return true;
}
}
}

View file

@ -37,7 +37,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -47,8 +46,7 @@ import mage.players.Player;
public class PrimalSurge extends CardImpl {
public PrimalSurge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{8}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{8}{G}{G}");
// Exile the top card of your library. If it's a permanent card, you may put it onto the battlefield. If you do, repeat this process.
this.getSpellAbility().addEffect(new PrimalSurgeEffect());
@ -82,33 +80,24 @@ class PrimalSurgeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
boolean repeat;
do {
repeat = false;
if (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToExile(null, "", source.getSourceId(), game);
if (card.isPermanent()
&& player.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield?", source, game)) {
card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(card.getId(), Zone.BATTLEFIELD);
}
if (permanent != null) {
repeat = true;
}
}
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
if (card.isPermanent()
&& controller.chooseUse(Outcome.PutCardInPlay, "Put " + card.getName() + " onto the battlefield?", source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
repeat = true;
}
}
} while (player.canRespond() && repeat);
} while (controller.canRespond() && repeat);
return true;
}

View file

@ -41,15 +41,13 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Library;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -102,16 +100,15 @@ class PropheticFlamespeakerExileEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && controller != null && controller.getLibrary().hasCards()) {
Library library = controller.getLibrary();
Card card = library.removeFromTop(game);
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
String exileName = new StringBuilder(sourcePermanent.getIdName()).append(" <this card may be played the turn it was exiled>").toString();
controller.moveCardToExileWithInfo(card, source.getSourceId(), exileName, source.getSourceId(), game, Zone.LIBRARY, true);
ContinuousEffect effect = new PropheticFlamespeakerCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
if (controller.moveCardsToExile(card, source, game, true, source.getSourceId(),
CardUtil.createObjectRealtedWindowTitle(source, game, "<this card may be played the turn it was exiled>"))) {
ContinuousEffect effect = new PropheticFlamespeakerCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
return true;
}

View file

@ -53,9 +53,10 @@ import mage.target.TargetCard;
public class PsychicSurgery extends CardImpl {
public PsychicSurgery(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
// Whenever an opponent shuffles his or her library, you may look at the top two cards of that library.
// You may exile one of those cards. Then put the rest on top of that library in any order.
this.addAbility(new PsychicSurgeryTriggeredAbility());
}
@ -100,7 +101,7 @@ class PsychicSurgeryTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Whenever an opponent shuffles their library, you may look at the top two cards of that library. You may exile one of those cards. Then put the rest on top of that library in any order.";
return "Whenever an opponent shuffles their library, " + super.getRule();
}
}
@ -108,7 +109,7 @@ class PsychicSurgeryEffect extends OneShotEffect {
public PsychicSurgeryEffect() {
super(Outcome.Exile);
this.staticText = "look at the top two cards of that library. You may exile one of those cards. Then put the rest on top of that library in any order";
this.staticText = "you may look at the top two cards of that library. You may exile one of those cards. Then put the rest on top of that library in any order";
}
public PsychicSurgeryEffect(final PsychicSurgeryEffect effect) {
@ -123,31 +124,23 @@ class PsychicSurgeryEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
UUID opponentId = (UUID) this.getValue("PsychicSurgeryOpponent");
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(opponentId);
if (player != null && opponent != null) {
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 2);
for (int i = 0; i < count; i++) {
Card card = opponent.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Psychic Surgery", cards, game);
if (!cards.isEmpty() && player.chooseUse(Outcome.Exile, "Do you wish to exile a card?", source, game)) {
if (controller != null && opponent != null) {
Cards cards = new CardsImpl(opponent.getLibrary().getTopCards(game, 2));
controller.lookAtCards(source, null, cards, game);
if (!cards.isEmpty() && controller.chooseUse(Outcome.Exile, "Do you wish to exile a card?", source, game)) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to exile"));
if (player.choose(Outcome.Exile, cards, target, game)) {
if (controller.choose(Outcome.Exile, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
cards.remove(card);
card.moveToZone(Zone.EXILED, source.getSourceId(), game, false);
}
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
return false;

View file

@ -27,22 +27,16 @@
*/
package mage.cards.q;
import java.util.Deque;
import java.util.LinkedList;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
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.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,7 +50,7 @@ import mage.target.common.TargetCreaturePermanent;
public class QuarryColossus extends CardImpl {
public QuarryColossus(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}");
this.subtype.add(SubType.GIANT);
this.power = new MageInt(5);
@ -102,27 +96,7 @@ class QuarryColossusReturnLibraryEffect extends OneShotEffect {
Player owner = game.getPlayer(permanent.getOwnerId());
if (owner != null) {
int plains = game.getBattlefield().countAll(new FilterPermanent(SubType.PLAINS, "Plains you control"), source.getControllerId(), game);
int xValue = Math.min(plains, owner.getLibrary().size());
Cards cards = new CardsImpl();
Deque<UUID> cardIds = new LinkedList<>();
for (int i = 0; i < xValue; i++) {
Card card = owner.getLibrary().removeFromTop(game);
cards.add(card);
cardIds.push(card.getId());
}
// return cards back to library
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts ").append(permanent.getName())
.append(" beneath the top ").append(xValue)
.append(" cards of ").append(owner.getLogName()).append("'s library").toString());
while(!cardIds.isEmpty()) {
UUID cardId = cardIds.poll();
Card card = cards.get(cardId, game);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
}
controller.putCardOnTopXOfLibrary(permanent, game, source, plains);
return true;
}
}

View file

@ -29,22 +29,16 @@ package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.keyword.EchoAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -53,7 +47,7 @@ import mage.target.TargetCard;
public class RavenFamiliar extends CardImpl {
public RavenFamiliar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add(SubType.BIRD);
this.power = new MageInt(1);
@ -65,7 +59,7 @@ public class RavenFamiliar extends CardImpl {
this.addAbility(new EchoAbility("{2}{U}"));
// When Raven Familiar enters the battlefield, look at the top three cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(
new LookLibraryAndPickControllerEffect(new StaticValue(3), false, new StaticValue(1), new FilterCard(), Zone.LIBRARY, false, false),
new LookLibraryAndPickControllerEffect(new StaticValue(3), false, new StaticValue(1), StaticFilters.FILTER_CARD, Zone.LIBRARY, false, false),
false));
}
@ -77,47 +71,4 @@ public class RavenFamiliar extends CardImpl {
public RavenFamiliar copy() {
return new RavenFamiliar(this);
}
static class RavenFamiliarEffect extends OneShotEffect {
public RavenFamiliarEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top three cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order";
}
public RavenFamiliarEffect(final RavenFamiliarEffect effect) {
super(effect);
}
@Override
public RavenFamiliarEffect copy() {
return new RavenFamiliarEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Raven Familiar", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.cards.r;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -44,8 +45,6 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author LevelX2
@ -53,7 +52,7 @@ import java.util.UUID;
public class Reweave extends CardImpl {
public Reweave(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{5}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{5}{U}");
this.subtype.add(SubType.ARCANE);
// Target permanent's controller sacrifices it. If he or she does, that player reveals cards from the top of their library until he or she reveals a permanent card that shares a card type with the sacrificed permanent, puts that card onto the battlefield, then shuffles their library.
@ -104,33 +103,24 @@ class ReweaveEffect extends OneShotEffect {
Library library = permanentController.getLibrary();
if (library.hasCards()) {
Cards cards = new CardsImpl();
Card card = null;
boolean cardFound = false;
if (library.hasCards()) {
do {
card = library.removeFromTop(game);
cards.add(card);
if (filter.match(card, game)) {
for (CardType cardType : permanent.getCardType()) {
if (card.getCardType().contains(cardType)) {
// a permanent card
cardFound = true;
break;
}
Card permanentCard = null;
for (Card card : permanentController.getLibrary().getCards(game)) {
cards.add(card);
if (card.isPermanent()) {
for (CardType cardType : permanent.getCardType()) {
if (card.getCardType().contains(cardType)) {
permanentCard = card;
break;
}
}
} while (!cardFound && library.hasCards());
permanentController.moveCards(card, Zone.BATTLEFIELD, source, game);
}
if (!cards.isEmpty()) {
permanentController.revealCards(sourceObject.getIdName(), cards, game);
if (cardFound && card != null) {
cards.remove(card);
}
library.addAll(cards.getCards(game), game);
permanentController.shuffleLibrary(source, game);
}
permanentController.revealCards(source, cards, game);
if (permanentCard != null) {
permanentController.moveCards(permanentCard, Zone.BATTLEFIELD, source, game);
}
permanentController.shuffleLibrary(source, game);
}
return true;
}

View file

@ -45,7 +45,6 @@ import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.watchers.common.PlayerAttackedWatcher;
@ -97,16 +96,14 @@ class RuinRaiderEffect 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) {
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controller.revealCards(sourcePermanent.getIdName(), cards, game);
controller.revealCards(source, cards, game);
controller.moveCards(card, Zone.HAND, source, game);
controller.loseLife(card.getConvertedManaCost(), game, false);
}
return true;
}

View file

@ -32,7 +32,6 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
@ -42,12 +41,10 @@ import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
@ -56,7 +53,7 @@ import mage.target.TargetCard;
public class SagesOfTheAnima extends CardImpl {
public SagesOfTheAnima(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{U}");
this.subtype.add(SubType.ELF);
this.subtype.add(SubType.WIZARD);
@ -101,47 +98,24 @@ class SagesOfTheAnimaReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
FilterCard filter = new FilterCard();
filter.add(new CardTypePredicate(CardType.CREATURE));
Player player = game.getPlayer(event.getPlayerId());
Cards cards = new CardsImpl();
if (player != null) {
for (int i = 0; i < 3; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.revealCards("Top three cards of library revealed", cards, game);
for (Card revealedCard : cards.getCards(game)) {
if (revealedCard.isCreature()) {
revealedCard.moveToZone(Zone.HAND, source.getSourceId(), game, false);
cards.remove(revealedCard);
}
}
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard());
while (player.canRespond() && cards.size() > 1) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
Cards revealedCards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
player.revealCards(source, revealedCards, game);
Cards creatures = new CardsImpl(revealedCards.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
player.moveCards(creatures, Zone.BATTLEFIELD, source, game);
revealedCards.removeAll(creatures);
player.putCardsOnBottomOfLibrary(revealedCards, game, source, true);
return true;
}
return true;
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DRAW_CARD;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getPlayerId().equals(source.getControllerId());

View file

@ -42,7 +42,7 @@ import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
@ -53,7 +53,7 @@ import mage.players.Player;
public class SaprazzanBreaker extends CardImpl {
public SaprazzanBreaker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}");
this.subtype.add(SubType.BEAST);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
@ -92,11 +92,11 @@ class SaprazzanBreakerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Card card = player.getLibrary().removeFromTop(game);
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
player.moveCards(card, Zone.GRAVEYARD, source, game);
if (card.isLand()) {
game.addEffect(new CantBeBlockedByAllSourceEffect(new FilterCreaturePermanent(), Duration.EndOfCombat), source);
game.addEffect(new CantBeBlockedByAllSourceEffect(StaticFilters.FILTER_PERMANENT_CREATURES, Duration.EndOfTurn), source);
}
}
return true;

View file

@ -27,8 +27,8 @@
*/
package mage.cards.s;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
@ -38,9 +38,12 @@ import mage.abilities.keyword.FlyingAbility;
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.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -51,7 +54,7 @@ import mage.players.Player;
public class Scalpelexis extends CardImpl {
public Scalpelexis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}");
this.subtype.add(SubType.BEAST);
this.power = new MageInt(1);
@ -92,38 +95,26 @@ class ScalpelexisEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
List<String> namesFiltered = new ArrayList<>();
boolean doneOnce = false;
while (checkDuplicatedNames(namesFiltered) || !doneOnce) {
doneOnce = true;
namesFiltered.clear();
int count = Math.min(player.getLibrary().size(), 4);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
namesFiltered.add(card.getName());
card.moveToExile(id, "Moved these cards to exile", source.getSourceId(), game);
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer == null) {
return false;
}
Set<String> cardNames = new HashSet<>();
boolean doubleName;
do {
doubleName = false;
Cards toExile = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 4));
cardNames.clear();
for (Card card : toExile.getCards(game)) {
if (cardNames.contains(card.getName())) {
doubleName = true;
break;
} else {
cardNames.add(card.getName());
}
}
}
targetPlayer.moveCards(toExile, Zone.EXILED, source, game);
} while (doubleName);
return true;
}
public boolean checkDuplicatedNames(List<String> string) {
for (int i = 0; i < string.size() - 1; i++) {
String stringToCheck = string.get(i);
if (stringToCheck == null) {
continue; //empty ignore
}
for (int j = i + 1; j < string.size(); j++) {
String stringToCompare = string.get(j);
if (stringToCheck.equals(stringToCompare)) {
return true;
}
}
}
return false;
}
}
}

View file

@ -28,7 +28,6 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -53,11 +52,10 @@ import mage.target.TargetCard;
public class ScoutTheBorders extends CardImpl {
public ScoutTheBorders(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard.
this.getSpellAbility().addEffect(new ScoutTheBordersEffect());
this.getSpellAbility().addEffect(new ScoutTheBordersEffect());
}
public ScoutTheBorders(final ScoutTheBorders card) {
@ -70,48 +68,36 @@ public class ScoutTheBorders extends CardImpl {
}
}
class ScoutTheBordersEffect extends OneShotEffect {
class ScoutTheBordersEffect extends OneShotEffect {
private static final FilterCard filterPutInHand = new FilterCard("creature or land card to put in hand");
static {
filterPutInHand.add(Predicates.or(new CardTypePredicate(CardType.CREATURE), new CardTypePredicate(CardType.LAND)));
}
public ScoutTheBordersEffect() {
public ScoutTheBordersEffect() {
super(Outcome.DrawCard);
this.staticText = "Reveal the top five cards of your library. You may put a creature or land card from among them into your hand. Put the rest into your graveyard";
}
public ScoutTheBordersEffect(final ScoutTheBordersEffect effect) {
public ScoutTheBordersEffect(final ScoutTheBordersEffect effect) {
super(effect);
}
@Override
public ScoutTheBordersEffect copy() {
return new ScoutTheBordersEffect(this);
public ScoutTheBordersEffect copy() {
return new ScoutTheBordersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
boolean properCardFound = false;
int count = Math.min(controller.getLibrary().size(), 5);
for (int i = 0; i < count; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (filterPutInHand.match(card, source.getSourceId(), source.getControllerId(), game)) {
properCardFound = true;
}
}
}
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
boolean properCardFound = cards.count(filterPutInHand, game) > 0;
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
if (properCardFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());

View file

@ -34,18 +34,14 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LookLibraryControllerEffect;
import mage.abilities.keyword.EntwineAbility;
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.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetOpponent;
/**
@ -91,7 +87,7 @@ class SecondSightEffect extends OneShotEffect {
public SecondSightEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top five cards of target opponent's library, then put them back in any order.";
this.staticText = "look at the top five cards of target opponent's library, then put them back in any order";
}
public SecondSightEffect(final SecondSightEffect effect) {
@ -105,36 +101,14 @@ class SecondSightEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || you == null) {
if (player == null || controller == null) {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 5);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
you.lookAtCards("Second Sight", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on the top of target player's library"));
while (player.canRespond() && cards.size() > 1) {
you.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 5));
controller.lookAtCards(source, null, cards, game);
controller.putCardsOnTopOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -28,13 +28,11 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.InvertCondition;
import mage.abilities.condition.common.FerociousCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
@ -42,7 +40,7 @@ import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -54,7 +52,7 @@ import mage.target.TargetCard;
public class SeeTheUnwritten extends CardImpl {
public SeeTheUnwritten(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}{G}");
// Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard.
// <i>Ferocious</i> &mdash; If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one.
@ -78,8 +76,6 @@ public class SeeTheUnwritten extends CardImpl {
class SeeTheUnwrittenEffect extends OneShotEffect {
private static final FilterCreatureCard filter = new FilterCreatureCard("creature card");
private final int numberOfCardsToPutIntoPlay;
public SeeTheUnwrittenEffect(int numberOfCardsToPutIntoPlay) {
@ -103,36 +99,18 @@ class SeeTheUnwrittenEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
int creatureCardsFound = 0;
int count = Math.min(controller.getLibrary().size(), 8);
for (int i = 0; i < count; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) {
creatureCardsFound++;
}
}
}
if (controller != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 8));
int creatureCardsFound = cards.count(StaticFilters.FILTER_CARD_CREATURE, game);
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
controller.revealCards(source, cards, game);
if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", source, game)) {
int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound);
TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, filter);
TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, StaticFilters.FILTER_CARD_CREATURE);
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
for (UUID creatureId : target.getTargets()) {
Card card = game.getCard(creatureId);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
Cards toBattlefield = new CardsImpl(target.getTargets());
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
cards.removeAll(toBattlefield);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);

View file

@ -47,7 +47,6 @@ public class SelvalasStampede extends CardImpl {
public SelvalasStampede(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}{G}");
// <i>Council's dilemma</i> &mdash Starting with you, each player votes for wild or free. Reveal cards from the top of your library until you reveal a creature card for each wild vote. Put those creature cards onto the battlefield, then shuffle the rest into your library. You may put a permanent card from your hand onto the battlefield for each free vote.
this.getSpellAbility().addEffect(new SelvalasStampedeDilemmaEffect());
@ -66,8 +65,9 @@ public class SelvalasStampede extends CardImpl {
class SelvalasStampedeDilemmaEffect extends CouncilsDilemmaVoteEffect {
public SelvalasStampedeDilemmaEffect() {
super(Outcome.Benefit);
this.staticText = "<i>Council's dilemma</i> — Starting with you, each player votes for wild or free. Reveal cards from the top of your library until you reveal a creature card for each wild vote. Put those creature cards onto the battlefield, then shuffle the rest into your library. You may put a permanent card from your hand onto the battlefield for each free vote";
super(Outcome.PutCardInPlay);
this.staticText = "<i>Council's dilemma</i> — Starting with you, each player votes for wild or free. Reveal cards from the top of your library until you reveal a creature card for each wild vote. Put those creature cards onto the battlefield, then shuffle the rest into your library. "
+ "You may put a permanent card from your hand onto the battlefield for each free vote";
}
public SelvalasStampedeDilemmaEffect(final SelvalasStampedeDilemmaEffect effect) {
@ -79,34 +79,37 @@ class SelvalasStampedeDilemmaEffect extends CouncilsDilemmaVoteEffect {
Player controller = game.getPlayer(source.getControllerId());
//If no controller, exit here and do not vote.
if (controller == null) return false;
if (controller == null) {
return false;
}
this.vote("wild", "free", controller, game, source);
//Wild Votes
if (voteOneCount > 0) {
Cards revealedCards = new CardsImpl();
int cardsToReveal = voteOneCount;
while (cardsToReveal > 0 && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
Cards toBattlefield = new CardsImpl();
for (Card card : controller.getLibrary().getCards(game)) {
revealedCards.add(card);
if (card.isCreature()) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
cardsToReveal--;
} else {
revealedCards.add(card);
toBattlefield.add(card);
if (toBattlefield.size() == voteOneCount) {
break;
}
}
}
controller.revealCards("Selvala's Stampede", revealedCards, game);
controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
controller.revealCards(source, revealedCards, game);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
revealedCards.removeAll(toBattlefield);
if (!revealedCards.isEmpty()) {
controller.shuffleLibrary(source, game);
}
}
//Free Votes
if (voteTwoCount > 0) {
TargetCardInHand target = new TargetCardInHand(0, voteTwoCount, new FilterPermanentCard("permanent cards"));
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
if (controller.choose(outcome, target, source.getSourceId(), game)) {
controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
}
}

View file

@ -30,13 +30,11 @@ package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -48,21 +46,14 @@ import mage.target.TargetPermanent;
*/
public class ShapeAnew extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("an artifact");
static {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
}
public ShapeAnew(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// The controller of target artifact sacrifices it, then reveals cards from the top
// of their library until he or she reveals an artifact card. That player puts
// that card onto the battlefield, then shuffles all other cards revealed this way into their library.
this.getSpellAbility().addEffect(new SacrificeTargetEffect("The controller of target artifact sacrifices it"));
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addEffect(new ShapeAnewEffect());
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_AN));
}
public ShapeAnew(final ShapeAnew card) {
@ -78,7 +69,7 @@ public class ShapeAnew extends CardImpl {
public ShapeAnewEffect() {
super(Outcome.PutCardInPlay);
staticText = ", then reveals cards from the top of their library until he or she reveals an artifact card. That player puts that card onto the battlefield, then shuffles all other cards revealed this way into their library";
staticText = "The controller of target artifact sacrifices it, then reveals cards from the top of their library until he or she reveals an artifact card. That player puts that card onto the battlefield, then shuffles all other cards revealed this way into their library";
}
public ShapeAnewEffect(ShapeAnewEffect effect) {
@ -87,32 +78,29 @@ public class ShapeAnew extends CardImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (sourcePermanent == null) {
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetPermanent == null) {
return false;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
targetPermanent.sacrifice(source.getSourceId(), game);
Player targetController = game.getPlayer(targetPermanent.getControllerId());
if (targetController == null) {
return false;
}
Cards revealed = new CardsImpl();
Card artifactCard = null;
Cards nonArtifactCards = new CardsImpl();
Player targetController = game.getPlayer(sourcePermanent.getControllerId());
while (artifactCard == null && targetController.getLibrary().hasCards()) {
Card card = targetController.getLibrary().removeFromTop(game);
for (Card card : targetController.getLibrary().getCards(game)) {
revealed.add(card);
if (card.isArtifact()) {
artifactCard = card;
} else {
nonArtifactCards.add(card);
break;
}
}
targetController.revealCards(sourcePermanent.getIdName(), revealed, game);
targetController.revealCards(source, revealed, game);
if (artifactCard != null) {
targetController.moveCards(artifactCard, Zone.BATTLEFIELD, source, game);
}
targetController.putCardsOnTopOfLibrary(nonArtifactCards, game, source, false);
// 1/1/2011: If the first card the player reveals is an artifact card, he or she will still have to shuffle his or her library even though no other cards were revealed this way.
targetController.shuffleLibrary(source, game);
return true;
}

View file

@ -68,7 +68,7 @@ public class ShrineOfPiercingVision extends CardImpl {
}
public ShrineOfPiercingVision(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
// At the beginning of your upkeep or whenever you cast a blue spell, put a charge counter on Shrine of Piercing Vision.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), TargetController.YOU, false));
@ -113,30 +113,19 @@ class ShrineOfPiercingVisionEffect extends OneShotEffect {
if (player == null || permanent == null) {
return false;
}
int count = permanent.getCounters(game).getCount(CounterType.CHARGE);
Cards cards = new CardsImpl();
count = Math.min(player.getLibrary().size(), count);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Shrine of Piercing Vision", cards, game);
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, permanent.getCounters(game).getCount(CounterType.CHARGE)));
if (!cards.isEmpty()) {
player.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
player.moveCards(card, Zone.HAND, source, game);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.s;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
@ -37,15 +36,13 @@ import mage.abilities.keyword.MenaceAbility;
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.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -55,7 +52,7 @@ import mage.players.Player;
public class SinProdder extends CardImpl {
public SinProdder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.DEVIL);
this.power = new MageInt(3);
this.toughness = new MageInt(2);
@ -98,32 +95,31 @@ class SinProdderEffect 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.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
controller.revealCards(sourcePermanent.getIdName(), cards, game);
StringBuilder sb = new StringBuilder();
sb.append("Put ").append(card.getName()).append(" in ").append(controller.getLogName()).append("'s graveyard?");
boolean putInGraveyard = false;
Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentUuid : opponents) {
Player opponent = game.getPlayer(opponentUuid);
if (opponent != null && !putInGraveyard && opponent.chooseUse(Outcome.Damage, sb.toString(), source, game)) {
putInGraveyard = true;
opponent.damage(card.getConvertedManaCost(), source.getSourceId(), game, false, true);
}
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.revealCards(source, new CardsImpl(card), game);
String message = "Put " + card.getName() + " in " + controller.getName() + "'s graveyard?";
boolean putInGraveyard = false;
for (UUID opponentUuid : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentUuid);
if (opponent != null && !putInGraveyard && opponent.chooseUse(Outcome.Damage, message, source, game)) {
putInGraveyard = true;
opponent.damage(card.getConvertedManaCost(), source.getSourceId(), game, false, true);
// 4/8/2016: Each opponent in turn order, starting with the one after you in turn order, may choose to have you put that card into your graveyard.
// Once a player does so, Sin Prodder deals damage equal to that card's converted mana cost to that player immediately
// and Sin Prodder's trigger has no further action.
break;
}
if (putInGraveyard) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
} else {
controller.moveCards(card, Zone.HAND, source, game);
}
return true;
}
if (putInGraveyard) {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
} else {
controller.moveCards(card, Zone.HAND, source, game);
}
}
return true;
}
return false;
}

View file

@ -42,7 +42,6 @@ import mage.constants.Zone;
import mage.filter.common.FilterInstantOrSorcerySpell;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Library;
import mage.players.Player;
import mage.target.TargetSpell;
@ -91,31 +90,22 @@ class SpellshiftEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK)).getControllerId());
if (player != null) {
Library library = player.getLibrary();
if (library.hasCards()) {
Cards cards = new CardsImpl();
Card card = library.removeFromTop(game);
cards.add(card);
while (!(card.isSorcery() || card.isInstant()) && library.hasCards()) {
card = library.removeFromTop(game);
cards.add(card);
}
Player spellController = game.getPlayer(((Spell) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK)).getControllerId());
if (spellController != null) {
Cards cardsToReveal = new CardsImpl();
Card toCast = null;
for (Card card : spellController.getLibrary().getCards(game)) {
cardsToReveal.add(card);
if (card.isSorcery() || card.isInstant()) {
if (player.chooseUse(outcome, "Cast " + card.getLogName() + " ?", source, game)) {
if (player.cast(card.getSpellAbility(), game, true)) {
cards.remove(card.getId());
}
}
}
if (!cards.isEmpty()) {
library.addAll(cards.getCards(game), game);
toCast = card;
break;
}
}
player.shuffleLibrary(source, game);
spellController.revealCards(source, cardsToReveal, game);
if (toCast != null && spellController.chooseUse(outcome, "Cast " + toCast.getLogName() + " without paying its mana cost?", source, game)) {
spellController.cast(toCast.getSpellAbility(), game, true);
}
spellController.shuffleLibrary(source, game);
return true;
}
return false;

View file

@ -43,8 +43,8 @@ import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
@ -58,7 +58,7 @@ import mage.target.TargetCard;
public class SphinxOfUthuun extends CardImpl {
public SphinxOfUthuun(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}");
this.subtype.add(SubType.SPHINX);
this.power = new MageInt(5);
@ -96,21 +96,13 @@ class SphinxOfUthuunEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || sourceObject == null) {
if (controller == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 5);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.revealCards(sourceObject.getName(), cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
controller.revealCards(source, cards, game);
Set<UUID> opponents = game.getOpponents(source.getControllerId());
if (!opponents.isEmpty()) {
@ -121,25 +113,15 @@ class SphinxOfUthuunEffect extends OneShotEffect {
List<Card> pile1 = new ArrayList<>();
Cards pile1CardsIds = new CardsImpl();
if (opponent.choose(Outcome.Neutral, cards, target, game)) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = game.getCard(targetId);
if (card != null) {
pile1.add(card);
pile1CardsIds.add(card.getId());
}
}
pile1CardsIds.addAll(target.getTargets());
pile1.addAll(pile1CardsIds.getCards(game));
}
List<Card> pile2 = new ArrayList<>();
Cards pile2CardsIds = new CardsImpl();
for (UUID cardId :cards) {
Card card = game.getCard(cardId);
if (card != null && !pile1.contains(card)) {
pile2.add(card);
pile2CardsIds.add(card.getId());
}
}
boolean choice = player.choosePile(Outcome.DestroyPermanent, "Choose a pile to put into hand.", pile1, pile2, game);
Cards pile2CardsIds = new CardsImpl(cards);
pile2CardsIds.removeAll(pile1CardsIds);
pile2.addAll(pile2CardsIds.getCards(game));
boolean choice = controller.choosePile(Outcome.DestroyPermanent, "Choose a pile to put into hand.", pile1, pile2, game);
Zone pile1Zone = Zone.GRAVEYARD;
Zone pile2Zone = Zone.HAND;
@ -148,7 +130,7 @@ class SphinxOfUthuunEffect extends OneShotEffect {
pile2Zone = Zone.GRAVEYARD;
}
StringBuilder sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 1, going to ").append(pile1Zone == Zone.HAND ?"Hand":"Graveyard").append (": ");
StringBuilder sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 1, going to ").append(pile1Zone == Zone.HAND ? "Hand" : "Graveyard").append(": ");
int i = 0;
for (UUID cardUuid : pile1CardsIds) {
i++;
@ -158,12 +140,12 @@ class SphinxOfUthuunEffect extends OneShotEffect {
if (i < pile1CardsIds.size()) {
sb.append(", ");
}
card.moveToZone(pile1Zone, source.getSourceId(), game, false);
}
}
controller.moveCards(pile1CardsIds, pile1Zone, source, game);
game.informPlayers(sb.toString());
sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 2, going to ").append(pile2Zone == Zone.HAND ?"Hand":"Graveyard").append (':');
sb = new StringBuilder(sourceObject.getLogName()).append(": Pile 2, going to ").append(pile2Zone == Zone.HAND ? "Hand" : "Graveyard").append(':');
i = 0;
for (UUID cardUuid : pile2CardsIds) {
Card card = game.getCard(cardUuid);
@ -173,9 +155,9 @@ class SphinxOfUthuunEffect extends OneShotEffect {
if (i < pile2CardsIds.size()) {
sb.append(", ");
}
card.moveToZone(pile2Zone, source.getSourceId(), game, false);
}
}
controller.moveCards(pile2CardsIds, pile2Zone, source, game);
game.informPlayers(sb.toString());
}

View file

@ -53,7 +53,7 @@ import mage.target.common.TargetOpponent;
public class SphinxsTutelage extends CardImpl {
public SphinxsTutelage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
// Whenever you draw a card, target opponent puts the top two cards of their library into their graveyard. If they're both nonland cards that share a color, repeat this process.
Ability ability = new DrawCardControllerTriggeredAbility(new SphinxsTutelageEffect(), false);
@ -108,19 +108,20 @@ class SphinxsTutelageEffect extends OneShotEffect {
return true;
}
colorShared = false;
Cards cards = new CardsImpl();
cards.addAll(targetPlayer.getLibrary().getTopCards(game, 2));
if (!cards.isEmpty()) {
Card card1 = targetPlayer.getLibrary().removeFromTop(game);
if (!card1.isLand() && targetPlayer.getLibrary().hasCards()) {
Card card2 = targetPlayer.getLibrary().removeFromTop(game);
if (!card2.isLand()) {
colorShared = card1.getColor(game).shares(card2.getColor(game));
}
Cards cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 2));
Card card1 = null;
for (Card card : cards.getCards(game)) {
if (card.isLand()) {
break;
}
if (card1 == null) {
card1 = card;
} else {
colorShared = card1.getColor(game).shares(card.getColor(game));
}
}
targetPlayer.moveCards(cards, Zone.GRAVEYARD, source, game);
} while (colorShared && targetPlayer.canRespond());
} while (colorShared && targetPlayer.isInGame());
return true;
}
return false;

View file

@ -28,7 +28,6 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
@ -42,10 +41,10 @@ import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -54,7 +53,7 @@ import mage.target.targetpointer.FixedTarget;
public class StolenGoods extends CardImpl {
public StolenGoods(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
// Target opponent exiles cards from the top of their library until he or she exiles a nonland card. Until end of turn, you may cast that card without paying its mana cost.
this.getSpellAbility().addEffect(new StolenGoodsEffect());
@ -90,16 +89,14 @@ class StolenGoodsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (opponent != null && opponent.getLibrary().hasCards() && sourceObject != null) {
Library library = opponent.getLibrary();
if (opponent != null) {
Card card;
do {
card = library.removeFromTop(game);
card = opponent.getLibrary().getFromTop(game);
if (card != null) {
opponent.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
opponent.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null));
}
} while (library.hasCards() && card != null && card.isLand());
} while (card != null && card.isLand());
if (card != null) {
ContinuousEffect effect = new StolenGoodsCastFromExileEffect();

View file

@ -28,20 +28,13 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
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.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -50,11 +43,11 @@ import mage.target.TargetCard;
public class StrategicPlanning extends CardImpl {
public StrategicPlanning(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}");
// Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new StrategicPlanningEffect());
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(3), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false));
}
public StrategicPlanning(final StrategicPlanning card) {
@ -66,44 +59,3 @@ public class StrategicPlanning extends CardImpl {
return new StrategicPlanning(this);
}
}
class StrategicPlanningEffect extends OneShotEffect {
public StrategicPlanningEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public StrategicPlanningEffect(final StrategicPlanningEffect effect) {
super(effect);
}
@Override
public StrategicPlanningEffect copy() {
return new StrategicPlanningEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.lookAtCards("Strategic Planning", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -29,23 +29,15 @@ package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.filter.StaticFilters;
/**
*
@ -54,7 +46,7 @@ import mage.target.TargetCard;
public class SultaiSoothsayer extends CardImpl {
public SultaiSoothsayer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{G}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}{U}");
this.subtype.add(SubType.NAGA);
this.subtype.add(SubType.SHAMAN);
@ -62,7 +54,8 @@ public class SultaiSoothsayer extends CardImpl {
this.toughness = new MageInt(5);
// When Sultai Soothsayer enters the battlefield, look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SultaiSoothsayerEffect(), false));
this.addAbility(new EntersBattlefieldTriggeredAbility(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false), false));
}
public SultaiSoothsayer(final SultaiSoothsayer card) {
@ -74,44 +67,3 @@ public class SultaiSoothsayer extends CardImpl {
return new SultaiSoothsayer(this);
}
}
class SultaiSoothsayerEffect extends OneShotEffect {
public SultaiSoothsayerEffect() {
super(Outcome.DrawCard);
this.staticText = "look at the top four cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public SultaiSoothsayerEffect(final SultaiSoothsayerEffect effect) {
super(effect);
}
@Override
public SultaiSoothsayerEffect copy() {
return new SultaiSoothsayerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
controller.lookAtCards(sourceObject.getName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -37,7 +37,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.target.TargetSpell;
/**
@ -55,7 +55,7 @@ public class SupremeWill extends CardImpl {
// or Look at the top four cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order.
Mode mode = new Mode();
mode.getEffects().add(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1), new FilterCard(), Zone.LIBRARY, false, false));
mode.getEffects().add(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1), StaticFilters.FILTER_CARD, Zone.LIBRARY, false, false));
this.getSpellAbility().addMode(mode);
}

View file

@ -31,7 +31,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -126,23 +125,20 @@ class SyntheticDestinyDelayedEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
if (controller != null) {
Cards revealed = new CardsImpl();
Set<Card> creatureCards = new LinkedHashSet<>();
Cards nonCreatureCards = new CardsImpl();
while (creatureCards.size() < numberOfCards && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
for (Card card : controller.getLibrary().getCards(game)) {
revealed.add(card);
if (card.isCreature()) {
creatureCards.add(card);
} else {
nonCreatureCards.add(card);
}
if (creatureCards.size() >= numberOfCards) {
break;
}
}
controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.moveCards(creatureCards, Zone.BATTLEFIELD, source, game, false, false, true, null);
controller.putCardsOnTopOfLibrary(nonCreatureCards, game, source, false);
controller.revealCards(source, revealed, game);
controller.moveCards(creatureCards, Zone.BATTLEFIELD, source, game);
controller.shuffleLibrary(source, game);
return true;
}

View file

@ -37,27 +37,26 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.ExileFromGraveCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.effects.common.SkipDrawStepEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
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.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
@ -81,7 +80,8 @@ public class TaigamSidisisHand extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect()));
// At the beginning of your upkeep, look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new TaigamSidisisHandDrawEffect(), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1),
StaticFilters.FILTER_CARD, Zone.GRAVEYARD, false, false, false, Zone.HAND, false), TargetController.YOU, false));
// {B}, {T}, Exile X cards from your graveyard: Target creature gets -X/-X until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TaigamSidisisHandEffect(), new ManaCostsImpl("{B}"));
@ -138,44 +138,3 @@ class TaigamSidisisHandEffect extends OneShotEffect {
return false;
}
}
class TaigamSidisisHandDrawEffect extends OneShotEffect {
public TaigamSidisisHandDrawEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top three cards of your library. Put one of them into your hand and the rest into your graveyard";
}
public TaigamSidisisHandDrawEffect(final TaigamSidisisHandDrawEffect effect) {
super(effect);
}
@Override
public TaigamSidisisHandDrawEffect copy() {
return new TaigamSidisisHandDrawEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.lookAtCards("Taigam, Sidisi's Hand", cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put in your hand"));
if (controller.choose(Outcome.Benefit, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -28,7 +28,6 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -86,31 +85,25 @@ class TeleminPerformanceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
if (controller != null) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent != null) {
Card creature = null;
CardsImpl cards = new CardsImpl();
boolean creatureFound = false;
while (opponent.getLibrary().hasCards() && !creatureFound) {
Card card = opponent.getLibrary().removeFromTop(game);
if (card != null) {
if (card.isCreature()) {
creature = card;
creatureFound = true;
}
if (!creatureFound) {
cards.add(card);
}
CardsImpl nonCreatures = new CardsImpl();
CardsImpl reveal = new CardsImpl();
for (Card card : opponent.getLibrary().getCards(game)) {
reveal.add(card);
if (card.isCreature()) {
creature = card;
break;
} else {
nonCreatures.add(card);
}
}
if (!cards.isEmpty()) {
opponent.revealCards(sourceObject.getIdName(), cards, game);
opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
}
game.applyEffects();
opponent.revealCards(source, reveal, game);
opponent.moveCards(nonCreatures, Zone.GRAVEYARD, source, game);
if (creature != null) {
game.applyEffects();
controller.moveCards(creature, Zone.BATTLEFIELD, source, game);
}
}

View file

@ -36,7 +36,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
/**
*
@ -45,14 +45,14 @@ import mage.filter.FilterCard;
public class ThievesFortune extends CardImpl {
public ThievesFortune(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.TRIBAL,CardType.INSTANT},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.INSTANT}, "{2}{U}");
this.subtype.add(SubType.ROGUE);
// Prowl {U}
this.addAbility(new ProwlAbility(this, "{U}"));
// Look at the top four cards of your library. Put one of them into your hand and the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1), new FilterCard(), Zone.LIBRARY, false, false));
this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(4), false, new StaticValue(1), StaticFilters.FILTER_CARD, Zone.LIBRARY, false, false));
}
public ThievesFortune(final ThievesFortune card) {

View file

@ -27,19 +27,13 @@
*/
package mage.cards.t;
import java.util.Deque;
import java.util.LinkedList;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
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.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -102,33 +96,14 @@ class TimeOutEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player owner = game.getPlayer(permanent.getOwnerId());
if (owner != null) {
int amount = controller.rollDice(game, 6);
Cards cards = new CardsImpl();
Deque<UUID> cardIds = new LinkedList<>();
for (int i = 0; i < amount; i++) {
Card card = owner.getLibrary().removeFromTop(game);
cards.add(card);
cardIds.push(card.getId());
}
// return cards back to library
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts ").append(permanent.getName())
.append(" beneath the top ").append(amount)
.append(" cards of ").append(owner.getLogName()).append("'s library").toString());
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
while (!cardIds.isEmpty()) {
UUID cardId = cardIds.poll();
Card card = cards.get(cardId, game);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
}
return true;
if (owner == null) {
return false;
}
int amount = controller.rollDice(game, 6);
controller.putCardOnTopXOfLibrary(permanent, game, source, amount);
return true;
}
}
return false;
}
}

View file

@ -41,6 +41,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
@ -53,8 +54,7 @@ import mage.target.TargetCard;
public class TrackersInstincts extends CardImpl {
public TrackersInstincts(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
// Reveal the top four cards of your library. Put a creature card from among them into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new TrackersInstinctsEffect());
@ -92,30 +92,17 @@ class TrackersInstinctsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
boolean creaturesFound = false;
int count = Math.min(controller.getLibrary().size(), 4);
for (int i = 0; i < count; i++) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (card.isCreature()) {
creaturesFound = true;
}
}
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
boolean creaturesFound = cards.count(StaticFilters.FILTER_CARD_CREATURE, game) > 0;
if (!cards.isEmpty()) {
controller.revealCards("Tracker's Instincts", cards, game);
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put in hand"));
if (creaturesFound && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}

View file

@ -38,7 +38,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
/**
@ -48,8 +47,7 @@ import mage.players.Player;
public class TreasureHunt extends CardImpl {
public TreasureHunt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}");
// Reveal cards from the top of your library until you reveal a nonland card, then put all cards revealed this way into your hand.
this.getSpellAbility().addEffect(new TreasureHuntEffect());
@ -83,22 +81,17 @@ class TreasureHuntEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().hasCards()) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.getLibrary().hasCards()) {
CardsImpl cards = new CardsImpl();
Library library = player.getLibrary();
Card card = null;
do {
card = library.removeFromTop(game);
if (card != null) {
cards.add(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
for (Card card : controller.getLibrary().getCards(game)) {
cards.add(card);
if (!card.isLand()) {
break;
}
} while (library.hasCards() && card != null && card.isLand());
if (!cards.isEmpty()) {
player.revealCards("Treasure Hunt", cards, game);
}
controller.revealCards(source, cards, game);
controller.moveCards(cards, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -29,7 +29,6 @@ package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -38,8 +37,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
@ -85,22 +84,18 @@ class TreasureKeeperEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
CardsImpl toReveal = new CardsImpl();
Card nonLandCard = null;
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
while (nonLandCard == null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().removeFromTop(game);
if (controller != null) {
CardsImpl toReveal = new CardsImpl();
Card nonLandCard = null;
for (Card card : controller.getLibrary().getCards(game)) {
toReveal.add(card);
if (!card.isLand() && card.getConvertedManaCost() < 4) {
nonLandCard = card;
break;
}
}
// reveal cards
if (!toReveal.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), toReveal, game);
}
controller.revealCards(source, toReveal, game);
if (nonLandCard != null && controller.chooseUse(outcome, "Cast " + nonLandCard.getLogName() + "without paying its mana cost?", source, game)) {
controller.cast(nonLandCard.getSpellAbility(), game, true);
toReveal.remove(nonLandCard);

View file

@ -29,26 +29,25 @@ package mage.cards.t;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -57,14 +56,13 @@ import mage.players.Player;
public class TrepanationBlade extends CardImpl {
public TrepanationBlade(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
this.subtype.add(SubType.EQUIPMENT);
// Whenever equipped creature attacks, defending player reveals cards from the top of their library until he or she reveals a land card.
// The creature gets +1/+0 until end of turn for each card revealed this way. That player puts the revealed cards into their graveyard.
Ability ability = new AttacksAttachedTriggeredAbility(new TrepanationBladeDiscardEffect());
ability.addEffect(new TrepanationBladeBoostEffect());
this.addAbility(ability);
this.addAbility(new AttacksAttachedTriggeredAbility(new TrepanationBladeDiscardEffect()));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2)));
}
@ -104,69 +102,26 @@ class TrepanationBladeDiscardEffect extends OneShotEffect {
return false;
}
UUID defenderId = game.getCombat().getDefenderId(creature.getId());
Player player = game.getPlayer(defenderId);
if (player == null) {
Player defendingPlayer = game.getPlayer(defenderId);
if (defendingPlayer == null) {
return false;
}
CardsImpl cards = new CardsImpl();
boolean landFound = false;
while (player.getLibrary().hasCards() && !landFound) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (card.isLand()) {
landFound = true;
}
for (Card card : defendingPlayer.getLibrary().getCards(game)) {
cards.add(card);
if (card.isLand()) {
break;
}
}
player.moveCards(cards, Zone.GRAVEYARD, source, game);
defendingPlayer.revealCards(equipment.getName(), cards, game);
defendingPlayer.moveCards(cards, Zone.GRAVEYARD, source, game);
if (!cards.isEmpty()) {
player.revealCards(equipment.getName(), cards, game);
game.getState().setValue(source.getSourceId().toString() + "_TrepanationBlade", cards.size());
return true;
ContinuousEffect effect = new BoostTargetEffect(cards.size(), 0, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
}
return true;
}
game.getState().setValue(source.getSourceId().toString() + "_TrepanationBlade", null);
return false;
}
@Override
public String getText(Mode mode) {
return super.getText(mode); //To change body of overridden methods use File | Settings | File Templates.
}
}
class TrepanationBladeBoostEffect extends ContinuousEffectImpl {
public TrepanationBladeBoostEffect() {
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
staticText = null;
}
public TrepanationBladeBoostEffect(final TrepanationBladeBoostEffect effect) {
super(effect);
}
@Override
public TrepanationBladeBoostEffect copy() {
return new TrepanationBladeBoostEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Integer amount = (Integer) game.getState().getValue(source.getSourceId().toString() + "_TrepanationBlade");
Permanent equipment = game.getPermanent(source.getSourceId());
if (amount != null && amount > 0 && equipment != null && equipment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(equipment.getAttachedTo());
if (creature != null) {
creature.addPower(amount);
return true;
}
}
return false;
}
}

View file

@ -27,10 +27,7 @@
*/
package mage.cards.t;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect;
@ -91,41 +88,29 @@ class TunnelVisionEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
if (sourceObject == null || targetPlayer == null || cardName == null || cardName.isEmpty()) {
if (targetPlayer == null || cardName == null || cardName.isEmpty()) {
return false;
}
Cards cardsToReveal = new CardsImpl();
Set<Card> cardsToBury = new HashSet<>();
Card namedCard = null;
// reveal until named card found
// if named card found, put all revealed cards in grave and put named card on top of library
// if named card not found, shuffle library
boolean namedCardFound = false;
while (targetPlayer.getLibrary().hasCards()) {
Card card = targetPlayer.getLibrary().removeFromTop(game);
if (card != null) {
cardsToReveal.add(card);
if (card.getName().equals(cardName)) {
namedCardFound = true;
namedCard = card;
break;
} else {
cardsToBury.add(card);
}
for (Card card : targetPlayer.getLibrary().getCards(game)) {
cardsToReveal.add(card);
if (card.getName().equals(cardName)) {
namedCard = card;
break;
}
}
targetPlayer.revealCards(sourceObject.getIdName(), cardsToReveal, game);
if (namedCardFound) {
targetPlayer.moveCards(cardsToBury, Zone.GRAVEYARD, source, game);
targetPlayer.moveCards(namedCard, Zone.LIBRARY, source, game);
targetPlayer.revealCards(source, cardsToReveal, game);
if (namedCard != null) {
cardsToReveal.remove(namedCard);
targetPlayer.moveCards(cardsToReveal, Zone.GRAVEYARD, source, game);
targetPlayer.putCardsOnTopOfLibrary(new CardsImpl(namedCard), game, source, true);
} else {
targetPlayer.getLibrary().addAll(cardsToBury, game);
targetPlayer.shuffleLibrary(source, game);
}
return true;

View file

@ -35,7 +35,6 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -60,7 +59,7 @@ import mage.target.targetpointer.FixedTarget;
public class UlamogTheCeaselessHunger extends CardImpl {
public UlamogTheCeaselessHunger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{10}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{10}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.ELDRAZI);
this.power = new MageInt(10);
@ -156,7 +155,7 @@ class UlamogAttackTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return new StringBuilder("Whenever {this} attacks, ").append(super.getRule()).toString();
return "Whenever {this} attacks, " + super.getRule();
}
}
@ -180,13 +179,7 @@ class UlamogExileLibraryEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player defender = game.getPlayer(targetPointer.getFirst(game, source));
if (defender != null) {
int count = Math.min(defender.getLibrary().size(), 20);
for (int i = 0; i < count; i++) {
Card card = defender.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToExile(null, null, source.getSourceId(), game);
}
}
defender.moveCards(defender.getLibrary().getTopCards(game, 20), Zone.EXILED, source, game);
return true;
}
return false;

View file

@ -104,18 +104,14 @@ class UndercityInformerEffect extends OneShotEffect {
if (player == null) {
return false;
}
Cards cards = new CardsImpl();
while (player.getLibrary().hasCards()) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (card.isLand()) {
break;
}
for (Card card : player.getLibrary().getCards(game)) {
cards.add(card);
if (card.isLand()) {
break;
}
}
player.revealCards("Undercity Informer", cards, game);
player.revealCards(source, cards, game);
player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}

View file

@ -30,6 +30,7 @@ package mage.cards.u;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.EpicEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -38,7 +39,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
@ -50,8 +50,7 @@ import mage.target.common.TargetAnyTarget;
public class UndyingFlames extends CardImpl {
public UndyingFlames(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}{R}");
// Exile cards from the top of your library until you exile a nonland card. Undying Flames deals damage to any target equal to that card's converted mana cost.
this.getSpellAbility().addEffect(new UndyingFlamesEffect());
@ -85,36 +84,22 @@ class UndyingFlamesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player you = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
while (you != null && sourceCard != null
&& you.getLibrary().hasCards() && you.canRespond()) {
Card card = you.getLibrary().removeFromTop(game);
if (card != null) {
you.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY, true);
if (!card.isLand()) {
int damage = card.getConvertedManaCost();
if (damage > 0) {
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (creature != null) {
creature.damage(damage, source.getSourceId(), game, false, true);
game.informPlayers(new StringBuilder(sourceCard.getName()).append(" deals ").append(damage).append(" damage to ").append(creature.getName()).toString());
applied = true;
break;
}
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
player.damage(card.getConvertedManaCost(), source.getSourceId(), game, false, true);
game.informPlayers(new StringBuilder(sourceCard.getName()).append(" deals ").append(damage).append(" damage to ").append(player.getLogName()).toString());
applied = true;
break;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
while (controller.getLibrary().hasCards() && controller.isInGame()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
controller.moveCards(card, Zone.LIBRARY, source, game);
if (!card.isLand()) {
new DamageTargetEffect(card.getConvertedManaCost()).apply(game, source);
break;
}
}
}
return true;
}
return applied;
return false;
}
@Override

View file

@ -27,22 +27,14 @@
*/
package mage.cards.u;
import java.util.Deque;
import java.util.LinkedList;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
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.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -54,18 +46,12 @@ import mage.target.TargetPermanent;
*/
public class UnexpectedlyAbsent extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("nonland permanent");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
}
public UnexpectedlyAbsent(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{W}{W}");
// Put target nonland permanent into its owner's library just beneath the top X cards of that library.
this.getSpellAbility().addEffect(new UnexpectedlyAbsentEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_NON_LAND));
}
@ -101,31 +87,8 @@ class UnexpectedlyAbsentEffect extends OneShotEffect {
if (controller != null) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player owner = game.getPlayer(permanent.getOwnerId());
if (owner != null) {
int xValue = Math.min(source.getManaCostsToPay().getX(), owner.getLibrary().size());
Cards cards = new CardsImpl();
Deque<UUID> cardIds = new LinkedList<>();
for (int i = 0; i < xValue; i++) {
Card card = owner.getLibrary().removeFromTop(game);
cards.add(card);
cardIds.push(card.getId());
}
// return cards back to library
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts ").append(permanent.getName())
.append(" beneath the top ").append(xValue)
.append(" cards of ").append(owner.getLogName()).append("'s library").toString());
permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
while(!cardIds.isEmpty()) {
UUID cardId = cardIds.poll();
Card card = cards.get(cardId, game);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
}
return true;
}
controller.putCardOnTopXOfLibrary(permanent, game, source, source.getManaCostsToPay().getX());
return true;
}
}

View file

@ -86,29 +86,25 @@ class VexingArcanixEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (controller != null && sourceObject != null && player != null) {
if (player.getLibrary().hasCards()) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card");
if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
return false;
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(sourceObject.getIdName(), cards, game);
if (card.getName().equals(cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {
player.moveCards(cards, Zone.GRAVEYARD, source, game);
player.damage(2, source.getSourceId(), game, false, true);
}
if (sourceObject != null && player != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.setMessage("Name a card");
if (!player.choose(Outcome.DrawCard, cardChoice, game)) {
return false;
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", player: " + player.getLogName() + ", named: [" + cardName + ']');
Card card = player.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl(card);
player.revealCards(sourceObject.getIdName(), cards, game);
if (card.getName().equals(cardName)) {
player.moveCards(cards, Zone.HAND, source, game);
} else {
player.moveCards(cards, Zone.GRAVEYARD, source, game);
player.damage(2, source.getSourceId(), game, false, true);
}
}
return true;

View file

@ -51,8 +51,7 @@ import mage.target.TargetCard;
public class WorldlyCounsel extends CardImpl {
public WorldlyCounsel(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Domain - Look at the top X cards of your library, where X is the number of basic land types among lands you control. Put one of those cards into your hand and the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new WorldlyCounselEffect());
@ -86,40 +85,30 @@ class WorldlyCounselEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
int count = (new DomainValue()).calculate(game, source, this);
count = Math.min(player.getLibrary().size(), count);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
}
}
player.lookAtCards("Worldly Counsel", cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, (new DomainValue()).calculate(game, source, this)));
controller.lookAtCards(source, null, cards, game);
if (!cards.isEmpty()) {
if (cards.size() == 1) {
Card card = cards.getRandom(game);
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
return true;
controller.moveCards(cards, Zone.HAND, source, game);
} else {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (player.choose(Outcome.DrawCard, cards, target, game)) {
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
controller.moveCards(card, Zone.HAND, source, game);
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -52,7 +52,7 @@ import mage.target.TargetCard;
public class WriteIntoBeing extends CardImpl {
public WriteIntoBeing(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}");
// Look at the top two cards of your library. Manifest one of those cards, then put the other on the top or bottom of your library.
this.getSpellAbility().addEffect(new WriteIntoBeingEffect());
@ -72,7 +72,8 @@ class WriteIntoBeingEffect extends OneShotEffect {
public WriteIntoBeingEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Look at the top two cards of your library. Manifest one of those cards, then put the other on the top or bottom of your library. <i>(To manifest a card, put it onto the battlefield face down as a 2/2 creature. Turn it face up any time for its mana cost if it's a creature card.)</i>";
this.staticText = "Look at the top two cards of your library. Manifest one of those cards, then put the other on the top or bottom of your library. "
+ "<i>(To manifest a card, put it onto the battlefield face down as a 2/2 creature. Turn it face up any time for its mana cost if it's a creature card.)</i>";
}
public WriteIntoBeingEffect(final WriteIntoBeingEffect effect) {
@ -89,9 +90,8 @@ class WriteIntoBeingEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 2));
controller.lookAtCards(sourceObject.getName(), cards, game);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 2));
controller.lookAtCards(source, null, cards, game);
Card cardToManifest = null;
if (cards.size() > 1) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to manifest"));

View file

@ -35,7 +35,6 @@ import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
@ -150,6 +149,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
FilterCard pickFilter, Zone targetZoneLookedCards, boolean putOnTop,
boolean reveal, boolean upTo, Zone targetZonePickedCards,
boolean optional) {
this(numberOfCards, mayShuffleAfter, numberToPick, pickFilter,
targetZoneLookedCards, putOnTop, reveal, upTo,
targetZonePickedCards, optional, true, true);
@ -207,16 +207,10 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
}
@Override
protected void cardLooked(Card card, Game game, Ability source) {
if (numberToPick.calculate(game, source, this) > 0 && filter.match(card, game)) {
++foundCardsToPick;
}
}
@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && foundCardsToPick > 0) {
if (player != null && numberToPick.calculate(game, source, this) > 0
&& cards.count(filter, source.getSourceId(), source.getControllerId(), game) > 0) {
if (!optional || player.chooseUse(Outcome.DrawCard, getMayText(), source, game)) {
FilterCard pickFilter = filter.copy();
pickFilter.setMessage(getPickText());
@ -231,7 +225,7 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
player.moveCards(pickedCards.getCards(game), targetPickedCards, source, game);
}
if (revealPickedCards) {
player.revealCards(windowName, pickedCards, game);
player.revealCards(source, pickedCards, game);
}
}
@ -346,7 +340,14 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
}
sb.append(" order");
} else if (targetZoneLookedCards == Zone.GRAVEYARD) {
sb.append(" and the other into your graveyard");
sb.append(" and the");
if (numberOfCards instanceof StaticValue && numberToPick instanceof StaticValue
&& ((StaticValue) numberToPick).getValue() + 1 == ((StaticValue) numberOfCards).getValue()) {
sb.append(" other");
} else {
sb.append(" rest");
}
sb.append(" into your graveyard");
}
}
// get text frame from super class and inject action text

View file

@ -29,18 +29,15 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
@ -105,46 +102,25 @@ public class LookLibraryControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
String windowName = "Reveal";
if (source instanceof SpellAbility) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
windowName = sourceCard.getIdName();
}
} else {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
windowName = sourcePermanent.getIdName();
}
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
// take cards from library and look at them
boolean topCardRevealed = player.isTopCardRevealed();
player.setTopCardRevealed(false);
Cards cards = new CardsImpl();
int count = Math.min(player.getLibrary().size(), this.numberOfCards.calculate(game, source, this));
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
this.cardLooked(card, game, source);
}
}
player.lookAtCards(windowName, cards, game);
boolean topCardRevealed = controller.isTopCardRevealed();
controller.setTopCardRevealed(false);
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, this.numberOfCards.calculate(game, source, this)));
this.actionWithSelectedCards(cards, game, source, windowName);
controller.lookAtCards(source, null, cards, game);
this.putCardsBack(source, player, cards, game);
this.actionWithSelectedCards(cards, game, source);
player.setTopCardRevealed(topCardRevealed);
this.putCardsBack(source, controller, cards, game);
this.mayShuffle(player, source, game);
controller.setTopCardRevealed(topCardRevealed);
this.mayShuffle(controller, source, game);
return true;
}
@ -158,10 +134,7 @@ public class LookLibraryControllerEffect extends OneShotEffect {
return this;
}
protected void cardLooked(Card card, Game game, Ability source) {
}
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
protected void actionWithSelectedCards(Cards cards, Game game, Ability source) {
}
/**

View file

@ -58,7 +58,7 @@ public class CantBeBlockedByAllSourceEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return source.getSourceId().equals(permanent.getId());
return permanent.equals(source.getSourcePermanentIfItStillExists(game));
}
@Override

View file

@ -109,6 +109,13 @@ public final class StaticFilters {
static {
FILTER_PERMANENT.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_AN = new FilterArtifactPermanent("an artifact");
static {
FILTER_PERMANENT_ARTIFACT_AN.setLockedFilter(true);
}
public static final FilterArtifactOrEnchantmentPermanent FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT = new FilterArtifactOrEnchantmentPermanent();
static {