# 1 Introduction
[NULL]

## 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 named Qheadache that displays an interface used to solve a specific headache.

## 1.3 Product overview
[NULL]

### 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 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. 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 software will perform the following major functions:
*   Provide a game board with movable blocks.
*   Allow the user to undo and redo up to one thousand actions.
*   Count and display the time elapsed and the number of user actions.
*   Record and display user scores.
*   Allow the user to save and open game files.

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

### 1.3.4 Limitations
There can be only one user per machine.

## 1.4 Definitions
[N/A]

# 2 References
[N/A]

# 3 Requirements
[NULL]

## 3.1 Functions
### Board and Block Actions
*   **Presentation of the board**: The board is a rectangular zone where the user can move blocks. Let x be the measure unit, where x is between 50 and 100 pixels. The board's height is 5x and its width is 4x. The board is black and the blocks are yellow. Blocks are separated by a margin of 0.1x. There are:
    *   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 selection**: When the user left-clicks down on a block, the game state becomes "Block deplacement".
*   **Block deselection**: When the user left-clicks up on a selected block, the game state becomes "Block selection".
*   **Block movement**: While in the "Block movement" state, mouse movement causes the selected block to follow the mouse cursor. The block cannot overlap other blocks or exit the game zone. The selected block must maintain a distance of at least 0.05x from other blocks.
*   **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 counted as a movement. The "undo" action is unavailable if there was no previous movement. The system must support undoing the last thousand actions.
*   **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 counted as a movement. The "redo" action is unavailable if the previous action was not an "undo" action. The system must support redoing the last thousand actions.

### End of Game Management
*   **End of the game condition**: The game ends when the great square block (2x by 2x) is moved to the bottom of the board. At this point, all player statistics are frozen.
*   **Finish Window with Statistics**: If the current player's number of block movements is lower than the highest number recorded, a "Finish Window with Statistics" is displayed. This window contains the text "You win ! Enter your name : ", an edit box for a 20-character name, and an "OK" pushbutton. When the user clicks "OK", the player's statistics are recorded, the finish window closes, and the statistic window is displayed.
*   **Simple Finish Window**: If the player's score is not a high score, a "Simple Finish Window" is displayed. This window contains the text "You win !" and an "OK" pushbutton. When the user clicks "OK", the window closes and the statistic window is displayed.

### Statistics Management
*   **Player Statistics Tracking**: The system records the number of block movements and the elapsed time since the start of the game. The number of block movements is incremented by 1 for each block movement.
*   **Game Statistics Recording**: When a player achieves a high score, their statistics (name, block movement number, time) are recorded in the statistic file. The game statistics file holds up to 10 player statistics. If 10 are already recorded, the new score replaces the one with the greatest number of block movements. If the file cannot be updated, an error message is displayed.
*   **Statistics Erasing**: The user can erase all statistics via a menu selection. The data in the statistic file is erased. If the file cannot be updated, an error message is displayed.
*   **Statistic Window**: The Player Statistics Window displays a list of up to 10 high scores. Each line shows the player's name, number of block movements, and time taken. This window is displayed at the end of a game or via a menu selection.

### File Management
*   **Open game**: The user can select a menu option to open a previously saved game. A dialog box allows the user to choose a file. The game board and player statistics are then loaded from the selected file.
*   **Save game**: The user can select a menu option to save the current game. If the game has been saved before, it overwrites the previous file with the current block positions, their last 1000 previous positions, the number of movements, and the elapsed time. If the game has not been saved before, this action performs a "Save game as".
*   **Save game as**: The user can select a menu option to save the current game to a new file. A dialog box allows the user to choose a file name and location. The current game state is then saved to that file.
*   **Exit**: The user can select a menu option to stop the game. If the game is not saved, a dialog box asks if the player wants to save. If "Yes" is selected, the "Save game" action is performed before the application closes. If "No" is selected, the application closes immediately.

### Menu Bar
*   **Game menu**: Contains the menu items "Open game ...", "Save Game ...", "Save Game As...", and "Exit", in that order. These items trigger the corresponding file management functions.
*   **Action menu**: Contains the menu items "Undo" and "Redo", in that order. These items trigger the corresponding undo/redo actions. A menu item is unavailable if its associated action is unavailable.
*   **Statistics menu**: Contains the menu items "Display" and "Erase", in that order. These items trigger the display of the statistic window and the erasing of statistics, respectively.
*   **Help menu**: Contains the menu item "About". Selecting this displays an "About 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**: A file shall store the game's high scores. It will contain up to 10 entries. Each entry consists of the player's name (up to 20 characters), the number of block movements, and the time passed to solve the game.
*   **Saved Game File**: A file shall store the state of a saved game. It must contain the current positions of all blocks, their last 1000 previous positions, the number of previous movements, and the time passed.

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

## 3.7 Software system attributes
*   **Portability**: The software must be portable to the Windows OS.

## 3.8 Supporting information
[N/A]

# 4 Verification
[NULL]

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

## 5.1 Assumptions and dependencies
[N/A]

## 5.2 Acronyms and abbreviations
[N/A]
