fix getText() overrides ignoring staticText (#11044)

* fix text: SkipNextPlayerUntapStepEffect

* remove old copyright info

* individual card text fixes

* fix overrides ignoring staticText
This commit is contained in:
xenohedron 2023-08-26 20:47:02 -04:00 committed by GitHub
parent 52eaa600ba
commit 869de1eac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 63 additions and 426 deletions

View file

@ -74,6 +74,9 @@ public class ConjureCardEffect extends OneShotEffect {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder("conjure ");
sb.append(CardUtil.numberToText(amount, "a"));
sb.append(' ');

View file

@ -59,6 +59,7 @@ public class ExileTargetAndSearchGraveyardHandLibraryEffect extends SearchTarget
@Override
public String getText(Mode mode) {
// TODO: Parent class sets static text so it must be overridden here for now
StringBuilder sb = new StringBuilder();
sb.append("Exile target ").append(mode.getTargets().get(0).getTargetName()).append(". ");
sb.append(CardUtil.getTextWithFirstCharUpperCase(super.getText(mode)));

View file

@ -46,6 +46,9 @@ public class PlayTargetWithoutPayingManaEffect extends OneShotEffect {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
if (!mode.getTargets().isEmpty()) {
Target target = mode.getTargets().get(0);

View file

@ -106,16 +106,16 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
if (staticText.isEmpty()) {
sb.append("prevent the next ").append(amountToPrevent).append(" damage that would be dealt ");
if (duration == Duration.EndOfTurn) {
sb.append("this turn ");
}
sb.append("to any number of targets, divided as you choose");
return sb.toString();
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return staticText;
StringBuilder sb = new StringBuilder();
sb.append("prevent the next ").append(amountToPrevent).append(" damage that would be dealt ");
if (duration == Duration.EndOfTurn) {
sb.append("this turn ");
}
sb.append("to any number of targets, divided as you choose");
return sb.toString();
}
}

View file

@ -69,6 +69,9 @@ public class PreventNextDamageFromChosenSourceToTargetEffect extends PreventionE
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
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();

View file

@ -2,7 +2,6 @@ package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
@ -18,8 +17,7 @@ public class PutOnLibrarySourceEffect extends OneShotEffect {
private final boolean onTop;
public PutOnLibrarySourceEffect(boolean onTop) {
super(Outcome.ReturnToHand);
this.onTop = onTop;
this(onTop, "put {this} on " + (onTop ? "top" : "the bottom") + " of its owner's library");
}
public PutOnLibrarySourceEffect(boolean onTop, String rule) {
@ -50,17 +48,4 @@ public class PutOnLibrarySourceEffect extends OneShotEffect {
}
return player.putCardsOnBottomOfLibrary((Card) sourceObject, game, source, false);
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
if (this.staticText != null && !this.staticText.isEmpty()) {
sb.append(staticText);
} else {
// Put Champion of Stray Souls on top of your library from your graveyard
sb.append("put {this} on ");
sb.append(onTop ? "top" : "the bottom").append(" of its owner's library");
}
return sb.toString();
}
}

View file

@ -59,6 +59,9 @@ public class ReturnFromGraveyardToBattlefieldWithCounterTargetEffect extends Ret
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder(super.getText(mode));
sb.append(" with ");
if (additional) {

View file

@ -89,6 +89,9 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder(prefixText);
sb.append('.');
for (TableEntry tableEntry : this.resultsTable) {
@ -157,4 +160,3 @@ public class RollDieWithResultTableEffect extends OneShotEffect {
return super.setTargetPointer(targetPointer);
}
}

View file

@ -1,32 +1,3 @@
/*
*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;

View file

@ -1,38 +1,8 @@
/*
*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*
*/
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.game.Game;
import mage.game.turn.TurnMod;
@ -50,7 +20,9 @@ public class SkipNextPlayerUntapStepEffect extends OneShotEffect {
public SkipNextPlayerUntapStepEffect(String text) {
super(Outcome.Detriment);
this.staticText = text;
this.staticText = text.isEmpty()
? "You skip your next untap step"
: text + " skips their next untap step";
}
public SkipNextPlayerUntapStepEffect(SkipNextPlayerUntapStepEffect effect) {
@ -79,14 +51,4 @@ public class SkipNextPlayerUntapStepEffect extends OneShotEffect {
return new SkipNextPlayerUntapStepEffect(this);
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
if (!staticText.isEmpty()) {
sb.append(staticText).append(" player skips their next untap step");
} else {
sb.append("You skip your next untap step");
}
return sb.toString();
}
}

View file

@ -164,6 +164,9 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
if (duration.toString() != null && !duration.toString().isEmpty()) {
sb.append(duration.toString()).append(", ");

View file

@ -46,6 +46,9 @@ public class LoseAllAbilitiesAllEffect extends ContinuousEffectImpl {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
if (duration == Duration.EndOfTurn) {
sb.append(duration.toString()).append(", ");

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.continuous;
import mage.constants.Duration;
@ -43,9 +41,10 @@ public class SwitchPowerToughnessTargetEffect extends ContinuousEffectImpl {
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("switch target ").append(mode.getTargets().get(0).getTargetName()).append("'s power and toughness")
.append(' ').append(duration.toString());
return sb.toString();
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "switch " + getTargetPointer().describeTargets(mode.getTargets(), "that creature") + "'s power and toughness" +
' ' + duration.toString();
}
}
}

View file

@ -79,13 +79,14 @@ public class EchoEffect extends OneShotEffect {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
if (cost == null) {
sb.append("pay this permanent's mana cost");
return sb.toString();
}
String costText = cost.getText();
if (costText.toLowerCase(Locale.ENGLISH).startsWith("discard")) {
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
@ -93,8 +94,6 @@ public class EchoEffect extends OneShotEffect {
} else {
sb.append("pay ").append(costText);
}
return sb.toString();
}
}

View file

@ -1,7 +1,6 @@
package mage.game.command.planes;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
@ -16,8 +15,8 @@ import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.command.Plane;
import mage.game.permanent.Permanent;
@ -32,8 +31,6 @@ import java.util.List;
*/
public class TazeemPlane extends Plane {
private static final String rule = "Creatures can't block";
public TazeemPlane() {
this.setPlaneType(Planes.PLANE_TAZEEM);
@ -70,15 +67,13 @@ public class TazeemPlane extends Plane {
class TazeemCantBlockAllEffect extends RestrictionEffect {
private FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures");
public TazeemCantBlockAllEffect() {
TazeemCantBlockAllEffect() {
super(Duration.Custom);
staticText = "creatures can't block";
}
protected TazeemCantBlockAllEffect(final TazeemCantBlockAllEffect effect) {
super(effect);
this.filter = effect.filter;
}
@Override
@ -88,7 +83,7 @@ class TazeemCantBlockAllEffect extends RestrictionEffect {
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_TAZEEM)) {
return false;
}
return filter.match(permanent, source.getControllerId(), source, game);
return StaticFilters.FILTER_PERMANENT_CREATURES.match(permanent, source.getControllerId(), source, game);
}
@Override
@ -101,10 +96,4 @@ class TazeemCantBlockAllEffect extends RestrictionEffect {
return new TazeemCantBlockAllEffect(this);
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append(filter.getMessage()).append(" can't block");
return sb.toString();
}
}