mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
* Cascade - Fixed a bug that caused the controlling player to lose the game if all cards of the library were exiled with cascade although the cards were returned to library.
This commit is contained in:
parent
3a89d12948
commit
a1208f1a73
4 changed files with 152 additions and 98 deletions
|
|
@ -28,17 +28,16 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
@ -94,23 +93,10 @@ public class CascadeAbility extends TriggeredAbilityImpl {
|
|||
public CascadeAbility copy() {
|
||||
return new CascadeAbility(this);
|
||||
}
|
||||
}
|
||||
|
||||
// !!! Changes to the cascade effect here have to be copied to the cascadeEffect of Maelstrom Nexus card eventually.
|
||||
// There is a functional copy of this effect
|
||||
// moved to static method because it's called also from class {link} MaelstromNexus
|
||||
|
||||
class CascadeEffect extends OneShotEffect {
|
||||
|
||||
public CascadeEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
public CascadeEffect(CascadeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public static boolean applyCascade(Outcome outcome, Game game, Ability source) {
|
||||
Card card;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
|
|
@ -125,6 +111,7 @@ class CascadeEffect extends OneShotEffect {
|
|||
}
|
||||
player.moveCardToExileWithInfo(card, exile.getId(), exile.getName(), source.getSourceId(), game, Zone.LIBRARY);
|
||||
} while (player.isInGame() && card.getCardType().contains(CardType.LAND) || card.getManaCost().convertedManaCost() >= sourceCost);
|
||||
player.getLibrary().reset();
|
||||
|
||||
if (card != null) {
|
||||
if (player.chooseUse(outcome, "Use cascade effect on " + card.getName() + "?", game)) {
|
||||
|
|
@ -142,6 +129,55 @@ class CascadeEffect extends OneShotEffect {
|
|||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// !!! Changes to the cascade effect here have to be copied to the cascadeEffect of Maelstrom Nexus card eventually.
|
||||
// There is a functional copy of this effect
|
||||
|
||||
class CascadeEffect extends OneShotEffect {
|
||||
|
||||
public CascadeEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
public CascadeEffect(CascadeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return CascadeAbility.applyCascade(outcome, game, source);
|
||||
// Card card;
|
||||
// Player player = game.getPlayer(source.getControllerId());
|
||||
// if (player == null) {
|
||||
// return false;
|
||||
// }
|
||||
// ExileZone exile = game.getExile().createZone(source.getSourceId(), player.getName() + " Cascade");
|
||||
// int sourceCost = game.getCard(source.getSourceId()).getManaCost().convertedManaCost();
|
||||
// do {
|
||||
// card = player.getLibrary().getFromTop(game);
|
||||
// if (card == null) {
|
||||
// break;
|
||||
// }
|
||||
// player.moveCardToExileWithInfo(card, exile.getId(), exile.getName(), source.getSourceId(), game, Zone.LIBRARY);
|
||||
// } while (player.isInGame() && card.getCardType().contains(CardType.LAND) || card.getManaCost().convertedManaCost() >= sourceCost);
|
||||
//
|
||||
// if (card != null) {
|
||||
// if (player.chooseUse(outcome, "Use cascade effect on " + card.getName() + "?", game)) {
|
||||
// if(player.cast(card.getSpellAbility(), game, true)){
|
||||
// exile.remove(card.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// while (exile.size() > 0) {
|
||||
// card = exile.getRandom(game);
|
||||
// exile.remove(card.getId());
|
||||
// player.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.EXILED, false, false);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CascadeEffect copy() {
|
||||
|
|
@ -149,3 +185,5 @@ class CascadeEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue