mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
refactor text gen to use target pointers, part x of y
This commit is contained in:
parent
7be16bdaac
commit
23ca66e3ce
23 changed files with 53 additions and 422 deletions
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
|
|
@ -14,8 +12,6 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -24,6 +20,8 @@ import mage.players.Player;
|
|||
import mage.target.TargetPlayer;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
|
|
@ -56,16 +54,9 @@ public final class CurseOfEchoes extends CardImpl {
|
|||
|
||||
class CurseOfEchoesCopyTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private static final FilterSpell filter = new FilterSpell();
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
CardType.INSTANT.getPredicate(),
|
||||
CardType.SORCERY.getPredicate()));
|
||||
}
|
||||
|
||||
public CurseOfEchoesCopyTriggeredAbility() {
|
||||
CurseOfEchoesCopyTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new CurseOfEchoesEffect(), false);
|
||||
setTriggerPhrase("Whenever enchanted player casts an instant or sorcery spell, ");
|
||||
}
|
||||
|
||||
private CurseOfEchoesCopyTriggeredAbility(final CurseOfEchoesCopyTriggeredAbility ability) {
|
||||
|
|
@ -98,16 +89,13 @@ class CurseOfEchoesCopyTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever enchanted player casts an instant or sorcery spell, each other player may copy that spell and may choose new targets for the copy they control.";
|
||||
}
|
||||
}
|
||||
|
||||
class CurseOfEchoesEffect extends OneShotEffect {
|
||||
|
||||
CurseOfEchoesEffect() {
|
||||
super(Outcome.Copy);
|
||||
staticText = "each other player may copy that spell and may choose new targets for the copy they control";
|
||||
}
|
||||
|
||||
private CurseOfEchoesEffect(final CurseOfEchoesEffect effect) {
|
||||
|
|
@ -137,11 +125,4 @@ class CurseOfEchoesEffect extends OneShotEffect {
|
|||
return new CurseOfEchoesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
return "Copy target " + mode.getTargets().get(0).getTargetName() + ". You may choose new targets for the copy";
|
||||
}
|
||||
return "No target";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,33 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.effects.common.continuous.GainControlAndUntapTargetEffect;
|
||||
import mage.abilities.effects.common.UntapTargetEffect;
|
||||
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
|
||||
import mage.abilities.effects.keyword.ScryEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DyadForceTransfer extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("noncreature permanent");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
|
||||
}
|
||||
|
||||
public DyadForceTransfer(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
|
||||
//Gain control of target noncreature permanent until end of turn. Untap it.
|
||||
this.getSpellAbility().addEffect(new GainControlAndUntapTargetEffect(Duration.EndOfTurn));
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(1, 1,
|
||||
StaticFilters.FILTER_PERMANENT_NON_CREATURE));
|
||||
this.getSpellAbility().addEffect(new GainControlTargetEffect(Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(new UntapTargetEffect().setText("Untap it"));
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter));
|
||||
|
||||
//Scry 3.
|
||||
this.getSpellAbility().addEffect(new ScryEffect(3, true));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ public final class Redeem extends CardImpl {
|
|||
|
||||
|
||||
// Prevent all damage that would be dealt this turn to up to two target creatures.
|
||||
this.getSpellAbility().addEffect(new PreventDamageToTargetEffect(Duration.EndOfTurn));
|
||||
this.getSpellAbility().addEffect(new PreventDamageToTargetEffect(Duration.EndOfTurn)
|
||||
.setText("prevent all damage that would be dealt this turn to up to two target creatures"));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 2));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package mage.cards.r;
|
|||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -47,6 +46,7 @@ class RenderSilentCounterEffect extends OneShotEffect {
|
|||
|
||||
RenderSilentCounterEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText = "counter target spell";
|
||||
}
|
||||
|
||||
private RenderSilentCounterEffect(final RenderSilentCounterEffect effect) {
|
||||
|
|
@ -68,11 +68,6 @@ class RenderSilentCounterEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Counter target " + mode.getTargets().get(0).getTargetName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RenderSilentEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
|
@ -108,10 +103,7 @@ class RenderSilentEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||
if (player != null && player.getId().equals(event.getPlayerId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return player != null && player.getId().equals(event.getPlayerId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterNoncreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -102,9 +101,11 @@ enum WelcomeToAdjuster implements TargetAdjuster {
|
|||
if (opponent == null) {
|
||||
continue;
|
||||
}
|
||||
FilterPermanent filter = new FilterNoncreaturePermanent(
|
||||
FilterPermanent filter = new FilterPermanent(
|
||||
"noncreature artifact controlled by " + opponent.getLogName());
|
||||
filter.add(Predicates.and(CardType.ARTIFACT.getPredicate(), new ControllerIdPredicate(opponentId)));
|
||||
filter.add(Predicates.not(CardType.CREATURE.getPredicate()));
|
||||
filter.add(CardType.ARTIFACT.getPredicate());
|
||||
filter.add(new ControllerIdPredicate(opponentId));
|
||||
ability.addTarget(new TargetPermanent(0, 1, filter, false));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,8 @@ public class CopyTargetStackAbilityEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("copy ");
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
|
||||
}
|
||||
sb.append(". You may choose new targets for the copy");
|
||||
return sb.toString();
|
||||
return "copy " + getTargetPointer().describeTargets(mode.getTargets(), "that spell")
|
||||
+ ". You may choose new targets for the copy";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ public class DestroyAllNamedPermanentsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Destroy target " + mode.getTargets().get(0).getTargetName() + " and all other permanents with the same name as that permanent";
|
||||
return "Destroy " + getTargetPointer().describeTargets(mode.getTargets(), "that permanent")
|
||||
+ " and all other permanents with the same name as that permanent";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,13 +51,7 @@ public class MillCardsTargetEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
sb.append("target ");
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
} else {
|
||||
sb.append("that player");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(getTargetPointer().describeTargets(mode.getTargets(), "that player"));
|
||||
sb.append(" mills ");
|
||||
String message = numberCards.getMessage();
|
||||
if (message.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class MillHalfLibraryTargetEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "target " + (mode.getTargets().isEmpty() ? "that player" : mode.getTargets().get(0).getTargetName()) +
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "that player") +
|
||||
" mills half their library, rounded " + (roundUp ? "up" : "down");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,7 @@ public class PreventDamageToTargetEffect extends PreventionEffectImpl {
|
|||
} else {
|
||||
sb.append("prevent the next ").append(amountToPrevent).append(" damage that would be dealt to ");
|
||||
}
|
||||
String targetName = mode.getTargets().get(0).getTargetName();
|
||||
if (targetName.contains("any")) {
|
||||
sb.append(targetName);
|
||||
} else {
|
||||
sb.append("target ").append(targetName);
|
||||
}
|
||||
sb.append(getTargetPointer().describeTargets(mode.getTargets(), "it"));
|
||||
if (!duration.toString().isEmpty()) {
|
||||
sb.append(' ');
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
|
|
|
|||
|
|
@ -70,11 +70,7 @@ public class PreventNextDamageFromChosenSourceToTargetEffect extends PreventionE
|
|||
}
|
||||
StringBuilder sb = new StringBuilder("The next time a ").append(targetSource.getFilter().getMessage());
|
||||
sb.append(" of your choice would deal damage to ");
|
||||
String targetName = mode.getTargets().get(0).getTargetName();
|
||||
if (!targetName.contains("target ") && !targetName.endsWith("any target")) {
|
||||
sb.append("target ");
|
||||
}
|
||||
sb.append(targetName);
|
||||
sb.append(getTargetPointer().describeTargets(mode.getTargets(), "it"));
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
sb.append(" this turn");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,12 +45,7 @@ public class CantAttackBlockTargetEffect extends RestrictionEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("target ");
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
sb.append("creature");
|
||||
} else {
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(getTargetPointer().describeTargets(mode.getTargets(), "that creature"));
|
||||
sb.append(" can't attack or block ");
|
||||
if (duration == Duration.EndOfTurn) {
|
||||
sb.append("this turn");
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ public class GoadTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
return "goad target " + (!mode.getTargets().isEmpty() ? mode.getTargets().get(0).getTargetName() : " creature")
|
||||
return "goad " + getTargetPointer().describeTargets(mode.getTargets(), "that creature")
|
||||
+ ". <i>(Until your next turn, that creature attacks each combat if able and attacks a player other than you if able.)</i>";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,12 +155,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("target ");
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
} else {
|
||||
sb.append("land");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(getTargetPointer().describeTargets(mode.getTargets(), "target land"));
|
||||
sb.append(" becomes ");
|
||||
if (chooseLandType) {
|
||||
sb.append("the basic land type of your choice");
|
||||
|
|
|
|||
|
|
@ -48,6 +48,6 @@ public class GainAllCreatureTypesTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "target " + mode.getTargets().get(0).getTargetName() + " gains all creature types " + duration.toString();
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "it") + " gains all creature types " + duration.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,159 +0,0 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Merlingilb
|
||||
*/
|
||||
public class GainControlAndUntapTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected UUID controllingPlayerId;
|
||||
private boolean fixedControl;
|
||||
private boolean firstControlChange = true;
|
||||
private final Condition condition;
|
||||
|
||||
public GainControlAndUntapTargetEffect(Duration duration) {
|
||||
this(duration, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duration
|
||||
* @param fixedControl Controlling player is fixed even if the controller of
|
||||
* the ability changes later
|
||||
*/
|
||||
public GainControlAndUntapTargetEffect(Duration duration, boolean fixedControl) {
|
||||
this(duration, fixedControl, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duration
|
||||
* @param controllingPlayerId Player that controls the target creature
|
||||
*/
|
||||
public GainControlAndUntapTargetEffect(Duration duration, UUID controllingPlayerId) {
|
||||
this(duration, true, controllingPlayerId);
|
||||
|
||||
}
|
||||
|
||||
public GainControlAndUntapTargetEffect(Duration duration, boolean fixedControl, UUID controllingPlayerId) {
|
||||
this(duration, fixedControl, controllingPlayerId, null);
|
||||
}
|
||||
|
||||
public GainControlAndUntapTargetEffect(Duration duration, boolean fixedControl, UUID controllingPlayerId, Condition condition) {
|
||||
super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
|
||||
this.controllingPlayerId = controllingPlayerId;
|
||||
this.fixedControl = fixedControl;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
protected GainControlAndUntapTargetEffect(final GainControlAndUntapTargetEffect effect) {
|
||||
super(effect);
|
||||
this.controllingPlayerId = effect.controllingPlayerId;
|
||||
this.fixedControl = effect.fixedControl;
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainControlAndUntapTargetEffect copy() {
|
||||
return new GainControlAndUntapTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
if (this.controllingPlayerId == null && fixedControl) {
|
||||
this.controllingPlayerId = source.getControllerId();
|
||||
}
|
||||
super.init(source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
discard(); // controller no longer exists
|
||||
return false;
|
||||
}
|
||||
boolean oneTargetStillExists = false;
|
||||
for (UUID permanentId : getTargetPointer().getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent == null) {
|
||||
continue;
|
||||
}
|
||||
oneTargetStillExists = true;
|
||||
if (permanent.isControlledBy(controllingPlayerId)) {
|
||||
permanent.untap(game);
|
||||
continue;
|
||||
}
|
||||
boolean controlChanged = false;
|
||||
if (controllingPlayerId != null) {
|
||||
if (permanent.changeControllerId(controllingPlayerId, game, source)) {
|
||||
permanent.untap(game);
|
||||
controlChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (permanent.changeControllerId(source.getControllerId(), game, source)) {
|
||||
permanent.untap(game);
|
||||
controlChanged = true;
|
||||
}
|
||||
}
|
||||
if (source instanceof ActivatedAbility
|
||||
&& firstControlChange && !controlChanged) {
|
||||
// If it was not possible to get control of target permanent by the activated ability the first time it took place
|
||||
// the effect failed (e.g. because of Guardian Beast) and must be discarded
|
||||
// This does not handle correctly multiple targets at once
|
||||
discard();
|
||||
}
|
||||
if (condition != null && !condition.apply(game, source)) {
|
||||
discard();
|
||||
}
|
||||
}
|
||||
// no valid target exists and the controller is no longer in the game, effect can be discarded
|
||||
if (!oneTargetStillExists || !controller.isInGame()) {
|
||||
discard();
|
||||
}
|
||||
firstControlChange = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
if (mode.getTargets().isEmpty()) {
|
||||
return "gain control of target permanent until end of turn. Untap it.";
|
||||
}
|
||||
|
||||
Target target = mode.getTargets().get(0);
|
||||
StringBuilder sb = new StringBuilder("gain control of ");
|
||||
if (target.getMaxNumberOfTargets() > 1) {
|
||||
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
||||
sb.append("up to ");
|
||||
}
|
||||
sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ");
|
||||
} else if (!target.getTargetName().startsWith("another")) {
|
||||
sb.append("target ");
|
||||
}
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
if (!duration.toString().isEmpty()) {
|
||||
sb.append(' ').append(duration.toString());
|
||||
}
|
||||
sb.append("and untap it");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -76,20 +76,7 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (!mode.getTargets().isEmpty()) {
|
||||
if (mode.getTargets().get(0).getTargetName().contains("target")) {
|
||||
sb.append(mode.getTargets().get(0).getTargetName());
|
||||
} else {
|
||||
sb.append("target ").append(mode.getTargets().get(0).getTargetName());
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append("gains protection from the color of your choice " + duration.toString());
|
||||
|
||||
return sb.toString();
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "it")
|
||||
+ " gains protection from the color of your choice " + duration.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
|
||||
/**
|
||||
* @author a
|
||||
*/
|
||||
public class LoseAbilityOrAnotherAbilityTargetEffect extends LoseAbilityTargetEffect {
|
||||
|
||||
protected Ability ability2;
|
||||
|
||||
public LoseAbilityOrAnotherAbilityTargetEffect(Ability ability, Ability ability2) {
|
||||
this(ability, ability2, Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
public LoseAbilityOrAnotherAbilityTargetEffect(Ability ability, Ability ability2, Duration duration) {
|
||||
super(ability, duration);
|
||||
this.ability2 = ability2;
|
||||
}
|
||||
|
||||
protected LoseAbilityOrAnotherAbilityTargetEffect(final LoseAbilityOrAnotherAbilityTargetEffect effect) {
|
||||
super(effect);
|
||||
this.ability2 = effect.ability2.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoseAbilityOrAnotherAbilityTargetEffect copy() {
|
||||
return new LoseAbilityOrAnotherAbilityTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
ChoiceImpl chooseAbility = new ChoiceImpl();
|
||||
chooseAbility.setMessage("Choose an ability to remove");
|
||||
|
||||
Set<String> choice = new HashSet<>();
|
||||
|
||||
if (permanent.getAbilities().contains(ability)) {
|
||||
choice.add(ability.getRule());
|
||||
}
|
||||
|
||||
if (permanent.getAbilities().contains(ability2)) {
|
||||
choice.add(ability2.getRule());
|
||||
}
|
||||
|
||||
chooseAbility.setChoices(choice);
|
||||
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
||||
if (player.choose(outcome, chooseAbility, game)) {
|
||||
String chosenAbility = chooseAbility.getChoice();
|
||||
if (chosenAbility.equals(ability.getRule())) {
|
||||
permanent.removeAbility(ability, source.getSourceId(), game);
|
||||
} else if (chosenAbility.equals(ability2.getRule())) {
|
||||
permanent.removeAbility(ability2, source.getSourceId(), game);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Target target = mode.getTargets().get(0);
|
||||
if (target.getNumberOfTargets() > 1) {
|
||||
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
||||
sb.append("Up to");
|
||||
}
|
||||
sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" loses ");
|
||||
} else {
|
||||
sb.append("Target ").append(target.getTargetName()).append(" loses ");
|
||||
}
|
||||
sb.append(ability.getRule());
|
||||
sb.append(" or ");
|
||||
sb.append(ability2.getRule());
|
||||
if (!duration.toString().isEmpty()) {
|
||||
sb.append(' ').append(duration.toString());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
|
|
@ -52,20 +52,8 @@ public class LoseAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Target target = mode.getTargets().get(0);
|
||||
if (target.getNumberOfTargets() > 1) {
|
||||
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
||||
sb.append("Up to");
|
||||
}
|
||||
sb.append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName()).append(" loses ");
|
||||
} else {
|
||||
sb.append("Target ").append(target.getTargetName()).append(" loses ");
|
||||
}
|
||||
sb.append(ability.getRule());
|
||||
if (!duration.toString().isEmpty()) {
|
||||
sb.append(' ').append(duration.toString());
|
||||
}
|
||||
return sb.toString();
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "it")
|
||||
+ " loses " + CardUtil.stripReminderText(ability.getRule())
|
||||
+ (duration.toString().isEmpty() ? "" : ' ' + duration.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -50,9 +50,8 @@ public class LoseAllAbilitiesTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" loses all abilities ").append(duration.toString());
|
||||
return sb.toString();
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "it")
|
||||
+ " loses all abilities " + (duration.toString().isEmpty() ? "" : ' ' + duration.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public class LoseAllCreatureTypesTargetEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return "target " + mode.getTargets().get(0).getTargetName() + " loses all creature types " + duration.toString();
|
||||
return getTargetPointer().describeTargets(mode.getTargets(), "it") + " loses all creature types"
|
||||
+ (duration.toString().isEmpty() ? "" : ' ' + duration.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -548,12 +548,6 @@ public final class StaticFilters {
|
|||
FILTER_OPPONENTS_PERMANENT_NON_LAND.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterNoncreaturePermanent FILTER_PERMANENT_NON_CREATURE = new FilterNoncreaturePermanent();
|
||||
|
||||
static {
|
||||
FILTER_PERMANENT_NON_CREATURE.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterCreaturePermanent FILTER_OPPONENTS_PERMANENT_CREATURE = new FilterOpponentsCreaturePermanent();
|
||||
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
|
||||
|
||||
/**
|
||||
* @author Merlingilb
|
||||
*/
|
||||
public class FilterNoncreaturePermanent extends FilterPermanent {
|
||||
|
||||
public FilterNoncreaturePermanent() {
|
||||
this("noncreature permanent");
|
||||
}
|
||||
|
||||
public FilterNoncreaturePermanent(String name) {
|
||||
super(name);
|
||||
this.add(Predicates.not(CardType.CREATURE.getPredicate()));
|
||||
}
|
||||
|
||||
protected FilterNoncreaturePermanent(final FilterNoncreaturePermanent filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterNoncreaturePermanent copy() {
|
||||
return new FilterNoncreaturePermanent(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue