* Reworked some card movement to player methods (#4866).

This commit is contained in:
LevelX2 2020-06-22 15:38:36 +02:00
parent cd624b2158
commit c8ddd62e3b
4 changed files with 39 additions and 29 deletions

View file

@ -49,7 +49,9 @@ public final class DireFleetDaredevil extends CardImpl {
// First strike
this.addAbility(FirstStrikeAbility.getInstance());
// When this enters the battlefield, exile target instant or sorcery card from an opponent's graveyard. You may cast that card this turn and you may spend mana as though it were mana of any color. If that card would be put into a graveyard this turn, exile it instead.
// When Dire Fleet Daredevil enters the battlefield, exile target instant or sorcery card from an opponent's graveyard.
// You may cast it this turn, and you may spend mana as though it were mana of any type to cast that spell.
// If that spell would be put into a graveyard this turn, exile it instead.
Ability ability = new EntersBattlefieldTriggeredAbility(new DireFleetDaredevilEffect());
ability.addTarget(new TargetCardInOpponentsGraveyard(filter));
this.addAbility(ability);
@ -167,8 +169,9 @@ class DireFleetDaredevilReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Card card = game.getCard(event.getTargetId());
if (card != null) {
return card.moveToZone(Zone.EXILED, source.getSourceId(), game, false);
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
return controller.moveCards(card, Zone.EXILED, source, game);
}
return false;
}

View file

@ -65,7 +65,7 @@ class DistantMemoriesEffect extends OneShotEffect {
if (controller.searchLibrary(target, source, game)) {
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
card.moveToZone(Zone.EXILED, source.getSourceId(), game, false);
controller.moveCards(card, Zone.EXILED, source, game);
controller.shuffleLibrary(source, game);
StringBuilder sb = new StringBuilder();
@ -76,9 +76,13 @@ class DistantMemoriesEffect extends OneShotEffect {
Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentUuid : opponents) {
Player opponent = game.getPlayer(opponentUuid);
if (opponent != null
&& opponent.chooseUse(Outcome.Detriment, sb.toString(), source, game)) {
putInHand = true;
if (opponent != null) {
if (opponent.chooseUse(Outcome.Detriment, sb.toString(), source, game)) {
putInHand = true;
game.informPlayers(opponent.getName() + " decides to put the selected card into the player's hand.");
} else {
game.informPlayers(opponent.getName() + " decides to leave the card in exile.");
}
}
}

View file

@ -5,8 +5,10 @@ import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.replacement.PutToGraveyardReplacementEffect;
import mage.abilities.keyword.BushidoAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -22,28 +24,29 @@ import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author LevelX2
*/
public final class ToshiroUmezawa extends CardImpl {
private static final FilterCreaturePermanent filter
= new FilterCreaturePermanent("a creature an opponent controls");
private static final FilterCard filterInstant = new FilterCard("instant card from your graveyard");
static {
filter.add(TargetController.OPPONENT.getControllerPredicate());
filterInstant.add(CardType.INSTANT.getPredicate());
}
public ToshiroUmezawa(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SAMURAI);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
@ -55,13 +58,13 @@ public final class ToshiroUmezawa extends CardImpl {
Ability ability = new DiesCreatureTriggeredAbility(new ToshiroUmezawaEffect(), true, filter);
ability.addTarget(new TargetCardInYourGraveyard(1, 1, filterInstant));
this.addAbility(ability);
}
public ToshiroUmezawa(final ToshiroUmezawa card) {
super(card);
}
@Override
public ToshiroUmezawa copy() {
return new ToshiroUmezawa(this);
@ -69,22 +72,22 @@ public final class ToshiroUmezawa extends CardImpl {
}
class ToshiroUmezawaEffect extends OneShotEffect {
public ToshiroUmezawaEffect() {
super(Outcome.Benefit);
this.staticText = "cast target instant card from your graveyard. "
+ "If that card would be put into a graveyard this turn, exile it instead";
}
public ToshiroUmezawaEffect(final ToshiroUmezawaEffect effect) {
super(effect);
}
@Override
public ToshiroUmezawaEffect copy() {
return new ToshiroUmezawaEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -104,45 +107,45 @@ class ToshiroUmezawaEffect extends OneShotEffect {
}
class ToshiroUmezawaReplacementEffect extends ReplacementEffectImpl {
private final UUID cardId;
public ToshiroUmezawaReplacementEffect(UUID cardId) {
super(Duration.EndOfTurn, Outcome.Exile);
this.cardId = cardId;
}
public ToshiroUmezawaReplacementEffect(final ToshiroUmezawaReplacementEffect effect) {
super(effect);
this.cardId = effect.cardId;
}
@Override
public ToshiroUmezawaReplacementEffect copy() {
return new ToshiroUmezawaReplacementEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
UUID eventObject = event.getTargetId();
StackObject stackObject = game.getStack().getStackObject(eventObject);
if (stackObject != null) {
Player controller = game.getPlayer(source.getControllerId());
if (stackObject != null && controller != null) {
if (stackObject instanceof Spell) {
game.rememberLKI(stackObject.getId(), Zone.STACK, stackObject);
}
if (stackObject instanceof Card && eventObject.equals(cardId)) {
((Card) stackObject).moveToExile(null, null, source.getSourceId(), game);
return true;
return controller.moveCards((Card) stackObject, Zone.EXILED, source, game);
}
}
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;

View file

@ -52,7 +52,7 @@ public class DiesReplacementEffect extends ReplacementEffectImpl {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null) {
return controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
return controller.moveCards(permanent, Zone.EXILED, source, game);
}
return false;
}