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
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull SpellDesc@NotNull SpellDescclone()booleanString[]getCards()@NotNull CardListgetFilteredCards(GameContext context, Player player, Entity host) Uses theSpellArg.CARD_FILTERandSpellArg.CARD_SOURCEto generated a list of filtered cards.intgetSpell()inthashCode()booleanstatic @NotNull SpellDescJoins a spell description with another spell using aMetaSpell.@NotNull SpellDescvoidsetTarget(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, setDescMethods inherited from class java.util.EnumMap
clear, containsKey, containsValue, entrySet, get, keySet, putAll, remove, size, valuesMethods inherited from class java.util.AbstractMap
isEmptyMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.demilich.metastone.game.cards.desc.HasEntrySet
bfs, entrySetMethods 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:
getDescImplClassin classDesc<SpellArg,Spell>
-
getClassArg
- Specified by:
getClassArgin 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.TARGETandSpellArg.RANDOM_TARGETattributes to put into theMetaSpell.childSpells- The spells that will occur after themasterSpellis casted.- Returns:
- A new
SpellDesc, or aNullSpellspell desc if all the inputs were null.
-
getCardFilter
-
getCardSource
-
getFilteredCards
Uses theSpellArg.CARD_FILTERandSpellArg.CARD_SOURCEto generated a list of filtered cards.When
SpellArg.CARD_FILTERis not specified, a filter that always returnstrue(i.e., selects all cards) is used.When
SpellArg.CARD_SOURCEis not specified, aCatalogueSourceusing the currentDeckFormatis 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:
tryCreatein interfaceAbstractEnchantmentDesc<Aftermath>
-