The model is a maze, a rectangular grid of one to sixteen deviously configured rooms. Each room is configured with zero to four doors that lead to neighboring rooms to the North, East, South, and West. A room may be occupied by zero or more players. Initially, a player occupies the room in the North-West corner of the maze and his health is 100%. Upon entering a room, a player's health is decremented by the room's deviously chosen penalty (note: penalties may be negative, too). When a player's health reaches zero, he dies and is removed from the maze. Each time a player unsuccessfully attempts to leave a room (for example, by moving North in a room that has no door leading to its Northern neighbor,) his health is again decremented by the room's penalty. One room in the maze contains a treasure. A player conquers the maze if he manages to enter the room containing the treasure without dying. In this case the player's score is his health plus the amount of treasure hidden in the room. The current highest score, together with the name of the player who achieved it, is stored as a maze attribute.
Suggestions: Implement the maze as a map consisting of 1 to 16 rooms indexed by unique identification numbers. Mazes, rooms, and players are entities. How will you make them persistent? Database? Static variable? Context?
The presentation tier of Maze Challenge employs the Service-to-Worker design pattern. A front controller receives from a player one of the following commands: N, E, W, S. The front controller uses either a cookie or a session object to determine where the player is currently located in the maze, moves the player to the specified neighboring room in the maze (if possible,) then updates the player's health. Finally, the front controller dispatches to a view that describes the room the player has just entered. The front controller accesses the maze through a DAO object.
An initial maze view is presented to players who do not currently occupy any room in the maze. This view describes the maze, the rules of the game, the current high score, and the player who achieved it. A form allows the user to specify his name and description.
A room view displays:
1. A
description of the room.
2. An indicator that displays the player's health.
3. A form that allows the player to submit a command to the front controller.
You may be creative in step 1, but at least you should print the room's description and penalty attributes.
A victory view displays a congratulatory message and the player's final score.