Taken and slightly adapted from the book:

Braude, E., “Software Engineering - An Object Oriented Perspective”, John Wiley and sons, 2001

 

Software Design Document for Role-Playing Game Framework

History of versions of this document.

NN/NN/NN K. Peters: Initial draft

NN/NN/NN K. Peters: Refined; Layout package modified extensively

NN/NN/NN E. Braun: reviewed

NN/NN/NN K. Peters Revised, incorporating comments by R. Bostwick

NN/NN/NN K. Peters: moved details of classes to section 3

5. May 2000 Update: Eric Braude and Tom van Court.  Reworked to reflect lessons learned by implementing previous version.

25. July 2004 Update: Živana Komlenov (Novi Sad) analysed the document and removed remarks for students and other comments. There is also conclusion that there is no deviations from IEEE Std 1016-1998 (Revision of IEEE Std 1016-1987) Recommended Practice for Software Design.

1. Introduction

1.1 Purpose

This document describes the packages and classes of a framework for role-playing video games.

1.2 Scope

This framework covers essentials of role-playing game classes. Its main intention is to provide an example of a framework for educational purposes. It is not intended as a framework for commercial games since its size is kept small to facilitate learning.

1.3 Definitions, acronyms and abbreviations

Framework: a collection of interrelated classes used, via inheritance or aggregation, to produce families of applications

RPG: Role-playing game - a video game in which characters interact in a manner which depends on their characteristics and their environment

2. References

Braude, E. J., Software Engineering: an Object-oriented perspective

UML: The Unified Modeling Language User Guide by G. Booch, J. Rumbaugh and I. Jacobson, Addison-Wesley Pub Co; ISBN: 0-201-57168-4

IEEE standard 1016-1987 (reaffirmed 1993) guidelines for generating a Software Design Document

3. Decomposition description

3.1 Module decomposition

The framework consists of the RolePlayingGame, Characters, Artifacts, and Layout packages. These are decomposed into the classes shown in figure 5.48.

 

Figure 5.48 RPG Framework for Role-Playing Video Games

The classes in these packages are explained below. Unless otherwise stated, all classes in these packages are public. As indicated by the (UML) italics notation, all of the framework classes are abstract.

3.1.1 RolePlayingGame package

This package is designed as a state-transition machine. The concept is that a role-playing game is always in one of several states. This package makes it possible to describe the possible states of the game, and the actions that can take place in response to events.  It implements the State design pattern (see [Ga]). The state of the game is encapsulated (represented) by the particular GameState object aggregated by the (single) RPGame object. This aggregated object is named state. In other words, state is an attribute of RPGame of type GameState

The function handleEvent() of RPGame is called to handle each event occurring on the monitor (mouse clicks etc.). It executes by calling the handleEvent() function of state. The applicable version of handleEvent() depends on the particular subclass of GameState that state belongs to.

3.1.2 Characters package

This package contains the GameCharacter class, which describes the characters of the game.

3.1.3 GameEnvironment package

This package describes the physical environment of the game. Each connection object aggregates the pair of GameArea objects which it connects. This architecture allows for multiple connections between two areas. 

Each GameArea object aggregates the game characters that is contains (if any), and can detect encounters among characters.

3.1.4 Artifacts package [Not implemented -- for future releases]

This package is intended to store elements that are to be located in areas, such as trees or tables, and entities possessed by characters, such as shields and briefcases.

3.2 Concurrent process decomposition

The framework does not involve concurrent processes.

4. Dependency description

The only dependency among the framework modules is the aggregation by GameArea of GameCharacter.

5. Interface description

All classes in these packages are public, and thus the interfaces consist of all of the methods in their classes.

6. Detailed design of Role-Playing Game Framework

6.1 Module detailed design

6.1.1 Role-playing game package

All mouse events are listened for by objects of the class RPGMouseEventListener, which inherits from MouseListener, as shown in figure 6.50.

Figure 6.50 Detailed Design of RPGame (Role-Playing Game)Package

Each object which is sensitive to mouse events asks an RPGame object to handle the event. RPGame passes control to the handleEvent() method of its aggregated GameState object. The sequence diagram for this is shown in figure 6.51.

Figure 6.51 Sequence Diagram for Handling Mouse Events

For the current release, the methods are either trivial, or are shown in the figure.

6.2.1 The Characters package

This section elaborates on section 3.1.2 of this SDD.

There is one class in the Character package: GameCharacter.

6.2.1.1 GameCharacter class

Methods of GameCharacter

setName().

Preconditions: none; Postconditions: none; Invariants: none

Its pseudocode is as follows. 

IF aName parameter OR maxNumCharsInName() make no sense

Set name to default value and show this in system window

ELSE

IF parameter string too long

truncate at maxNumCharsInName()

ELSE assign the parameter name

6.2.1 The GameEnvironment package

This package is described completely in section 3.1 of this SDD.

6.2.1 The Artifacts package

[Not applicable in this iteration.]