Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > cant find a pattern to fit neatly - how to make a large number of monsters?

Thread Tools

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

steve mathers
Posts: n/a
Hi , fairly new to OO design. Trying to solve a 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

* 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

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?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
cant find a pattern to fit neatly - how to make a large number of monsters? steve mathers Java 15 02-03-2005 02:12 PM
Make wxListCtrl fit around contents and parent frame fit around listctrl Piet Python 0 07-18-2004 08:27 AM
Neatly truncating text to fit a physical dimension Geoff Soper Javascript 2 01-26-2004 08:03 PM
Backup your projects neatly Guy C++ 2 10-03-2003 04:40 AM