forked from External/mage
* Fixed a bug with DiscardTargetCost causing problems for cards with discard costs (e.g. Solitary Confinement).
This commit is contained in:
parent
f47a2d9384
commit
1ef99e775f
3 changed files with 18 additions and 26 deletions
|
|
@ -54,16 +54,15 @@ public class SolitaryConfinement extends CardImpl {
|
|||
super(ownerId, 24, "Solitary Confinement", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||
this.expansionSetCode = "JUD";
|
||||
|
||||
|
||||
// At the beginning of your upkeep, sacrifice Solitary Confinement unless you discard a card.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new SacrificeSourceUnlessPaysEffect(new DiscardTargetCost(new TargetCardInHand())), TargetController.YOU, false));
|
||||
|
||||
|
||||
// Skip your draw step.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipDrawStepEffect()));
|
||||
|
||||
|
||||
// You have shroud.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControllerEffect(ShroudAbility.getInstance())));
|
||||
|
||||
|
||||
// Prevent all damage that would be dealt to you.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,7 @@ public class DiscardTargetCost extends CostImpl {
|
|||
|
||||
public DiscardTargetCost(DiscardTargetCost cost) {
|
||||
super(cost);
|
||||
for (Card card : cost.cards) {
|
||||
this.cards.add(card.copy());
|
||||
}
|
||||
this.cards.addAll(cost.cards);
|
||||
this.randomDiscard = cost.randomDiscard;
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +82,7 @@ public class DiscardTargetCost extends CostImpl {
|
|||
return false;
|
||||
}
|
||||
player.discard(card, ability, game);
|
||||
this.cards.add(card.copy());
|
||||
this.cards.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +94,7 @@ public class DiscardTargetCost extends CostImpl {
|
|||
public void clearPaid() {
|
||||
super.clearPaid();
|
||||
this.cards.clear();
|
||||
this.targets.clear();
|
||||
this.targets.clearChosen();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,29 +1,26 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Loki
|
||||
* Date: 21.12.10
|
||||
* Time: 9:21
|
||||
* Created by IntelliJ IDEA. User: Loki Date: 21.12.10 Time: 9:21
|
||||
*/
|
||||
public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
||||
|
||||
protected Cost cost;
|
||||
|
||||
public SacrificeSourceUnlessPaysEffect(Cost cost) {
|
||||
super(Outcome.Sacrifice);
|
||||
this.cost = cost;
|
||||
}
|
||||
}
|
||||
|
||||
public SacrificeSourceUnlessPaysEffect(final SacrificeSourceUnlessPaysEffect effect) {
|
||||
super(effect);
|
||||
|
|
@ -33,14 +30,13 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null && player != null && permanent != null) {
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (player != null && sourcePermanent != null) {
|
||||
StringBuilder sb = new StringBuilder(cost.getText()).append("?");
|
||||
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ") ) {
|
||||
if (!sb.toString().toLowerCase().startsWith("exile ") && !sb.toString().toLowerCase().startsWith("return ")) {
|
||||
sb.insert(0, "Pay ");
|
||||
}
|
||||
String message = CardUtil.replaceSourceName(sb.toString(), sourceObject.getLogName());
|
||||
String message = CardUtil.replaceSourceName(sb.toString(), sourcePermanent.getLogName());
|
||||
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
|
||||
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
cost.clearPaid();
|
||||
|
|
@ -48,7 +44,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
sourcePermanent.sacrifice(source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -61,7 +57,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if(staticText != null && !staticText.isEmpty()) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
|
|
@ -74,11 +70,10 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
|| costText.toLowerCase().startsWith("sacrifice")) {
|
||||
sb.append(costText.substring(0, 1).toLowerCase());
|
||||
sb.append(costText.substring(1));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("pay ").append(costText);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue