* Cascade - Fixed that the remaining cards were not set to graveyard in a random order.

This commit is contained in:
LevelX2 2015-10-02 15:05:00 +02:00
parent e35e44941c
commit abca80e951
2 changed files with 42 additions and 80 deletions

View file

@ -92,8 +92,20 @@ public class CascadeAbility extends TriggeredAbilityImpl {
return new CascadeAbility(this); return new CascadeAbility(this);
} }
// moved to static method because it's called also from class {link} MaelstromNexus }
public static boolean applyCascade(Outcome outcome, Game game, Ability source) {
class CascadeEffect extends OneShotEffect {
public CascadeEffect() {
super(Outcome.PutCardInPlay);
}
public CascadeEffect(CascadeEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Card card; Card card;
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player == null) { if (player == null) {
@ -117,7 +129,7 @@ public class CascadeAbility extends TriggeredAbilityImpl {
} }
} }
} }
// Mobe the remaining cards to the buttom of the libraray in a random order // Move the remaining cards to the buttom of the library in a random order
Cards cardsFromExile = new CardsImpl(); Cards cardsFromExile = new CardsImpl();
Cards cardsToLibrary = new CardsImpl(); Cards cardsToLibrary = new CardsImpl();
cardsFromExile.addAll(exile); cardsFromExile.addAll(exile);
@ -126,57 +138,9 @@ public class CascadeAbility extends TriggeredAbilityImpl {
cardsFromExile.remove(card.getId()); cardsFromExile.remove(card.getId());
cardsToLibrary.add(card); cardsToLibrary.add(card);
} }
player.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, true); player.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, false);
return true; 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 @Override
public CascadeEffect copy() { public CascadeEffect copy() {

View file

@ -48,35 +48,32 @@ import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.util.CardUtil; import mage.util.CardUtil;
/** /**
* 702.65. Delve * 702.65. Delve 702.65a Delve is a static ability that functions while the
* 702.65a Delve is a static ability that functions while the spell with delve is on the stack. * spell with delve is on the stack. Delve means For each generic mana in
* Delve means For each generic mana in this spells total cost, you may exile a card * this spells total cost, you may exile a card from your graveyard rather than
* from your graveyard rather than pay that mana. The delve ability isnt an additional * pay that mana. The delve ability isnt an additional or alternative cost and
* or alternative cost and applies only after the total cost of the spell with delve is * applies only after the total cost of the spell with delve is determined.
* determined.
* 702.65b Multiple instances of delve on the same spell are redundant. * 702.65b Multiple instances of delve on the same spell are redundant.
* *
* * The rules for delve have changed slightly since it was last in an expansion. Previously, delve * * The rules for delve have changed slightly since it was last in an
* reduced the cost to cast a spell. Under the current rules, you exile cards from your graveyard * expansion. Previously, delve reduced the cost to cast a spell. Under the
* at the same time you pay the spells cost. Exiling a card this way is simply another way to pay * current rules, you exile cards from your graveyard at the same time you pay
* that cost. * the spells cost. Exiling a card this way is simply another way to pay that
* * Delve doesnt change a spells mana cost or converted mana cost. For example, Dead Drops converted * cost. * Delve doesnt change a spells mana cost or converted mana cost. For
* mana cost is 10 even if you exiled three cards to cast it. * example, Dead Drops converted mana cost is 10 even if you exiled three cards
* * You cant exile cards to pay for the colored mana requirements of a spell with delve. * to cast it. * You cant exile cards to pay for the colored mana requirements
* * You cant exile more cards than the generic mana requirement of a spell with delve. For example, * of a spell with delve. * You cant exile more cards than the generic mana
* you cant exile more than nine cards from your graveyard to cast Dead Drop. * requirement of a spell with delve. For example, you cant exile more than
* * Because delve isnt an alternative cost, it can be used in conjunction with alternative costs. * nine cards from your graveyard to cast Dead Drop. * Because delve isnt an
* * alternative cost, it can be used in conjunction with alternative costs.
*
* @author LevelX2 * @author LevelX2
* *
* TODO: Change card exiling to a way to pay mana costs, now it's maybe not passible to pay costs from effects that * TODO: Change card exiling to a way to pay mana costs, now it's maybe not
* increase the mana costs. * passible to pay costs from effects that increase the mana costs.
*/ */
public class DelveAbility extends SimpleStaticAbility implements AlternateManaPaymentAbility {
public class DelveAbility extends SimpleStaticAbility implements AlternateManaPaymentAbility {
public DelveAbility() { public DelveAbility() {
super(Zone.STACK, null); super(Zone.STACK, null);
@ -89,12 +86,12 @@ import mage.util.CardUtil;
@Override @Override
public DelveAbility copy() { public DelveAbility copy() {
return new DelveAbility(this); return new DelveAbility(this);
} }
@Override @Override
public String getRule() { public String getRule() {
return "Delve <i>(Each card you exile from your graveyard while casting this spell pays for {1})</i>"; return "Delve <i>(Each card you exile from your graveyard while casting this spell pays for {1})</i>";
} }
@Override @Override
@ -110,7 +107,7 @@ import mage.util.CardUtil;
unpaidAmount = 1; unpaidAmount = 1;
} }
specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard( specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(
0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard()))); 0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard())));
if (specialAction.canActivate(source.getControllerId(), game)) { if (specialAction.canActivate(source.getControllerId(), game)) {
game.getState().getSpecialActions().add(specialAction); game.getState().getSpecialActions().add(specialAction);
} }
@ -160,9 +157,10 @@ class DelveEffect extends OneShotEffect {
List<Card> exiledCards = exileFromGraveCost.getExiledCards(); List<Card> exiledCards = exileFromGraveCost.getExiledCards();
if (exiledCards.size() > 0) { if (exiledCards.size() > 0) {
ManaPool manaPool = controller.getManaPool(); ManaPool manaPool = controller.getManaPool();
manaPool.addMana(new Mana(0,0,0,0,0,exiledCards.size(),0), game, source); manaPool.addMana(new Mana(0, 0, 0, 0, 0, exiledCards.size(), 0), game, source);
manaPool.unlockManaType(ManaType.COLORLESS); manaPool.unlockManaType(ManaType.COLORLESS);
String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game); String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game);
@SuppressWarnings("unchecked")
List<Card> delvedCards = (List<Card>) game.getState().getValue(keyString); List<Card> delvedCards = (List<Card>) game.getState().getValue(keyString);
if (delvedCards == null) { if (delvedCards == null) {
game.getState().setValue(keyString, exiledCards); game.getState().setValue(keyString, exiledCards);