# 1 Introduction

## 1.1 Purpose
This specification establishes the requirements for the product named Qheadache. The intended audience is the analyst, programmer, and tester of Qheadache.

## 1.2 Scope
The product is a computerized game that displays an interface used to solve a specific headache.

## 1.3 Product overview

### 1.3.1 Product perspective
The product runs as a stand-alone application.

#### System interfaces
[N/A]

#### User interfaces
The product's user interface uses menus, graphics, and sounds. It generally requires a mouse and a keyboard for input. Other pointing and input devices are allowable, provided they provide similar functions to a mouse and keyboard, namely the ability to move a cursor onscreen to select buttons and the ability to type names.

The main window shall provide the following parts:
*   A board
*   A menu bar

#### Hardware interfaces
The product requires the use of a keyboard and a mouse to interface with the user. It requires a graphical display of at least 800x600 resolution. The hardware must provide an 800x600 screen resolution.

#### Software interfaces
The product uses the Qt graphical library. It must run with all the operating systems that Qt supports.

#### Communications interfaces
[N/A]

#### Memory constraints
[N/A]

#### Operations
[N/A]

#### Site adaptation requirements
[N/A]

#### Interfaces with services
[N/A]

### 1.3.2 Product functions
The major functions the software will perform include:
*   Undo and Redo actions for user movements.
*   Counting and displaying the time the user spends playing.
*   Counting and displaying the number of user actions.
*   Recording the score (time and number of counts) of a play associated with a user's name.
*   Displaying a window with all recorded player scores.

### 1.3.3 User characteristics
No specific qualification is necessary for users. The users consist of anyone who wants to play a simple game who knows how to operate a computer, with a beginning level player starting at age 8, up through an advanced level player who could be an adult.

### 1.3.4 Limitations
*   There can be only one user per machine.
*   The product does not support communication interfaces.
*   The product does not have specific memory constraints beyond what is required by the operating system and Qt library.
*   Sound is not required to play the game.

## 1.4 Definitions
[N/A]

# 2 References
[N/A]

# 3 Requirements

## 3.1 Functions

### 3.1.1 Actions

#### 3.1.1.1 Presentation of the board
The board is a rectangular zone where the user could move some blocks. Let x be the measure unit. The height of the board game is 5x, its width is 4x. x cannot be less than 50 pixels and greater than 100 pixels. The blocks are separated by a margin of 0.1x.
There are four square blocks with a side of x.
There are four rectangular blocks with the following dimensions: a height of 2x and a width of x.
There is one block with the following dimensions: a height of x and a width of 2x.
There is one square block with a side of 2x.
The board is black and the blocks are yellow.

#### 3.1.1.2 Block selection
*   **Description:** The user can select a block on the board.
*   **Input:** Left-clicked down on a block.
*   **Processing:** The game state becomes "Block deplacement".
*   **Output:** None.

#### 3.1.1.3 Block deselection
*   **Description:** The user can deselect a previously selected block.
*   **Input:** Left-clicked up on a selected block.
*   **Processing:** The game state becomes "Block selection".
*   **Output:** None.

#### 3.1.1.4 Block movement
*   **Description:** The user can move a selected block.
*   **Input:** Mouse movement during the "Block movement" state.
*   **Processing:** The selected block follows the mouse movement without overlapping other blocks and without exiting the game zone. The selected block cannot move near other blocks at least 0.05x from the others blocks.
*   **Output:** None.

#### 3.1.1.5 Undo Action
*   **Description:** The user can cancel a movement.
*   **Input:** Menu selection.
*   **Processing:** The game displays the block positions at the places where they were before the last movement. This action is considered a movement. The "undo" action is unavailable if there was no previous movement.
*   **Output:** New game board display.

#### 3.1.1.6 Redo Action
*   **Description:** The user can redo a movement that has been canceled.
*   **Input:** Menu selection.
*   **Processing:** The game displays the block positions at the places where they were before the last movement was canceled. This action is considered a movement. The redo action is unavailable if the previous action wasn't an "undo" action.
*   **Output:** New game board display.

### 3.1.2 End of the game management

