mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
tests: added runtime check for OrTriggeredAbility (related to #12826, 13309)
This commit is contained in:
parent
a63ad8f99c
commit
9f2cfc9e09
1 changed files with 16 additions and 1 deletions
|
|
@ -51,6 +51,21 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
}
|
||||
setTriggerPhrase(generateTriggerPhrase());
|
||||
|
||||
// runtime check: enters and sacrifice must use Zone.ALL, see https://github.com/magefree/mage/issues/12826
|
||||
boolean haveEnters = false;
|
||||
boolean haveSacrifice = false;
|
||||
for (Ability ability : abilities) {
|
||||
if (ability.getRule().toLowerCase(Locale.ENGLISH).contains("enters")) {
|
||||
haveEnters = true;
|
||||
}
|
||||
if (ability.getRule().toLowerCase(Locale.ENGLISH).contains("sacrifice")) {
|
||||
haveSacrifice = true;
|
||||
}
|
||||
}
|
||||
if (zone != Zone.ALL && haveEnters && haveSacrifice) {
|
||||
throw new IllegalArgumentException("Wrong code usage: on enters and sacrifice OrTriggeredAbility must use Zone.ALL");
|
||||
}
|
||||
}
|
||||
|
||||
public OrTriggeredAbility(OrTriggeredAbility ability) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue