* Some rework of card movement.

This commit is contained in:
LevelX2 2015-08-04 17:54:17 +02:00
parent 96bbe01aae
commit a644e66b7f
83 changed files with 798 additions and 816 deletions

View file

@ -28,6 +28,7 @@
package mage.sets.apocalypse;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -51,9 +52,10 @@ import mage.target.common.TargetCardInLibrary;
* @author emerald000
*/
public class WildResearch extends CardImpl {
private static final FilterCard filterEnchantment = new FilterCard("enchantment card");
private static final FilterCard filterInstant = new FilterCard("instant card");
static {
filterEnchantment.add(new CardTypePredicate(CardType.ENCHANTMENT));
filterInstant.add(new CardTypePredicate(CardType.INSTANT));
@ -65,7 +67,7 @@ public class WildResearch extends CardImpl {
// {1}{W}: Search your library for an enchantment card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterEnchantment), new ManaCostsImpl<>("{1}{W}")));
// {1}{U}: Search your library for an instant card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterInstant), new ManaCostsImpl<>("{1}{U}")));
@ -82,43 +84,44 @@ public class WildResearch extends CardImpl {
}
class WildResearchEffect extends OneShotEffect {
protected final FilterCard filter;
WildResearchEffect(FilterCard filter) {
super(Outcome.DrawCard);
this.staticText = "Search your library for an " + filter.getMessage() + " and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.";
this.filter = filter;
}
WildResearchEffect(final WildResearchEffect effect) {
super(effect);
this.filter = effect.filter;
}
@Override
public WildResearchEffect copy() {
return new WildResearchEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Wild Research", cards, game, true);
controller.revealCards(sourceObject.getIdName(), cards, game, true);
}
}
}
player.discardOne(true, source, game);
player.shuffleLibrary(game);
controller.discardOne(true, source, game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.betrayersofkamigawa;
import java.util.UUID;
@ -39,7 +38,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.constants.CardType;
import mage.constants.Outcome;
@ -69,7 +67,7 @@ public class QuillmaneBaku extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Whenever you cast a Spirit or Arcane spell, you may put a ki counter on Skullmane Baku.
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.KI.createInstance()), filter, true));
@ -87,11 +85,11 @@ public class QuillmaneBaku extends CardImpl {
int maxConvManaCost = 0;
for (Cost cost : ability.getCosts()) {
if (cost instanceof RemoveVariableCountersSourceCost) {
maxConvManaCost = ((RemoveVariableCountersSourceCost)cost).getAmount();
maxConvManaCost = ((RemoveVariableCountersSourceCost) cost).getAmount();
}
}
ability.getTargets().clear();
FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with converted mana cost " + maxConvManaCost + " or less");
FilterCreaturePermanent newFilter = new FilterCreaturePermanent("creature with converted mana cost " + maxConvManaCost + " or less");
newFilter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, maxConvManaCost + 1));
TargetCreaturePermanent target = new TargetCreaturePermanent(newFilter);
ability.getTargets().add(target);
@ -106,7 +104,7 @@ public class QuillmaneBaku extends CardImpl {
public QuillmaneBaku copy() {
return new QuillmaneBaku(this);
}
class QuillmaneBakuReturnEffect extends OneShotEffect {
public QuillmaneBakuReturnEffect() {
@ -125,16 +123,15 @@ public class QuillmaneBaku extends CardImpl {
@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;
}
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
player.moveCardToHandWithInfo((Card) permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
return true;
controller.moveCards(permanent, null, Zone.HAND, source, game);
}
return false;
return true;
}
}
}

View file

@ -27,8 +27,8 @@
*/
package mage.sets.bornofthegods;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -44,7 +44,6 @@ import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterBasicLandCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
@ -59,7 +58,6 @@ public class Peregrination extends CardImpl {
super(ownerId, 132, "Peregrination", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{G}");
this.expansionSetCode = "BNG";
// Seach your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle your library, then scry 1.
this.getSpellAbility().addEffect(new PeregrinationEffect());
Effect effect = new ScryEffect(1);
@ -97,36 +95,39 @@ class PeregrinationEffect 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) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId());
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl();
for (UUID cardId: target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
player.revealCards("Peregrination", revealed, game);
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.PICK, filter);
player.choose(Outcome.Benefit, revealed, target2, game);
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card);
card = revealed.getCards(game).iterator().next();
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
}
else if (target.getTargets().size() == 1) {
controller.moveCards(card, null, Zone.HAND, source, game);
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}

View file

@ -103,13 +103,13 @@ class SatyrWayfinderEffect extends OneShotEffect {
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filterPutInHand);
if (properCardFound &&
controller.chooseUse(outcome, "Put a land card into your hand?", source, game) &&
controller.choose(Outcome.DrawCard, cards, target, game)) {
if (properCardFound
&& controller.chooseUse(outcome, "Put a land card into your hand?", source, game)
&& controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}

View file

@ -28,6 +28,7 @@
package mage.sets.coldsnap;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -57,7 +58,7 @@ public class ScryingSheets extends CardImpl {
// {tap}: Add {1} to your mana pool.
this.addAbility(new ColorlessManaAbility());
// {1}{snow}, {tap}: Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ScryingSheetsEffect(), new ManaCostsImpl<>("{1}{snow}"));
ability.addCost(new TapSourceCost());
@ -75,35 +76,35 @@ public class ScryingSheets extends CardImpl {
}
class ScryingSheetsEffect extends OneShotEffect {
ScryingSheetsEffect() {
super(Outcome.Benefit);
this.staticText = "Look at the top card of your library. If that card is snow, you may reveal it and put it into your hand";
}
ScryingSheetsEffect(final ScryingSheetsEffect effect) {
super(effect);
}
@Override
public ScryingSheetsEffect copy() {
return new ScryingSheetsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
player.lookAtCards("Scrying Sheets", cards, game);
controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (card.getSupertype().contains("Snow")) {
if (player.chooseUse(outcome, new StringBuilder("Reveal ").append(card.getName()).append(" and put it into your hand?").toString(), source, game)) {
card = player.getLibrary().removeFromTop(game);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
player.revealCards("Scrying Sheets", cards, game);
if (controller.chooseUse(outcome, "Reveal " + card.getLogName() + " and put it into your hand?", source, game)) {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cards, game);
}
}
}

View file

@ -113,22 +113,20 @@ class DesecratorHagEffect extends OneShotEffect {
}
}
if (cards.size() == 0) {
return false;
return true;
}
if (cards.size() > 1
&& you.choose(Outcome.DrawCard, cards, target, game)) {
if (target != null) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
return you.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
return you.moveCards(card, null, Zone.HAND, source, game);
}
}
} else {
for (Card card : cards.getCards(game)) {
return you.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
return you.moveCards(cards, null, Zone.HAND, source, game);
}
}
return false;
}
}
}

View file

@ -27,8 +27,8 @@
*/
package mage.sets.commander;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -57,7 +57,6 @@ public class KodamasReach extends CardImpl {
this.expansionSetCode = "CMD";
this.subtype.add("Arcane");
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library.
this.getSpellAbility().addEffect(new KodamasReachEffect());
}
@ -92,43 +91,46 @@ class KodamasReachEffect 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) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId());
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl();
for (UUID cardId: target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
player.revealCards("Kodama's Reach", revealed, game);
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.PICK, filter);
player.choose(Outcome.Benefit, revealed, target2, game);
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card);
}
card = revealed.getCards(game).iterator().next();
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}
else if (target.getTargets().size() == 1) {
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
}
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}
}
}

View file

@ -51,7 +51,6 @@ public class WhirlpoolWhelm extends CardImpl {
super(ownerId, 69, "Whirlpool Whelm", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
this.expansionSetCode = "CMD";
// Clash with an opponent, then return target creature to its owner's hand. If you win, you may put that creature on top of its owner's library instead.
this.getSpellAbility().addEffect(new WhirlpoolWhelmEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@ -90,15 +89,15 @@ class WhirlpoolWhelmEffect extends OneShotEffect {
if (controller != null) {
boolean topOfLibrary = false;
if (ClashEffect.getInstance().apply(game, source)) {
topOfLibrary = controller.chooseUse(outcome, "Put " + creature.getLogName() + " to top of libraray instead?" , source, game);
topOfLibrary = controller.chooseUse(outcome, "Put " + creature.getLogName() + " to top of libraray instead?", source, game);
}
if (topOfLibrary) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD);
} else {
controller.moveCardToLibraryWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD, true, true);
} else {
controller.moveCards(creature, null, Zone.HAND, source, game);
}
return true;
}
return false;
}
}
}

View file

@ -32,8 +32,8 @@ 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.CardsImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
@ -101,22 +101,17 @@ class GraveSifterEffect extends OneShotEffect {
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId: controller.getInRange()) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
typeChoice.clearChoice();
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice()+ " from your graveyard");
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
filter.add(new SubtypePredicate(typeChoice.getChoice()));
Target target = new TargetCardInYourGraveyard(0,Integer.MAX_VALUE, filter);
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game);
for (UUID cardId: target.getTargets()) {
Card card = game.getCard(cardId);
if (card !=null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
}
player.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
}

View file

