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

Why I stopped publishing blog posts as information provider

Now the AI can generate content. Does that mean the web publishing industry reaches the end? ChatGPT said: ChatGPT Not at all. While AI can ...