[FIN] various text fixes

This commit is contained in:
theelk801 2025-05-30 21:27:14 -04:00
parent bf487046e1
commit 9ef2aac469
54 changed files with 222 additions and 141 deletions

View file

@ -32,6 +32,7 @@ import mage.constants.*;
import mage.filter.Filter;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.game.command.Dungeon;
import mage.game.command.Plane;
import mage.game.draft.DraftCube;
@ -70,7 +71,7 @@ public class VerifyCardDataTest {
private static final Logger logger = Logger.getLogger(VerifyCardDataTest.class);
private static final String FULL_ABILITIES_CHECK_SET_CODES = "WHO"; // check ability text due mtgjson, can use multiple sets like MAT;CMD or * for all
private static final String FULL_ABILITIES_CHECK_SET_CODES = "FIN"; // check ability text due mtgjson, can use multiple sets like MAT;CMD or * for all
private static final boolean CHECK_ONLY_ABILITIES_TEXT = false; // use when checking text locally, suppresses unnecessary checks and output messages
private static final boolean CHECK_COPYABLE_FIELDS = true; // disable for better verify test performance
@ -2320,7 +2321,81 @@ public class VerifyCardDataTest {
// TODO: add legality checks (by sets and cards, by banned)
}
private String prepareRule(String cardName, String rule) {
private static final List<SubType> selfRefNamedSubtypes = Arrays.asList(
SubType.EQUIPMENT,
SubType.VEHICLE,
SubType.AURA,
SubType.CLASS,
SubType.SAGA,
SubType.SIEGE
);
private static String applySelfReference(String rule, MageObject mageObject, Game game) {
return rule
.replace("{this}", getCardSelfReference(mageObject, game))
.replace(". this", ". This")
.replace("\nthis", "\nThis")
.replace("-this", "-This")
.replace(": this", ": This")
.replace("&bull this", "&bull This")
.replace("&mdash; this", "&mdash; This")
.replace("&mdash;this", "&mdash;This")
.replace("- this", "- This");
}
/**
* Returns the description of the card for rules text that references itself.
* Applies to abilities that function only on the battlefield.
* Does not account for every exception.
* <a href="https://scryfall.com/blog/errata-notice-aetherdrift-231">Details here</a>
*/
private static String getCardSelfReference(MageObject mageObject, Game game) {
if (!mageObject.isPermanent(game)) {
return mageObject.getName();
}
if (mageObject.isPlaneswalker(game)) {
// try to ref by planeswalker name which is subtype
return mageObject
.getSubtype(game)
.stream()
.filter(SubType.getPlaneswalkerTypes()::contains)
.findFirst()
.map(SubType::getDescription)
.orElse(mageObject.getName());
}
if (mageObject.isLegendary(game)) {
// Generate shortname for legendary permanent (other than planeswalker)
List<String> parts = Arrays.asList(mageObject.getName().split("(, | of the )"));
if (parts.size() > 1) {
return parts.get(0);
} else {
return mageObject.getName();
}
}
if (mageObject.isCreature(game)) {
return "this creature";
}
if (mageObject.isLand(game)) {
return "this land";
}
for (SubType subType : selfRefNamedSubtypes) {
if (mageObject.hasSubtype(subType, game)) {
return "this " + subType.getDescription();
}
}
if (mageObject.isBattle(game)) {
return "this battle";
}
if (mageObject.isEnchantment(game)) {
return "this enchantment";
}
if (mageObject.isArtifact(game)) {
return "this artifact";
}
return "this permanent";
}
private String prepareRule(Card card, String rule) {
// remove and optimize rule text for analyze
String newRule = rule;
@ -2336,8 +2411,7 @@ public class VerifyCardDataTest {
}
// replace special text and symbols
newRule = newRule
.replace("{this}", cardName)
newRule = applySelfReference(newRule, card, null)
.replace("", "-")
.replace("", "-")
.replace("&mdash;", "-");
@ -2349,7 +2423,7 @@ public class VerifyCardDataTest {
newRule = CardNameUtil.normalizeCardName(newRule);
return newRule.trim();
return CardUtil.getTextWithFirstCharUpperCase(newRule.trim());
}
@Test
@ -2582,7 +2656,7 @@ public class VerifyCardDataTest {
String[] refRules = refText.split("[\\$\\\n]"); // ref card's abilities can be splited by \n or $ chars
for (int i = 0; i < refRules.length; i++) {
refRules[i] = prepareRule(card.getName(), refRules[i]);
refRules[i] = prepareRule(card, refRules[i]);
}
if (ref.subtypes.contains("Adventure")) {
@ -2615,7 +2689,7 @@ public class VerifyCardDataTest {
.replace("</b>", "")
.split("[\\$\\\n]");
for (int i = 0; i < cardRules.length; i++) {
cardRules[i] = prepareRule(card.getName(), cardRules[i]);
cardRules[i] = prepareRule(card, cardRules[i]);
}
boolean isFine = true;