- W cards: A player now moves the card/permanent to a zone.

This commit is contained in:
jeffwadsworth 2021-02-23 19:45:47 -06:00
parent f5f7638216
commit 1ac7112b5d
4 changed files with 27 additions and 22 deletions

View file

@ -1,4 +1,3 @@
package mage.cards.w; package mage.cards.w;
import java.util.UUID; import java.util.UUID;
@ -14,6 +13,7 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
/** /**
@ -65,8 +65,10 @@ class WarrenPilferersReturnEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getFirstTarget()); Card card = game.getCard(source.getFirstTarget());
if (card != null) { Player controller = game.getPlayer(source.getControllerId());
card.moveToZone(Zone.HAND, source, game, false); if (card != null
&& controller != null
&& controller.moveCards(card, Zone.HAND, source, game)) {
if (card.hasSubtype(SubType.GOBLIN, game)) { if (card.hasSubtype(SubType.GOBLIN, game)) {
game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn), source); game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn), source);
} }

View file

@ -1,10 +1,12 @@
package mage.cards.w; package mage.cards.w;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
@ -63,15 +65,17 @@ class WashOutEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Set<Card> cardsToReturn = new LinkedHashSet<>();
ChoiceColor choice = new ChoiceColor(); ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) { if (controller != null
&& controller.choose(Outcome.ReturnToHand, choice, game)) {
ObjectColor color = choice.getColor(); ObjectColor color = choice.getColor();
FilterPermanent filter = new FilterPermanent(); FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(color)); filter.add(new ColorPredicate(color));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.moveToZone(Zone.HAND, source, game, true); cardsToReturn.add((Card) permanent);
} }
return true; return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
} }
return false; return false;
} }

View file

@ -75,9 +75,10 @@ class WoodlandSleuthEffect extends OneShotEffect {
Card[] cards = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game).toArray(new Card[0]); Card[] cards = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game).toArray(new Card[0]);
if (cards.length > 0) { if (cards.length > 0) {
Card card = cards[RandomUtil.nextInt(cards.length)]; Card card = cards[RandomUtil.nextInt(cards.length)];
card.moveToZone(Zone.HAND, source, game, true); if (player.moveCards(card, Zone.HAND, source, game)) {
game.informPlayers(card.getName() + " returned to the hand of " + player.getLogName()); game.informPlayers(card.getName() + " returned to the hand of " + player.getLogName());
return true; return true;
}
} }
} }
return false; return false;

View file

@ -1,4 +1,3 @@
package mage.cards.w; package mage.cards.w;
import java.util.List; import java.util.List;
@ -28,8 +27,7 @@ import mage.target.common.TargetControlledPermanent;
public final class WordsOfWind extends CardImpl { public final class WordsOfWind extends CardImpl {
public WordsOfWind(UUID ownerId, CardSetInfo setInfo) { public WordsOfWind(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
// {1}: The next time you would draw a card this turn, each player returns a permanent they control to its owner's hand instead. // {1}: The next time you would draw a card this turn, each player returns a permanent they control to its owner's hand instead.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WordsOfWindEffect(), new ManaCostsImpl("{1}"))); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WordsOfWindEffect(), new ManaCostsImpl("{1}")));
@ -62,40 +60,40 @@ class WordsOfWindEffect extends ReplacementEffectImpl {
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
game.informPlayers("Each player returns a permanent they control to its owner's hand instead"); game.informPlayers("Each player returns a permanent they control to its owner's hand instead");
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
TargetControlledPermanent target = new TargetControlledPermanent(); TargetControlledPermanent target = new TargetControlledPermanent();
List<Permanent> liste = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), playerId, game); List<Permanent> liste = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), playerId, game);
if(!liste.isEmpty()){ if (!liste.isEmpty()) {
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)){ while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
if (!player.canRespond()) { if (!player.canRespond()) {
return false; return false;
} }
} }
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
permanent.moveToZone(Zone.HAND, source, game, false); player.moveCards(permanent, Zone.HAND, source, game);
} }
} }
} }
} }
this.used = true; this.used = true;
discard(); discard();
return true; return true;
} }
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DRAW_CARD; return event.getType() == GameEvent.EventType.DRAW_CARD;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used) { if (!this.used) {
return source.isControlledBy(event.getPlayerId()); return source.isControlledBy(event.getPlayerId());
} }
return false; return false;
} }