Class ValueProvider
java.lang.Object
net.demilich.metastone.game.spells.desc.valueprovider.ValueProvider
- All Implemented Interfaces:
Serializable,HasDesc<ValueProviderDesc>
- Direct Known Subclasses:
AftermathsCountValueProvider,AlgebraicValueProvider,AttributeCounter,AttributeValueProvider,CardsPlayedValueProvider,ConditionalValueProvider,CurrentTurnValueProvider,DestroyedThisSequenceValueProvider,DiedThisTurnValueProvider,DistinctTribesValueProvider,EntityCountValueProvider,EventValueProvider,ExcessHealingThisTurnValueProvider,FiresLeftValueProvider,GameValueProvider,GatekeeperShaValueProvider,HeroPowerDamageValueProvider,IndexInSourceValueProvider,LastTurnValueProvider,ManaCostModifierValueProvider,ManaCostProvider,MaxBoardSizeValueProvider,MinionSummonValueProvider,OriginalValueProvider,PlayedLastTurnValueProvider,PlayedThisTurnValueProvider,PlayerAttributeValueProvider,RandomValueProvider,ReduceValueProvider,SpellDamageValueProvider,SpellstoneValueProvider,TurnsNoCardPlayedValueProvider
public abstract class ValueProvider
extends Object
implements Serializable, HasDesc<ValueProviderDesc>
Value providers compute an integer value given
ValueProviderArg, an underlying implementation, and the
player, host and target from whose point of view the value should be calculated.
Value providers are typically executed by Desc.getValue(Enum, GameContext, Player, Entity, Entity, int).
All value providers support the following features:
ValueProviderArg.OFFSET: Specifies an amount to always add (possibly negative) to the calculated value. Defaults to0.ValueProviderArg.MULTIPLIER: Specifies an amount to always multiply (possible negative) to the calculate value. Defaults to1. This is applied before the offset.ValueProviderArg.TARGET_PLAYER: Specifies a change to whose point of view the value provider should be computed. For example, if theplayeris casting a spell that calculates something from theTargetPlayer.BOTHpoint of view, the result of this value provider for both player's points of view are added together.
Observe that ValueProviderArg.TARGET is not available to all value providers. The target that the
value provider is evaluated against depends on the context and the ValueProviderArg.TARGET is ignored unless
the underlying class (like e.g. AttributeValueProvider) specifically handles the ValueProviderArg.TARGET argument. It is almost always the SpellArg.TARGET.
The target is interpreted as:
- The
SpellArg.TARGETof the spell calling this value provider. - The
GameEvent.getTarget()when a value provider is used in a condition on aEventTriggerDesc. - The
Cardaffected by theCardCostModifierArg.TARGETargument of a card cost modifier. nullinMissilesSpellandHealingMissilesSpell'sgetValuecalls.nullif theAttributeFilterhas aEntityFilterArg.TARGETthat evaluates to zero entities.nullin all other situations.
Refer to the class hierarchy of this class for all the possible value providers.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDesc()intgetValue(GameContext context, Player player, Entity target, Entity host) protected abstract intprovideValue(GameContext context, Player player, Entity target, Entity host) void
-
Constructor Details
-
ValueProvider
-
-
Method Details
-
getValue
-
provideValue
-
getDesc
- Specified by:
getDescin interfaceHasDesc<ValueProviderDesc>
-
setDesc
- Specified by:
setDescin interfaceHasDesc<ValueProviderDesc>
-