mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
refactored zone changes, letters M through P
most cards are minor refactors except for Puppet Master which was heavily reworked
This commit is contained in:
parent
d4311916a4
commit
ffd5f68220
15 changed files with 425 additions and 559 deletions
|
@ -1,23 +1,23 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -34,10 +34,9 @@ public final class MagusOfTheJar extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// {tap}, Sacrifice Magus of the Jar: Each player exiles all cards from their hand face down and draws seven cards. At the beginning of the next end step, each player discards their hand and returns to their hand each card they exiled this way.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MagusoftheJarEffect(), new TapSourceCost());
|
||||
Ability ability = new SimpleActivatedAbility(new MagusoftheJarEffect(), new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
private MagusOfTheJar(final MagusOfTheJar card) {
|
||||
|
@ -52,32 +51,32 @@ public final class MagusOfTheJar extends CardImpl {
|
|||
|
||||
class MagusoftheJarEffect extends OneShotEffect {
|
||||
|
||||
public MagusoftheJarEffect() {
|
||||
MagusoftheJarEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
staticText = "Each player exiles all cards from their hand face down and draws seven cards. At the beginning of the next end step, each player discards their hand and returns to their hand each card they exiled this way.";
|
||||
staticText = "Each player exiles all cards from their hand face down and draws seven cards. " +
|
||||
"At the beginning of the next end step, each player discards their hand " +
|
||||
"and returns to their hand each card they exiled this way.";
|
||||
}
|
||||
|
||||
public MagusoftheJarEffect(final MagusoftheJarEffect effect) {
|
||||
private MagusoftheJarEffect(final MagusoftheJarEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl();
|
||||
//Exile hand
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Cards handCards = new CardsImpl(player.getHand());
|
||||
for (UUID cardId : handCards) {
|
||||
Card card = handCards.get(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(getId(), "Magus of the Jar", source, game);
|
||||
card.setFaceDown(true, game);
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
cards.addAll(player.getHand());
|
||||
player.moveCards(player.getHand(), Zone.EXILED, source, game);
|
||||
}
|
||||
//Draw 7 cards
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
|
@ -86,10 +85,10 @@ class MagusoftheJarEffect extends OneShotEffect {
|
|||
player.drawCards(7, source, game);
|
||||
}
|
||||
}
|
||||
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
|
||||
cards.getCards(game).stream().filter(Objects::nonNull).forEach(card -> card.setFaceDown(true, game));
|
||||
//Delayed ability
|
||||
Effect effect = new MagusoftheJarDelayedEffect();
|
||||
effect.setValue("MagusoftheJarCards", cards);
|
||||
game.addDelayedTriggeredAbility(new MagusoftheJarDelayedTriggeredAbility(effect), source);
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new MagusoftheJarDelayedEffect(cards)), source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,12 +100,21 @@ class MagusoftheJarEffect extends OneShotEffect {
|
|||
|
||||
class MagusoftheJarDelayedEffect extends OneShotEffect {
|
||||
|
||||
public MagusoftheJarDelayedEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
staticText = "At the beginning of the next end step, each player discards their hand and returns to their hand each card they exiled this way";
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
static {
|
||||
filter.add(TargetController.YOU.getOwnerPredicate());
|
||||
}
|
||||
|
||||
public MagusoftheJarDelayedEffect(final MagusoftheJarDelayedEffect effect) {
|
||||
private final Cards cards = new CardsImpl();
|
||||
|
||||
MagusoftheJarDelayedEffect(Cards cards) {
|
||||
super(Outcome.DrawCard);
|
||||
this.cards.addAll(cards);
|
||||
staticText = "each player discards their hand and returns to their hand each card they exiled this way";
|
||||
}
|
||||
|
||||
private MagusoftheJarDelayedEffect(final MagusoftheJarDelayedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -117,51 +125,14 @@ class MagusoftheJarDelayedEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Cards cards = (Cards) this.getValue("MagusoftheJarCards");
|
||||
|
||||
if (cards != null) {
|
||||
//Discard
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.discard(player.getHand().size(), false, false, source, game);
|
||||
}
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
//Return to hand
|
||||
for (Iterator<Card> it = cards.getCards(game).iterator(); it.hasNext(); ) {
|
||||
Card card = it.next();
|
||||
card.moveToZone(Zone.HAND, source, game, true);
|
||||
}
|
||||
return true;
|
||||
player.discard(player.getHand(), false, source, game);
|
||||
player.moveCards(cards.getCards(filter, source.getSourceId(), playerId, game), Zone.HAND, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MagusoftheJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public MagusoftheJarDelayedTriggeredAbility(Effect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
public MagusoftheJarDelayedTriggeredAbility(final MagusoftheJarDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagusoftheJarDelayedTriggeredAbility copy() {
|
||||
return new MagusoftheJarDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public final class MakeAWish extends CardImpl {
|
||||
|
@ -39,12 +40,12 @@ public final class MakeAWish extends CardImpl {
|
|||
|
||||
class MakeAWishEffect extends OneShotEffect {
|
||||
|
||||
public MakeAWishEffect() {
|
||||
MakeAWishEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "Return two cards at random from your graveyard to your hand";
|
||||
}
|
||||
|
||||
public MakeAWishEffect(final MakeAWishEffect effect) {
|
||||
private MakeAWishEffect(final MakeAWishEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -56,20 +57,13 @@ class MakeAWishEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Cards cards = player.getGraveyard();
|
||||
for (int i = 0; i < 2 && !cards.isEmpty(); i++) {
|
||||
Card card = cards.getRandom(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source, game, true);
|
||||
cards.remove(card);
|
||||
game.informPlayers(card.getName() + " returned to the hand of " + player.getLogName());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (player == null || player.getGraveyard().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCard target = new TargetCardInYourGraveyard(Math.min(player.getGraveyard().size(), 2), StaticFilters.FILTER_CARD);
|
||||
target.setNotTarget(true);
|
||||
target.setRandom(true);
|
||||
player.choose(outcome, target, source.getSourceId(), game);
|
||||
return player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SpellCastAllTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -12,25 +10,24 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
|
||||
*/
|
||||
public final class ManaBreach extends CardImpl {
|
||||
|
||||
public ManaBreach(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
|
||||
|
||||
// Whenever a player casts a spell, that player returns a land they control to its owner's hand.
|
||||
this.addAbility(new SpellCastAllTriggeredAbility(new ManaBreachEffect(), StaticFilters.FILTER_SPELL, false, SetTargetPointer.PLAYER));
|
||||
this.addAbility(new SpellCastAllTriggeredAbility(
|
||||
new ManaBreachEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.PLAYER
|
||||
));
|
||||
}
|
||||
|
||||
private ManaBreach(final ManaBreach card) {
|
||||
|
@ -45,32 +42,32 @@ public final class ManaBreach extends CardImpl {
|
|||
|
||||
class ManaBreachEffect extends OneShotEffect {
|
||||
|
||||
public ManaBreachEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText="that player returns a land they control to its owner's hand.";
|
||||
ManaBreachEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "that player returns a land they control to its owner's hand";
|
||||
}
|
||||
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if(player != null) {
|
||||
FilterLandPermanent filter = new FilterLandPermanent("a land you control");
|
||||
filter.add(new ControllerIdPredicate(player.getId()));
|
||||
TargetLandPermanent toBounce = new TargetLandPermanent(1, 1, filter, true);
|
||||
if(player.chooseTarget(Outcome.ReturnToHand, toBounce, source, game)) {
|
||||
Permanent land = game.getPermanent(toBounce.getTargets().get(0));
|
||||
land.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ManaBreachEffect(final ManaBreachEffect effect) {
|
||||
private ManaBreachEffect(final ManaBreachEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaBreachEffect copy() {
|
||||
return new ManaBreachEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player == null || game.getBattlefield().count(
|
||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND,
|
||||
source.getSourceId(), player.getId(), game
|
||||
) < 1) {
|
||||
return false;
|
||||
}
|
||||
TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND);
|
||||
target.setNotTarget(true);
|
||||
player.choose(outcome, target, source.getSourceId(), game);
|
||||
return player.moveCards(game.getPermanent(target.getFirstTarget()), Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +36,6 @@ public final class MemoryJar extends CardImpl {
|
|||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MemoryJarEffect(), new TapSourceCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
private MemoryJar(final MemoryJar card) {
|
||||
|
@ -48,32 +50,32 @@ public final class MemoryJar extends CardImpl {
|
|||
|
||||
class MemoryJarEffect extends OneShotEffect {
|
||||
|
||||
public MemoryJarEffect() {
|
||||
MemoryJarEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
staticText = "Each player exiles all cards from their hand face down and draws seven cards. At the beginning of the next end step, each player discards their hand and returns to their hand each card they exiled this way.";
|
||||
staticText = "Each player exiles all cards from their hand face down and draws seven cards. " +
|
||||
"At the beginning of the next end step, each player discards their hand " +
|
||||
"and returns to their hand each card they exiled this way.";
|
||||
}
|
||||
|
||||
public MemoryJarEffect(final MemoryJarEffect effect) {
|
||||
private MemoryJarEffect(final MemoryJarEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl();
|
||||
//Exile hand
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Cards handCards = new CardsImpl(player.getHand());
|
||||
for (UUID cardId : handCards) {
|
||||
Card card = handCards.get(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(getId(), "Memory Jar", source, game);
|
||||
card.setFaceDown(true, game);
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
cards.addAll(player.getHand());
|
||||
player.moveCards(player.getHand(), Zone.EXILED, source, game);
|
||||
}
|
||||
//Draw 7 cards
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
|
@ -82,10 +84,10 @@ class MemoryJarEffect extends OneShotEffect {
|
|||
player.drawCards(7, source, game);
|
||||
}
|
||||
}
|
||||
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
|
||||
cards.getCards(game).stream().filter(Objects::nonNull).forEach(card -> card.setFaceDown(true, game));
|
||||
//Delayed ability
|
||||
Effect effect = new MemoryJarDelayedEffect();
|
||||
effect.setValue("MemoryJarCards", cards);
|
||||
game.addDelayedTriggeredAbility(new MemoryJarDelayedTriggeredAbility(effect), source);
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new MemoryJarDelayedEffect(cards)), source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -97,12 +99,21 @@ class MemoryJarEffect extends OneShotEffect {
|
|||
|
||||
class MemoryJarDelayedEffect extends OneShotEffect {
|
||||
|
||||
public MemoryJarDelayedEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
staticText = "At the beginning of the next end step, each player discards their hand and returns to their hand each card they exiled this way";
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
static {
|
||||
filter.add(TargetController.YOU.getOwnerPredicate());
|
||||
}
|
||||
|
||||
public MemoryJarDelayedEffect(final MemoryJarDelayedEffect effect) {
|
||||
private final Cards cards = new CardsImpl();
|
||||
|
||||
MemoryJarDelayedEffect(Cards cards) {
|
||||
super(Outcome.DrawCard);
|
||||
this.cards.addAll(cards);
|
||||
staticText = "each player discards their hand and returns to their hand each card they exiled this way";
|
||||
}
|
||||
|
||||
private MemoryJarDelayedEffect(final MemoryJarDelayedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -113,51 +124,14 @@ class MemoryJarDelayedEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Cards cards = (Cards) this.getValue("MemoryJarCards");
|
||||
|
||||
if (cards != null) {
|
||||
//Discard
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.discard(player.getHand().size(), false, false, source, game);
|
||||
}
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
//Return to hand
|
||||
for (Iterator<Card> it = cards.getCards(game).iterator(); it.hasNext(); ) {
|
||||
Card card = it.next();
|
||||
card.moveToZone(Zone.HAND, source, game, true);
|
||||
}
|
||||
return true;
|
||||
player.discard(player.getHand(), false, source, game);
|
||||
player.moveCards(cards.getCards(filter, source.getSourceId(), playerId, game), Zone.HAND, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MemoryJarDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
public MemoryJarDelayedTriggeredAbility(Effect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
public MemoryJarDelayedTriggeredAbility(final MemoryJarDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemoryJarDelayedTriggeredAbility copy() {
|
||||
return new MemoryJarDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
|
||||
import mage.abilities.common.DiesCreatureTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -14,21 +11,22 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class MerenOfClanNelToth extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you control");
|
||||
|
||||
private static final FilterCreaturePermanent filter
|
||||
= new FilterCreaturePermanent("another creature you control");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
|
@ -36,7 +34,7 @@ public final class MerenOfClanNelToth extends CardImpl {
|
|||
}
|
||||
|
||||
public MerenOfClanNelToth(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.SHAMAN);
|
||||
|
@ -44,15 +42,14 @@ public final class MerenOfClanNelToth extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Whenever another creature you control dies, you get an experience counter.
|
||||
Effect effect = new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1), false);
|
||||
effect.setText("you get an experience counter");
|
||||
this.addAbility(new DiesCreatureTriggeredAbility(effect, false, filter));
|
||||
|
||||
this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersControllerEffect(
|
||||
CounterType.EXPERIENCE.createInstance(1), false
|
||||
).setText("you get an experience counter"), false, filter));
|
||||
|
||||
// At the beginning of your end step, choose target creature card in your graveyard.
|
||||
// If that card's converted mana cost is less than or equal to the number of experience counters you have, return it to the battlefield. Otherwise, put it into your hand.
|
||||
Target target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
|
||||
Ability ability = new BeginningOfYourEndStepTriggeredAbility(new MerenOfClanNelTothEffect(), false);
|
||||
ability.addTarget(target);
|
||||
ability.addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
@ -68,12 +65,14 @@ public final class MerenOfClanNelToth extends CardImpl {
|
|||
|
||||
class MerenOfClanNelTothEffect extends OneShotEffect {
|
||||
|
||||
public MerenOfClanNelTothEffect() {
|
||||
MerenOfClanNelTothEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.staticText = "choose target creature card in your graveyard. If that card's converted mana cost is less than or equal to the number of experience counters you have, return it to the battlefield. Otherwise, put it into your hand";
|
||||
this.staticText = "choose target creature card in your graveyard. If that card's converted mana cost " +
|
||||
"is less than or equal to the number of experience counters you have, " +
|
||||
"return it to the battlefield. Otherwise, put it into your hand";
|
||||
}
|
||||
|
||||
public MerenOfClanNelTothEffect(final MerenOfClanNelTothEffect effect) {
|
||||
private MerenOfClanNelTothEffect(final MerenOfClanNelTothEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -85,21 +84,11 @@ class MerenOfClanNelTothEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
int amount = player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (card != null) {
|
||||
Zone targetZone = Zone.HAND;
|
||||
String text = " put into hand of ";
|
||||
if (card.getConvertedManaCost() <= amount) {
|
||||
targetZone = Zone.BATTLEFIELD;
|
||||
text = " put onto battlefield for ";
|
||||
}
|
||||
card.moveToZone(targetZone, source, game, false);
|
||||
game.informPlayers("Meren of Clan Nel Toth: " + card.getName() + text + player.getLogName());
|
||||
return true;
|
||||
}
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (player == null || card == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
boolean flag = card.getConvertedManaCost() <= player.getCounters().getCount(CounterType.EXPERIENCE);
|
||||
return player.moveCards(card, flag ? Zone.BATTLEFIELD : Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -23,8 +25,8 @@ public final class MoltenBirth extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}{R}");
|
||||
|
||||
// Create two 1/1 red Elemental creature tokens. Then flip a coin. If you win the flip, return Molten Birth to its owner's hand.
|
||||
this.getSpellAbility().addEffect(new CreateTokenEffect(new MoltenBirthElementalToken(), 2));
|
||||
this.getSpellAbility().addEffect(new MoltenBirthEffect());
|
||||
|
||||
}
|
||||
|
||||
private MoltenBirth(final MoltenBirth card) {
|
||||
|
@ -39,12 +41,12 @@ public final class MoltenBirth extends CardImpl {
|
|||
|
||||
class MoltenBirthEffect extends OneShotEffect {
|
||||
|
||||
public MoltenBirthEffect() {
|
||||
MoltenBirthEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
staticText = "Create two 1/1 red Elemental creature tokens. Then flip a coin. If you win the flip, return {this} to its owner's hand";
|
||||
staticText = "Then flip a coin. If you win the flip, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public MoltenBirthEffect(final MoltenBirthEffect effect) {
|
||||
private MoltenBirthEffect(final MoltenBirthEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -56,19 +58,10 @@ class MoltenBirthEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
MoltenBirthElementalToken token = new MoltenBirthElementalToken();
|
||||
token.putOntoBattlefield(2, game, source, source.getControllerId());
|
||||
if (controller.flipCoin(source, game, true)) {
|
||||
Card molten = game.getCard(source.getSourceId());
|
||||
if (molten != null) {
|
||||
molten.moveToZone(Zone.HAND, source, game, true);
|
||||
game.informPlayers(controller.getLogName() + " won the flip. " + molten.getLogName() + " is returned to " + controller.getLogName() + "'s hand.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
return controller != null
|
||||
&& controller.flipCoin(source, game, true)
|
||||
&& sourceObject instanceof Card
|
||||
&& controller.moveCards((Card) sourceObject, Zone.HAND, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.cards.n;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -10,12 +7,16 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
|
@ -24,6 +25,8 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Loki
|
||||
*/
|
||||
|
@ -36,7 +39,7 @@ public final class NightDealings extends CardImpl {
|
|||
this.addAbility((new NightDealingsTriggeredAbility()));
|
||||
|
||||
// {2}{B}{B}, Remove X theft counters from Night Dealings: Search your library for a nonland card with converted mana cost X, reveal it, and put it into your hand. Then shuffle your library.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NightDealingsSearchEffect(), new ManaCostsImpl("{2}{B}{B}"));
|
||||
Ability ability = new SimpleActivatedAbility(new NightDealingsSearchEffect(), new ManaCostsImpl("{2}{B}{B}"));
|
||||
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.THEFT.createInstance(1)));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -50,13 +53,13 @@ public final class NightDealings extends CardImpl {
|
|||
return new NightDealings(this);
|
||||
}
|
||||
|
||||
private class NightDealingsTriggeredAbility extends TriggeredAbilityImpl {
|
||||
private static final class NightDealingsTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public NightDealingsTriggeredAbility() {
|
||||
private NightDealingsTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new NightDealingsEffect());
|
||||
}
|
||||
|
||||
public NightDealingsTriggeredAbility(final NightDealingsTriggeredAbility ability) {
|
||||
private NightDealingsTriggeredAbility(final NightDealingsTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
@ -73,16 +76,12 @@ public final class NightDealings extends CardImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
// to another player
|
||||
if (!Objects.equals(this.getControllerId(), event.getTargetId())) {
|
||||
// a source you control
|
||||
UUID sourceControllerId = game.getControllerId(event.getSourceId());
|
||||
if (sourceControllerId != null && sourceControllerId.equals(this.getControllerId())) {
|
||||
// save amount of damage to effect
|
||||
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
|
||||
return true;
|
||||
}
|
||||
if (this.isControlledBy(event.getTargetId())
|
||||
|| !this.isControlledBy(game.getControllerId(event.getSourceId()))) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
this.getEffects().setValue("damageAmount", event.getAmount());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,14 +90,14 @@ public final class NightDealings extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
private static class NightDealingsEffect extends OneShotEffect {
|
||||
private static final class NightDealingsEffect extends OneShotEffect {
|
||||
|
||||
public NightDealingsEffect() {
|
||||
private NightDealingsEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "put that many theft counters on {this}";
|
||||
}
|
||||
|
||||
public NightDealingsEffect(final NightDealingsEffect effect) {
|
||||
private NightDealingsEffect(final NightDealingsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -109,26 +108,27 @@ public final class NightDealings extends CardImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
Integer damageAmount = (Integer) this.getValue("damageAmount");
|
||||
if (damageAmount != null) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.addCounters(CounterType.THEFT.createInstance(damageAmount), source.getControllerId(), source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return permanent != null
|
||||
&& damageAmount != null
|
||||
&& damageAmount > 0
|
||||
&& permanent.addCounters(
|
||||
CounterType.THEFT.createInstance(damageAmount),
|
||||
source.getControllerId(), source, game
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static class NightDealingsSearchEffect extends OneShotEffect {
|
||||
private static final class NightDealingsSearchEffect extends OneShotEffect {
|
||||
|
||||
public NightDealingsSearchEffect() {
|
||||
private NightDealingsSearchEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
this.staticText = "Search your library for a nonland card with converted mana cost X, reveal it, and put it into your hand. Then shuffle your library";
|
||||
this.staticText = "Search your library for a nonland card with converted mana cost X, " +
|
||||
"reveal it, and put it into your hand. Then shuffle your library";
|
||||
}
|
||||
|
||||
public NightDealingsSearchEffect(final NightDealingsSearchEffect effect) {
|
||||
private NightDealingsSearchEffect(final NightDealingsSearchEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -148,33 +148,21 @@ public final class NightDealings extends CardImpl {
|
|||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof RemoveVariableCountersSourceCost) {
|
||||
cmc = ((RemoveVariableCountersSourceCost) cost).getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FilterNonlandCard filter = new FilterNonlandCard("nonland card with converted mana cost X = " + cmc);
|
||||
FilterCard filter = new FilterNonlandCard("nonland card with converted mana cost " + cmc);
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, cmc));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source, game, false);
|
||||
|
||||
String name = "Reveal";
|
||||
Cards cards = new CardsImpl(card);
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null) {
|
||||
name = sourceCard.getName();
|
||||
}
|
||||
player.revealCards(name, cards, game);
|
||||
game.informPlayers(player.getLogName() + " reveals " + card.getName());
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
player.searchLibrary(target, source, game);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.revealCards(source, new CardsImpl(card), game);
|
||||
player.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
|
||||
package mage.cards.n;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class NoeticScales extends CardImpl {
|
||||
|
@ -26,7 +30,9 @@ public final class NoeticScales extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// At the beginning of each player's upkeep, return to its owner's hand each creature that player controls with power greater than the number of cards in their hand.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new NoeticScalesEffect(), TargetController.ANY, false, true));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new NoeticScalesEffect(), TargetController.ANY, false
|
||||
));
|
||||
}
|
||||
|
||||
private NoeticScales(final NoeticScales card) {
|
||||
|
@ -41,12 +47,18 @@ public final class NoeticScales extends CardImpl {
|
|||
|
||||
class NoeticScalesEffect extends OneShotEffect {
|
||||
|
||||
public NoeticScalesEffect() {
|
||||
private static final FilterPermanent filter = new FilterControlledCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(NoeticScalesPredicate.instance);
|
||||
}
|
||||
|
||||
NoeticScalesEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "return to its owner's hand each creature that player controls with power greater than the number of cards in their hand";
|
||||
}
|
||||
|
||||
public NoeticScalesEffect(final NoeticScalesEffect effect) {
|
||||
private NoeticScalesEffect(final NoeticScalesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -57,19 +69,24 @@ class NoeticScalesEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
int numberOfCardsInHand = player.getHand().size();
|
||||
for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
||||
if (creature.getPower().getValue() > numberOfCardsInHand) {
|
||||
if (creature.moveToZone(Zone.HAND, source, game, false)) {
|
||||
game.informPlayers(player.getLogName() + " moves " + creature.getLogName() + " from the battlefield to their hand.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Cards cards = new CardsImpl();
|
||||
game.getBattlefield().getActivePermanents(
|
||||
filter, game.getActivePlayerId(), source.getSourceId(), game
|
||||
).stream().filter(Objects::nonNull).forEach(cards::add);
|
||||
return player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
enum NoeticScalesPredicate implements Predicate<Permanent> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
Player player = game.getPlayer(input.getControllerId());
|
||||
return player != null && player.getHand().size() < input.getPower().getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
|
||||
package mage.cards.o;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.TapTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
|
@ -15,29 +12,20 @@ import mage.abilities.keyword.LifelinkAbility;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class OjutaiExemplars extends CardImpl {
|
||||
|
||||
private static final FilterSpell filter = new FilterSpell("a noncreature spell");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
|
||||
}
|
||||
|
||||
public OjutaiExemplars(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
|
@ -46,23 +34,22 @@ public final class OjutaiExemplars extends CardImpl {
|
|||
this.toughness = new MageInt(4);
|
||||
|
||||
// Whenever you cast a noncreature spell, choose one - Tap target creature;
|
||||
Ability ability = new SpellCastControllerTriggeredAbility(new TapTargetEffect(), filter, false);
|
||||
Ability ability = new SpellCastControllerTriggeredAbility(
|
||||
new TapTargetEffect(), StaticFilters.FILTER_SPELL_A_NON_CREATURE, false
|
||||
);
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
|
||||
// Ojutai Exemplars gain first strike and lifelink until end of turn;
|
||||
Mode mode = new Mode();
|
||||
Effect effect = new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn);
|
||||
effect.setText("{this} gains first strike");
|
||||
mode.addEffect(effect);
|
||||
Effect effect2 = new GainAbilitySourceEffect(LifelinkAbility.getInstance(), Duration.EndOfTurn);
|
||||
effect2.setText("and lifelink until end of turn");
|
||||
mode.addEffect(effect2);
|
||||
Mode mode = new Mode(new GainAbilitySourceEffect(
|
||||
FirstStrikeAbility.getInstance(), Duration.EndOfTurn
|
||||
).setText("{this} gains first strike"));
|
||||
mode.addEffect(new GainAbilitySourceEffect(
|
||||
LifelinkAbility.getInstance(), Duration.EndOfTurn
|
||||
).setText("and lifelink until end of turn"));
|
||||
ability.addMode(mode);
|
||||
|
||||
// or Exile Ojutai Exemplars, then return it to the battlefield tapped under its owner's control.
|
||||
mode = new Mode();
|
||||
mode.addEffect(new OjutaiExemplarsEffect());
|
||||
ability.addMode(mode);
|
||||
ability.addMode(new Mode(new OjutaiExemplarsEffect()));
|
||||
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -79,12 +66,12 @@ public final class OjutaiExemplars extends CardImpl {
|
|||
|
||||
class OjutaiExemplarsEffect extends OneShotEffect {
|
||||
|
||||
public OjutaiExemplarsEffect() {
|
||||
OjutaiExemplarsEffect() {
|
||||
super(Outcome.Neutral);
|
||||
this.staticText = "Exile {this}, then return it to the battlefield tapped under its owner's control";
|
||||
}
|
||||
|
||||
public OjutaiExemplarsEffect(final OjutaiExemplarsEffect effect) {
|
||||
private OjutaiExemplarsEffect(final OjutaiExemplarsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -95,15 +82,14 @@ class OjutaiExemplarsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent ojutaiExemplars = game.getPermanent(source.getSourceId());
|
||||
if (ojutaiExemplars != null) {
|
||||
if (ojutaiExemplars.moveToExile(source.getSourceId(), "Ojutai Exemplars", source, game)) {
|
||||
Card card = game.getExile().getCard(source.getSourceId(), game);
|
||||
if (card != null) {
|
||||
return card.moveToZone(Zone.BATTLEFIELD, source, game, true);
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = permanent.getMainCard();
|
||||
player.moveCards(permanent, Zone.EXILED, source, game);
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
|
||||
package mage.cards.o;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
|
@ -24,38 +19,37 @@ import mage.target.common.TargetCardInYourGraveyard;
|
|||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class OrzhovCharm extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCreatureCard("creature card with converted mana cost 1 or less from your graveyard");
|
||||
private static final FilterCard filter
|
||||
= new FilterCreatureCard("creature card with converted mana cost 1 or less from your graveyard");
|
||||
|
||||
static {
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 2));
|
||||
}
|
||||
|
||||
public OrzhovCharm(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}{B}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}{B}");
|
||||
|
||||
//Choose one - Return target creature you control and all Auras you control attached to it to their owner's hand
|
||||
this.getSpellAbility().addEffect(new OrzhovCharmReturnToHandEffect());
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
|
||||
// or destroy target creature and you lose life equal to its toughness;
|
||||
Mode mode = new Mode();
|
||||
mode.addEffect(new OrzhovCharmDestroyAndLoseLifeEffect());
|
||||
Mode mode = new Mode(new OrzhovCharmDestroyAndLoseLifeEffect());
|
||||
mode.addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().addMode(mode);
|
||||
|
||||
// or return target creature card with converted mana cost 1 or less from your graveyard to the battlefield.
|
||||
Mode mode2 = new Mode();
|
||||
mode2.addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
|
||||
mode2.addTarget(new TargetCardInYourGraveyard(filter));
|
||||
this.getSpellAbility().addMode(mode2);
|
||||
|
||||
|
||||
mode = new Mode(new ReturnFromGraveyardToBattlefieldTargetEffect());
|
||||
mode.addTarget(new TargetCardInYourGraveyard(filter));
|
||||
this.getSpellAbility().addMode(mode);
|
||||
}
|
||||
|
||||
private OrzhovCharm(final OrzhovCharm card) {
|
||||
|
@ -70,12 +64,12 @@ public final class OrzhovCharm extends CardImpl {
|
|||
|
||||
class OrzhovCharmReturnToHandEffect extends OneShotEffect {
|
||||
|
||||
public OrzhovCharmReturnToHandEffect() {
|
||||
OrzhovCharmReturnToHandEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "Return target creature you control and all Auras you control attached to it to their owner's hand";
|
||||
}
|
||||
|
||||
public OrzhovCharmReturnToHandEffect(final OrzhovCharmReturnToHandEffect effect) {
|
||||
private OrzhovCharmReturnToHandEffect(final OrzhovCharmReturnToHandEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -86,34 +80,31 @@ class OrzhovCharmReturnToHandEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (target != null) {
|
||||
LinkedList<UUID> attachments = new LinkedList<>();
|
||||
attachments.addAll(target.getAttachments());
|
||||
for (UUID attachmentId : attachments) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.isControlledBy(source.getControllerId())
|
||||
&& attachment.hasSubtype(SubType.AURA, game)) {
|
||||
attachment.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
}
|
||||
if (target.isControlledBy(source.getControllerId())) {
|
||||
target.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
return true;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Cards cards = new CardsImpl(permanent);
|
||||
permanent.getAttachments()
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> p.isControlledBy(source.getControllerId()))
|
||||
.filter(p -> p.hasSubtype(SubType.AURA, game))
|
||||
.forEach(cards::add);
|
||||
return player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
class OrzhovCharmDestroyAndLoseLifeEffect extends OneShotEffect {
|
||||
|
||||
public OrzhovCharmDestroyAndLoseLifeEffect() {
|
||||
OrzhovCharmDestroyAndLoseLifeEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
this.staticText = "destroy target creature and you lose life equal to its toughness";
|
||||
}
|
||||
|
||||
public OrzhovCharmDestroyAndLoseLifeEffect(final OrzhovCharmDestroyAndLoseLifeEffect effect) {
|
||||
private OrzhovCharmDestroyAndLoseLifeEffect(final OrzhovCharmDestroyAndLoseLifeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -126,14 +117,14 @@ class OrzhovCharmDestroyAndLoseLifeEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (target != null && controller != null) {
|
||||
int toughness = target.getToughness().getValue();
|
||||
target.destroy(source, game, false);
|
||||
if (toughness > 0) {
|
||||
controller.loseLife(toughness, game, source, false);
|
||||
}
|
||||
return true;
|
||||
if (target == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
int toughness = target.getToughness().getValue();
|
||||
target.destroy(source, game, false);
|
||||
if (toughness > 0) {
|
||||
controller.loseLife(toughness, game, source, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
package mage.cards.p;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
@ -24,7 +19,8 @@ public final class PeelFromReality extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
|
||||
// Return target creature you control and target creature you don't control to their owners' hands.
|
||||
this.getSpellAbility().addEffect(new PeelFromRealityEffect());
|
||||
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true)
|
||||
.setText("return target creature you control and target creature you don't control to their owners' hands"));
|
||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));
|
||||
}
|
||||
|
@ -38,36 +34,3 @@ public final class PeelFromReality extends CardImpl {
|
|||
return new PeelFromReality(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PeelFromRealityEffect extends OneShotEffect {
|
||||
|
||||
PeelFromRealityEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "Return target creature you control and target creature you don't control to their owners' hands";
|
||||
}
|
||||
|
||||
private PeelFromRealityEffect(final PeelFromRealityEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PeelFromRealityEffect copy() {
|
||||
return new PeelFromRealityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = false;
|
||||
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
result |= permanent.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (permanent != null) {
|
||||
result |= permanent.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -16,13 +14,15 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class PerilousVoyage extends CardImpl {
|
||||
|
||||
private static final FilterNonlandPermanent filter = new FilterNonlandPermanent("nonland permanent you don't control");
|
||||
private static final FilterNonlandPermanent filter
|
||||
= new FilterNonlandPermanent("nonland permanent you don't control");
|
||||
|
||||
static {
|
||||
filter.add(TargetController.NOT_YOU.getControllerPredicate());
|
||||
|
@ -49,11 +49,12 @@ public final class PerilousVoyage extends CardImpl {
|
|||
class PerilousVoyageEffect extends OneShotEffect {
|
||||
|
||||
PerilousVoyageEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Return target nonland permanent you don't control to its owner's hand. If its converted mana cost was 2 or less, scry 2";
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "Return target nonland permanent you don't control to its owner's hand. " +
|
||||
"If its converted mana cost was 2 or less, scry 2";
|
||||
}
|
||||
|
||||
PerilousVoyageEffect(final PerilousVoyageEffect effect) {
|
||||
private PerilousVoyageEffect(final PerilousVoyageEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -66,13 +67,14 @@ class PerilousVoyageEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
boolean isLittle = permanent.getConvertedManaCost() < 3;
|
||||
permanent.moveToZone(Zone.HAND, source, game, true);
|
||||
if (isLittle && player != null) {
|
||||
player.scry(2, source, game);
|
||||
}
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
boolean flag = permanent.getConvertedManaCost() <= 2;
|
||||
player.moveCards(permanent, Zone.HAND, source, game);
|
||||
if (flag) {
|
||||
player.scry(2, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -13,38 +11,38 @@ import mage.abilities.keyword.EnchantAbility;
|
|||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class PhantomWings extends CardImpl {
|
||||
|
||||
public PhantomWings(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
|
||||
this.subtype.add(SubType.AURA);
|
||||
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature has flying.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FlyingAbility.getInstance(), AttachmentType.AURA)));
|
||||
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
|
||||
FlyingAbility.getInstance(), AttachmentType.AURA
|
||||
)));
|
||||
|
||||
// Sacrifice Phantom Wings: Return enchanted creature to its owner's hand.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PhantomWingsReturnEffect(), new SacrificeSourceCost()));
|
||||
|
||||
this.addAbility(new SimpleActivatedAbility(new PhantomWingsReturnEffect(), new SacrificeSourceCost()));
|
||||
}
|
||||
|
||||
private PhantomWings(final PhantomWings card) {
|
||||
|
@ -56,14 +54,14 @@ public final class PhantomWings extends CardImpl {
|
|||
return new PhantomWings(this);
|
||||
}
|
||||
|
||||
private static class PhantomWingsReturnEffect extends OneShotEffect {
|
||||
private static final class PhantomWingsReturnEffect extends OneShotEffect {
|
||||
|
||||
public PhantomWingsReturnEffect() {
|
||||
private PhantomWingsReturnEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
staticText = "Return enchanted creature to its owner's hand";
|
||||
}
|
||||
|
||||
public PhantomWingsReturnEffect(final PhantomWingsReturnEffect effect) {
|
||||
private PhantomWingsReturnEffect(final PhantomWingsReturnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -74,15 +72,13 @@ public final class PhantomWings extends CardImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null && permanent.getAttachedTo() != null)
|
||||
{
|
||||
Permanent enchantedCreature = game.getPermanent(permanent.getAttachedTo());
|
||||
if (enchantedCreature != null) {
|
||||
return enchantedCreature.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = source.getSourcePermanentOrLKI(game);
|
||||
if (player == null || permanent == null || permanent.getAttachedTo() == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent enchantedCreature = game.getPermanent(permanent.getAttachedTo());
|
||||
return enchantedCreature != null && player.moveCards(enchantedCreature, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,12 +54,13 @@ public final class PuppetMaster extends CardImpl {
|
|||
|
||||
class PuppetMasterEffect extends OneShotEffect {
|
||||
|
||||
public PuppetMasterEffect() {
|
||||
PuppetMasterEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
staticText = "return that card to its owner's hand. If that card is returned to its owner's hand this way, you may pay {U}{U}{U}. If you do, return {this} to its owner's hand";
|
||||
staticText = "return that card to its owner's hand. If that card is returned to its owner's hand this way, " +
|
||||
"you may pay {U}{U}{U}. If you do, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public PuppetMasterEffect(final PuppetMasterEffect effect) {
|
||||
private PuppetMasterEffect(final PuppetMasterEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -70,25 +71,30 @@ class PuppetMasterEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Object object = getValue("attachedTo");
|
||||
if (object instanceof Permanent) {
|
||||
Card card = game.getCard(((Permanent) object).getId());
|
||||
if (card != null) {
|
||||
if (card.moveToZone(Zone.HAND, source, game, false)) {
|
||||
Cost cost = new ManaCostsImpl("{U}{U}{U}");
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null && sourcePermanent != null) {
|
||||
if (controller.chooseUse(Outcome.Neutral, "Pay " + cost.getText() + " to return " + sourcePermanent.getLogName() + " to its owner's hand?", source, game)
|
||||
&& cost.pay(source, game, source, controller.getId(), false, null)) {
|
||||
sourcePermanent.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = (Permanent) getValue("attachedTo");
|
||||
if (controller == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = permanent.getMainCard();
|
||||
if (card == null || card.getZoneChangeCounter(game) != permanent.getZoneChangeCounter(game) + 1) {
|
||||
return false;
|
||||
}
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
if (game.getState().getZone(card.getId()) != Zone.HAND) {
|
||||
return false;
|
||||
}
|
||||
card = game.getCard(source.getSourceId());
|
||||
if (card == null || card.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter() + 1) {
|
||||
return false;
|
||||
}
|
||||
Cost cost = new ManaCostsImpl("{U}{U}{U}");
|
||||
if (!controller.chooseUse(Outcome.Neutral, "Pay " + cost.getText()
|
||||
+ " to return " + card.getLogName() + " to its owner's hand?", source, game)
|
||||
|| !cost.pay(source, game, source, controller.getId(), false, null)) {
|
||||
return true;
|
||||
}
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private String attachedDescription;
|
||||
private boolean diesRuleText;
|
||||
private final String attachedDescription;
|
||||
private final boolean diesRuleText;
|
||||
protected SetTargetPointer setTargetPointer;
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription) {
|
||||
|
@ -35,7 +35,7 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional,
|
||||
boolean diesRuleText, SetTargetPointer setTargetPointer) {
|
||||
boolean diesRuleText, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.ALL, effect, optional); // because the trigger only triggers if the object was attached, it doesn't matter where the Attachment was moved to (e.g. by replacement effect) after the trigger triggered, so Zone.all
|
||||
this.attachedDescription = attachedDescription;
|
||||
this.diesRuleText = diesRuleText;
|
||||
|
@ -61,65 +61,64 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget() != null
|
||||
&& zEvent.getTarget().getAttachments() != null
|
||||
&& zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If the attachment and attachedTo went to graveyard at the same time, the trigger applies.
|
||||
// If the attachment is removed beforehand, the trigger fails.
|
||||
// IE: A player cast Planar Clensing. The attachment is Disenchanted in reponse
|
||||
// and successfully removed from the attachedTo. The trigger fails.
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
Card attachmentCard = game.getCard(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null
|
||||
&& attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())) {
|
||||
Permanent attachedTo = game.getPermanentOrLKIBattlefield(attachment.getAttachedTo());
|
||||
if (attachedTo != null
|
||||
&& game.getState().getZone(attachedTo.getId()) == (Zone.GRAVEYARD) // Demonic Vigor
|
||||
&& attachmentCard != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)
|
||||
&& attachment.getZoneChangeCounter(game) == attachmentCard.getZoneChangeCounter(game)) {
|
||||
triggered = true;
|
||||
}
|
||||
if (!((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
return false;
|
||||
}
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget() != null
|
||||
&& zEvent.getTarget().getAttachments() != null
|
||||
&& zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If the attachment and attachedTo went to graveyard at the same time, the trigger applies.
|
||||
// If the attachment is removed beforehand, the trigger fails.
|
||||
// IE: A player cast Planar Clensing. The attachment is Disenchanted in reponse
|
||||
// and successfully removed from the attachedTo. The trigger fails.
|
||||
Permanent attachment = getSourcePermanentOrLKI(game);
|
||||
Card attachmentCard = game.getCard(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null
|
||||
&& attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())) {
|
||||
Permanent attachedTo = game.getPermanentOrLKIBattlefield(attachment.getAttachedTo());
|
||||
if (attachedTo != null
|
||||
&& game.getState().getZone(attachedTo.getId()) == (Zone.GRAVEYARD) // Demonic Vigor
|
||||
&& attachmentCard != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)
|
||||
&& attachment.getZoneChangeCounter(game) == attachmentCard.getZoneChangeCounter(game)) {
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
if (zEvent.getTarget() != null) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
effect.setValue("zcc", zEvent.getTarget().getZoneChangeCounter(game) + 1); // zone change info from battlefield
|
||||
if (setTargetPointer == SetTargetPointer.ATTACHED_TO_CONTROLLER) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null
|
||||
&& attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(),
|
||||
Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (!triggered) {
|
||||
return false;
|
||||
}
|
||||
if (zEvent.getTarget() == null) {
|
||||
return true;
|
||||
}
|
||||
getEffects().setValue("attachedTo", zEvent.getTarget());
|
||||
getEffects().setValue("zcc", zEvent.getTarget().getZoneChangeCounter(game) + 1); // zone change info from battlefield
|
||||
if (setTargetPointer == SetTargetPointer.ATTACHED_TO_CONTROLLER) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null
|
||||
&& attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(),
|
||||
Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
getEffects().setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(attachedDescription.startsWith("equipped")) {
|
||||
if (attachedDescription.startsWith("equipped")) {
|
||||
sb.append("Whenever ");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("When ");
|
||||
}
|
||||
sb.append(attachedDescription);
|
||||
|
|
Loading…
Reference in a new issue