Sorcerers design

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(Solution to sorcerer design)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Warwick Irwin)
 
(3 intermediate revisions by 3 users not shown)
Line 18: Line 18:
 
* Making a spell involves several phases: preparation, overture, invocation, execution, sacrifice, and closure. Some of these may be omitted in particular spells.
 
* Making a spell involves several phases: preparation, overture, invocation, execution, sacrifice, and closure. Some of these may be omitted in particular spells.
 
* Any sorcerer becomes a necromancer when they have the power to raise dead spirits. A corpse reanimated this way can appear just like a normal human, but works differently internally.
 
* Any sorcerer becomes a necromancer when they have the power to raise dead spirits. A corpse reanimated this way can appear just like a normal human, but works differently internally.
 
== Solutions ==
 
Here are the patterns I could find in about half an hour. Note that the design isn't complete. --[[User:TobiW|TobiW]]
 
* Decorator: Necromancer ability
 
* Strategy: Spells
 
* State: Curses casted on victims
 
* Flyweight: Using spells more efficiently
 
* Observer: Spell tells victim what happens to him/her (wait for full moon, ...)
 
[[Image:TobiWSorcerersDesign.png]]
 

Latest revision as of 03:11, 25 November 2010

An OO model of sorcerers. This question appeared in the 2005 427 exam.

Requirements Statement

Using good OO and as many design patterns and maxims (etc) as possible, produce a design for the following requirements:

  • This system models sorcerers, such as witches and warlocks, and their victims.
  • Sorcerers are practitioners of magic, and are not human.
  • Victims are human (and not magic).
  • Witches are female and ride brooms. Warlocks are male and ride pitchforks.
  • Sorcerers cast magic spells; different sorcerers know different spells. They can learn and forget spells, but when they know a spell they can cast it as much as they like.
  • Warlocks have no magic powers of their own, but can steal from witches the power to cast spells.
  • Warlocks are usually male witches, but some are wizards that turned evil.
  • Princes and princesses are common victims, and are often turned into frogs or put to sleep for 100 years.
  • Spells can be undone by counterspells, or by some event such as being kissed by a princess.
  • Some spells don’t take effect until a specific event occurs (possibly recurrently), such as a full moon or when the victim tells a lie. A regression spell, for example, is triggered by some event, and changes the victim back to what they were like at the time the spell was cast.
  • The evil eye can be cast only by females. It can cause bad luck, disease, or even death, depending on the power of the sorcerer.
  • Victims can be protected from some spells by talismans, e.g. a person might wear the hand of Fatima to ward off the evil eye.
  • Making a spell involves several phases: preparation, overture, invocation, execution, sacrifice, and closure. Some of these may be omitted in particular spells.
  • Any sorcerer becomes a necromancer when they have the power to raise dead spirits. A corpse reanimated this way can appear just like a normal human, but works differently internally.
Personal tools