another batch of text cleanup (#11694)

* minor refactor EntersBattlefieldEffect

* more minor refactoring

* text fix

* fix more text

* more text adjustments

* more text discrepancy fixes

* continue the text fixes

* followup fixes and more fixes
This commit is contained in:
xenohedron 2024-01-20 23:13:03 -05:00 committed by GitHub
parent 7008f0a7f0
commit 4959ef4d49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 192 additions and 212 deletions

View file

@ -226,7 +226,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
}
}
if (replaceRuleText && triggerPhrase != null) {
superRule = superRule.replaceFirst("^((?:you may )?sacrifice |(put|remove) an? [^ ]+ counter (on|from) |return |transform |untap |regenerate )?\\{this\\}", "$1it");
superRule = superRule.replaceFirst("^((?:you may )?sacrifice |(put|remove) [^ ]+ [^ ]+ counters? (on|from) |return |transform |untap |regenerate )?\\{this\\}", "$1it");
}
sb.append(superRule);
if (triggersOnceEachTurn) {

View file

@ -18,9 +18,9 @@ import mage.game.events.GameEvent;
*/
public class BecomesAttachedToCreatureSourceEffect extends ReplacementEffectImpl {
protected Effects baseEffects = new Effects();
protected String text;
protected Condition condition;
private final Effects baseEffects;
private final String text;
private final Condition condition;
public BecomesAttachedToCreatureSourceEffect(Effect baseEffect) {
this(baseEffect, "");
@ -32,6 +32,7 @@ public class BecomesAttachedToCreatureSourceEffect extends ReplacementEffectImpl
public BecomesAttachedToCreatureSourceEffect(Effect baseEffect, Condition condition, String text) {
super(Duration.WhileOnBattlefield, baseEffect.getOutcome(), false);
this.baseEffects = new Effects();
this.baseEffects.add(baseEffect);
this.text = text;
this.condition = condition;

View file

@ -1,4 +1,3 @@
package mage.abilities.effects;
import mage.MageObject;
@ -20,11 +19,11 @@ import mage.players.Player;
*/
public class EntersBattlefieldEffect extends ReplacementEffectImpl {
protected Effects baseEffects = new Effects();
protected String text;
protected Condition condition;
protected boolean optional;
protected EnterEventType enterEventType;
private final Effects baseEffects;
private final String text;
private final Condition condition;
private final boolean optional;
private final EnterEventType enterEventType;
public static final String SOURCE_CAST_SPELL_ABILITY = "sourceCastSpellAbility";
@ -46,6 +45,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
public EntersBattlefieldEffect(Effect baseEffect, Condition condition, String text, boolean selfScope, boolean optional, EnterEventType enterEventType) {
super(Duration.WhileOnBattlefield, baseEffect.getOutcome(), selfScope);
this.baseEffects = new Effects();
this.baseEffects.add(baseEffect);
this.enterEventType = enterEventType;
this.text = text;
@ -83,12 +83,8 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) {
if (condition == null || condition.apply(game, source)) {
return true;
}
}
return false;
return event.getTargetId().equals(source.getSourceId())
&& (condition == null || condition.apply(game, source));
}
@Override

View file

@ -43,6 +43,9 @@ public class AddContinuousEffectToGame extends OneShotEffect {
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return effects.getText(mode);
}
}

View file

@ -21,6 +21,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
protected DontUntapInControllersNextUntapStepSourceEffect(final DontUntapInControllersNextUntapStepSourceEffect effect) {
super(effect);
this.validForTurnNum = effect.validForTurnNum;
}
@Override

View file

@ -20,7 +20,7 @@ public class ExileCardYouChooseTargetOpponentEffect extends OneShotEffect {
public ExileCardYouChooseTargetOpponentEffect(FilterCard filter) {
super(Outcome.Discard);
this.staticText = "target opponent reveals their hand. You choose "
+ filter.getMessage() + " from it and exile that card";
+ filter.getMessage() + (filter.getMessage().contains("from it") ? "" : " from it") + " and exile that card";
this.filter = filter;
}

View file

@ -8,7 +8,6 @@ import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/**
* @author mzulch
@ -17,14 +16,22 @@ public class CanBlockAdditionalCreatureTargetEffect extends ContinuousEffectImpl
protected int amount;
/**
* Need to set text manually
* Target can block an additional creature this turn
*/
public CanBlockAdditionalCreatureTargetEffect() {
this(Duration.EndOfTurn, 1);
}
/**
* Need to set text manually
* @param duration of effect
* @param amount 0 = any number
*/
public CanBlockAdditionalCreatureTargetEffect(Duration duration, int amount) {
super(duration, Outcome.Benefit);
this.amount = amount;
staticText = setText();
}
protected CanBlockAdditionalCreatureTargetEffect(final CanBlockAdditionalCreatureTargetEffect effect) {
@ -59,24 +66,6 @@ public class CanBlockAdditionalCreatureTargetEffect extends ContinuousEffectImpl
return false;
}
private String setText() {
String text = "target can block ";
switch (amount) {
case 0:
text += "any number of creatures";
break;
default:
text += CardUtil.numberToText(amount, "an") + " additional creature" + (amount > 1 ? "s" : "");
}
if (duration == Duration.EndOfTurn) {
text += " this turn";
}
if (duration == Duration.WhileOnBattlefield) {
text += " each combat";
}
return text;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.RulesEffects;