refactor: improved ETB rules generations, fixed some cards/abilities (related to #12791)

This commit is contained in:
Oleg Agafonov 2025-02-09 17:25:48 +04:00
parent 0d0661cc92
commit 19269b22b0
24 changed files with 129 additions and 41 deletions

View file

@ -2,15 +2,22 @@ package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.cards.Card;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.Arrays;
import java.util.List;
/**
* @author BetaSteward_at_googlemail.com
*/
public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
static public boolean ENABLE_TRIGGER_PHRASE_AUTO_FIX = false;
public EntersBattlefieldTriggeredAbility(Effect effect) {
this(effect, false);
}
@ -47,4 +54,59 @@ public class EntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl {
public EntersBattlefieldTriggeredAbility copy() {
return new EntersBattlefieldTriggeredAbility(this);
}
@Override
public EntersBattlefieldTriggeredAbility setTriggerPhrase(String triggerPhrase) {
super.setTriggerPhrase(triggerPhrase);
return this;
}
/**
* Find description of "{this}" like "this creature"
*/
static public String getThisObjectDescription(Card card) {
// prepare {this} description
// short names like Aatchik for Aatchik, Emerald Radian
// except: Mu Yanling, Wind Rider (maybe related to spaces in name)
List<String> parts = Arrays.asList(card.getName().split(","));
if (parts.size() > 1 && !parts.get(0).contains(" ")) {
return parts.get(0);
}
// some types have priority, e.g. Vehicle instead artifact, example: Boommobile
if (card.getSubtype().contains(SubType.VEHICLE)) {
return "this Vehicle";
}
if (card.getSubtype().contains(SubType.AURA)) {
return "this Aura";
}
// by priority
if (card.isCreature()) {
return "this creature";
} else if (card.isPlaneswalker()) {
return "this planeswalker";
} else if (card.isLand()) {
return "this land";
} else if (card.isEnchantment()) {
return "this enchantment";
} else if (card.isArtifact()) {
return "this artifact";
} else {
return "this permanent";
}
}
public static List<String> getPossibleTriggerPhrases() {
// for verify tests - must be same list as above (only {this} relates phrases)
return Arrays.asList(
"when this creature enters",
"when this planeswalker enters",
"when this land enters",
"when this enchantment enters",
"when this artifact enters",
"when this permanent enters"
);
}
}