foul-magics/Mage/src/main/java/mage/game/MageObjectAttribute.java
ssk97 bea33c7493
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
2023-11-16 23:12:32 +04:00

60 lines
1.6 KiB
Java

package mage.game;
import mage.MageObject;
import mage.ObjectColor;
import mage.constants.CardType;
import mage.constants.SuperType;
import mage.util.Copyable;
import mage.util.SubTypes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* This class saves changed attributes of mage objects (e.g. in command zone, graveyard, exile or
* player hands or libraries).
*
* @author LevelX2
*/
public class MageObjectAttribute implements Serializable, Copyable<MageObjectAttribute> {
protected final ObjectColor color;
protected final SubTypes subtype;
protected final List<CardType> cardType;
protected final List<SuperType> superType;
public MageObjectAttribute(MageObject mageObject, Game game) {
color = mageObject.getColor().copy();
subtype = mageObject.getSubtype(game).copy();
cardType = new ArrayList<>(mageObject.getCardType(game));
superType = new ArrayList<>(mageObject.getSuperType(game));
}
public MageObjectAttribute(MageObjectAttribute mageObjectAttribute) {
this.color = mageObjectAttribute.color;
this.subtype = mageObjectAttribute.subtype;
this.cardType = mageObjectAttribute.cardType;
this.superType = mageObjectAttribute.superType;
}
public MageObjectAttribute copy() {
return new MageObjectAttribute(this);
}
public ObjectColor getColor() {
return color;
}
public SubTypes getSubtype() {
return subtype;
}
public List<CardType> getCardType() {
return cardType;
}
public List<SuperType> getSuperType() {
return superType;
}
}