Class CardCostModifier
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Entity>
,HasDesc<CardCostModifierDesc>
,HasCard
,Trigger
- Direct Known Subclasses:
OneTurnCostModifier
,ToggleCostModifier
In this example, the specified modifier reduces the hosting entity's cost by one.
{ "class": "CardCostModifier", "target": "SELF", "operation": "SUBTRACT", "value": 1 }
When a target isn't specified, the card cost modification applies to the hand of the owner of this card cost modifier
(i.e. EntityReference.FRIENDLY_HAND
.
To make a card cost modifier apply to both player's hands during both player's turns, CardCostModifierArg.TARGET_PLAYER
must be TargetPlayer.BOTH
and the target
should be EntityReference.BOTH_HANDS
.
-
Field Summary
Fields inherited from class net.demilich.metastone.game.spells.trigger.Enchantment
activated, activationTriggers, added, copyToActor, countByValue, countUntilCast, expirationTriggers, expired, firesThisSequence, hostReference, keepAfterTransform, maxFiresPerSequence, oneTurn, persistentOwner, spell, triggers, usesSpellTrigger, zones
Fields inherited from class net.demilich.metastone.game.entities.Entity
attributes, effectSource, entityLocation, name, NO_OWNER, sourceCard
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
appliesTo
(GameContext context, Card card, Player player) Determines whether this modifier applies to the specified card.protected void
clone()
Clone an entity, including its ID and location.protected Object
get
(CardCostModifierArg arg) Returns the value of the specifiedCardCostModifierArg
protected com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType
protected EventTriggerDesc[]
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
getDesc()
protected EntityFilter
Gets the filter to apply to theCardCostModifierArg.TARGET
.int
protected Attribute
protected String
Gets the target player of the given card cost modifier.boolean
Indicates this trigger cannot change owners.void
onAdd
(GameContext context, Player player, Entity source, Entity host) Called when the trigger is added into aGameContext
's state.int
process
(GameContext context, Entity host, Card card, int currentManaCost, Player player) void
protected boolean
boolean
Methods inherited from class net.demilich.metastone.game.spells.trigger.Enchantment
activate, endOfSequence, expire, fires, getActivationTriggers, getCopy, getCountUntilCast, getDefaultBattlefieldZones, getDefaultBattlefieldZonesSet, getDefaultDeckZones, getDefaultGameZones, getDefaultPassiveZones, getEntityType, getEntrySet, getExpirationTriggers, getFires, getHostReference, getMaxFires, getMaxFiresPerSequence, getOneTurn, getSourceCard, getSpell, getTriggers, getUsesSpellTrigger, getZones, innerQueues, interestedIn, isActivated, isCopyToActor, isCountByValue, isExpired, isKeptAfterTransform, oneTurnOnly, onGameEvent, process, queues, setActivated, setActivationTriggers, setCopyToActor, setCountByValue, setCountUntilCast, setExpirationTriggers, setFires, setHostReference, setKeepAfterTransform, setMaxFires, setMaxFiresPerSequence, setOneTurn, setPersistentOwner, setSpell, setTriggers, setUsesSpellTrigger, setZones, toString
Methods inherited from class net.demilich.metastone.game.entities.Entity
compareTo, diedOnBattlefield, evaluateDescriptions, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getCardInventoryId, getCopySource, getDescription, getDescription, getDynamicDescription, getEffectSource, getEntityLocation, getGameTriggers, getId, getIndex, getMaxNumberOfAttacks, getName, getOwner, getRace, getReference, getUserId, getZone, hasAttribute, hasPersistentEffects, isDestroyed, isInPlay, isRemovedPeacefully, modifyAttribute, modifyHpBonus, moveOrAddTo, moveOrAddTo, resetEntityLocations, setAttribute, setAttribute, setAttribute, setDescription, setEffectSource, setEntityLocation, setId, setName, setOwner, setSourceCard, setUserId, transformResolved, transformResolved
-
Constructor Details
-
CardCostModifier
-
-
Method Details
-
appliesTo
Determines whether this modifier applies to the specified card.First, the method checks if the modifier has been
Enchantment.expired
due to itsCardCostModifierArg.EXPIRATION_TRIGGER
. For aOneTurnCostModifier
, the expiration trigger is assumed to be aTurnEndTrigger
.Then, the modifier evaluates its
CardCostModifierArg.TARGET
andCardCostModifierArg.FILTER
and sees if the card is equal to or is contained within the resulting set ofEntity
objects. When not specified, theCardCostModifierArg.TARGET
is assumed to be theEntityReference.FRIENDLY_HAND
.The
CardCostModifierArg.RACE
argument, if specified, is compared to thecard
instance'sCard.getRace()
.The
CardCostModifierArg.CARD_TYPE
argument, if specified, is compared to thecard
instance'sCard.getCardType()
.Finally, the
CardCostModifierArg.TARGET_PLAYER
argument, if specified, is compared to thecard
instance'sEntity.getOwner()
with respect to theEnchantment.getHostReference()
of this modifier. For example, ifCardCostModifierArg.TARGET_PLAYER
isTargetPlayer.SELF
, then the card'sEntity.getOwner()
is compared to theEnchantment.getHostReference()
Entity.getOwner()
.- Parameters:
context
- The game context.card
- The card to evaluate.player
- The player from whose point of view this should be evaluated.- Returns:
true
if the modifier applies to this card.
-
get
Returns the value of the specifiedCardCostModifierArg
- Parameters:
arg
- The argument- Returns:
- The value
-
getFilter
Gets the filter to apply to theCardCostModifierArg.TARGET
.- Returns:
- An
EntityFilter
- See Also:
-
getCardType
protected com.hiddenswitch.spellsource.rpc.Spellsource.CardTypeMessage.CardType getCardType() -
getMinValue
public int getMinValue() -
getRequiredAttribute
-
getRequiredRace
-
getTargetPlayer
Gets the target player of the given card cost modifier.This is relative to the owner of the modifier, which is typically the caster, not the owner of the
Enchantment.getHostReference()
.- Returns:
TargetPlayer.SELF
if not specified, otherwise theTargetPlayer
specified by the modifier.
-
onAdd
Description copied from interface:Trigger
Called when the trigger is added into aGameContext
's state.- Specified by:
onAdd
in interfaceTrigger
- Overrides:
onAdd
in classEnchantment
- Parameters:
context
- The game context.
-
process
-
isPersistentOwner
public boolean isPersistentOwner()Description copied from interface:Trigger
Indicates this trigger cannot change owners. For example, aSecret
does not have a persistent owner, because card texts can steal secrets. However, the trigger described by Blessing of Wisdom does have a persistent owner, since the casting player of that spell should always draw the card it receives.- Specified by:
isPersistentOwner
in interfaceTrigger
- Overrides:
isPersistentOwner
in classEnchantment
- Returns:
true
if the trigger'sTrigger.onGameEvent(GameEvent)
should be evaluated from the point of view of the owner when the trigger was created, as opposed to what the owner is right now (which may have changed).
-
targetsSelf
public boolean targetsSelf() -
getDesc
- Specified by:
getDesc
in interfaceHasDesc<CardCostModifierDesc>
-
setDesc
- Specified by:
setDesc
in interfaceHasDesc<CardCostModifierDesc>
-
getDefaultTriggers
- Overrides:
getDefaultTriggers
in classEnchantment
-
clone
Description copied from class:Entity
Clone an entity, including its ID and location.Use this method for emulating an "immutable" view on an entity. This kind of cloning is not suitable for most gameplay situations, because using the clone will cause two entities with identical IDs and locations to exist. Instead, a subclass will provide a
getCopy()
method that is more helpful for gameplay.- Specified by:
clone
in interfaceTrigger
- Overrides:
clone
in classEnchantment
- Returns:
- An exact clone.
-
cast
- Overrides:
cast
in classEnchantment
-
getDefaultZones
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultZones()- Overrides:
getDefaultZones
in classEnchantment
-
shouldNotifyEnchantmentFired
- Overrides:
shouldNotifyEnchantmentFired
in classEnchantment
-