# 1 Introduction
## 1.1 Purpose
This specifications 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. The main window shall provide a game board and a menu bar.

#### Hardware interfaces
The product requires the use of a keyboard and a mouse to interface with the user. Other pointing and input devices are allowable, provided they provide similar functions. The product requires a graphical display of at least 800x600 resolution. Sound is not required to play the game.

#### Software interfaces
The product uses the Qt graphical library.

#### 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 user must be able to undo and redo their last thousand actions.
*   The product must count and display the time that the user uses to play.
*   The product must count and display the number of the user's actions.
*   The product must record the score (time and number of actions) of a play associated with the name of a user.
*   The product must display a window with all the player's scores.

### 1.3.3 User characteristics
No qualification is necessary. 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.

## 1.4 Definitions
[N/A]

# 2 References
[N/A]

# 3 Requirements
## 3.1 Functions
### Game Board Presentation
The board is a rectangular zone where the user can move blocks. Let x be the measure unit, where x cannot be less than 50 pixels and greater than 100 pixels. The height of the board is 5x, and its width is 4x. The blocks are separated by a margin of 0.1x. The board is black and the blocks are yellow.

The board contains the following blocks:
*   Four square blocks with a side of x.
*   Four rectangular blocks with a height of 2x and a width of x.
*   One block with a height of x and a width of 2x.
*   One square block with a side of 2x.

### Block Actions
*   **Block Selection**: A block is selected when the user left-clicks down on it. The game state becomes "Block deplacement".
*   **Block Deselection**: A block is deselected when the user left-clicks up on a selected block. The game state becomes "Block selection".
*   **Block Movement**: When the mouse is moved while a block is selected, the block follows the mouse movement. The block cannot overlap other blocks or exit the game zone. The selected block cannot move nearer than 0.05x to other blocks.

### Undo and Redo Actions
*   **Undo Action**: The user can cancel the last movement via a menu selection. The game displays the block positions as they were before the last movement. This action is considered a movement. The "undo" action is unavailable if there was no previous movement.
*   **Redo Action**: The user can redo a movement that has been canceled via a menu selection. The game displays the block positions as they were before the last movement was canceled. This action is considered a movement. The "redo" action is unavailable if the previous action was not an "undo" action.

### End of Game Management
*   **End of Game Trigger**: The game ends when the large square block (2x by 2x) is moved to the bottom of the board. All player statistics are frozen.
*   **Finish Window with Statistics**: If the number of block movements of the current player is lower than the highest number of block movements recorded, this window is displayed. It contains the text "You win ! Enter your name : ", an edit box that can contain 20 characters, and an "OK" pushbutton. When the user clicks "OK", their statistics are recorded and the statistics window is displayed.
*   **Simple Finish Window**: If the player's score is not a high score, this window is displayed. It contains the text "You win !" and an "OK" pushbutton. When the user clicks "OK", the window closes and the statistics window is displayed.

### Statistics Management
*   **Player Statistics Tracking**: The number of block movements and the elapsed time are recorded during the game. Each block movement increments the movement count.
*   **Game Statistics Storage**: The game statistics file is composed of up to 10 player statistics. When a player achieves a high score, their name, block movement number, and time are recorded in the statistic file. If 10 statistics are already recorded, the entry with the greatest number of block movements is erased. An error message is displayed if the file cannot be updated.
*   **Statistics Erasing**: The user can erase all statistics via a menu selection. The data in the statistic file is erased. An error message is displayed if the file cannot be updated.
*   **Statistic Window**: This window displays a list of up to 10 player scores. Each line shows the player's name, number of block movements, and time used. This window is displayed at the end of a game or via a menu selection.

### File Management
*   **Open Game**: The user can open a previously saved game via a menu selection. A dialog box allows the user to choose a file. The game board and player statistics are restored from the file data.
*   **Save Game**: The user can save the current game via a menu selection. If the game has been saved before, the file is overwritten with the current block positions, the last 1000 positions, the number of movements, and the elapsed time. If the game has not been saved before, this action is identical to "Save game as".
*   **Save Game As**: The user can save the current game to a new file via a menu selection. A dialog box allows the user to choose a file name and location.
*   **Exit**: The user can stop the game via a menu selection. If the game is not saved, a dialog box asks the player if they want to save the game. If "Yes" is selected, the "Save" action is processed before the application closes. If "No" is selected, the application closes.

### Menu Bar
*   **Game Menu**: Contains menu items for "Open game ...", "Save Game ...", "Save Game As...", and "Exit".
*   **Action Menu**: Contains menu items for "Undo" and "Redo". These items are unavailable if the associated action is unavailable.
*   **Statistics Menu**: Contains menu items to "Display" the statistic window and "Erase" all statistics.
*   **Help Menu**: Contains an "About" menu item that displays a window with the text "Qheadache 1.0 by Jean-Philippe Brossat jp_brossat@yahoo.fr".

## 3.2 Performance requirements
There can be only one user per machine.

## 3.3 Usability requirements
[N/A]

## 3.5 Logical database requirements
*   **Game Statistics File**: The application shall maintain a file to store game statistics. This file contains up to 10 entries. Each entry consists of a player's name (up to 20 characters), the total number of block movements, and the total time passed to solve the game.
*   **Saved Game File**: The application shall be able to save the state of a game to a file. This file must store the current positions of all blocks, their last 1000 previous positions, the current number of movements, and the current elapsed time.

## 3.6 Design constraints
*   The product must use the Qt graphical library.
*   The product requires a graphical display of at least 800x600 resolution.

## 3.7 Software system attributes
*   **Portability**: The software must be portable to the Windows OS. It must run with all the operating systems that Qt supports.

## 3.8 Supporting information
[N/A]

# 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]