Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualwqking

Posted 12 November 2012 - 02:27 AM

Separate item system and effect system, don't mix them up.

The effect system manages a collection of effects.
Each effect has a unique ID (the ID can be either string or integer, whatever), and implement an interface, e.g IEffect.
IEffect has a function, something like, void perform(Item * item);
When you add new effect, just implement IEffect and add the interface to effect system.

The item system manages a collection of items.
The items can be read from database, or added by code.
An item holds a collection of effect IDs.
When you want to do the effect, just ask the effect system with the effect ID, and the call IEffect::perform with the given item.

With this design, your item only knows an effect ID. It doesn't care what's the effect, or how effect works.

#1wqking

Posted 12 November 2012 - 02:25 AM

Separate item system and effect system, don't mix them up.

The effect system manages a collection of effects.
Each effect has a unique ID (the ID can be either string or integer, whatever), and implement an interface, e.g IEffect.
IEffect has a function, something like, void perform(Item * item);
When you add new effect, just implement IEffect and add the interface to effect system.

The item system manages a collection of items.
The items can be read from database, or added by code.
An item holds a collection of effect IDs.
When you want to do the effect, just ask the effect system with the effect ID, and the call IEffect::perform with the given item.

With this deisng, your item only knows an effect ID. It doesn't care what's the effect, or how effect works.

PARTNERS