@ -28,10 +28,6 @@
package mage.sets.conflux;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -42,6 +38,10 @@ import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -73,7 +73,7 @@ public class SkywardEyeProphets extends CardImpl {
public SkywardEyeProphets copy() {
return new SkywardEyeProphets(this);
}
public static class SkywardEyeProphetsEffect extends OneShotEffect {
public SkywardEyeProphetsEffect() {
@ -108,7 +108,7 @@ public class SkywardEyeProphets extends CardImpl {
if (card.getCardType().contains(CardType.LAND)) {
return controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
} else {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}
return true;

View file

@ -66,21 +66,21 @@ public class PulseOfTheFields extends CardImpl {
}
class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect {
PulseOfTheFieldsReturnToHandEffect() {
super(Outcome.Benefit);
this.staticText = "Then if an opponent has more life than you, return {this} to its owner's hand";
}
PulseOfTheFieldsReturnToHandEffect(final PulseOfTheFieldsReturnToHandEffect effect) {
super(effect);
}
@Override
public PulseOfTheFieldsReturnToHandEffect copy() {
return new PulseOfTheFieldsReturnToHandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -89,7 +89,7 @@ class PulseOfTheFieldsReturnToHandEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (player != null && player.getLife() > controller.getLife()) {
Card card = game.getCard(source.getSourceId());
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
controller.moveCards(card, null, Zone.HAND, source, game);
return true;
}
}

View file

@ -66,21 +66,21 @@ public class PulseOfTheGrid extends CardImpl {
}
class PulseOfTheGridReturnToHandEffect extends OneShotEffect {
PulseOfTheGridReturnToHandEffect() {
super(Outcome.Benefit);
this.staticText = "Draw two cards, then discard a card. Then if an opponent has more cards in hand than you, return {this} to its owner's hand";
}
PulseOfTheGridReturnToHandEffect(final PulseOfTheGridReturnToHandEffect effect) {
super(effect);
}
@Override
public PulseOfTheGridReturnToHandEffect copy() {
return new PulseOfTheGridReturnToHandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -89,7 +89,7 @@ class PulseOfTheGridReturnToHandEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (player != null && player.getHand().size() > controller.getHand().size()) {
Card card = game.getCard(source.getSourceId());
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
controller.moveCards(card, null, Zone.HAND, source, game);
return true;
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.darksteel;
import java.util.UUID;
@ -105,7 +104,7 @@ public class SwordOfLightAndShadow extends CardImpl {
// Target may only be added if possible target exists. Else the gain life effect won't trigger, becuase there is no valid target for the
// return to hand ability
if (controller.getGraveyard().count(new FilterCreatureCard(), ability.getSourceId(), ability.getControllerId(), game) > 0) {
ability.addTarget(new TargetCardInYourGraveyard(0,1,new FilterCreatureCard("creature card from your graveyard")));
ability.addTarget(new TargetCardInYourGraveyard(0, 1, new FilterCreatureCard("creature card from your graveyard")));
}
}
}
@ -118,7 +117,7 @@ class SwordOfLightAndShadowAbility extends TriggeredAbilityImpl {
public SwordOfLightAndShadowAbility() {
super(Zone.BATTLEFIELD, new SwordOfLightAndShadowReturnToHandTargetEffect(), false);
this.addEffect(new GainLifeEffect(3));
}
public SwordOfLightAndShadowAbility(final SwordOfLightAndShadowAbility ability) {
@ -178,8 +177,8 @@ class SwordOfLightAndShadowReturnToHandTargetEffect extends OneShotEffect {
case GRAVEYARD:
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
} else {
controller.moveCards(card, null, Zone.HAND, source, game);
} else {
result = false;
}
break;

View file

@ -29,15 +29,15 @@ package mage.sets.dissension;
import java.util.UUID;
import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
@ -54,9 +54,9 @@ import mage.target.common.TargetCreaturePermanent;
public class RiseFall extends SplitCard {
public RiseFall(UUID ownerId) {
super(ownerId, 156, "Rise", "Fall", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{B}","{B}{R}", false );
super(ownerId, 156, "Rise", "Fall", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{B}", "{B}{R}", false);
this.expansionSetCode = "DIS";
// Rise
// Return target creature card from a graveyard and target creature on the battlefield to their owners' hands.
getLeftHalfCard().getSpellAbility().addEffect(new RiseEffect());
@ -99,14 +99,16 @@ class RiseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToHand = new CardsImpl();
Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source));
if (cardInGraveyard != null) {
controller.moveCardToHandWithInfo(cardInGraveyard, source.getSourceId(), game, Zone.GRAVEYARD);
cardsToHand.add(cardInGraveyard);
}
Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
cardsToHand.add(permanent);
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;
@ -147,7 +149,7 @@ class FallEffect extends OneShotEffect {
cards.add(card);
}
targetPlayer.revealCards(sourceObject.getName(), cards, game);
for (Card cardToDiscard: cards.getCards(game)) {
for (Card cardToDiscard : cards.getCards(game)) {
if (!cardToDiscard.getCardType().contains(CardType.LAND)) {
targetPlayer.discard(cardToDiscard, source, game);
}

View file

@ -28,15 +28,14 @@
package mage.sets.dragonsmaze;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
@ -55,7 +54,6 @@ public class MorgueBurst extends CardImpl {
super(ownerId, 86, "Morgue Burst", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{4}{B}{R}");
this.expansionSetCode = "DGM";
// Return target creature card from your graveyard to your hand. Morgue Burst deals damage to target creature or player equal to the power of the card returned this way.
this.getSpellAbility().addEffect(new MorgueBurstEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard")));
@ -93,7 +91,7 @@ class MorgueBurstEffect extends OneShotEffect {
if (card != null) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.HAND);
player.moveCards(card, null, Zone.HAND, source, game);
int damage = card.getPower().getValue();
Permanent creature = game.getPermanent(source.getTargets().get(1).getTargets().get(0));
if (creature != null) {

View file

@ -95,9 +95,9 @@ class FoulRenewalEffect extends OneShotEffect {
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
int xValue = card.getToughness().getValue() * -1;
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(card, null, Zone.HAND, source, game);
if (xValue != 0) {
ContinuousEffect effect = new BoostTargetEffect(xValue,xValue, Duration.EndOfTurn);
ContinuousEffect effect = new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
game.addEffect(effect, source);
}

View file

@ -60,7 +60,6 @@ import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author LevelX2
@ -73,13 +72,13 @@ public class NarsetTranscendent extends CardImpl {
this.subtype.add("Narset");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(6)), false));
// +1: Look at the top card of your library. If it's a noncreature, nonland card, you may reveal it and put it into your hand.
this.addAbility(new LoyaltyAbility(new NarsetTranscendentEffect1(), 1));
// -2: When you cast your next instant or sorcery spell from your hand this turn, it gains rebound.
this.addAbility(new LoyaltyAbility(new CreateDelayedTriggeredAbilityEffect(new NarsetTranscendentTriggeredAbility()), -2));
// -9:You get an emblem with "Your opponents can't cast noncreature spells."
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new NarsetTranscendentEmblem()), -9));
}
@ -119,11 +118,11 @@ class NarsetTranscendentEffect1 extends OneShotEffect {
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
controller.lookAtCards(sourceObject.getName(), cards, game);
controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (!card.getCardType().contains(CardType.CREATURE) && !card.getCardType().contains(CardType.LAND)) {
if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.revealCards(sourceObject.getName(), cards, game);
if (controller.chooseUse(outcome, "Reveal " + card.getLogName() + " and put it into your hand?", source, game)) {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cards, game);
}
}
return true;
@ -142,6 +141,7 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
private NarsetTranscendentTriggeredAbility(final NarsetTranscendentTriggeredAbility ability) {
super(ability);
}
@Override
public NarsetTranscendentTriggeredAbility copy() {
return new NarsetTranscendentTriggeredAbility(this);
@ -157,9 +157,9 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && spell.getFromZone().equals(Zone.HAND)) {
if (spell.getCard() != null &&
spell.getCard().getCardType().contains(CardType.INSTANT) || spell.getCard().getCardType().contains(CardType.SORCERY)) {
for(Effect effect: getEffects()) {
if (spell.getCard() != null
&& spell.getCard().getCardType().contains(CardType.INSTANT) || spell.getCard().getCardType().contains(CardType.SORCERY)) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(spell.getId()));
}
return true;
@ -171,7 +171,7 @@ class NarsetTranscendentTriggeredAbility extends DelayedTriggeredAbility {
@Override
public String getRule() {
return "When you cast your next instant or sorcery spell from your hand this turn, " + super.getRule() ;
return "When you cast your next instant or sorcery spell from your hand this turn, " + super.getRule();
}
}
@ -226,11 +226,11 @@ class NarsetTranscendentGainReboundEffect extends ContinuousEffectImpl {
class NarsetTranscendentEmblem extends Emblem {
// "Your opponents can't cast noncreature spells.
public NarsetTranscendentEmblem() {
this.setName("EMBLEM: Narset Transcendent");
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new NarsetTranscendentCantCastEffect()));
}
}
@ -269,7 +269,7 @@ class NarsetTranscendentCantCastEffect extends ContinuousRuleModifyingEffectImpl
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());

View file

@ -34,6 +34,8 @@ import mage.abilities.common.ExploitCreatureTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.ExploitAbility;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -99,9 +101,11 @@ class ProfanerOfTheDeadReturnEffect extends OneShotEffect {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerPredicate(TargetController.OPPONENT));
filter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, exploitedCreature.getToughness().getValue()));
Cards cardsToHand = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
cardsToHand.add(permanent);
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -105,10 +105,10 @@ class VolcanicVisionReturnToHandTargetEffect extends OneShotEffect {
case GRAVEYARD:
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(card, null, Zone.HAND, source, game);
int damage = card.getManaCost().convertedManaCost();
if (damage > 0) {
for(Permanent creature: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
creature.damage(damage, source.getSourceId(), game, false, true);
}
}

View file

@ -32,12 +32,13 @@ import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.permanent.PermanentIdPredicate;
import mage.game.Game;
@ -96,11 +97,13 @@ class ReturnToHandAllNamedPermanentsEffect extends OneShotEffect {
if (permanent.getName().isEmpty()) {
filter.add(new PermanentIdPredicate(permanent.getId())); // if no name (face down creature) only the creature itself is selected
} else {
filter.add(new NamePredicate(permanent.getName()));
filter.add(new NamePredicate(permanent.getName()));
}
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
controller.moveCardToHandWithInfo(perm, source.getSourceId(), game, Zone.BATTLEFIELD);
Cards cardsToHand = new CardsImpl();
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
cardsToHand.add(perm);
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return true;

View file

@ -115,7 +115,7 @@ class RenownedWeaponsmithCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
MageObject object = game.getObject(source.getSourceId());
return (object != null
return (object != null
&& object.getCardType().contains(CardType.ARTIFACT));
}
}
@ -149,8 +149,8 @@ class RenownedWeaponsmithEffect extends OneShotEffect {
Card card = game.getCard(target.getFirstTarget());
Cards revealed = new CardsImpl();
revealed.add(card);
controller.revealCards(sourceObject.getName(), revealed, game);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.moveCards(revealed, null, Zone.HAND, source, game);
}
}
controller.shuffleLibrary(game);

View file

@ -100,7 +100,7 @@ class SageEyeAvengersEffect extends OneShotEffect {
if (sourceObject != null && controller != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.getPower().getValue() < sourceObject.getPower().getValue()) {
controller.moveCardToHandWithInfo(targetCreature, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(targetCreature, null, Zone.HAND, source, game);
}
return true;
}

View file

@ -130,28 +130,28 @@ class GainAbilitySpellsEffect extends ContinuousEffectImpl {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
for (Card card: game.getExile().getAllCards(game)) {
for (Card card : game.getExile().getAllCards(game)) {
if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card: player.getLibrary().getCards(game)) {
for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card: player.getHand().getCards(game)) {
for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card: player.getGraveyard().getCards(game)) {
for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (StackObject stackObject : game.getStack()) {
if (stackObject.getControllerId().equals(source.getControllerId())) {
if (stackObject.getControllerId().equals(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (card != null && filter.match(card, game)) {
if (!card.getAbilities().contains(ability)) {
@ -199,15 +199,15 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
MageObject mageObject = game.getObject(spellId);
if (mageObject == null || !(mageObject instanceof Spell) || ((Spell)mageObject).isCopiedSpell()) {
MageObject mageObject = game.getObject(spellId);
if (mageObject == null || !(mageObject instanceof Spell) || ((Spell) mageObject).isCopiedSpell()) {
return false;
} else {
Card sourceCard = game.getCard(spellId);
if (sourceCard != null) {
Player player = game.getPlayer(sourceCard.getOwnerId());
if (player != null) {
player.moveCardToHandWithInfo(sourceCard, source.getSourceId(), game, Zone.STACK);
player.moveCards(sourceCard, null, Zone.HAND, source, game);
discard();
return true;
}
@ -215,6 +215,7 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
}
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
@ -225,21 +226,21 @@ class SoulfireGrandMasterCastFromHandReplacementEffect extends ReplacementEffect
//Something hit the stack from the hand, see if its a spell with this ability.
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (spellId == null && // because this effect works only once, spellId has to be null here
zEvent.getFromZone() == Zone.HAND &&
zEvent.getToZone() == Zone.STACK &&
event.getPlayerId().equals(source.getControllerId())) {
zEvent.getFromZone() == Zone.HAND
&& zEvent.getToZone() == Zone.STACK
&& event.getPlayerId().equals(source.getControllerId())) {
MageObject object = game.getObject(event.getTargetId());
if (object instanceof Card) {
if (filter.match((Card)object, game)) {
if (filter.match((Card) object, game)) {
this.spellId = event.getTargetId();
}
}
} else {
// the spell goes to graveyard now so move it to hand again
if (zEvent.getFromZone() == Zone.STACK &&
zEvent.getToZone() == Zone.GRAVEYARD &&
event.getTargetId().equals(spellId)) {
Spell spell = game.getStack().getSpell(spellId);
if (zEvent.getFromZone() == Zone.STACK
&& zEvent.getToZone() == Zone.GRAVEYARD
&& event.getTargetId().equals(spellId)) {
Spell spell = game.getStack().getSpell(spellId);
if (spell != null && !spell.isCountered()) {
return true;
}

View file

@ -33,6 +33,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -89,24 +91,26 @@ class SuddenReclamationEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToHand = new CardsImpl();
Target target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
controller.chooseTarget(outcome, target, source, game)) {
if (target.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
cardsToHand.add(card);
}
}
target = new TargetCardInYourGraveyard(new FilterLandCard("land card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
controller.chooseTarget(outcome, target, source, game)) {
if (target.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
cardsToHand.add(card);
}
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -120,7 +120,7 @@ class TasigurTheGoldenFangEffect extends OneShotEffect {
opponent.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}
}

View file

@ -103,13 +103,13 @@ class TemurSabertoothEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetPermanent(1,1, filter, true);
Target target = new TargetPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (controller.chooseUse(outcome, "Return another creature to hand?", source, game) &&
controller.chooseTarget(outcome, target, source, game)) {
if (controller.chooseUse(outcome, "Return another creature to hand?", source, game)
&& controller.chooseTarget(outcome, target, source, game)) {
Permanent toHand = game.getPermanent(target.getFirstTarget());
if (toHand != null) {
controller.moveCardToHandWithInfo(toHand, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(toHand, null, Zone.HAND, source, game);
}
game.addEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn), source);
}

View file

@ -31,8 +31,9 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -52,7 +53,6 @@ public class Recall extends CardImpl {
super(ownerId, 93, "Recall", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{X}{U}");
this.expansionSetCode = "5ED";
// Discard X cards, then return a card from your graveyard to your hand for each card discarded this way.
this.getSpellAbility().addEffect(new RecallEffect());
// Exile Recall.
@ -75,38 +75,33 @@ class RecallEffect extends OneShotEffect {
super(Outcome.ReturnToHand);
this.staticText = "Discard X cards, then return a card from your graveyard to your hand for each card discarded this way. ";
}
public RecallEffect(final RecallEffect effect) {
super(effect);
}
@Override
public RecallEffect copy() {
return new RecallEffect(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) {
// Discard X cards
int amount = source.getManaCostsToPay().getX();
int discarded = Math.min(amount, player.getHand().size());
player.discard(amount, false, source, game);
// then return a card from your graveyard to your hand for each card discarded this way
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(discarded, new FilterCard());
target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game);
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
Cards cardsDiscarded = controller.discard(source.getManaCostsToPay().getX(), false, source, game);
if (!cardsDiscarded.isEmpty()) {
// then return a card from your graveyard to your hand for each card discarded this way
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(cardsDiscarded.size(), new FilterCard());
target.setNotTarget(true);
target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game);
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
return true;
}
return false;
}
}

View file

@ -76,13 +76,13 @@ public class LinessaZephyrMage extends CardImpl {
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
// Grandeur - Discard another card named Linessa, Zephyr Mage: Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land.
ability = new GrandeurAbility(new LinessaZephyrMageEffect(), "Linessa, Zephyr Mage");
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
public LinessaZephyrMage(final LinessaZephyrMage card) {
super(card);
}
@ -105,21 +105,21 @@ public class LinessaZephyrMage extends CardImpl {
}
class LinessaZephyrMageEffect extends OneShotEffect {
LinessaZephyrMageEffect() {
super(Outcome.ReturnToHand);
this.staticText = "Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land";
}
LinessaZephyrMageEffect(final LinessaZephyrMageEffect effect) {
super(effect);
}
@Override
public LinessaZephyrMageEffect copy() {
return new LinessaZephyrMageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -132,7 +132,7 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
}
}
@ -144,10 +144,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
}
}
// an enchantment,
filter = new FilterControlledPermanent("enchantment you control");
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
@ -156,10 +156,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
}
}
// and a land.
filter = new FilterControlledPermanent("land you control");
filter.add(new CardTypePredicate(CardType.LAND));
@ -168,10 +168,10 @@ class LinessaZephyrMageEffect extends OneShotEffect {
if (target.choose(Outcome.ReturnToHand, targetPlayer.getId(), source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetPlayer.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
targetPlayer.moveCards(permanent, null, Zone.HAND, source, game);
}
}
return true;
}
}

View file

@ -103,18 +103,19 @@ class VenserShaperSavantEffect extends OneShotEffect {
if (controller != null) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
return controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
return controller.moveCards(permanent, null, Zone.HAND, source, game);
}
/**
* 01.05.2007 If a spell is returned to its owner's hand, it's removed from
* the stack and thus will not resolve. The spell isn't countered; it just no longer exists.
* 01.05.2007 If a copy of a spell is returned to its owner's hand, it's moved there,
* then it will cease to exist as a state-based action.
* 01.05.2007 If Venser's enters-the-battlefield ability targets a spell cast with flashback,
* that spell will be exiled instead of returning to its owner's hand.
* 01.05.2007 If a spell is returned to its owner's hand, it's
* removed from the stack and thus will not resolve. The spell isn't
* countered; it just no longer exists. 01.05.2007 If a copy of a
* spell is returned to its owner's hand, it's moved there, then it
* will cease to exist as a state-based action. 01.05.2007 If
* Venser's enters-the-battlefield ability targets a spell cast with
* flashback, that spell will be exiled instead of returning to its
* owner's hand.
*/
Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
Card card = null;
@ -123,7 +124,7 @@ class VenserShaperSavantEffect extends OneShotEffect {
}
game.getStack().remove(spell);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
controller.moveCards(card, null, Zone.HAND, source, game);
}
return true;
}

View file

@ -28,15 +28,15 @@
package mage.sets.gatecrash;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -95,8 +95,8 @@ class DinrovaHorrorEffect extends OneShotEffect {
if (target != null) {
Player controller = game.getPlayer(target.getControllerId());
if (controller != null) {
controller.moveCardToHandWithInfo(target, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.discard(1, source, game);
controller.moveCards(target, null, Zone.HAND, source, game);
controller.discard(1, false, source, game);
return true;
}
}

View file

@ -29,11 +29,6 @@ package mage.sets.gatecrash;
import java.util.UUID;
import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.EntersBattlefieldAbility;
@ -50,7 +45,11 @@ import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
@ -71,8 +70,6 @@ public class DomriRade extends CardImpl {
this.expansionSetCode = "GTC";
this.subtype.add("Domri");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(3)), false));
// +1: Look at the top card of your library. If it's a creature card, you may reveal it and put it into your hand.
@ -127,8 +124,8 @@ class DomriRadeEffect1 extends OneShotEffect {
controller.lookAtCards(sourceObject.getName(), cards, game);
if (card.getCardType().contains(CardType.CREATURE)) {
if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.revealCards(sourceObject.getName(), cards, game);
controller.moveCards(card, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cards, game);
}
}
return true;
@ -139,7 +136,9 @@ class DomriRadeEffect1 extends OneShotEffect {
}
class DomriRadeEmblem extends Emblem {
// "Creatures you control have double strike, trample, hexproof and haste."
public DomriRadeEmblem() {
this.setName("EMBLEM: Domri Rade");
FilterPermanent filter = new FilterControlledCreaturePermanent("Creatures");
@ -156,7 +155,7 @@ class DomriRadeEmblem extends Emblem {
}
class DomriRadeTargetOtherCreaturePermanent extends TargetCreaturePermanent {
public DomriRadeTargetOtherCreaturePermanent() {
super();
}

View file

@ -28,6 +28,7 @@
package mage.sets.iceage;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -54,7 +55,6 @@ public class DemonicConsultation extends CardImpl {
super(ownerId, 9, "Demonic Consultation", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "ICE";
// Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way.
this.getSpellAbility().addEffect(new DemonicConsultationEffect());
}
@ -70,63 +70,58 @@ public class DemonicConsultation extends CardImpl {
}
class DemonicConsultationEffect extends OneShotEffect {
DemonicConsultationEffect() {
super(Outcome.Benefit);
this.staticText = "Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card. Put that card into your hand and exile all other cards revealed this way";
}
DemonicConsultationEffect(final DemonicConsultationEffect effect) {
super(effect);
}
@Override
public DemonicConsultationEffect copy() {
return new DemonicConsultationEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
// Name a card.
Choice choice = new ChoiceImpl();
choice.setChoices(CardRepository.instance.getNames());
while (!player.choose(Outcome.Benefit, choice, game)) {
if (!player.canRespond()) {
while (!controller.choose(Outcome.Benefit, choice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String name = choice.getChoice();
game.informPlayers("Card named: " + name);
// Exile the top six cards of your library,
int num = Math.min(6, player.getLibrary().size());
for (int i = 0; i < num; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
controller.moveCards(controller.getLibrary().getTopCards(game, 6), null, Zone.EXILED, source, game);
// then reveal cards from the top of your library until you reveal the named card.
Cards cards = new CardsImpl(Zone.LIBRARY);
while (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
Cards cardsToReaveal = new CardsImpl();
Card cardToHand = null;
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
cardsToReaveal.add(card);
// Put that card into your hand
if (card.getName().equals(name)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
cardToHand = card;
break;
}
// and exile all other cards revealed this way.
else {
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
}
player.revealCards("Demonic Consultation", cards, game);
controller.moveCards(cardToHand, null, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cardsToReaveal, game);
cardsToReaveal.remove(cardToHand);
controller.moveCards(cardsToReaveal, null, Zone.EXILED, source, game);
return true;
}
return false;

View file

@ -29,10 +29,6 @@ package mage.sets.innistrad;
import java.util.UUID;
import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.effects.OneShotEffect;
@ -40,6 +36,10 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterBasicLandCard;
import mage.game.Game;
import mage.players.Player;
@ -55,7 +55,6 @@ public class CaravanVigil extends CardImpl {
super(ownerId, 173, "Caravan Vigil", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{G}");
this.expansionSetCode = "ISD";
// Search your library for a basic land card, reveal it, put it into your hand, then shuffle your library.
// Morbid - You may put that card onto the battlefield instead of putting it into your hand if a creature died this turn.
this.getSpellAbility().addEffect(new CaravanVigilEffect());
@ -103,10 +102,10 @@ class CaravanVigilEffect extends OneShotEffect {
&& controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", source, game)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
} else {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
controller.revealCards(sourceObject.getName(), cards, game);
}
controller.revealCards(sourceObject.getIdName(), cards, game);
}
}
controller.shuffleLibrary(game);
return true;

View file

@ -50,11 +50,10 @@ public class Recoil extends CardImpl {
super(ownerId, 264, "Recoil", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}{B}");
this.expansionSetCode = "INV";
// Return target permanent to its owner's hand. Then that player discards a card.
this.getSpellAbility().addEffect(new RecoilEffect());
this.getSpellAbility().addTarget(new TargetPermanent());
this.getSpellAbility().addTarget(new TargetPermanent());
}
public Recoil(final Recoil card) {
@ -86,13 +85,11 @@ class RecoilEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
Player controller = game.getPlayer(target.getControllerId());
if (controller != null) {
controller.moveCardToHandWithInfo(target, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.discard(1, source, game);
return true;
}
Player controller = game.getPlayer(target.getControllerId());
if (target != null && controller != null) {
controller.moveCards(target, null, Zone.HAND, source, game);
controller.discard(1, false, source, game);
return true;
}
return false;
}

View file

@ -64,12 +64,12 @@ import mage.target.common.TargetOpponent;
public class AthreosGodOfPassage extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you own");
static {
filter.add(new AnotherPredicate());
filter.add(new OwnerPredicate(TargetController.YOU));
}
public AthreosGodOfPassage(UUID ownerId) {
super(ownerId, 146, "Athreos, God of Passage", Rarity.MYTHIC, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{W}{B}");
this.expansionSetCode = "JOU";
@ -84,12 +84,12 @@ public class AthreosGodOfPassage extends CardImpl {
// As long as your devotion to white and black is less than seven, Athreos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.B), 7);
effect.setText("As long as your devotion to white and black is less than seven, Athreos isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// Whenever another creature you own dies, return it to your hand unless target opponent pays 3 life.
Ability ability = new AthreosDiesCreatureTriggeredAbility(new AthreosGodOfPassageReturnEffect(), false, filter);
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
}
public AthreosGodOfPassage(final AthreosGodOfPassage card) {
@ -103,21 +103,21 @@ public class AthreosGodOfPassage extends CardImpl {
}
class AthreosGodOfPassageReturnEffect extends OneShotEffect {
public AthreosGodOfPassageReturnEffect() {
super(Outcome.Benefit);
this.staticText = "return it to your hand unless target opponent pays 3 life";
}
public AthreosGodOfPassageReturnEffect(final AthreosGodOfPassageReturnEffect effect) {
super(effect);
}
@Override
public AthreosGodOfPassageReturnEffect copy() {
return new AthreosGodOfPassageReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -134,13 +134,13 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false)) {
paid = true;
}
}
}
}
if (opponent == null || !paid) {
if (game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(creature, null, Zone.HAND, source, game);
}
}
}
}
return true;
}

View file

@ -27,7 +27,6 @@
*/
package mage.sets.journeyintonyx;
import java.util.LinkedList;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
@ -74,7 +73,7 @@ public class BrainMaggot extends CardImpl {
Ability ability = new EntersBattlefieldTriggeredAbility(new BrainMaggotExileEffect());
ability.addTarget(new TargetOpponent());
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new BrainMaggotReturnExiledCardAbility()));
this.addAbility(ability);
this.addAbility(ability);
}
public BrainMaggot(final BrainMaggot card) {
@ -110,7 +109,7 @@ class BrainMaggotExileEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && opponent != null && sourcePermanent != null) {
if (!opponent.getHand().isEmpty()) {
opponent.revealCards(sourcePermanent.getName(), opponent.getHand(), game);
opponent.revealCards(sourcePermanent.getIdName(), opponent.getHand(), game);
FilterCard filter = new FilterNonlandCard("nonland card to exile");
TargetCard target = new TargetCard(Zone.HAND, filter);
@ -130,11 +129,10 @@ class BrainMaggotExileEffect extends OneShotEffect {
}
/**
* Returns the exiled card as source permanent leaves battlefield
* Uses no stack
* Returns the exiled card as source permanent leaves battlefield Uses no stack
*
* @author LevelX2
*/
class BrainMaggotReturnExiledCardAbility extends DelayedTriggeredAbility {
public BrainMaggotReturnExiledCardAbility() {
@ -190,18 +188,13 @@ class BrainMaggotReturnExiledCardEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1;
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (exile != null && sourcePermanent != null) {
LinkedList<UUID> cards = new LinkedList<>(exile);
for (UUID cardId : cards) {
Card card = game.getCard(cardId);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
exile.clear();
controller.moveCards(exile, null, Zone.HAND, source, game);
return true;
}
}
}
return false;
}

View file

@ -31,6 +31,8 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -52,12 +54,10 @@ public class Hubris extends CardImpl {
super(ownerId, 41, "Hubris", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
this.expansionSetCode = "JOU";
// Return target creature and all Auras attached to it to their owners' hand.
this.getSpellAbility().addEffect(new HubrisReturnEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
public Hubris(final Hubris card) {
@ -96,16 +96,12 @@ class HubrisReturnEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID targetId: targetPointer.getTargets(game, source)) {
for (UUID targetId : targetPointer.getTargets(game, source)) {
Permanent creature = game.getPermanent(targetId);
if (creature != null) {
controller.moveCardToHandWithInfo(creature, source.getSourceId(), game, Zone.BATTLEFIELD);
for (UUID attachementId: creature.getAttachments()) {
Permanent attachment = game.getPermanent(attachementId);
if (attachment != null && filter.match(attachment, game)) {
controller.moveCardToHandWithInfo(attachment, source.getSourceId(), game, Zone.BATTLEFIELD);
}
}
Cards cardsToHand = new CardsImpl(creature.getAttachments());
cardsToHand.add(creature);
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
}
}
return true;

View file

@ -101,36 +101,30 @@ class NessianGameWardenEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player == null || sourcePermanent == null) {
if (controller == null || sourcePermanent == null) {
return false;
}
Cards cards = new CardsImpl();
int count = new PermanentsOnBattlefieldCount(filter).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(sourcePermanent.getName(), cards, game);
cards.addAll(controller.getLibrary().getTopCards(game, count));
controller.lookAtCards(sourcePermanent.getIdName(), cards, game);
if (!cards.isEmpty()) {
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to put into your hand"));
if (target.canChoose(source.getSourceId(), player.getId(), game) && player.choose(Outcome.DrawCard, cards, target, game)) {
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
player.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
controller.revealCards(sourcePermanent.getName(), new CardsImpl(card), game);
cards.remove(card);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -33,6 +33,8 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -78,27 +80,27 @@ public class ScourgeOfFleets extends CardImpl {
}
class ScourgeOfFleetsEffect extends OneShotEffect {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("number of Islands you control");
static {
filter.add(new SubtypePredicate("Island"));
}
public ScourgeOfFleetsEffect() {
super(Outcome.Benefit);
this.staticText = "return each creature your opponents control with toughness X or less, where X is the number of Islands you control";
}
public ScourgeOfFleetsEffect(final ScourgeOfFleetsEffect effect) {
super(effect);
}
@Override
public ScourgeOfFleetsEffect copy() {
return new ScourgeOfFleetsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -106,10 +108,12 @@ class ScourgeOfFleetsEffect extends OneShotEffect {
int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
FilterPermanent creatureFilter = new FilterCreaturePermanent();
creatureFilter.add(new ControllerPredicate(TargetController.OPPONENT));
creatureFilter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, islands +1));
for (Permanent permanent: game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
creatureFilter.add(new ToughnessPredicate(Filter.ComparisonType.LessThan, islands + 1));
Cards cardsToHand = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
cardsToHand.add(permanent);
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,16 +20,15 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.magic2011;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -93,41 +92,44 @@ class CultivateEffect 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) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
Player player = game.getPlayer(source.getControllerId());
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl();
for (UUID cardId: (List<UUID>)target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
player.revealCards("Cultivate", revealed, game);
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
player.choose(Outcome.Benefit, revealed, target2, game);
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
revealed.remove(card);
}
card = revealed.getCards(game).iterator().next();
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
}
}
else if (target.getTargets().size() == 1) {
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
}
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}

View file

@ -79,6 +79,7 @@ public class Quickling extends CardImpl {
return new Quickling(this);
}
}
class QuicklingEffect extends OneShotEffect {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature you control");
@ -88,12 +89,12 @@ class QuicklingEffect extends OneShotEffect {
filter.add(new AnotherPredicate());
}
QuicklingEffect ( ) {
QuicklingEffect() {
super(Outcome.ReturnToHand);
staticText = effectText;
}
QuicklingEffect ( QuicklingEffect effect ) {
QuicklingEffect(QuicklingEffect effect) {
super(effect);
}
@ -106,13 +107,13 @@ class QuicklingEffect extends OneShotEffect {
if (target.canChoose(controller.getId(), game) && controller.chooseUse(outcome, "Return another creature you control to its owner's hand?", source, game)) {
controller.chooseTarget(Outcome.ReturnToHand, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {
if (permanent != null) {
targetChosen = true;
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(permanent, null, Zone.HAND, source, game);
}
}
if ( !targetChosen ) {
if (!targetChosen) {
new SacrificeSourceEffect().apply(game, source);
}
return true;

View file

@ -57,7 +57,6 @@ public class ForbiddenCrypt extends CardImpl {
super(ownerId, 22, "Forbidden Crypt", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}");
this.expansionSetCode = "MIR";
// If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ForbiddenCryptDrawCardReplacementEffect()));
// If a card would be put into your graveyard from anywhere, exile that card instead.
@ -80,7 +79,7 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
super(Duration.WhileOnBattlefield, Outcome.Neutral);
this.staticText = "If you would draw a card, return a card from your graveyard to your hand instead. If you can't, you lose the game";
}
public ForbiddenCryptDrawCardReplacementEffect(final ForbiddenCryptDrawCardReplacementEffect effect) {
super(effect);
}
@ -92,22 +91,23 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean cardReturned = false;
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) {
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (target.choose(Outcome.ReturnToHand, controller.getId(), source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(card, null, Zone.HAND, source, game);
cardReturned = true;
}
}
}
if (!cardReturned) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" can't return a card from graveyard to hand.").toString());
player.lost(game);
game.informPlayers(controller.getLogName() + " can't return a card from graveyard to hand.");
controller.lost(game);
}
return true;
}
@ -118,12 +118,12 @@ class ForbiddenCryptDrawCardReplacementEffect extends ReplacementEffectImpl {
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DRAW_CARD;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getPlayerId().equals(source.getControllerId());
}
}
class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEffectImpl {
@ -132,7 +132,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
super(Duration.WhileOnBattlefield, Outcome.Detriment);
this.staticText = "If a card would be put into your graveyard from anywhere, exile that card instead";
}
public ForbiddenCryptPutIntoYourGraveyardReplacementEffect(final ForbiddenCryptPutIntoYourGraveyardReplacementEffect effect) {
super(effect);
}
@ -141,7 +141,7 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
public ForbiddenCryptPutIntoYourGraveyardReplacementEffect copy() {
return new ForbiddenCryptPutIntoYourGraveyardReplacementEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
@ -166,12 +166,12 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
}
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
}
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
@ -185,5 +185,5 @@ class ForbiddenCryptPutIntoYourGraveyardReplacementEffect extends ReplacementEff
}
return false;
}
}

View file

@ -53,7 +53,6 @@ public class SpoilsOfTheVault extends CardImpl {
super(ownerId, 78, "Spoils of the Vault", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "MRD";
// Name a card. Reveal cards from the top of your library until you reveal the named card, then put that card into your hand. Exile all other cards revealed this way, and you lose 1 life for each of the exiled cards.
this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.ALL));
this.getSpellAbility().addEffect(new SpoilsOfTheVaultEffect());
@ -69,7 +68,6 @@ public class SpoilsOfTheVault extends CardImpl {
}
}
class SpoilsOfTheVaultEffect extends OneShotEffect {
public SpoilsOfTheVaultEffect() {
@ -94,28 +92,25 @@ class SpoilsOfTheVaultEffect extends OneShotEffect {
if (sourceObject == null || controller == null || cardName == null || cardName.isEmpty()) {
return false;
}
Cards cards = new CardsImpl();
Cards cardsToReveal = new CardsImpl();
Cards cardsToExile = new CardsImpl();
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if(card.getName().equals(cardName)){
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
cardsToReveal.add(card);
if (card.getName().equals(cardName)) {
controller.moveCards(card, null, Zone.HAND, source, game);
break;
} else {
cardsToExile.add(card);
}
else{
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
else{
break;
}
}
controller.revealCards(sourceObject.getName(), cards, game);
controller.loseLife(cards.size(), game);
controller.revealCards(sourceObject.getIdName(), cardsToReveal, game);
controller.moveCards(cardsToExile, null, Zone.EXILED, source, game);
controller.loseLife(cardsToExile.size(), game);
return true;
}
}

View file

@ -28,6 +28,7 @@
package mage.sets.modernmasters;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -52,7 +53,6 @@ public class PetalsOfInsight extends CardImpl {
this.expansionSetCode = "MMA";
this.subtype.add("Arcane");
// Look at the top three cards of your library. You may put those cards on the bottom of your library in any order. If you do, return Petals of Insight to its owner's hand. Otherwise, draw three cards.
this.getSpellAbility().addEffect(new PetalsOfInsightEffect());
}
@ -85,33 +85,23 @@ class PetalsOfInsightEffect 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());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == 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);
}
}
player.lookAtCards("Petals of Insight", cards, game);
if (player.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, game)) {
player.putCardsOnBottomOfLibrary(cards, game, source, true);
cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.lookAtCards(sourceObject.getIdName(), cards, game);
if (controller.chooseUse(outcome, "Put the cards on the bottom of your library in any order?", source, game)) {
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
controller.moveCards(spellCard, null, Zone.HAND, source, game);
}
} else {
for (UUID cardId: cards) {
Card card = game.getCard(cardId);
if (card != null) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
}
player.drawCards(3, game);
controller.drawCards(3, game);
}
return true;
}

View file

@ -34,6 +34,8 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -56,7 +58,7 @@ public class AllSunsDawn extends CardImpl {
private final static FilterCard filterBlue = new FilterCard("blue card from your graveyard");
private final static FilterCard filterBlack = new FilterCard("black card from your graveyard");
private final static FilterCard filterWhite = new FilterCard("white card from your graveyard");
static {
filterGreen.add(new ColorPredicate(ObjectColor.GREEN));
filterRed.add(new ColorPredicate(ObjectColor.RED));
@ -64,18 +66,18 @@ public class AllSunsDawn extends CardImpl {
filterBlack.add(new ColorPredicate(ObjectColor.BLACK));
filterWhite.add(new ColorPredicate(ObjectColor.WHITE));
}
public AllSunsDawn(UUID ownerId) {
super(ownerId, 138, "All Suns' Dawn", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{G}");
this.expansionSetCode = "MM2";
// For each color, return up to one target card of that color from your graveyard to your hand.
// For each color, return up to one target card of that color from your graveyard to your hand.
this.getSpellAbility().addEffect(new AllSunsDawnEffect());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterGreen));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterRed));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterBlue));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterBlack));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0,1,filterWhite));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterGreen));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterRed));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterBlue));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterBlack));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, filterWhite));
// Exile All Suns' Dawn.
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}
@ -91,32 +93,34 @@ public class AllSunsDawn extends CardImpl {
}
class AllSunsDawnEffect extends OneShotEffect {
public AllSunsDawnEffect() {
super(Outcome.ReturnToHand);
this.staticText = "For each color, return up to one target card of that color from your graveyard to your hand. Exile {this}";
}
public AllSunsDawnEffect(final AllSunsDawnEffect effect) {
super(effect);
}
@Override
public AllSunsDawnEffect copy() {
return new AllSunsDawnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for(Target target: source.getTargets()) {
Cards cardsToHand = new CardsImpl();
for (Target target : source.getTargets()) {
UUID targetId = target.getFirstTarget();
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true);
cardsToHand.add(card);
}
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -28,14 +28,13 @@
package mage.sets.onslaught;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
@ -55,7 +54,6 @@ public class ChainOfVapor extends CardImpl {
super(ownerId, 73, "Chain of Vapor", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "ONS";
// Return target nonland permanent to its owner's hand. Then that permanent's controller may sacrifice a land. If the player does, he or she may copy this spell and may choose a new target for that copy.
this.getSpellAbility().addEffect(new ChainOfVaporEffect());
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
@ -94,16 +92,14 @@ class ChainOfVaporEffect extends OneShotEffect {
}
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (!controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD)){
return false;
}
controller.moveCards(permanent, null, Zone.HAND, source, game);
Player player = game.getPlayer(permanent.getControllerId());
if (player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", source, game)){
if (player.chooseUse(Outcome.ReturnToHand, "Sacrifice a land to copy this spell?", source, game)) {
TargetControlledPermanent target = new TargetControlledPermanent(new FilterControlledLandPermanent());
if (player.chooseTarget(Outcome.Sacrifice, target, source, game)){
if (player.chooseTarget(Outcome.Sacrifice, target, source, game)) {
Permanent land = game.getPermanent(target.getFirstTarget());
if(land != null){
if(land.sacrifice(source.getSourceId(), game)){
if (land != null) {
if (land.sacrifice(source.getSourceId(), game)) {
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell != null) {
Spell copy = spell.copySpell();
@ -123,9 +119,10 @@ class ChainOfVaporEffect extends OneShotEffect {
}
}
}
return true;
}
return true;
return false;
}
@Override

View file

@ -30,9 +30,9 @@ package mage.sets.onslaught;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
@ -55,7 +55,6 @@ public class WeirdHarvest extends CardImpl {
super(ownerId, 299, "Weird Harvest", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{G}{G}");
this.expansionSetCode = "ONS";
// Each player may search his or her library for up to X creature cards, reveal those cards, and put them into his or her hand. Then each player who searched his or her library this way shuffles it.
getSpellAbility().addEffect(new WeirdHarvestEffect());
}
@ -89,20 +88,21 @@ class WeirdHarvestEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
int xValue = source.getManaCostsToPay().getX();
if (xValue > 0) {
List<Player> usingPlayers = new ArrayList<>();
this.chooseAndSearchLibrary(usingPlayers, controller, xValue, source, game);
for (UUID playerId: controller.getInRange()) {
this.chooseAndSearchLibrary(usingPlayers, controller, xValue, source, sourceObject, game);
for (UUID playerId : controller.getInRange()) {
if (!playerId.equals(controller.getId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
this.chooseAndSearchLibrary(usingPlayers, player, xValue, source, game);
this.chooseAndSearchLibrary(usingPlayers, player, xValue, source, sourceObject, game);
}
}
}
for (Player player: usingPlayers) {
for (Player player : usingPlayers) {
player.shuffleLibrary(game);
}
return true;
@ -111,21 +111,15 @@ class WeirdHarvestEffect extends OneShotEffect {
return false;
}
private void chooseAndSearchLibrary(List<Player> usingPlayers, Player player, int xValue, Ability source, Game game) {
private void chooseAndSearchLibrary(List<Player> usingPlayers, Player player, int xValue, Ability source, MageObject sourceObject, Game game) {
if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for up " + xValue + " creature cards and put them into your hand?", source, game)) {
usingPlayers.add(player);
TargetCardInLibrary target = new TargetCardInLibrary(0, xValue, new FilterCreatureCard());
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards cards = new CardsImpl();
for (UUID cardId: (List<UUID>)target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
if (card != null) {
cards.add(card);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
}
}
player.revealCards("Weird Harvest", cards, game);
Cards cards = new CardsImpl(target.getTargets());
player.moveCards(cards, null, Zone.HAND, source, game);
player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ")", cards, game);
}
}
}

View file

@ -34,61 +34,60 @@ import mage.util.CardUtil;
* @author nick.myers
*/
public class SkyshipWeatherlight extends CardImpl {
public SkyshipWeatherlight(UUID ownerId) {
super(ownerId, 133, "Skyship Weatherlight", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "PLS";
this.supertype.add("Legendary");
// When Skyship Weatherlight enters the battlefield, search your library for any number of artifact and/or creature cards and exile them. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkyshipWeatherlightEffect(), false));
// {4}, {tap}, Choose a card at random that was removed from the game with Skyship Weatherlight. Put that card into your hand.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SkyshipWeatherlightEffect2(), new GenericManaCost(4));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
public SkyshipWeatherlight(final SkyshipWeatherlight card) {
super(card);
}
@Override
public SkyshipWeatherlight copy() {
return new SkyshipWeatherlight(this);
}
}
class SkyshipWeatherlightEffect extends SearchEffect {
private static final FilterCard filter = new FilterCard("artifact and/or creature card");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
}
public SkyshipWeatherlightEffect() {
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.Neutral);
this.staticText = "search your library for any number of artifact and/or creature cards and remove them from the game. Then shuffle your library";
}
public SkyshipWeatherlightEffect(final SkyshipWeatherlightEffect effect) {
super(effect);
}
@Override
public SkyshipWeatherlightEffect copy() {
return new SkyshipWeatherlightEffect(this);
}
@Override
public boolean apply (Game game, Ability source) {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null) {
@ -108,25 +107,25 @@ class SkyshipWeatherlightEffect extends SearchEffect {
}
return false;
}
}
class SkyshipWeatherlightEffect2 extends OneShotEffect {
public SkyshipWeatherlightEffect2() {
super(Outcome.ReturnToHand);
this.staticText = "Choose a card at random that was removed from the game with {this}. Put that card into your hand";
}
public SkyshipWeatherlightEffect2(final SkyshipWeatherlightEffect2 effect) {
super(effect);
}
@Override
public SkyshipWeatherlightEffect2 copy() {
return new SkyshipWeatherlightEffect2(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -134,12 +133,11 @@ class SkyshipWeatherlightEffect2 extends OneShotEffect {
if (sourceObject != null && controller != null) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
if (exZone != null) {
Card card = exZone.getRandom(game);
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
controller.moveCards(exZone.getRandom(game), null, Zone.HAND, source, game);
}
return true;
}
return false;
}
}

View file

@ -57,6 +57,7 @@ import mage.target.TargetPermanent;
public class CloudstoneCurio extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("a nonartifact permanent");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT)));
filter.add(new ControllerPredicate(TargetController.YOU));
@ -69,7 +70,6 @@ public class CloudstoneCurio extends CardImpl {
// Whenever a nonartifact permanent enters the battlefield under your control, you may return another permanent you control that shares a card type with it to its owner's hand.
this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new CloudstoneCurioEffect(), filter, true, SetTargetPointer.PERMANENT, "", true));
}
public CloudstoneCurio(final CloudstoneCurio card) {
@ -120,7 +120,7 @@ class CloudstoneCurioEffect extends OneShotEffect {
if (target.canChoose(controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
Permanent returningCreature = game.getPermanent(target.getFirstTarget());
if (returningCreature != null) {
controller.moveCardToHandWithInfo(returningCreature, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(returningCreature, null, Zone.HAND, source, game);
}
}
}

View file

@ -28,10 +28,6 @@
package mage.sets.ravnica;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -40,8 +36,11 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -76,6 +75,7 @@ public class DarkConfidant extends CardImpl {
}
class DarkConfidantEffect extends OneShotEffect {
DarkConfidantEffect() {
super(Outcome.DrawCard);
this.staticText = "reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost";
@ -87,17 +87,16 @@ class DarkConfidantEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && sourcePermanent != null) {
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
if (controller != null && sourcePermanent != null) {
if (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(sourcePermanent.getName(), cards, game);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
player.loseLife(card.getManaCost().convertedManaCost(), game);
Cards cards = new CardsImpl(card);
controller.revealCards(sourcePermanent.getIdName(), cards, game);
controller.moveCards(card, null, Zone.HAND, source, game);
controller.loseLife(card.getManaCost().convertedManaCost(), game);
}
return true;

View file

@ -28,9 +28,6 @@
package mage.sets.returntoravnica;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -38,7 +35,9 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
@ -88,12 +87,12 @@ class FaerieImpostorEffect extends OneShotEffect {
filter.add(new AnotherPredicate());
}
FaerieImpostorEffect ( ) {
FaerieImpostorEffect() {
super(Outcome.ReturnToHand);
staticText = effectText;
}
FaerieImpostorEffect ( FaerieImpostorEffect effect ) {
FaerieImpostorEffect(FaerieImpostorEffect effect) {
super(effect);
}
@ -108,13 +107,13 @@ class FaerieImpostorEffect extends OneShotEffect {
controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {
if (permanent != null) {
targetChosen = true;
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(permanent, null, Zone.HAND, source, game);
}
}
if ( !targetChosen ) {
if (!targetChosen) {
new SacrificeSourceEffect().apply(game, source);
}
return true;

View file

@ -258,7 +258,7 @@ class JaceArchitectOfThoughtEffect2 extends OneShotEffect {
for (UUID cardUuid : cardsToHand) {
Card card = cardsToHand.get(cardUuid, game);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
player.moveCards(card, null, Zone.HAND, source, game);
}
}

View file

@ -99,13 +99,13 @@ class ElderPineOfJukaiEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.revealCards(sourceObject.getName(), cards, game);
for (Card card: cards.getCards(game)) {
for (Card card : cards.getCards(game)) {
if (card.getCardType().contains(CardType.LAND)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
cards.remove(card);
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
@ -28,6 +28,7 @@
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -55,7 +56,6 @@ public class CerebralEruption extends CardImpl {
super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}");
this.expansionSetCode = "SOM";
// Target opponent reveals the top card of his or her library. Cerebral Eruption deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls. If a land card is revealed this way, return Cerebral Eruption to its owner's hand.
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().addEffect(new CerebralEruptionEffect());
@ -87,21 +87,21 @@ class CerebralEruptionEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null && player.getLibrary().size() > 0) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Cerebral Eruption", cards, game);
Cards cards = new CardsImpl(card);
player.revealCards(sourceObject.getIdName(), cards, game);
game.getState().setValue(source.getSourceId().toString(), card);
int damage = card.getManaCost().convertedManaCost();
player.damage(damage, source.getSourceId(), game, false, true);
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
perm.damage(damage, source.getSourceId(), game, false, true);
}
if (card.getCardType().contains(CardType.LAND)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
player.moveCards(spellCard, null, Zone.HAND, source, game);
}
}
return true;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
@ -50,7 +50,6 @@ public class PsychicMiasma extends CardImpl {
super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}");
this.expansionSetCode = "SOM";
// Target player discards a card. If a land card is discarded this way, return Psychic Miasma to its owner's hand.
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new PsychicMiasmaEffect());
@ -86,9 +85,10 @@ class PsychicMiasmaEffect extends OneShotEffect {
if (discardedCard != null && discardedCard.getCardType().contains(CardType.LAND)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
player.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
player.moveCards(spellCard, null, Zone.HAND, source, game);
}
}
return true;
}
return false;
}

View file

@ -100,7 +100,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
for (Card card : cardsFromTopLibrary) {
cards.add(card);
}
controller.lookAtCards(mageObject.getName(), cards, game);
controller.lookAtCards(mageObject.getIdName(), cards, game);
int max = 0;
for (UUID playerId : controller.getInRange()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
@ -111,20 +111,11 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
}
}
}
if (game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max) {
TargetCard target = new TargetCard(2, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getSourceId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getFirstTarget()));
controller.moveCardToHandWithInfo(game.getCard(target.getTargets().get(1)), source.getSourceId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getTargets().get(1)));
}
} else {
TargetCard target = new TargetCard(1, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
controller.moveCardToHandWithInfo(game.getCard(target.getFirstTarget()), source.getSourceId(), game, Zone.LIBRARY);
cards.remove(game.getCard(target.getFirstTarget()));
}
boolean moreCreatures = game.getBattlefield().countAll(new FilterControlledCreaturePermanent(), controller.getId(), game) > max;
TargetCard target = new TargetCard(moreCreatures ? 2 : 1, Zone.LIBRARY, new FilterCard());
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
cards.removeAll(target.getTargets());
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;

View file

@ -50,7 +50,6 @@ public class AdNauseam extends CardImpl {
super(ownerId, 63, "Ad Nauseam", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{B}{B}");
this.expansionSetCode = "ALA";
// Reveal the top card of your library and put that card into your hand. You lose life equal to its converted mana cost. You may repeat this process any number of times.
this.getSpellAbility().addEffect(new AdNauseamEffect());
}
@ -92,12 +91,12 @@ class AdNauseamEffect extends OneShotEffect {
while (controller.chooseUse(outcome, message, source, game) && controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
int cmc = card.getManaCost().convertedManaCost();
if (cmc > 0) {
controller.loseLife(cmc, game);
}
controller.revealCards(new StringBuilder(sourceCard.getName()).append(" put into hand").toString(), new CardsImpl(card), game);
controller.revealCards(sourceCard.getIdName() + " put into hand", new CardsImpl(card), game);
}
}
return true;

View file

@ -58,7 +58,6 @@ public class CruelUltimatum extends CardImpl {
super(ownerId, 164, "Cruel Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{U}{U}{B}{B}{B}{R}{R}");
this.expansionSetCode = "ALA";
// Target opponent sacrifices a creature, discards three cards, then loses 5 life.
// You return a creature card from your graveyard to your hand, draw three cards, then gain 5 life.
this.getSpellAbility().addTarget(new TargetOpponent());
@ -99,17 +98,17 @@ class CruelUltimatumEffect 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;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card from your graveyard"));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && controller.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
return player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
controller.moveCards(card, null, Zone.HAND, source, game);
}
return true;
}

View file

@ -69,9 +69,8 @@ public class TidehollowSculler extends CardImpl {
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
// When Tidehollow Sculler leaves the battlefield, return the exiled card to its owner's hand.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new TidehollowScullerLeaveEffect(), false ));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new TidehollowScullerLeaveEffect(), false));
}
public TidehollowSculler(final TidehollowSculler card) {
@ -124,7 +123,6 @@ class TidehollowScullerExileEffect extends OneShotEffect {
return false;
}
}
class TidehollowScullerLeaveEffect extends OneShotEffect {
@ -148,17 +146,13 @@ class TidehollowScullerLeaveEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1;
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exZone != null) {
for (Card card : exZone.getCards(game)) {
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
}
}
controller.moveCards(exZone, null, Zone.HAND, source, game);
}
return true;
}
return false;
}
}
}

View file

@ -28,6 +28,7 @@
package mage.sets.tenthedition;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
@ -94,35 +95,35 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
Player controller = game.getPlayer(event.getPlayerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
FilterCard filter = new FilterCard();
if (player.chooseUse(Outcome.Benefit, "Choose land? (No = nonland)", source, game)) {
if (controller.chooseUse(Outcome.Benefit, "Choose land? (No = nonland)", source, game)) {
filter.add(new CardTypePredicate(CardType.LAND));
}
else {
} else {
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
}
Cards cards = new CardsImpl();
while (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (filter.match(card, source.getSourceId(), source.getControllerId(), game)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
controller.moveCards(card, null, Zone.HAND, source, game);
break;
}
cards.add(card);
}
player.revealCards("Abundance", cards, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
@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) {
if (event.getPlayerId().equals(source.getControllerId())) {
@ -133,4 +134,4 @@ class AbundanceReplacementEffect extends ReplacementEffectImpl {
}
return false;
}
}
}

View file

@ -71,7 +71,7 @@ public class MesmericFiend extends CardImpl {
this.addAbility(ability);
// When Mesmeric Fiend leaves the battlefield, return the exiled card to its owner's hand.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new MesmericFiendLeaveEffect(), false ));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new MesmericFiendLeaveEffect(), false));
}
public MesmericFiend(final MesmericFiend card) {
@ -83,6 +83,7 @@ public class MesmericFiend extends CardImpl {
return new MesmericFiend(this);
}
}
class MesmericFiendExileEffect extends OneShotEffect {
public MesmericFiendExileEffect() {
@ -120,7 +121,6 @@ class MesmericFiendExileEffect extends OneShotEffect {
return false;
}
}
class MesmericFiendLeaveEffect extends OneShotEffect {
@ -143,18 +143,13 @@ class MesmericFiendLeaveEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject !=null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() -1;
if (controller != null && sourceObject != null) {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exZone != null) {
for (Card card : exZone.getCards(game)) {
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.EXILED);
}
}
return true;
return controller.moveCards(exZone, null, Zone.HAND, source, game);
}
}
return false;
}
}
}

View file

@ -32,8 +32,8 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.discard.DiscardHandAllEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -54,13 +54,12 @@ public class IllGottenGains extends CardImpl {
super(ownerId, 138, "Ill-Gotten Gains", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{B}");
this.expansionSetCode = "USG";
// Exile Ill-Gotten Gains.
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
// Each player discards his or her hand,
this.getSpellAbility().addEffect(new DiscardHandAllEffect());
//then returns up to three cards from his or her graveyard to his or her hand.
this.getSpellAbility().addEffect(new IllGottenGainsEffect());
}
@ -76,34 +75,31 @@ public class IllGottenGains extends CardImpl {
}
class IllGottenGainsEffect extends OneShotEffect {
IllGottenGainsEffect() {
super(Outcome.ReturnToHand);
this.staticText = ", then returns up to three cards from his or her graveyard to his or her hand.";
}
IllGottenGainsEffect(final IllGottenGainsEffect effect) {
super(effect);
}
@Override
public IllGottenGainsEffect copy() {
return new IllGottenGainsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : controller.getInRange()){
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
Target target = new TargetCardInYourGraveyard(0, 3, new FilterCard());
if (target.choose(Outcome.ReturnToHand, player.getId(), source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
}
}

View file

@ -35,6 +35,8 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -86,22 +88,20 @@ class NoRestForTheWickedEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get("NoRestForTheWickedWatcher");
if (watcher != null) {
Player controller = game.getPlayer(source.getControllerId());
if (watcher != null && controller != null) {
Cards cardsToHand = new CardsImpl();
for (UUID cardId : watcher.cards) {
Card c = game.getCard(cardId);
if (c != null) {
if (game.getState().getZone(cardId) == Zone.GRAVEYARD
&& c.getCardType().contains(CardType.CREATURE)
&& c.getOwnerId().equals(source.getControllerId())) {
//400.3
Player p = game.getPlayer(source.getControllerId());
if (p != null) {
p.moveCardToHandWithInfo(c, source.getSourceId(), game, Zone.GRAVEYARD);
}
return false;
cardsToHand.add(c);
}
}
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.zendikar;
import java.util.UUID;
@ -108,10 +107,10 @@ class GoblinGuideTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId()) ) {
if (event.getSourceId().equals(this.getSourceId())) {
UUID defenderId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
if (defenderId != null) {
for (Effect effect :this.getEffects()) {
for (Effect effect : this.getEffects()) {
// set here because attacking creature can be removed until effect resolves
effect.setTargetPointer(new FixedTarget(defenderId));
}
@ -134,8 +133,8 @@ class GoblinGuideTriggeredAbility extends TriggeredAbilityImpl {
return new GoblinGuideTriggeredAbility(this);
}
}
class GoblinGuideEffect extends OneShotEffect {
public GoblinGuideEffect() {
@ -153,7 +152,7 @@ class GoblinGuideEffect extends OneShotEffect {
}
@Override
public boolean apply(Game game, Ability source) {
public boolean apply(Game game, Ability source) {
Player defender = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && defender != null) {
@ -163,7 +162,7 @@ class GoblinGuideEffect extends OneShotEffect {
cards.add(card);
defender.revealCards(sourceObject.getName(), cards, game);
if (card.getCardType().contains(CardType.LAND)) {
defender.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
defender.moveCards(card, null, Zone.HAND, source, game);
}
}
return true;
@ -171,4 +170,4 @@ class GoblinGuideEffect extends OneShotEffect {
return false;
}
}
}

View file

@ -0,0 +1,58 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.triggers.combat.damage;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class GravebladeMarauderTest extends CardTestPlayerBase {
@Test
public void testTwoAttackers() {
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion", 3);
// Whenever Graveblade Marauder deals combat damage to a player, that player loses life equal to the number of creature cards in your graveyard.
addCard(Zone.BATTLEFIELD, playerB, "Graveblade Marauder", 2);// 1/4
attack(2, playerB, "Graveblade Marauder");
attack(2, playerB, "Graveblade Marauder");
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 12); // 1 + 3 + 1 + 3 = 8
assertLife(playerB, 20);
}
}

View file

@ -1693,13 +1693,13 @@ public class TestPlayer implements Player {
}
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, fromZone);
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game);
}
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, fromZone, withName);
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
return computerPlayer.moveCardToHandWithInfo(card, sourceId, game, withName);
}
@Override

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,22 +20,19 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.CostImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -52,6 +49,7 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
this.text = new StringBuilder("return ").append(target.getTargetName()).append(" from graveyard to it's owner's hand").toString();
}
}
public ReturnToHandFromGraveyardCost(ReturnToHandFromGraveyardCost cost) {
super(cost);
}
@ -61,12 +59,12 @@ public class ReturnToHandFromGraveyardCost extends CostImpl {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) {
for (UUID targetId : targets.get(0).getTargets()) {
mage.cards.Card targetCard = game.getCard(targetId);
if (targetCard == null) {
return false;
}
paid |= controller.moveCardToHandWithInfo(targetCard, sourceId, game, Zone.HAND);
paid |= controller.moveCardToHandWithInfo(targetCard, sourceId, game);
}
}
}

View file

@ -25,14 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.CostImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -62,12 +60,12 @@ public class ReturnToHandTargetPermanentCost extends CostImpl {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
if (targets.choose(Outcome.ReturnToHand, controllerId, sourceId, game)) {
for (UUID targetId: targets.get(0).getTargets()) {
for (UUID targetId : targets.get(0).getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent == null) {
return false;
}
paid |= controller.moveCardToHandWithInfo(permanent, sourceId, game, Zone.HAND);
paid |= controller.moveCardToHandWithInfo(permanent, sourceId, game);
}
}
}
@ -84,5 +82,4 @@ public class ReturnToHandTargetPermanentCost extends CostImpl {
return new ReturnToHandTargetPermanentCost(this);
}
}

View file

@ -60,7 +60,7 @@ public class ClashWinReturnToHandSpellEffect extends OneShotEffect implements Ma
if (ClashEffect.getInstance().apply(game, source)) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
if (spellCard != null) {
controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
controller.moveCards(spellCard, null, Zone.HAND, source, game);
}
}
return true;

View file

@ -71,18 +71,20 @@ public class EnvoyEffect extends OneShotEffect {
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 || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, numCards));
controller.revealCards(sourceObject.getName(), cards, game);
for(Card card: cards.getCards(game)) {
if(filter.match(card, game)) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
cards.remove(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
Cards cardsToHand = new CardsImpl();
for (Card card : cards.getCards(game)) {
if (filter.match(card, game)) {
cardsToHand.add(card);
}
}
cards.removeAll(cardsToHand);
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
@ -94,6 +96,6 @@ public class EnvoyEffect extends OneShotEffect {
}
return "Reveal the top " + CardUtil.numberToText(numCards) + " cards of your library. Put all "
+ filter.getMessage() + " revealed this way into your hand and the rest on the bottom of your library in any order.";
+ filter.getMessage() + " revealed this way into your hand and the rest on the bottom of your library in any order.";
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,19 +20,17 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
@ -61,16 +59,11 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
for (UUID cardId: getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(cardId);
if (card != null && game.getState().getZone(cardId).equals(Zone.GRAVEYARD)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
}
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), null, Zone.HAND, source, game);
}
return true;
return false;
}
@Override
@ -79,14 +72,14 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
return staticText;
}
StringBuilder sb = new StringBuilder();
Target target = mode.getTargets().get(0);
Target target = mode.getTargets().get(0);
sb.append("return ");
if (target.getMaxNumberOfTargets() > 1) {
if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) {
sb.append("up to ");
}
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" ");
}
}
if (!mode.getTargets().get(0).getTargetName().startsWith("another")) {
sb.append("target ");
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -61,7 +60,7 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Card card = controller.getGraveyard().get(source.getSourceId(), game);
if (card != null) {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
return controller.moveCards(card, null, Zone.HAND, source, game);
}
return false;
}

