cleanup AbilityType for easier check that an ability is an activated ability (#12153)

* cleanup AbilityType

* further cleanup

* cleanup instanceof

* tweak formatting

* rework Rex

* fix mistake in PlayerImpl

* cleanup 'instanceof' for 'ActivatedManaAbilityImpl'
This commit is contained in:
Susucre 2024-05-04 04:13:34 +02:00 committed by GitHub
parent 62cc49ffa3
commit 85cad4ff1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 486 additions and 574 deletions

View file

@ -203,7 +203,9 @@ public abstract class TargetImpl implements Target {
@Override
public boolean isRequired(Ability ability) {
return ability == null || ability.isActivated() || !(ability.getAbilityType() == AbilityType.SPELL || ability.getAbilityType() == AbilityType.ACTIVATED);
return ability == null
|| ability.isActivated()
|| !(ability.getAbilityType() == AbilityType.SPELL || ability.getAbilityType().isActivatedAbility());
}
@Override
@ -675,10 +677,10 @@ public abstract class TargetImpl implements Target {
String abilityText = source.getRule(true).toLowerCase();
boolean strictModeEnabled = player.getStrictChooseMode();
boolean canAutoChoose = this.getMinNumberOfTargets() == this.getMaxNumberOfTargets() // Targets must be picked
&& possibleTargets.size() == this.getNumberOfTargets() - this.getSize() // Available targets are equal to the number that must be picked
&& !strictModeEnabled // Test AI is not set to strictChooseMode(true)
&& playerAutoTargetLevel > 0 // Human player has enabled auto-choose in settings
&& !abilityText.contains("search"); // Do not autochoose for any effects which involve searching
&& possibleTargets.size() == this.getNumberOfTargets() - this.getSize() // Available targets are equal to the number that must be picked
&& !strictModeEnabled // Test AI is not set to strictChooseMode(true)
&& playerAutoTargetLevel > 0 // Human player has enabled auto-choose in settings
&& !abilityText.contains("search"); // Do not autochoose for any effects which involve searching
if (canAutoChoose) {