Jump to content

  • Log In with Google      Sign In   
  • Create Account


vincero

Member Since 10 Nov 2012
Offline Last Active Nov 10 2012 03:29 PM
-----

Topics I've Started

Item system - design patterns

10 November 2012 - 04:35 AM

Hello,

I want to design an easily extensible item system for my game where I don't need to modify existing code much. I want to add items with new effects on the fly.

Traits my items have in common:

A name,
a description,
an npc sell price,
if it can be equipped,
required level,
if it is usable in battle,
if it is usable outside of battle,
a cooldown

So I can encapsulate this already into a class. But now there are item effects.

Example:
heals x health points,
heals x mana points,
removes debuff x,
adds buff x,
gives x stat points on equipping,
has x% chance to create some other effect when equipped,
etc.

And those can be combined like: heals x health and mana points. The first four are examples for effects a usable item can have while the last two are examples for effects equipable items can have.

The idea behind it is that I have this structure in a database as well and I can add a new item with a new effect combination in my database, my code reads this then and builds it together into a new fancy item, without me having to modify much. The only time I need to modify my code is when I add new effects obviously.

How would you put this together in design pattern(s)? I am writing my game in a language which has support for OO obviously.

PARTNERS