View file

@ -25,11 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
@ -41,12 +42,10 @@ import mage.players.Player;
*
* @author Plopman
*/
public class ReturnToHandFromBattlefieldAllEffect extends OneShotEffect {
private final FilterPermanent filter;
public ReturnToHandFromBattlefieldAllEffect(FilterPermanent filter) {
super(Outcome.ReturnToHand);
this.filter = filter;
@ -62,9 +61,11 @@ public class ReturnToHandFromBattlefieldAllEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToHand = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
cardsToHand.add(permanent);
}
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
@ -45,20 +45,23 @@ import mage.players.Player;
public class ReturnToHandSourceEffect extends OneShotEffect {
boolean fromBattlefieldOnly;
boolean returnFromNextZone ;
boolean returnFromNextZone;
public ReturnToHandSourceEffect() {
this(false);
}
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly) {
this(fromBattlefieldOnly, false);
}
/**
*
* @param fromBattlefieldOnly the object is only returned if it's on the battlefield as the effect resolves
* @param returnFromNextZone the object is only returned, if it has changed the zone one time after the source ability triggered or was activated (e.g. Angelic Destiny)
*
* @param fromBattlefieldOnly the object is only returned if it's on the
* battlefield as the effect resolves
* @param returnFromNextZone the object is only returned, if it has changed
* the zone one time after the source ability triggered or was activated
* (e.g. Angelic Destiny)
*/
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly, boolean returnFromNextZone) {
super(Outcome.ReturnToHand);
@ -83,8 +86,8 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
MageObject mageObject;
if (returnFromNextZone &&
game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
if (returnFromNextZone
&& game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
mageObject = game.getObject(source.getSourceId());
} else {
mageObject = source.getSourceObjectIfItStillExists(game);
@ -94,13 +97,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
case BATTLEFIELD:
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
return controller.moveCardToHandWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD);
return controller.moveCards(permanent, null, Zone.HAND, source, game);
}
break;
case GRAVEYARD:
Card card = (Card) mageObject;
if (!fromBattlefieldOnly) {
return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD);
return controller.moveCards(card, null, Zone.HAND, source, game);
}
}
}