#### 3.1.2.1 End of the game
*   **Description:** How the user finishes the game.
*   **Input:** The great square is moved at the bottom of the board.
*   **Processing:** All the player statistics are frozen.
*   **Outputs:** If the number of block movements of the current player is lower than the highest number of block movement recorded in the statistic file, the "Finish Window with Statistics" is displayed. If not, the "Simple finish Window" is displayed.

#### 3.1.2.2 Finish Window with Statistics
*   **Description:** The Finish Window with Statistics contains the text: "You win! Enter your name:", an Edit Box that can contain 20 characters, and a pushbutton with the label "OK".
*   **Input:** The game is over.
*   **Processing:** The player clicks on the pushbutton "OK". The player statistics are recorded in the statistic file of the software.
*   **Outputs:** The "finish" window is closed. The statistic window is displayed.

#### 3.1.2.3 Simple Finish Window
*   **Description:** The Simple Finish Window contains the text: "You win!" and a pushbutton with the label "OK".
*   **Input:** The game is over.
*   **Processing:** The player clicks on the pushbutton "OK".
*   **Outputs:** The Simple Finish Window is closed. The statistic window is displayed.

### 3.1.3 Statistics Management

#### 3.1.3.1 Player Statistics management
*   **Description:** The following statistics are recorded during the game: number of block movements since the start, time since the start.
*   **Input:** A block movement.
*   **Processing:** The number of block movements is incremented by 1. The difference of time of the block movement and the previous recorded time is recorded.
*   **Output:** None.

#### 3.1.3.2 Game Statistics management
*   **Description:** The game statistics are composed of 10 player statistics.
*   **Input:** The Finish Window with Statistics is completed by the player.
*   **Processing:** The statistics of the player (its name, the block movement number, the time passed to solve the headache) are recorded in the statistic file. If 10 player statistics are already recorded, the player statistics of the file with the greatest number of block movements are erased.
*   **Output:** If the file was correctly updated, there is no output. If not, like wrong permissions or disk full, an error message is displayed.

#### 3.1.3.3 Statistics erasing
*   **Description:** The user can erase all the statistics.
*   **Input:** Menu selection.
*   **Processing:** The data stored in the statistic file are erased.
*   **Output:** If the file was correctly updated, there is no output. If not, like wrong permissions or disk full, an error message is displayed.

#### 3.1.3.4 Statistic Window
*   **Description:** The Player Statistics Window is composed of a listbox of 10 lines. Each line is composed of the name of a player, the number of block movements, and the time used by the player to solve the headache. These statistics are read from the statistic file of the game.
*   **Input:** End of the game or menu selection.
*   **Processing:** Window display.
*   **Output:** None.

### 3.1.4 File management

#### 3.1.4.1 Open game
*   **Description:** Open a previously saved game.
*   **Input:** Menu selection.
*   **Processing:** A dialog box is opened: the user can choose a file that contains all the data of the game previously saved.
*   **Output:** The board game is redrawn according to the file data. The player statistics are set to the player statistics of the file data.

#### 3.1.4.2 Save game
*   **Description:** Save the current game.
*   **Input:** Menu selection.
*   **Processing:** If the game was never saved, the processing is identical to the action "Save as...". If not, the following internal data are saved into the previous file that was used to save the game: the current positions of the blocks, their last 10000 previous positions, the number of the previous movements, and the time passed by the user to solve the headache.
*   **Output:** None.

#### 3.1.4.3 Save game as
*   **Description:** Save the current game to a new file.
*   **Input:** Menu selection.
*   **Processing:** A dialog box is opened: the user can choose a file that will contain all the data of the current game. Next, the following internal data are saved into the file: the current positions of the blocks, their previous positions, the number of the previous movements, and the time passed by the user to solve the headache.
*   **Output:** None.

#### 3.1.4.4 Exit
*   **Description:** Stop the game.
*   **Input:** Menu selection.
*   **Processing:** If the game is not saved, a dialog box is displayed that asks the player if they want to save the game. Two choices are possible: "Yes" and "No". If "Yes" is selected, the action "Save" is processed and the main window disappears. If "No" is selected, the main window disappears.
*   **Output:** None.

### 3.1.5 Menu bar

