cant find a pattern to fit neatly - how to make a large number of monsters?

Discussion in 'Java' started by steve mathers, Jan 23, 2005.

  1. Hi , fairly new to OO design. Trying to solve a problem:

    problem:
    I want to make a large number of different monsters. what makes
    monsters different from each other is their 'abilities'. These could
    such things as carrying a weapon or magic item that allows them to
    perform an action, or something like an intrinsic resistance to attack
    with fire, or a temporary ability ability granted by a spell cast on
    them.

    * I want to be able to define different monster types and different
    ability types using as little memory as possible (mobile phone
    platform) - a hard coded table of abilities and then another table of
    monsters that lists which ability each monster has. Some sort of
    factory will have to create the monster given an index into this
    table. Thats not the hard part.

    * I want to be able to add new monsters and new abilities to the table
    without changing the inteface of the monster and ability class. I
    think this is the hard part.

    solution: At first thought, the decorator pattern seems right, but
    because abilities can come and go all the time, it seems to be
    unweildy.

    I think what I want to happen is that every time the monster has to do
    something that involves its characteristics which may be modified by
    abilities (such as fire resistance), or it wants to perform an
    optional action that an ability may bestow it with (such as hit
    something with a weapon), it should interogate its entire list of
    current abilities to see if they impact on that charicteristic or
    action. But how to structure that process in my design?

    Is there a particular pattern I should be looking at?

    thanks,

    Steve
    steve mathers, Jan 23, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steve mathers
    Replies:
    15
    Views:
    560
    Utilisateur PC Libre Service
    Feb 3, 2005
  2. Piet
    Replies:
    0
    Views:
    510
  3. Nagaraj
    Replies:
    1
    Views:
    842
    Lionel B
    Mar 1, 2007
  4. Ben Galyean

    Where did the monsters go?

    Ben Galyean, Apr 22, 2008, in forum: Ruby
    Replies:
    7
    Views:
    123
    Phlip
    Apr 23, 2008
  5. Geoff Soper
    Replies:
    2
    Views:
    142
    Lasse Reichstein Nielsen
    Jan 26, 2004
Loading...

Share This Page