Thursday, May 21, 2009

Model a fighter's conditions with OBSERVER design pattern

Below you will find classes and interfaces for the conditions of a fighter during combat. You will find classes for events along with classes for conditions the fighters may have during a combat. Each event can cause many conditions to change, while each condition can be changed by many events during a combat.

Here we see one-to-many relationship. For example, an event of "get hit" can cause energy, power, speed, looking and other conditions to change; energy condition can be changed by events such as "get hit", "get inspired", "get rest". The thing that varies are the state of the events and the number and type of the conditions that get effected by a specific event. The thing that stay constant is a subject-observer relationship in the picture, therefore we abstract them into two interfaces: Observable and Observer.
Show   Hide

No comments:

Post a Comment

meta.ai impression

Meta.ai is released by meta yesterday, it is super fast you can generate image while typing! You can ask meta.ai to draw a cat with curvy fu...