refactor: shared logic for diff implementation of isInUseableZone, improved docs and readability;

This commit is contained in:
Oleg Agafonov 2024-11-30 03:26:03 +04:00
parent 57ef74da90
commit d49ff89a81
76 changed files with 285 additions and 273 deletions

View file

@ -86,9 +86,6 @@ public interface Ability extends Controllable, Serializable {
* Gets the id of the object which put this ability in motion.
* <p>
* WARNING, MageSingleton abilities contains dirty data here, so you can't use sourceId with it
*
* @return The {@link java.util.UUID} of the object this ability is
* associated with.
*/
UUID getSourceId();
@ -358,16 +355,17 @@ public interface Ability extends Controllable, Serializable {
* - for leave battlefield triggers - keep default + set setLeavesTheBattlefieldTrigger(true)
* - for dies triggers - override and use TriggeredAbilityImpl.isInUseableZoneDiesTrigger inside + set setLeavesTheBattlefieldTrigger(true)
*
* @param source can be null for static continues effects checking like rules modification (example: Yixlid Jailer)
* @param sourceObject can be null for static continues effects checking like rules modification (example: Yixlid Jailer)
* @param event can be null for state base effects checking like "when you control seven or more" (example: Endrek Sahr, Master Breeder)
*/
boolean isInUseableZone(Game game, MageObject source, GameEvent event);
boolean isInUseableZone(Game game, MageObject sourceObject, GameEvent event);
/**
* Returns true if the source object has currently the ability (e.g. The
* object can have lost all or some abilities for some time (e.g. Turn to
* Frog)
*/
boolean hasSourceObjectAbility(Game game, MageObject source, GameEvent event);
boolean hasSourceObjectAbility(Game game, MageObject sourceObject, GameEvent event);
/**
* Returns true if the ability has a tap itself in their costs
@ -485,6 +483,7 @@ public interface Ability extends Controllable, Serializable {
/**
* Finds the source object regardless of its zcc. Can be LKI from battlefield in some cases.
* Warning, do not use with singleton abilities
*/
MageObject getSourceObject(Game game);