Class Spell
- All Implemented Interfaces:
Serializable
,HasDesc<SpellDesc>
- Direct Known Subclasses:
AbholosSpell
,AbstractModifyEnchantmentSpell
,AbstractRemoveCardSpell
,ActivateTriggeredEffectSpell
,ActorOrCardSpell
,AddActorEffectsToTargetActorSpell
,AddBattlecrySpell
,AddDeathrattleSpell
,AddEnchantmentSpell
,AddQuestSpell
,AddSecretSpell
,AuraBuffSpell
,AysaCloudsingerSpell
,BaulPocuseSpell
,BrothersInBloodSpell
,CalamityBeckonsSpell
,CardCostModifierSpell
,CastAfterSequenceSpell
,CastCardsSpell
,CastFromGroupSpell
,CastOnCardsInStorageSpell
,CastOnEntitiesInStorageSpell
,CastRandomSpellSpell
,CastRepeatedlySpell
,CastSpellSpell
,CastSpellWithTargetOrElseSpell
,CelestialConduitSpell
,ChangeHeroPowerSpell
,ChangeHeroSpell
,ChangeSignatureSpell
,ChooseAndReshuffleSpell
,ChooseOneSpell
,ChooseSignatureSpell
,ClearOverloadSpell
,ClearStorageSpell
,CloneMinionSpell
,ConditionalAttackBonusSpell
,ConditionalEffectSpell
,ConditionalSpell
,CopyCardEnchantmentsSpell
,CopyCardSpell
,CopyEnchantmentsSpell
,CopyLowestCostMinionSpell
,CopyMinionSpell
,CreateAndTeachSpell
,CreateCardFromChoicesSpell
,CreateCardSpell
,CreateSummonSpell
,CreationSpell
,DamageAdjacentMinionsSpell
,DamageOppositeMinionsSpell
,DamageSpell
,DecaySpell
,DestroySecretsSpell
,DestroySpell
,DiluteSoulSpell
,DiscardCardsFromDeckSpell
,DiscoverClassSpell
,DiscoverDiscardSpell
,DiscoverOptionSpell
,DiscoverSpell
,DoubleAttackSpell
,DrainSpell
,DrawCardFromGraveyardSpell
,DrawCardSpell
,DrawCardUntilConditionSpell
,EitherOrSpell
,EnrageSpell
,EquipWeaponSpell
,FarseerNobundoSpell
,FatigueSpell
,FelfireDrakeSpell
,FightSpell
,FinalFeastSpell
,ForceDeathPhaseSpell
,FromDeckToHandSpell
,FumbleSpell
,GainManaSpell
,GetChooseOneChoicesSpell
,GuessCardSpell
,HealAndBuffExcessAsDrainSpell
,HealSpell
,HeroPowerToSpellSpell
,JailMinionSpell
,JoustSpell
,LambdaSpellDesc.LambdaSpell
,LastMinionCardInDeckSpell
,MergeSpell
,MetaSpell
,MindControlSpell
,MisdirectSpell
,ModifyDamageSpell
,ModifyDurabilitySpell
,ModifyMaxManaSpell
,MultiTargetSpell
,NullSpell
,OverrideTargetSpell
,PlayCardsRandomlySpell
,ProphetWaRanSpell
,PutCopyInHandSpell
,PutDeckTopSpell
,PutMinionOnBoardFromDeckSpell
,PutMinionOnBoardSpell
,PutOnBottomOfDeckSpell
,PutRandomSecretIntoPlaySpell
,QueryTargetSpell
,RandomCardTargetSpell
,RandomlyCastSpell
,RecastMinionSpells
,RecastWhileSpell
,ReceiveCardsInStorageSpell
,ReceiveCardSpell
,RecruitSpell
,RefreshAttacksSpell
,RefreshHeroPowerSpell
,RefreshManaSpell
,RelativeToTargetEffectSpell
,RemoveActorPeacefullySpell
,RemoveBonusAttributes
,RemoveEnchantmentSpell
,RemoveTopUntilMinionAndSummonSpell
,RenounceClassSpell
,RepeatAllAftermathsSpell
,RepeatAllOtherBattlecriesSpell
,ReplaceCardsSpell
,ResetDeckSpell
,ResurrectFromBothSpell
,ResurrectFromEntityStorageSpell
,ResurrectSpell
,ReturnTargetToHandSpell
,RevealCardSpell
,RevertableSpell
,ReviveMinionSpell
,SetAttackerSpell
,SetAttackSpell
,SetAttributeSpell
,SetDescriptionSpell
,SetHeroHpSpell
,SetHpSpell
,SetMaxManaSpell
,SetRaceSpell
,ShuffleToDeckSpell
,SilenceSpell
,SortDeckByManaCostSpell
,SowDistrustSpell
,StealCardSpell
,StealRandomSecretSpell
,StoreEntitySpell
,StoreRaceToAttributeSpell
,SummonCardFromAttributeSpell
,SummonFriendlyMinionsThatDiedSpell
,SummonSpell
,SwapAttackAndHpSpell
,SwapAttackSpell
,SwapCardsSpell
,SwapHpAndCostSpell
,SwapHpSpell
,SwapMinionSpell
,SwipeSpell
,TargetToSourceSecondaryToTargetSpell
,TemporaryAttackSpell
,TextifySpell
,TransformCardSpell
,TransformInHandSpell
,TransformMinionSpell
,TriggerDeathrattleSpell
,TriggerOpenerSpell
,TriggerQuickDrawSpell
,TriggerSecretRevealSpell
,TriggerSecretSpell
,UseHeroPowerSpell
,ValueToHowManySpell
,VohkrovanisSpell
,VolatileWisdomSpell
,WeaponOnEquipEffectSpell
,WeaponOnUnEquipEffectSpell
,WitherSpell
,YaganLifetakerSpell
Spell in this context means something broader than a spell card. It refers to anything that causes changes to the game, like a deathrattle or a triggered effect.
To browse all the possible effects, visit the deriving classes of this class.
These classes are the value for SpellArg.CLASS
, i.e., what you write after "class": ...
in the card
JSON for spell objects. Each string in the "class"
values corresponds exactly to a subclass of this class.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Casts a spell for the given arguments.protected void
castForPlayer
(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) Casts this spell on behalf of the specified player to the specified target.protected void
checkArguments
(org.slf4j.Logger logger, GameContext context, Entity source, SpellDesc desc, SpellArg... validArgs) Allows an implementation to log when it encounters unexpected arguments.getDesc()
protected boolean
Indicates this instance uses Java field memory to maintain state instead ofGameContext
memory like the environment or entities.protected abstract void
Implementations ofonCast
are the meat-and-bones of a spell's effects.void
toString()
-
Constructor Details
-
Spell
public Spell()
-
-
Method Details
-
cast
public void cast(GameContext context, Player player, SpellDesc desc, Entity source, List<Entity> targets) Casts a spell for the given arguments.If there is at least one valid target in
targets
andSpellArg.RANDOM_TARGET
istrue
, a single target from the list will be chosen at random.If
targets
isnull
, this is a spell that does not ordinarily receive targets, so it will be cast once.If
targets.size()
is0
, this spell takes targets but none were found, so the spell is not cast.The
EntityFilter
specified inSpellArg.FILTER
is applied to the list of targets to filter it. Therefore, this spell casting code is responsible for interpreting theSpellArg.FILTER
andSpellArg.RANDOM_TARGET
attributes of aSpellDesc
.Typically the
targets
list is generated by either using the player's single target choice from a combination of the spell or battlecry'sTargetSelection
applied through aSpellArg.FILTER
(resulting in a list of length one), or the resolvedSpellArg.TARGET
predefined target reference (usually a group reference) resulting in a list of length zero or greater.- Parameters:
context
- The game contextplayer
- The casting player. This can be overridden by theSpellArg.TARGET_PLAYER
arg in thedesc
.desc
- The spell descriptionsource
- The source entity of this spell casttargets
- A list of targets- See Also:
-
castForPlayer
protected void castForPlayer(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) Casts this spell on behalf of the specified player to the specified target.When
TargetPlayer.BOTH
is specified by theSpellArg.TARGET_PLAYER
in thedesc
, this effect occurs twice: first for the initiating player and then for that player's opponent.- Parameters:
context
-player
-desc
-source
-target
-
-
onCast
protected abstract void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) Implementations ofonCast
are the meat-and-bones of a spell's effects. This should actually call a variety of methods inGameLogic
, generate cards usingSpellUtils.getCards(GameContext, Player, Entity, Entity, SpellDesc)
, interpretSpellArg
keys in thedesc
, etc.Observe that subclasses of
Spell
mostly just need to implement this function. Also, observe that instances ofSpell
are stateless: all the state is provided as arguments to this function.- Parameters:
context
- The game contextplayer
- The casting playerdesc
- The collection ofSpellArg
keys and values that are interpreted by the implementation of this function to actually cause effects in a gamesource
- The entity from which this effect is happening (typically a card or a minion if it's a battlecry).target
- The particular target of this invocation of the spell. When a spell hits multiple targets, like an AoE damage effect, this method is called once for each target in the list of targets.- See Also:
-
toString
-
checkArguments
protected void checkArguments(org.slf4j.Logger logger, GameContext context, Entity source, SpellDesc desc, SpellArg... validArgs) Allows an implementation to log when it encounters unexpected arguments.- Parameters:
logger
- The logger to print tocontext
- The context whoseGameContext.getGameId()
will be used to mark the logsource
- The source of this calldesc
- The description used in this callvalidArgs
- The valid arguments
-
setDesc
-
getDesc
-
isNativeStateful
protected boolean isNativeStateful()Indicates this instance uses Java field memory to maintain state instead ofGameContext
memory like the environment or entities.- Returns:
-