User:AVS/Spellcasting

From VCMI Project Wiki
< User:AVS
Revision as of 17:09, 10 March 2014 by AVS (talk | contribs) (Spell)
Jump to: navigation, search

Entities

Caster

  1. Hero
  2. Creature
  3. Artifact
  4. (*) Scriptable virtual. Fully customizable by scripts.

Magic resource

Encapsulates remaining casts or mana.

  1. constructs with type (CASTS or MANA) and initial amount.
  2. 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)

Target

  1. Object - any object in adv map. (f.e. scuttle boat).
  2. (?)Tile - any tile on map (f.e. DD)
  3. Battle creature
  4. Battle obstacle
  5. Battle hex
  6. (*) 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.

ISpellTarger - 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 or synthetic object (???) in case of targets like "battle hex".

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

  1. CSpellInfo - proxy class. Constructs from TSpell.
  • (+) more readable
  • (+) low coupling

OO design version

  1. CSpell -
  2. CSpellHandler
  • (+) current version
  • (-) higher coupling

GUI related interface

used by GUI

  • animation
  • sound
  • description for spellbook
  • icon for spellbook, scroll etc.
  • (+) inherit all from common interface.

OO design version with proxy

  1. SpellView - proxy class. Header file public.
  2. 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]

Spell Format