Costs Tag Tracking part 2: Tag system and X values, reworked deep copy code (#11406)

* Implement Costs Tag Map system

* Use Costs Tag Map system to store X value for spells, abilities, and resolving permanents

* Store Bestow without target's tags
Change functions for getting tags and storing the tags of a new permanent

* Create and use deep copy function in CardUtil, add Copyable<T> to many classes

* Fix Hall Of the Bandit Lord infinite loop

* Add additional comments

* Don't store null/empty costs tags maps (saves memory)

* Fix two more Watchers with Ability variable

* Add check for exact collection types during deep copy

* Use generics instead of pure type erasure during deep copy

* convert more code to using deep copy helper, everything use Object copier, add EnumMap

* fix documentation

* Don't need the separate null checks anymore (handled in deepCopyObject)

* Minor cleanup
This commit is contained in:
ssk97 2023-11-16 11:12:32 -08:00 committed by GitHub
parent 72e30f1574
commit bea33c7493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 458 additions and 338 deletions

View file

@ -26,6 +26,7 @@ import mage.watchers.Watcher;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
@ -157,6 +158,26 @@ public interface Ability extends Controllable, Serializable {
void addManaCostsToPay(ManaCost manaCost);
/**
* Gets a map of the cost tags (set while casting/activating) of this ability, can be null if no tags have been set yet
* does NOT return the source permanent's tags
*
* @return The map of tags and corresponding objects
*/
Map<String, Object> getCostsTagMap();
/**
* Set tag to the value, initializes this ability's tags map if it is null
*/
void setCostsTag(String tag, Object value);
/**
* Returns the value of the tag or defaultValue if the tag is not found in this ability's tag map
* does NOT check the source permanent's tags, use CardUtil.getSourceCostsTag for that
*
* @return The given tag value (or the default if not found)
*/
Object getCostsTagOrDefault(String tag, Object defaultValue);
/**
* Retrieves the effects that are put into the place by the resolution of
* this ability.