Difference between revisions of "User:AVS/Spellcasting"
From VCMI Project Wiki
< User:AVS
(→Configuration) |
|||
(17 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
# Hero | # Hero | ||
# Creature | # Creature | ||
+ | # Artifact | ||
# (*) Scriptable virtual. Fully customizable by scripts. | # (*) Scriptable virtual. Fully customizable by scripts. | ||
− | ISpellCaster - public interface. | + | === Magic resource === |
+ | Encapsulates remaining casts or mana. | ||
+ | |||
+ | # constructs with type (CASTS or MANA) and initial amount. | ||
+ | # Should it disclose actual type? | ||
+ | |||
+ | * '''bool canAfford(Spell*)''' | ||
+ | * '''si32 getBalance()''' (?) or maybe directly print to smth - actual amount is also detail | ||
+ | |||
+ | |||
+ | === Spellbook === | ||
+ | In (abstract) public interface provides access to all spells available for caster. | ||
+ | |||
+ | As concrete object in hero instance contains permanent spells aviable for caster. | ||
+ | |||
+ | |||
+ | === ISpellCaster - public interface. === | ||
+ | (Magic resource and Spellbook should be hidden) | ||
+ | * cast(Spell*, Target*) | ||
== Target == | == Target == | ||
Line 19: | Line 38: | ||
* (->) target selection configuration use selector semantic similar to bonus system. | * (->) target selection configuration use selector semantic similar to bonus system. | ||
− | + | === ISpellTarget - public interface. === | |
+ | |||
+ | * bool canBeTargetedBy(Spell*) //affects casting GUI and AI logic (client and server) - trying to cast spell to not possible target shall be recoverable error (no exceptions just log) | ||
+ | * bool isImmuneTo(Spell*) //affects mechanics processing (server side) | ||
+ | * void cast(Spell*) //apply spell effects (server side) | ||
+ | |||
+ | * TODO: resisting mirror etc | ||
== Spell == | == Spell == | ||
+ | |||
+ | * bool isImmuneBy(BonusBearer*) - should be called by target in '''isImmuneTo''' with ''this'' as parameter or isImmuneTo shall return false. | ||
+ | * bool canBeTargetedBy(BonusBearer*) - should be called by target in '''canBeTargetedBy''' with ''this'' as parameter if some bonus related mechanics should be involved - in such case target shall be Bearer. | ||
= Common interface = | = Common interface = | ||
Line 55: | Line 83: | ||
* description for spellbook | * description for spellbook | ||
* icon for spellbook, scroll etc. | * icon for spellbook, scroll etc. | ||
+ | * (+) inherit all from common interface. | ||
== OO design version with proxy == | == OO design version with proxy == | ||
Line 68: | Line 97: | ||
** set timed effects | ** set timed effects | ||
** adv map logic | ** adv map logic | ||
+ | |||
+ | = Configuration = | ||
+ | {{wip}} | ||
+ | |||
+ | Current version: [[Spell Format]] | ||
+ | |||
+ | Next version [[User:AVS/Spell Format Version2]] |
Latest revision as of 11:47, 11 March 2014
Entities
Caster
- Hero
- Creature
- Artifact
- (*) Scriptable virtual. Fully customizable by scripts.
Magic resource
Encapsulates remaining casts or mana.
- constructs with type (CASTS or MANA) and initial amount.
- Should it disclose actual type?
- bool canAfford(Spell*)
- si32 getBalance() (?) or maybe directly print to smth - actual amount is also detail
Spellbook
In (abstract) public interface provides access to all spells available for caster.
As concrete object in hero instance contains permanent spells aviable for caster.
ISpellCaster - public interface.
(Magic resource and Spellbook should be hidden)
- cast(Spell*, Target*)
Target
- Object - any object in adv map. (f.e. scuttle boat).
- (?)Tile - any tile on map (f.e. DD)
- Battle creature
- Battle obstacle
- Battle hex
- (*) Battle hero.
- there can be multiple targets.
- on adv map, if no target then it assumed hero itself (f.e. vision, viewXXX ).
- (->) target selection configuration use selector semantic similar to bonus system.
ISpellTarget - public interface.
- bool canBeTargetedBy(Spell*) //affects casting GUI and AI logic (client and server) - trying to cast spell to not possible target shall be recoverable error (no exceptions just log)
- bool isImmuneTo(Spell*) //affects mechanics processing (server side)
- void cast(Spell*) //apply spell effects (server side)
- TODO: resisting mirror etc
Spell
- bool isImmuneBy(BonusBearer*) - should be called by target in isImmuneTo with this as parameter or isImmuneTo shall return false.
- bool canBeTargetedBy(BonusBearer*) - should be called by target in canBeTargetedBy with this as parameter if some bonus related mechanics should be involved - in such case target shall be Bearer.
Common interface
Used by GUI, AI, (?) Server. Readonly.
Service-oriented design version
Use singleton Handler and methods accepting TSpell as first parameter.
- (+) script-frendly
- (+) low coupling
OO design version with proxy
- CSpellInfo - proxy class. Constructs from TSpell.
- (+) more readable
- (+) low coupling
OO design version
- CSpell -
- CSpellHandler
- (+) current version
- (-) higher coupling
used by GUI
- animation
- sound
- description for spellbook
- icon for spellbook, scroll etc.
- (+) inherit all from common interface.
OO design version with proxy
- SpellView - proxy class. Header file public.
- SpellViewHandler - singleton class (hidden) Header file private: used only by implementation of SpellView and CGI.
Server interface
used by server-side handlers
- applying effects
- do damage
- set timed effects
- adv map logic
Configuration
[WiP]
Current version: Spell Format
Next version User:AVS/Spell Format Version2