How to implment the database for event conditions and item bonuses for a browser based game

Posted by Saifis on Game Development See other posts from Game Development or by Saifis
Published on 2011-03-04T07:46:58Z Indexed on 2011/03/04 15:34 UTC
Read the original article Hit count: 287

I am currently creating a browser based game, and was wondering what was the standard approach in making diverse conditions and status bonuses database wise. Currently considering two cases.

  • Event Conditions
    1. Needs min 1000 gold
    2. Needs min Lv 10
    3. Needs certain item.
    4. Needs fulfillment of another event
  • Status Bonus
    1. Reduces damage by 20%
    2. +100 attack points
    3. Deflects certain type of attack

I wish to be able to continually change these parameters during the process of production and operation, so having them hard-coded isn't the best way.

All I could come up with are the following two methods.

Method 1 Create a table that contains each conditions with needed attributes

Have a model named conditions with all the attributes it would need to set them

 conditions
   condition_type (level, money_min, money_max item, event_aquired)
   condition_amount
   prerequisite_condition_id
   prerequisite_item_id

Method 2 write it in a DSL form that could be interpreted later in the code

Perhaps something like yaml, have a text area in the setting form and have the code interpret it.

condition_foo:
  condition_type :level
    min_level: 10
  condition_type :item
    item_id: 2

At current Method 2 looks to be more practical and flexible for future changes, trade off being that all the flex must be done on the code side.

Not to sure how this is supposed to be done, is it supposed to be hard coded? separate config file? Any help would be appreciated.

Added

For additional info, it will be implemented with Ruby on Rails

© Game Development or respective owner

Related posts about design-patterns

Related posts about databases