Contains the logical pieces of an Amazing Quest game.

Structure

Game logic pieces

The following picture shows the structure of the game logic part of the package:

Only the containment of objects in other objects is drawn. The GameLogic object contains e.g. one Maze3D, which contains 100 MazeCorridor3D objects.

The most important class is GameLogic. There is always one GameLogic object that defines a complete Amazing Quest game. When a game is started, the game server creates such an object and distributes it to all the users and spectators of the game.

First of all, a GameLogic object contains all the users in a game (as GameUser objects) in a GameUserList. Users are the people that are activily playing the game, they participate in it. Second, it contains the spectators of a game (as GameSpectator objects) in a GameSpectatorSet. Spectators are people that are just watching the game.

Each user has a Mission to accomplish: the collection of a certain amount of Treasure objects. Every time a user collects a treasure, he puts it in his Backpack. The user that collects all the treasures in his mission wins the game.

The game itself takes place in a 3 dimensional maze (the Maze3D object). This maze can be visualized as a grid, in which each cell is a MazeCorridor3D object. These objects have a certain position (MazePosition3D) and 2D orientation (Orientation2D). Think of it as standard building blocks (corners, crossings etc.) that can be placed in 4 different orientations (facing north, east, south or west). These blocks together form the maze. Each of these corridors can contain a treasure, which the users have to find.

Some parts of the game can be selected by users. These object implement the Selectable interface (not drawn) and contain a SelectionState object.

Communication

The following picture shows the structure of the communication parts in this package:

Communication between the clients and the server is done with GameMessage objects. There are a lot of game messages, which are all subclasses of GameMessage itself. For the protocol, see {@link quest.global.game.GameMessage}.

One of the game message is GameMessage.Gamemove. These messages all contain one game move. A game move is some basic action a user can do, such as walking to a new location in the maze or picking up a treasure. All these action are defined as subclasses of GameMove. Playing the game now involves:

  1. The user who's turn it is initiates an action by using the interface of the game
  2. The interface then changes something in the logical part of the game
  3. This triggers some code in that logical part that builds a game move
  4. This game move is sent to the central server, which puts it in the GameLogic object it maintains for each running game.
  5. When the move is valid, the game server distributes the received move to all the users and spectators of the game
  6. Each person receives the GameMove and puts it in his GameLogic object.
  7. The interface reacts to this change by displaying the new game state
In this way, a user can never cheat by hacking a client, because his invalid moves won't be accepted by the server. This scheme also makes it very easy to expand the game and define new moves, since this doesn't affect the design of the game server at all.