View file

@ -31,7 +31,7 @@ public class ReturnToHandSpellEffect extends OneShotEffect implements MageSingle
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card spellCard = game.getStack().getSpell(source.getSourceId()).getCard();
controller.moveCardToHandWithInfo(spellCard, source.getSourceId(), game, Zone.STACK);
controller.moveCards(spellCard, null, Zone.HAND, source, game);
return true;
}
return false;

View file

@ -28,11 +28,13 @@
package mage.abilities.effects.common;
import java.util.Set;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
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;
@ -45,7 +47,6 @@ import mage.util.CardUtil;
*
* @author LevelX
*/
public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
private DynamicValue amountCards;
@ -78,27 +79,26 @@ public class RevealLibraryPutIntoHandEffect 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());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
CardsImpl cards = new CardsImpl();
int amount = Math.min(amountCards.calculate(game, source, this), player.getLibrary().size());
for (int i = 0; i < amount; i++) {
cards.add(player.getLibrary().removeFromTop(game));
}
player.revealCards(new StringBuilder("Put ").append(filter.getMessage()).append(" into hand").toString(), cards, game);
cards.addAll(controller.getLibrary().getTopCards(game, amountCards.calculate(game, source, this)));
controller.revealCards(sourceObject.getIdName(), cards, game);
Set<Card> cardsList = cards.getCards(game);
Cards cardsToHand = new CardsImpl();
for (Card card : cardsList) {
if (filter.match(card, game)) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
cardsToHand.add(card);
cards.remove(card);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
controller.moveCards(cardsToHand, null, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
return true;
}

View file

@ -134,7 +134,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
Cards revealedCards = new CardsImpl(Zone.HAND);
numberToReveal = Math.min(player.getHand().size(), numberToReveal);
if (player.getHand().size() > numberToReveal) {
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in "+ player.getLogName() +"'s hand"));
TargetCardInHand chosenCards = new TargetCardInHand(numberToReveal, numberToReveal, new FilterCard("card in " + player.getLogName() + "'s hand"));
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(player.getId(), game) && player.chooseTarget(Outcome.Discard, player.getHand(), chosenCards, source, game)) {
if (!chosenCards.getTargets().isEmpty()) {
@ -151,7 +151,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
revealedCards.addAll(player.getHand());
}
player.revealCards(sourceCard != null ? sourceCard.getName() :"Discard", revealedCards, game);
player.revealCards(sourceCard != null ? sourceCard.getIdName() + " (" + sourceCard.getZoneChangeCounter(game) + ")" : "Discard", revealedCards, game);
boolean result = true;
int filteredCardsCount = revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game);
@ -183,7 +183,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
private String setText() {
StringBuilder sb = new StringBuilder("Target ");
switch(targetController) {
switch (targetController) {
case OPPONENT:
sb.append("opponent");
break;

View file

@ -93,14 +93,12 @@ public class SearchLibraryPutInHandEffect extends SearchEffect {
if (target.getTargets().size() > 0) {
Cards cards = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().remove(cardId, game);
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY, revealCards);
if (revealCards) {
cards.add(card);
}
cards.add(card);
}
}
controller.moveCards(cards, null, Zone.HAND, source, game);
if (revealCards) {
String name = "Reveal";
Card sourceCard = game.getCard(source.getSourceId());

View file

@ -27,16 +27,15 @@
*/
package mage.abilities.effects.keyword;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
@ -53,7 +52,7 @@ public class SweepEffect extends OneShotEffect {
public SweepEffect(String sweepSubtype) {
super(Outcome.Benefit);
this.sweepSubtype = sweepSubtype;
this.staticText = "<i>Sweep</i> - Return any number of "+ sweepSubtype + (sweepSubtype.endsWith("s") ? "":"s") + " you control to their owner's hand";
this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.endsWith("s") ? "" : "s") + " you control to their owner's hand";
}
public SweepEffect(final SweepEffect effect) {
@ -75,10 +74,7 @@ public class SweepEffect extends OneShotEffect {
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) {
game.getState().setValue(CardUtil.getCardZoneString("sweep", source.getSourceId(), game), target.getTargets().size());
for (UUID uuid : target.getTargets()) {
Permanent land = game.getPermanent(uuid);
controller.moveCardToHandWithInfo(land, source.getSourceId(), game, Zone.HAND);
}
controller.moveCards(new CardsImpl(target.getTargets()), null, Zone.HAND, source, game);
}
return true;
}

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -48,21 +47,21 @@ import mage.target.common.TargetCardInHand;
* @author Mael
*/
public class AuraSwapAbility extends ActivatedAbilityImpl {
public AuraSwapAbility(ManaCost manaCost) {
super(Zone.BATTLEFIELD, new AuraSwapEffect(), manaCost);
}
public AuraSwapAbility(final AuraSwapAbility ability) {
super(ability);
}
@Override
public AuraSwapAbility copy() {
return new AuraSwapAbility(this);
}
@Override
public String getRule() {
return new StringBuilder("Aura swap ").append(getManaCostsToPay().getText()).append(" <i>(")
@ -72,42 +71,42 @@ public class AuraSwapAbility extends ActivatedAbilityImpl {
}
class AuraSwapEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard();
static {
filter.add(new SubtypePredicate("Aura"));
}
AuraSwapEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "Exchange this Aura with an Aura card in your hand.";
}
AuraSwapEffect(final AuraSwapEffect effect) {
super(effect);
}
@Override
public AuraSwapEffect copy() {
return new AuraSwapEffect(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) {
Permanent auraPermanent = game.getPermanent(source.getSourceId());
if (auraPermanent != null && auraPermanent.getSubtype().contains("Aura") && auraPermanent.getOwnerId().equals(source.getControllerId())) {
Permanent enchantedPermanent = game.getPermanent(auraPermanent.getAttachedTo());
filter.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Card auraInHand = game.getCard(target.getFirstTarget());
if (auraInHand != null) {
player.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId());
controller.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId());
enchantedPermanent.addAttachment(auraInHand.getId(), game);
player.moveCardToHandWithInfo(auraPermanent, source.getSourceId(), game, Zone.BATTLEFIELD);
controller.moveCards(auraPermanent, null, Zone.HAND, source, game);
return true;
}
}

View file

@ -5,7 +5,6 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
@ -17,25 +16,29 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
import mage.MageObject;
import mage.constants.TimingRule;
/**
*
* 702.52. Transmute
* 702.52. Transmute
*
* 702.52a Transmute is an activated ability that functions only while the card with transmute is
* in a players hand. Transmute [cost] means [Cost], Discard this card: Search your library for
* a card with the same converted mana cost as the discarded card, reveal that card, and put it into
* your hand. Then shuffle your library. Play this ability only any time you could play a sorcery.
* 702.52a Transmute is an activated ability that functions only while the card
* with transmute is in a players hand. Transmute [cost] means [Cost],
* Discard this card: Search your library for a card with the same converted
* mana cost as the discarded card, reveal that card, and put it into your hand.
* Then shuffle your library. Play this ability only any time you could play a
* sorcery.
*
* 702.52b Although the transmute ability is playable only if the card is in a players hand, it
* continues to exist while the object is in play and in all other zones. Therefore objects with
* transmute will be affected by effects that depend on objects having one or more activated abilities.
* 702.52b Although the transmute ability is playable only if the card is in a
* players hand, it continues to exist while the object is in play and in all
* other zones. Therefore objects with transmute will be affected by effects
* that depend on objects having one or more activated abilities.
*
* @author Loki
*/
public class TransmuteAbility extends SimpleActivatedAbility {
public TransmuteAbility(String manaCost) {
super(Zone.HAND, new TransmuteEffect(), new ManaCostsImpl(manaCost));
this.setTiming(TimingRule.SORCERY);
@ -60,6 +63,7 @@ public class TransmuteAbility extends SimpleActivatedAbility {
}
class TransmuteEffect extends OneShotEffect {
TransmuteEffect() {
super(Outcome.Benefit);
staticText = "Transmute";
@ -71,27 +75,20 @@ class TransmuteEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null && player != null) {
FilterCard filter = new FilterCard("card with converted mana cost " + sourceCard.getManaCost().convertedManaCost());
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceCard.getManaCost().convertedManaCost()));
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
FilterCard filter = new FilterCard("card with converted mana cost " + sourceObject.getManaCost().convertedManaCost());
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceObject.getManaCost().convertedManaCost()));
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Cards revealed = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().remove(cardId, game);
if (card != null) {
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
revealed.add(card);
}
}
player.revealCards("Search", revealed, game);
Cards revealed = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), revealed, game);
controller.moveCards(revealed, null, Zone.HAND, source, game);
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}

View file

@ -640,18 +640,17 @@ public interface Player extends MageItem, Copyable<Player> {
* @param fromZone if null, this info isn't postet
* @return
*/
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone);
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game);
/**
* @param card
* @param sourceId
* @param game
* @param withName show the card name in the log
* @param fromZone
* @return
*
*/
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName);
boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName);
/**
* Uses card.moveToExile and posts a inform message about moving the card to
@ -662,7 +661,6 @@ public interface Player extends MageItem, Copyable<Player> {
* @param exileName name of exile zone (optional)
* @param sourceId
* @param game
* @param fromZone if null, this info isn't postet
* @param withName
* @return
*/

