I'm new in OOD and I don't really know how to handle the spell-casting mechanism which i want to implement in my game.
- I want to produce following classes
Team,Actor,Spelland interfaceSpellEffect - Actor can cast spells on other actors however the spell can have different behaviour while being casted on allies and enemies ( ally is an actor from the same team )
I tried this way:
- I implement
SpellEffectinDamaging,Stunning,Healingclasses which overridesexecuteOn(Actor a) - In
Spellclass I have two lists ofSpellEffect- one for allies and second for enemies so in the Spell class I need to know is the attacked actor is and ally or enemy of the caster -
I was thinking about StrategyPattern for spell so I can do something like this:
actor.setCastingStrategy( new TargetingAllyStrategy() ) -
Strategies would be then something like:
execute a spell on the targeted actor using `Spells`'s `allyCast()` method
However I'm not sure about passing Actor object to the lower level object. Moreover what if not every actor can be stunned? Should I make any inherited class UnstunnableActor ? Or maybe use instanceOf to check implemented interfaces. I'm pretty new in the topic so any help would be great.
Aucun commentaire:
Enregistrer un commentaire