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

View file

@ -1,10 +1,12 @@
package mage.cards.w;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;
@ -63,15 +65,17 @@ class WashOutEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> cardsToReturn = new LinkedHashSet<>();
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();
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(color));
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;
}

View file

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

View file

@ -1,4 +1,3 @@
package mage.cards.w;
import java.util.List;
@ -28,8 +27,7 @@ import mage.target.common.TargetControlledPermanent;
public final class WordsOfWind extends CardImpl {
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.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WordsOfWindEffect(), new ManaCostsImpl("{1}")));
@ -62,40 +60,40 @@ class WordsOfWindEffect extends ReplacementEffectImpl {
}
@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");
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetControlledPermanent target = new TargetControlledPermanent();
List<Permanent> liste = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), playerId, game);
if(!liste.isEmpty()){
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)){
if (!liste.isEmpty()) {
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
if (!player.canRespond()) {
return false;
}
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.moveToZone(Zone.HAND, source, game, false);
player.moveCards(permanent, Zone.HAND, source, game);
}
}
}
}
this.used = true;
this.used = true;
discard();
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 (!this.used) {
return source.isControlledBy(event.getPlayerId());
return source.isControlledBy(event.getPlayerId());
}
return false;
}