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 theplayer
is casting a spell that calculates something from theTargetPlayer.BOTH
point 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.TARGET
of the spell calling this value provider. - The
GameEvent.getTarget()
when a value provider is used in a condition on aEventTriggerDesc
. - The
Card
affected by theCardCostModifierArg.TARGET
argument of a card cost modifier. null
inMissilesSpell
andHealingMissilesSpell
'sgetValue
calls.null
if theAttributeFilter
has aEntityFilterArg.TARGET
that evaluates to zero entities.null
in 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()
int
getValue
(GameContext context, Player player, Entity target, Entity host) protected abstract int
provideValue
(GameContext context, Player player, Entity target, Entity host) void
-
Constructor Details
-
ValueProvider
-
-
Method Details
-
getValue
-
provideValue
-
getDesc
- Specified by:
getDesc
in interfaceHasDesc<ValueProviderDesc>
-
setDesc
- Specified by:
setDesc
in interfaceHasDesc<ValueProviderDesc>
-