#### 3.1.5.1 Game menu
*   **Description:** Contains "Open game ...", "Save Game ...", "Save Game As...", and "Exit", in this order.
*   **Input:** Menu selection.
*   **Processing:** The selected action is performed:
    *   "Open game ..." -> action "Open game"
    *   "Save Game ..." -> action "Save Game"
    *   "Save Game As ..." -> action "Save game as"
    *   "Exit" -> action "Exit"
*   **Output:** Menu disappears. Requirements of the action determine the continuation.

#### 3.1.5.2 Action menu
*   **Description:** Contains "Undo" and "Redo", in this order. The menu selection is unavailable if the associated action is unavailable.
*   **Inputs:** Menu selection.
*   **Processing:** The selected action is performed:
    *   "Undo" -> action "Undo"
    *   "Redo" -> action "Redo"
*   **Outputs:** Menu disappears. Requirements of the action determine the continuation.

#### 3.1.5.3 Statistics menu
*   **Description:** Contains "Display" and "Erase", in this order.
*   **Inputs:** Menu selection.
*   **Processing:** The selected action is performed:
    *   "Display" -> displays the statistic window
    *   "Erase" -> erases the statistics
*   **Outputs:** Menu disappears. Requirements of the action determine the continuation.

#### 3.1.5.4 Help menu
*   **Description:** Contains "About".
*   **Inputs:** Menu selection.
*   **Processing:** "About Window" is displayed. The "About Window" is composed of the text "Qheadache 1.0 by Jean-Philippe Brossat jp_brossat@yahoo.fr".
*   **Outputs:** Menu disappears. Requirements of the action determine the continuation.

## 3.2 Performance requirements
*   There can be only one user per machine.
*   The user must be able to undo and redo their last thousand actions.
*   The game statistics must store up to 10 player statistics.

## 3.3 Usability requirements
[N/A]

## 3.5 Logical database requirements
The software maintains player statistics and game state data.
*   **Player Statistics:**
    *   Types of information: Player name (up to 20 characters), number of block movements, time taken to solve the headache.
    *   Storage: Recorded in a statistic file.
    *   Capacity: Composed of 10 player statistics.
    *   Integrity: If 10 player statistics are already recorded, the player statistics with the greatest number of block movements are erased when a new, better score is achieved.
    *   Accessing: Displayed in a listbox of 10 lines in the Statistic Window.
    *   Retention: Data can be erased by user menu selection.
*   **Game State Data:**
    *   Types of information: Current positions of blocks, last 10000 previous positions of blocks, number of previous movements, time passed by the user.
    *   Storage: Saved to a user-chosen file.
    *   Accessing: Loaded from a user-chosen file to restore game state.

## 3.6 Design constraints
*   The product must use the Qt graphical library.
*   The product must run with all operating systems that Qt supports.
*   The board game dimensions are constrained: height is 5x, width is 4x, where x is a unit of measure between 50 and 100 pixels.
*   Blocks are separated by a margin of 0.1x.
*   A selected block cannot move closer than 0.05x from other blocks.

## 3.7 Software system attributes

### 3.7.1 Portability
The software must be portable to the Windows OS. It must run with all the operating systems that Qt supports.

### 3.7.2 Reliability
[N/A]

### 3.7.3 Availability
[N/A]

### 3.7.4 Security
[N/A]

### 3.7.5 Maintainability
[N/A]

## 3.8 Supporting information
The remaining sections of this document provide a general description, including characteristics of the users of this project, the product's hardware, and the functional and data requirements of the product. General description of the project is discussed in section 2 of this document. Section 2 gives the functional requirements, data requirements and constraints and assumptions made while designing the game. It also gives the user viewpoint of product use. Section 3 gives the specific requirements of the product. Section 3.0 also discusses the external interface requirements and gives detailed description of functional requirements.

# 4 Verification

## 4.1 Functions
[N/A]

## 4.2 Performance requirements
[N/A]

## 4.3 Usability requirements
[N/A]

## 4.5 Logical database requirements
[N/A]

## 4.6 Design constraints
[N/A]

## 4.7 Software system attributes
[N/A]

# 5 Appendices

## 5.1 Assumptions and dependencies
[N/A]

## 5.2 Acronyms and abbreviations
[N/A]