View file

@ -2881,6 +2881,9 @@ public abstract class PlayerImpl implements Player, Serializable {
public boolean moveCards(Cards cards, Zone fromZone, Zone toZone, Ability source, Game game, boolean withName) {
ArrayList<Card> cardList = new ArrayList<>();
for (UUID cardId : cards) {
if (fromZone == null) {
fromZone = game.getState().getZone(cardId);
}
if (fromZone.equals(Zone.BATTLEFIELD)) {
Permanent permanent = game.getPermanent(cardId);
if (permanent != null) {
@ -2925,6 +2928,7 @@ public abstract class PlayerImpl implements Player, Serializable {
case EXILED:
boolean result = false;
for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName);
}
return result;
@ -2933,18 +2937,21 @@ public abstract class PlayerImpl implements Player, Serializable {
case HAND:
result = false;
for (Card card : cards) {
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, withName);
fromZone = game.getState().getZone(card.getId());
result |= moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, withName);
}
return result;
case BATTLEFIELD:
result = false;
for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= putOntoBattlefieldWithInfo(card, game, fromZone, source == null ? null : source.getSourceId(), false, !withName);
}
return result;
case LIBRARY:
result = false;
for (Card card : cards) {
fromZone = game.getState().getZone(card.getId());
result |= moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, withName);
}
return result;
@ -2954,13 +2961,14 @@ public abstract class PlayerImpl implements Player, Serializable {
}
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
return this.moveCardToHandWithInfo(card, sourceId, game, fromZone, true);
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game) {
return this.moveCardToHandWithInfo(card, sourceId, game, true);
}
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean withName) {
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
boolean result = false;
Zone fromZone = game.getState().getZone(card.getId());
if (card.moveToZone(Zone.HAND, sourceId, game, false)) {
if (card instanceof PermanentCard) {
card = game.getCard(card.getId());
@ -3025,6 +3033,7 @@ public abstract class PlayerImpl implements Player, Serializable {
Card card = cards.get(targetObjectId, game);
cards.remove(targetObjectId);
if (card != null) {
fromZone = game.getState().getZone(card.getId());
result &= choosingPlayer.moveCardToGraveyardWithInfo(card, sourceId, game, fromZone);
}
target.clearChosen();
@ -3045,6 +3054,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
boolean result = false;
// Zone fromZone = game.getState().getZone(card.getId());
if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) {
if (!game.isSimulation()) {
if (card instanceof PermanentCard) {
@ -3052,7 +3062,7 @@ public abstract class PlayerImpl implements Player, Serializable {
}
StringBuilder sb = new StringBuilder(this.getLogName())
.append(" puts ").append(card.getLogName()).append(" ")
.append(fromZone != null ? new StringBuilder("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") : "");
.append(fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + " " : "");
if (card.getOwnerId().equals(getId())) {
sb.append("into his or her graveyard");
} else {