removed a few deprecated method calls

This commit is contained in:
Evan Kranzler 2020-09-29 18:00:50 -04:00
parent 56815ca9ec
commit 1ad62b0ad9
4 changed files with 60 additions and 71 deletions

View file

@ -1,30 +1,30 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
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.Zone;
import mage.counters.Counter;
import mage.counters.Counters;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AetherSnap extends CardImpl {
public AetherSnap(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
// Remove all counters from all permanents and exile all tokens.
this.getSpellAbility().addEffect(new AetherSnapEffect());
@ -59,19 +59,23 @@ class AetherSnapEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), controller.getId(), source.getSourceId(), game)) {
if (permanent instanceof PermanentToken) {
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
} else if (!permanent.getCounters(game).isEmpty()) {
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter, game);
}
}
}
return true;
if (controller == null) {
return false;
}
return false;
Cards tokens = new CardsImpl();
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getSourceId(), game)) {
if (permanent instanceof PermanentToken) {
tokens.add(permanent);
}
if (permanent.getCounters(game).isEmpty()) {
continue;
}
Counters counters = permanent.getCounters(game).copy();
for (Counter counter : counters.values()) {
permanent.removeCounters(counter, game);
}
}
controller.moveCards(tokens, Zone.EXILED, source, game);
return true;
}
}

View file

@ -1,8 +1,6 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.abilities.keyword.CyclingAbility;
import mage.cards.CardImpl;
@ -11,8 +9,9 @@ import mage.constants.CardType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import java.util.UUID;
/**
*
* @author Loki
*/
public final class AkromasVengeance extends CardImpl {
@ -23,13 +22,14 @@ public final class AkromasVengeance extends CardImpl {
filter.add(Predicates.or(
CardType.ARTIFACT.getPredicate(),
CardType.CREATURE.getPredicate(),
CardType.ENCHANTMENT.getPredicate()));
CardType.ENCHANTMENT.getPredicate()
));
}
public AkromasVengeance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}{W}");
this.addAbility(new CyclingAbility(new ManaCostsImpl("{3}")));
this.addAbility(new CyclingAbility(new GenericManaCost(3)));
this.getSpellAbility().addEffect(new DestroyAllEffect(filter));
}

View file

@ -1,7 +1,6 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
@ -24,8 +23,9 @@ import mage.game.permanent.PermanentToken;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class AnafenzaTheForemost extends CardImpl {
@ -38,7 +38,7 @@ public final class AnafenzaTheForemost extends CardImpl {
}
public AnafenzaTheForemost(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}{B}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{B}{G}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SOLDIER);
@ -93,12 +93,12 @@ class AnafenzaTheForemostEffect extends ReplacementEffectImpl {
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null && !(permanent instanceof PermanentToken)) {
return controller.moveCardToExileWithInfo(permanent, null, null, source.getSourceId(), game, Zone.BATTLEFIELD, true);
return controller.moveCards(permanent, Zone.EXILED, source, game);
}
} else {
Card card = game.getCard(event.getTargetId());
if (card != null) {
return controller.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, ((ZoneChangeEvent) event).getFromZone(), true);
return controller.moveCards(card, Zone.EXILED, source, game);
}
}
}

View file

@ -1,38 +1,36 @@
package mage.cards.n;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterLandPermanent;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class NightmareIncursion extends CardImpl {
public NightmareIncursion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{5}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{B}");
// Search target player's library for up to X cards, where X is the number of Swamps you control, and exile them. Then that player shuffles their library.
Effect effect = new NightmareIncursionEffect();
this.getSpellAbility().addEffect(new NightmareIncursionEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(effect);
}
public NightmareIncursion(final NightmareIncursion card) {
@ -47,18 +45,13 @@ public final class NightmareIncursion extends CardImpl {
class NightmareIncursionEffect extends OneShotEffect {
private static final FilterLandPermanent filter = new FilterLandPermanent();
static {
filter.add(TargetController.YOU.getControllerPredicate());
filter.add(SubType.SWAMP.getPredicate());
}
boolean exiled = false;
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.SWAMP);
public NightmareIncursionEffect() {
super(Outcome.Benefit);
this.staticText = "Search target player's library for up to X cards, where X is the number of Swamps you control, and exile them. Then that player shuffles their library";
this.staticText = "Search target player's library for up to X cards, " +
"where X is the number of Swamps you control, and exile them. " +
"Then that player shuffles their library";
}
public NightmareIncursionEffect(final NightmareIncursionEffect effect) {
@ -72,26 +65,18 @@ class NightmareIncursionEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (controller != null && targetPlayer != null) {
int amount = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard());
if (controller.searchLibrary(target, source, game, targetPlayer.getId())) {
List<UUID> targetId = target.getTargets();
for (UUID targetCard : targetId) {
Card card = targetPlayer.getLibrary().remove(targetCard, game);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, null, source.getSourceId(), game, Zone.LIBRARY, true);
result = true;
}
}
}
if (controller == null || targetPlayer == null) {
return false;
}
if (targetPlayer != null) {
targetPlayer.shuffleLibrary(source, game);
int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, StaticFilters.FILTER_CARD);
if (controller.searchLibrary(target, source, game, targetPlayer.getId())) {
Cards cards = new CardsImpl(target.getTargets());
controller.moveCards(cards, Zone.EXILED, source, game);
}
return result;
targetPlayer.shuffleLibrary(source, game);
return true;
}
}