forked from External/mage
Rework Spell.counter using PutCards and reimplement Desertion. Fixes #9299
This commit is contained in:
parent
cbe610d339
commit
e40934921f
27 changed files with 124 additions and 251 deletions
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.ZoneDetail;
|
||||
import mage.constants.PutCards;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
|
|
@ -15,29 +13,20 @@ import mage.players.Player;
|
|||
*/
|
||||
public class CounterTargetWithReplacementEffect extends OneShotEffect {
|
||||
|
||||
private Zone targetZone;
|
||||
private ZoneDetail zoneDetail;
|
||||
|
||||
public CounterTargetWithReplacementEffect(Zone targetZone) {
|
||||
this(targetZone, ZoneDetail.NONE);
|
||||
}
|
||||
private final PutCards putIt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param targetZone
|
||||
* @param zoneDetail use to specify when moving card to library <ul><li>true
|
||||
* = put on top</li><li>false = put on bottom</li></ul>
|
||||
* @param putIt
|
||||
*/
|
||||
public CounterTargetWithReplacementEffect(Zone targetZone, ZoneDetail zoneDetail) {
|
||||
public CounterTargetWithReplacementEffect(PutCards putIt) {
|
||||
super(Outcome.Detriment);
|
||||
this.targetZone = targetZone;
|
||||
this.zoneDetail = zoneDetail;
|
||||
this.putIt = putIt;
|
||||
}
|
||||
|
||||
public CounterTargetWithReplacementEffect(final CounterTargetWithReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.targetZone = effect.targetZone;
|
||||
this.zoneDetail = effect.zoneDetail;
|
||||
this.putIt = effect.putIt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -49,41 +38,26 @@ public class CounterTargetWithReplacementEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
return game.getStack().counter(targetPointer.getFirst(game, source), source, game, targetZone, false, zoneDetail);
|
||||
return game.getStack().counter(getTargetPointer().getFirst(game, source), source, game, putIt);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
StringBuilder sb = new StringBuilder("Counter target ");
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("counter ");
|
||||
sb.append(getTargetPointer().describeTargets(mode.getTargets(), "it"));
|
||||
sb.append(". If that spell is countered this way, ");
|
||||
if (targetZone == Zone.EXILED) {
|
||||
if (putIt == PutCards.EXILED) {
|
||||
sb.append("exile it instead of putting it into its owner's graveyard");
|
||||
} else {
|
||||
sb.append(putIt == PutCards.TOP_OR_BOTTOM ? "put that card " : "put it ");
|
||||
sb.append(putIt.getMessage(true, false));
|
||||
sb.append(" instead of into that player's graveyard");
|
||||
}
|
||||
if (targetZone == Zone.HAND) {
|
||||
sb.append("put it into its owner's hand instead of into that player's graveyard");
|
||||
}
|
||||
if (targetZone == Zone.LIBRARY) {
|
||||
sb.append("put it on ");
|
||||
switch (zoneDetail) {
|
||||
case BOTTOM:
|
||||
sb.append("the bottom");
|
||||
break;
|
||||
case TOP:
|
||||
sb.append("top");
|
||||
break;
|
||||
case CHOOSE:
|
||||
sb.append("top or bottom");
|
||||
break;
|
||||
case NONE:
|
||||
sb.append("<not allowed value>");
|
||||
break;
|
||||
}
|
||||
sb.append(" of its owner's library instead of into that player's graveyard");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue