Class SpellDesc
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<SpellArg,
,Object> HasDesc<Desc<SpellArg,
,Spell>> HasEntrySet<SpellArg,
,Object> AbstractEnchantmentDesc<Aftermath>
- Direct Known Subclasses:
LambdaSpellDesc
A spell description has a variety of arguments of type SpellArg
. Each SpellArg
is transformed into a
"camelCase" form and become the keys of the JSON version of an instance.
For example, the following JSON implements the spell effect, "Summon a Bloodfen Raptor. Summon an extra one for each attack your Hero has.":
{ "class": "SummonSpell", "card": "minion_bloodfen_raptor", "value": { "class": "AttributeValueProvider", "target": "FRIENDLY_HERO", "attribute": "ATTACK", "offset": 1 } }This JSON would deserialize into a
SpellDesc
instance that would equal the following code:
final Map<SpellArg, Object> arguments = SpellDesc.build(SummonSpell.class);
arguments.put(SpellArg.CARD, "minion_bloodfen_raptor");
final Map<ValueProviderArg, Object> valueProvider = ValueProviderDesc.build(AttributeValueProvider.class);
valueProvider.put(ValueProviderArg.TARGET, EntityReference.FRIENDLY_HERO);
valueProvider.put(ValueProviderArg.ATTRIBUTE, Attribute.ATTACK);
valueProvider.put(ValueProviderArg.OFFSET, 1);
arguments.put(SpellArg.VALUE, new ValueProviderDesc(valueProvider).createInstance());
SpellDesc spellDesc = new SpellDesc(arguments);
Notice that the keys of the objects in the JSON are transformed, "camelCase", from the names in the enum
in
SpellArg
.
Deathrattles
This class also describes an actor's deathrattle.
The spell here is cast with the dying minion as the source
(e.g., EntityReference.SELF
will refer to the now-destroyed minion).
Deathrattles are resolved whenever an actor is destroyed before an GameLogic.endOfSequence()
occurs, which is
generally at the end of any action besides discovering.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> Nested classes/interfaces inherited from interface net.demilich.metastone.game.cards.desc.HasEntrySet
HasEntrySet.BfsEnum, HasEntrySet.BfsNode<T extends Enum,
V> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull SpellDesc
@NotNull SpellDesc
clone()
boolean
String[]
getCards()
@NotNull CardList
getFilteredCards
(GameContext context, Player player, Entity host) Uses theSpellArg.CARD_FILTER
andSpellArg.CARD_SOURCE
to generated a list of filtered cards.int
getSpell()
int
hashCode()
boolean
static @NotNull SpellDesc
Joins a spell description with another spell using aMetaSpell
.@NotNull SpellDesc
void
setTarget
(EntityReference target) spellStream
(boolean includeThis) spellStream
(int depth) spellStream
(int depth, boolean includeThis) subSpells
(int depth) toString()
tryCreate
(GameContext context, Player player, Entity effectSource, Card enchantmentSource, Entity host, boolean force) Methods inherited from class net.demilich.metastone.game.cards.desc.Desc
copyTo, create, getBool, getDesc, getDescClass, getInt, getString, getValue, put, setDesc
Methods inherited from class java.util.EnumMap
clear, containsKey, containsValue, entrySet, get, keySet, putAll, remove, size, values
Methods inherited from class java.util.AbstractMap
isEmpty
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.demilich.metastone.game.cards.desc.HasEntrySet
bfs, entrySet
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
SpellDesc
public SpellDesc() -
SpellDesc
-
SpellDesc
public SpellDesc(Class<? extends Spell> spellClass, EntityReference target, EntityFilter filter, boolean randomTarget) -
SpellDesc
-
-
Method Details
-
getDescImplClass
- Specified by:
getDescImplClass
in classDesc<SpellArg,
Spell>
-
getClassArg
- Specified by:
getClassArg
in classDesc<SpellArg,
Spell>
-
addArg
-
removeArg
-
clone
-
getEntityFilter
-
getInt
-
getTarget
-
getTargetPlayer
-
hasPredefinedTarget
public boolean hasPredefinedTarget() -
toString
-
hashCode
public int hashCode() -
equals
-
setTarget
-
subSpells
-
subSpells
-
spellStream
-
spellStream
-
spellStream
-
spellStream
-
join
Joins a spell description with another spell using aMetaSpell
.- Parameters:
masterSpell
- The spell from which to inherit theEntityFilter
,TargetPlayer
,SpellArg.TARGET
andSpellArg.RANDOM_TARGET
attributes to put into theMetaSpell
.childSpells
- The spells that will occur after themasterSpell
is casted.- Returns:
- A new
SpellDesc
, or aNullSpell
spell desc if all the inputs were null.
-
getCardFilter
-
getCardSource
-
getFilteredCards
Uses theSpellArg.CARD_FILTER
andSpellArg.CARD_SOURCE
to generated a list of filtered cards.When
SpellArg.CARD_FILTER
is not specified, a filter that always returnstrue
(i.e., selects all cards) is used.When
SpellArg.CARD_SOURCE
is not specified, aCatalogueSource
using the currentDeckFormat
is assumed.When neither is specified, this method returns all
CardDesc.getCollectible()
cards in the given format.- Parameters:
context
- The game context to use for evaluating the card source and filter.player
- The player from whose point of view the card source and filter should be evaluated.host
- The host entity from whose point of view the card source and filter should be evaluated.- Returns:
- A possibly empty list of cards.
-
getAttribute
-
getSecondaryTarget
-
getSpell
-
getCards
-
tryCreate
public Optional<Aftermath> tryCreate(GameContext context, Player player, Entity effectSource, Card enchantmentSource, Entity host, boolean force) - Specified by:
tryCreate
in interfaceAbstractEnchantmentDesc<Aftermath>
-