mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
some changes to payment text generation
This commit is contained in:
parent
fe42bc6e49
commit
4868afe0e0
8 changed files with 25 additions and 48 deletions
|
|
@ -23,10 +23,9 @@ import java.util.UUID;
|
|||
*/
|
||||
public class RemoveCounterCost extends CostImpl {
|
||||
|
||||
protected TargetPermanent target;
|
||||
private String name;
|
||||
private CounterType counterTypeToRemove;
|
||||
protected int countersToRemove;
|
||||
protected final TargetPermanent target;
|
||||
private final CounterType counterTypeToRemove;
|
||||
protected final int countersToRemove;
|
||||
|
||||
public RemoveCounterCost(TargetPermanent target) {
|
||||
this(target, null);
|
||||
|
|
@ -47,7 +46,6 @@ public class RemoveCounterCost extends CostImpl {
|
|||
public RemoveCounterCost(final RemoveCounterCost cost) {
|
||||
super(cost);
|
||||
this.target = cost.target.copy();
|
||||
this.name = cost.name;
|
||||
this.countersToRemove = cost.countersToRemove;
|
||||
this.counterTypeToRemove = cost.counterTypeToRemove;
|
||||
}
|
||||
|
|
@ -128,7 +126,7 @@ public class RemoveCounterCost extends CostImpl {
|
|||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Remove ");
|
||||
StringBuilder sb = new StringBuilder("remove ");
|
||||
if (counterTypeToRemove != null) {
|
||||
sb.append(CardUtil.numberToText(countersToRemove, counterTypeToRemove.getArticle())).append(' ').append(counterTypeToRemove.getName());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
|
||||
protected Effects executingEffects = new Effects();
|
||||
protected Effects otherwiseEffects = new Effects(); // used for Imprison
|
||||
private final Cost cost;
|
||||
protected final Cost cost;
|
||||
private final String chooseUseText;
|
||||
private final boolean optional;
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
if (!effectText.isEmpty() && effectText.charAt(effectText.length() - 1) == '.') {
|
||||
effectText = effectText.substring(0, effectText.length() - 1);
|
||||
}
|
||||
message = getCostText() + (effectText.isEmpty() ? "" : " and " + effectText) + "?";
|
||||
message = CardUtil.addCostVerb(cost.getText()) + (effectText.isEmpty() ? "" : " and " + effectText) + "?";
|
||||
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
|
|
@ -155,19 +155,13 @@ public class DoIfCostPaid extends OneShotEffect {
|
|||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return (optional ? "you may " : "") + getCostText() + ". If you do, " + executingEffects.getText(mode)
|
||||
return (optional ? "you may " : "")
|
||||
+ CardUtil.addCostVerb(cost.getText())
|
||||
+ ". If you do, "
|
||||
+ executingEffects.getText(mode)
|
||||
+ (!otherwiseEffects.isEmpty() ? " If you don't, " + otherwiseEffects.getText(mode) : "");
|
||||
}
|
||||
|
||||
protected String getCostText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String costText = cost.getText();
|
||||
if (!CardUtil.checkCostWords(costText)) {
|
||||
sb.append("pay ");
|
||||
}
|
||||
return sb.append(costText).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String key, Object value) {
|
||||
super.setValue(key, value);
|
||||
|
|
|
|||
|
|
@ -74,16 +74,10 @@ public class DoWhenCostPaid extends OneShotEffect {
|
|||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
return (optional ? "you may " : "") + getCostText() + ". When you do, " + CardUtil.getTextWithFirstCharLowerCase(ability.getRule());
|
||||
}
|
||||
|
||||
private String getCostText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String costText = cost.getText();
|
||||
if (!CardUtil.checkCostWords(costText)) {
|
||||
sb.append("pay ");
|
||||
}
|
||||
return sb.append(costText).toString();
|
||||
return (optional ? "you may " : "")
|
||||
+ CardUtil.addCostVerb(cost.getText())
|
||||
+ ". When you do, "
|
||||
+ CardUtil.getTextWithFirstCharLowerCase(ability.getRule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -175,8 +175,7 @@ public class SacrificeOpponentsUnlessPayEffect extends OneShotEffect {
|
|||
sb.append(" unless they ");
|
||||
|
||||
if (cost != null) {
|
||||
sb.append(CardUtil.checkCostWords(cost.getText()) ? "" : "pay ");
|
||||
sb.append(cost.getText());
|
||||
sb.append(CardUtil.addCostVerb(cost.getText()));
|
||||
} else {
|
||||
sb.append("pay {X}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ import mage.players.Player;
|
|||
import mage.util.CardUtil;
|
||||
import mage.util.ManaUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA. User: Loki Date: 21.12.10 Time: 9:21
|
||||
*/
|
||||
|
|
@ -92,17 +90,6 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("sacrifice {this} unless you ");
|
||||
String costText = cost != null ? cost.getText() : "{X}";
|
||||
|
||||
if (CardUtil.checkCostWords(costText)) {
|
||||
sb.append(costText.substring(0, 1).toLowerCase(Locale.ENGLISH));
|
||||
sb.append(costText.substring(1));
|
||||
} else {
|
||||
sb.append("pay ").append(costText);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
return "sacrifice {this} unless you " + CardUtil.addCostVerb(cost != null ? cost.getText() : "{X}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1284,8 +1284,11 @@ public final class CardUtil {
|
|||
return zcc;
|
||||
}
|
||||
|
||||
public static boolean checkCostWords(String text) {
|
||||
return text != null && costWords.stream().anyMatch(text.toLowerCase(Locale.ENGLISH)::startsWith);
|
||||
public static String addCostVerb(String text) {
|
||||
if (costWords.stream().anyMatch(text.toLowerCase(Locale.ENGLISH)::startsWith)) {
|
||||
return text;
|
||||
}
|
||||
return "pay " + text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue