# 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

#### System interfaces
The product runs as a stand-alone application.

#### 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 for user interaction. 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. It requires a graphical display with at least 800x600 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 software will perform the following major functions:
*   Undo and Redo actions for user movements.
*   Count and display the time the user spends playing.
*   Count and display the number of user actions.
*   Record the score (time and number of counts) of a play, associated with a user's name.
*   Display a window with all recorded player scores.

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

### 1.3.4 Limitations
*   There can be only one user per machine.
*   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 can move blocks. The height of the board game is 5x, and its width is 4x, where x is a measure unit. x cannot be less than 50 pixels and greater than 100 pixels. The blocks are separated by a margin of 0.1x.
The board contains:
*   Four square blocks with a side of x.
*   Four rectangular blocks with dimensions: height of 2x and width of x.
*   One block with dimensions: height of x and width of 2x.
*   One square block with a side of 2x.
The board is black, and the blocks are yellow.

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

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

#### 3.1.1.4 Block movement
*   **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 closer than 0.05x from other 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 as 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 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.
*   **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 to the bottom of the board.
*   **Processing:** All player statistics are frozen.
*   **Outputs:** If the number of block movements of the current player is lower than the highest number of block movements recorded in the statistic file, the "Finish Window with Statistics" is displayed. Otherwise, the "Simple Finish Window" is displayed.

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

#### 3.1.2.3 Simple Finish Window
*   **Description:** This window contains the text: "You win!" and a pushbutton labeled "OK".
*   **Input:** The game is over.
*   **Processing:** The player clicks on the "OK" pushbutton.
*   **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, and time since the start.
*   **Input:** A block movement.
*   **Processing:** The number of block movements is incremented by 1. The time difference between the current block movement and the previously 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 player's statistics (name, block movement number, time passed to solve the headache) are recorded in the statistic file. If 10 player statistics are already recorded, the player statistics in the file with the greatest number of block movements are erased.
*   **Output:** If the file was correctly updated, there is no output. If not, such as wrong permissions or disk full, an error message is displayed.

#### 3.1.3.3 Statistics erasing
*   **Description:** The user can erase all 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, such as 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 game's statistic file.
*   **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, allowing the user to choose a file that contains all the data of a previously saved game.
*   **Output:** The board game is redrawn according to the file data. The player statistics are set to the player statistics from 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 "Save as..." action. Otherwise, the following internal data are saved into the previous file used to save the game: the current positions of the blocks, their last 10000 previous positions, the number of 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, allowing the user to choose a file that will contain all the data of the current game. Then, the following internal data are saved into the file: the current positions of the blocks, their previous positions, the number of 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 asking the player if they want to save the game. Two choices are possible: "Yes" and "No". If "Yes" is selected, the "Save" action 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:** The "About Window" is displayed.
*   **Outputs:** Menu disappears. Requirements of the action determine the continuation.

## 3.2 Performance requirements
The software must support only one user per machine.

## 3.3 Usability requirements
[N/A]

## 3.5 Logical database requirements
The software maintains a statistic file that stores up to 10 player statistics. Each player statistic entry includes the player's name, the number of block movements, and the time taken to solve the headache. When a new statistic is recorded and the file already contains 10 entries, the entry with the greatest number of block movements is erased to make room for the new one.

## 3.6 Design constraints
*   **Hardware:** The product requires a graphical display of at least 800x600 resolution.
*   **Software:** The product uses the Qt graphical library and must run on all operating systems supported by Qt.
*   **User Interface:** The user interface must utilize menus, graphics, and sounds.
*   **Game Board:** The unit 'x' for board dimensions must be between 50 and 100 pixels (inclusive).
*   **Undo/Redo History:** The system must be able to undo and redo the last thousand actions. The internal data for saving the game includes the last 10000 previous block positions.
*   **Block Movement:** Selected blocks must not overlap other blocks or exit the game zone. Selected blocks cannot move closer than 0.05x from other blocks.

## 3.7 Software system attributes

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

### Reliability
[N/A]

### Availability
[N/A]

### Security
[N/A]

### Maintainability
[N/A]

## 3.8 Supporting information
The "About Window" displays the text "Qheadache 1.0 by Jean-Philippe Brossat jp_brossat@yahoo.fr".

# 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
*   The Qt graphical library is available and functional on the target operating systems.
*   The software will run on operating systems that Qt supports.

## 5.2 Acronyms and abbreviations
[N/A]