From ddf007e6f1438177e839b79de1c8f2ff71830f89 Mon Sep 17 00:00:00 2001 From: 18ths <13023067+18ths@users.noreply.github.com> Date: Thu, 16 Jul 2020 16:56:12 +0200 Subject: [PATCH] Removed redundant Living End effect. Fixes #6385 --- Mage.Sets/src/mage/cards/l/LivingDeath.java | 77 +------------------ Mage.Sets/src/mage/cards/l/LivingEnd.java | 70 +---------------- .../effects/common/LivingDeathEffect.java | 76 ++++++++++++++++++ 3 files changed, 80 insertions(+), 143 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java diff --git a/Mage.Sets/src/mage/cards/l/LivingDeath.java b/Mage.Sets/src/mage/cards/l/LivingDeath.java index bfe880cbca..37485fcd50 100644 --- a/Mage.Sets/src/mage/cards/l/LivingDeath.java +++ b/Mage.Sets/src/mage/cards/l/LivingDeath.java @@ -1,23 +1,11 @@ package mage.cards.l; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; import java.util.UUID; -import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; + +import mage.abilities.effects.common.LivingDeathEffect; 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.players.Player; /** * @@ -41,64 +29,3 @@ public final class LivingDeath extends CardImpl { return new LivingDeath(this); } } - -class LivingDeathEffect extends OneShotEffect { - - public LivingDeathEffect() { - super(Outcome.Benefit); - this.staticText = "Each player exiles all creature cards from their graveyard, then sacrifices all creatures they control, then puts all cards they exiled this way onto the battlefield"; - } - - public LivingDeathEffect(final LivingDeathEffect effect) { - super(effect); - } - - @Override - public LivingDeathEffect copy() { - return new LivingDeathEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null) { - Map> exiledCards = new HashMap<>(); - - // Move creature cards from graveyard to exile - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - Set cardsPlayer = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game); - if (!cardsPlayer.isEmpty()) { - exiledCards.put(player.getId(), cardsPlayer); - player.moveCards(cardsPlayer, Zone.EXILED, source, game); - } - } - } - game.getState().processAction(game); - - // Sacrifice all creatures - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { - permanent.sacrifice(source.getSourceId(), game); - } - game.getState().processAction(game); - - // Exiled cards are put onto the battlefield at the same time under their owner's control - Set cardsToReturnFromExile = new HashSet<>(); - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - Set cardsPlayer = exiledCards.get(playerId); - if (cardsPlayer != null - && !cardsPlayer.isEmpty()) { - cardsToReturnFromExile.addAll(cardsPlayer); - } - } - } - controller.moveCards(cardsToReturnFromExile, Zone.BATTLEFIELD, source, game, false, false, true, null); - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/l/LivingEnd.java b/Mage.Sets/src/mage/cards/l/LivingEnd.java index 8868bb5357..9ee799e48e 100644 --- a/Mage.Sets/src/mage/cards/l/LivingEnd.java +++ b/Mage.Sets/src/mage/cards/l/LivingEnd.java @@ -1,24 +1,12 @@ package mage.cards.l; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; import java.util.UUID; -import mage.MageObject; -import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.LivingDeathEffect; import mage.abilities.keyword.SuspendAbility; -import mage.cards.Card; 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.players.Player; /** * @@ -35,8 +23,7 @@ public final class LivingEnd extends CardImpl { this.addAbility(new SuspendAbility(3, new ManaCostsImpl("{2}{B}{B}"), this)); // Each player exiles all creature cards from their graveyard, then sacrifices all creatures // they control, then puts all cards they exiled this way onto the battlefield. - this.getSpellAbility().addEffect(new LivingEndEffect()); - + this.getSpellAbility().addEffect(new LivingDeathEffect()); } public LivingEnd(final LivingEnd card) { @@ -48,56 +35,3 @@ public final class LivingEnd extends CardImpl { return new LivingEnd(this); } } - -class LivingEndEffect extends OneShotEffect { - - public LivingEndEffect() { - super(Outcome.Benefit); - this.staticText = "Each player exiles all creature cards from their graveyard, then sacrifices all creatures they control, then puts all cards they exiled this way onto the battlefield"; - } - - public LivingEndEffect(final LivingEndEffect effect) { - super(effect); - } - - @Override - public LivingEndEffect copy() { - return new LivingEndEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null) { - Map> exiledCards = new HashMap<>(); - // move creature cards from graveyard to exile - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - Set cardsPlayer = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game); - if (!cardsPlayer.isEmpty()) { - exiledCards.put(player.getId(), cardsPlayer); - player.moveCards(cardsPlayer, Zone.EXILED, source, game); - } - } - } - // sacrifice all creatures - for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { - permanent.sacrifice(source.getSourceId(), game); - } - // put exiled cards to battlefield - for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - Set cardsPlayer = exiledCards.get(playerId); - if (cardsPlayer != null && !cardsPlayer.isEmpty()) { - player.moveCards(cardsPlayer, Zone.BATTLEFIELD, source, game, false, false, false, null); - } - } - } - return true; - } - return false; - } -} diff --git a/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java new file mode 100644 index 0000000000..21ba872a1c --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/LivingDeathEffect.java @@ -0,0 +1,76 @@ +package mage.abilities.effects.common; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +import java.util.*; + +public class LivingDeathEffect extends OneShotEffect { + + public LivingDeathEffect() { + super(Outcome.Benefit); + this.staticText = "Each player exiles all creature cards from their graveyard, then sacrifices all creatures they control, then puts all cards they exiled this way onto the battlefield"; + } + + public LivingDeathEffect(final LivingDeathEffect effect) { + super(effect); + } + + @Override + public LivingDeathEffect copy() { + return new LivingDeathEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + Map> exiledCards = new HashMap<>(); + + // Move creature cards from graveyard to exile + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + Set cardsPlayer = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game); + if (!cardsPlayer.isEmpty()) { + exiledCards.put(player.getId(), cardsPlayer); + player.moveCards(cardsPlayer, Zone.EXILED, source, game); + } + } + } + game.getState().processAction(game); + + // Sacrifice all creatures + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { + permanent.sacrifice(source.getSourceId(), game); + } + + game.getState().processAction(game); + + // Exiled cards are put onto the battlefield at the same time under their owner's control + Set cardsToReturnFromExile = new HashSet<>(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + Set cardsPlayer = exiledCards.get(playerId); + if (cardsPlayer != null + && !cardsPlayer.isEmpty()) { + cardsToReturnFromExile.addAll(cardsPlayer); + } + } + } + controller.moveCards(cardsToReturnFromExile, Zone.BATTLEFIELD, source, game, false, false, true, null); + return true; + } + return false; + } +}