Simplified effects by removing unnecessary getText instances. (#9374)

This commit is contained in:
Alex Vasile 2022-09-09 12:02:22 -04:00 committed by GitHub
parent 076c55f1ea
commit 092f3c3fe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
83 changed files with 134 additions and 677 deletions

View file

@ -81,6 +81,14 @@ class GainManaAbilitiesWhileExiledEffect extends ContinuousEffectImpl {
GainManaAbilitiesWhileExiledEffect(String colors) {
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.colors = colors;
this.staticText =
"target land gains \"{T}: Add " +
CardUtil.concatWithOr(
Arrays.stream(colors.split(""))
.map(s -> '{' + s + '}')
.collect(Collectors.toList())
) +
"\" until {this} is cast from exile";
}
private GainManaAbilitiesWhileExiledEffect(final GainManaAbilitiesWhileExiledEffect effect) {
@ -129,17 +137,6 @@ class GainManaAbilitiesWhileExiledEffect extends ContinuousEffectImpl {
}
return true;
}
@Override
public String getText(Mode mode) {
return "target land gains \"{T}: Add " +
CardUtil.concatWithOr(
Arrays.stream(colors.split(""))
.map(s -> '{' + s + '}')
.collect(Collectors.toList())
) +
"\" until {this} is cast from exile";
}
}
class WasCastFromExileWatcher extends Watcher {

View file

@ -83,6 +83,9 @@ public class AmplifyEffect extends ReplacementEffectImpl {
public AmplifyEffect(AmplifyFactor amplifyFactor) {
super(Duration.EndOfGame, Outcome.BoostCreature);
this.amplifyFactor = amplifyFactor;
this.staticText = amplifyFactor.toString() +
" <i>(As this enter the battlefield, " + amplifyFactor.getRuleText() + " for each card"
+ " you reveal that shares a type with it in your hand.)</i>";
}
public AmplifyEffect(final AmplifyEffect effect) {
@ -133,15 +136,6 @@ public class AmplifyEffect extends ReplacementEffectImpl {
return false;
}
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder(amplifyFactor.toString());
sb.append(" <i>(As this enter the battlefield, ");
sb.append(amplifyFactor.getRuleText()).append(" for each card"
+ " you reveal that shares a type with it in your hand.)</i>");
return sb.toString();
}
@Override
public AmplifyEffect copy() {
return new AmplifyEffect(this);

View file

@ -19,6 +19,7 @@ public class CantBeRegeneratedSourceEffect extends ContinuousRuleModifyingEffect
public CantBeRegeneratedSourceEffect(Duration duration) {
super(duration, Outcome.Benefit, false, false);
this.staticText = buildStaticText();
}
public CantBeRegeneratedSourceEffect(final CantBeRegeneratedSourceEffect effect) {
@ -56,8 +57,7 @@ public class CantBeRegeneratedSourceEffect extends ContinuousRuleModifyingEffect
return Objects.equals(source.getSourceId(), event.getTargetId());
}
@Override
public String getText(Mode mode) {
private String buildStaticText() {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}

View file

@ -11,6 +11,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -28,46 +29,17 @@ import java.util.UUID;
public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
protected Cost cost;
protected DynamicValue genericMana;
protected DynamicValue amount;
protected FilterPermanent filter;
public SacrificeOpponentsUnlessPayEffect(Cost cost) {
this(cost, new FilterPermanent(), 1);
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost) {
this(genericManaCost, new FilterPermanent(), 1);
this(new GenericManaCost(genericManaCost), StaticFilters.FILTER_PERMANENT);
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter) {
this(cost, filter, 1);
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost, FilterPermanent filter) {
this(genericManaCost, filter, 1);
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter, int amount) {
this(cost, filter, StaticValue.get(amount));
}
public SacrificeOpponentsUnlessPayEffect(int genericManaCost, FilterPermanent filter, int amount) {
this(new GenericManaCost(genericManaCost), filter, StaticValue.get(amount));
}
public SacrificeOpponentsUnlessPayEffect(Cost cost, FilterPermanent filter, DynamicValue amount) {
super(Outcome.Sacrifice);
this.cost = cost;
this.amount = amount;
this.filter = filter;
}
public SacrificeOpponentsUnlessPayEffect(DynamicValue genericMana, FilterPermanent filter, DynamicValue amount) {
super(Outcome.Sacrifice);
this.genericMana = genericMana;
this.amount = amount;
this.filter = filter;
this.staticText = "each opponent sacrifices " + CardUtil.addArticle(filter.getMessage()) + " unless they " + CardUtil.addCostVerb(cost.getText());
}
public SacrificeOpponentsUnlessPayEffect(final SacrificeOpponentsUnlessPayEffect effect) {
@ -76,14 +48,6 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
this.cost = effect.cost.copy();
}
if (effect.genericMana != null) {
this.genericMana = effect.genericMana.copy();
}
if (effect.amount != null) {
this.amount = effect.amount.copy();
}
if (effect.filter != null) {
this.filter = effect.filter.copy();
}
@ -103,27 +67,16 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
Player player = game.getPlayer(playerId);
if (player != null) {
Cost costToPay;
String costValueMessage;
if (cost != null) {
costToPay = cost.copy();
costValueMessage = costToPay.getText();
} else {
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
}
String message = "";
if (costToPay instanceof ManaCost) {
message += "Pay ";
}
message += costValueMessage + '?';
Cost costToPay = cost.copy();
String costValueMessage = costToPay.getText();
String message = ((costToPay instanceof ManaCost) ? "Pay " : "") + costValueMessage + '?';
costToPay.clearPaid();
if (!(player.chooseUse(Outcome.Benefit, message, source, game)
&& costToPay.pay(source, game, source, player.getId(), false, null))) {
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent the sacrifice effect");
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
int numTargets = Math.min(1, game.getBattlefield().countAll(filter, player.getId(), game));
if (numTargets > 0) {
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, true);
@ -148,43 +101,4 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
return true;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("each opponent sacrifices ");
switch (amount.toString()) {
case "1":
sb.append(CardUtil.addArticle(filter.getMessage()));
break;
case "X":
sb.append("X ");
sb.append(filter.getMessage());
break;
default:
sb.append(CardUtil.numberToText(amount.toString()));
sb.append(' ');
sb.append(filter.getMessage());
}
sb.append(" unless they ");
if (cost != null) {
sb.append(CardUtil.addCostVerb(cost.getText()));
} else {
sb.append("pay {X}");
}
if (genericMana != null && !genericMana.getMessage().isEmpty()) {
sb.append(", where X is ");
sb.append(genericMana.getMessage());
}
return sb.toString();
}
}

View file

@ -19,6 +19,8 @@ public class CreaturesBecomeOtherTypeEffect extends ContinuousEffectImpl {
this.subType = subType;
this.dependendToTypes.add(DependencyType.BecomeCreature); // Opalescence and Starfield of Nyx
this.staticText = this.filter.getMessage() + " is " + this.subType.getIndefiniteArticle()
+ " " + this.subType.toString() + " in addition to its other types";
}
protected CreaturesBecomeOtherTypeEffect(final CreaturesBecomeOtherTypeEffect effect) {
@ -52,14 +54,4 @@ public class CreaturesBecomeOtherTypeEffect extends ContinuousEffectImpl {
public boolean hasLayer(Layer layer) {
return layer == Layer.TypeChangingEffects_4;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return this.filter.getMessage() + " is " + this.subType.getIndefiniteArticle()
+ " " + this.subType.toString() + " in addition to its other types";
}
}

View file

@ -38,6 +38,7 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
this.searchWhatText = searchWhatText;
this.searchForText = searchForText;
this.graveyardExileOptional = graveyardExileOptional;
this.staticText = "search " + searchWhatText + " graveyard, hand, and library for " + searchForText + " and exile them. Then that player shuffles";
}
public SearchTargetGraveyardHandLibraryForCardNameAndExileEffect(final SearchTargetGraveyardHandLibraryForCardNameAndExileEffect effect) {
@ -98,17 +99,4 @@ public abstract class SearchTargetGraveyardHandLibraryForCardNameAndExileEffect
return false;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("search ").append(this.searchWhatText);
sb.append(" graveyard, hand, and library for ");
sb.append(this.searchForText);
sb.append(" and exile them. Then that player shuffles");
return sb.toString();
}
}