# Game Phase

## Reality Game Phase

`Reality Game Phase` defines a phase of gameplay inside a game mode.

A phase can control:

* when a phase begins and ends,
* how long it lasts,
* how many times it repeats,
* which actions run on begin or end,
* which conditions end the phase,
* optional sub-phases,
* event-driven logic during the phase.

> Use phases to build structured game flow such as Lobby, Preparation, Combat, Sudden Death, Results, or any custom sequence.

***

## Overview

| Feature               | Description                                             |
| --------------------- | ------------------------------------------------------- |
| Phase Lifecycle       | Begin, end, and move to the next phase                  |
| Duration              | Optional timed phase duration                           |
| Iterations            | Repeat the phase multiple times                         |
| Transition Conditions | End the phase based on conditions                       |
| Begin / End Actions   | Run actions when the phase starts or ends               |
| Sub-Phases            | Create nested phase flow inside a phase                 |
| Event Logic           | Attach player, GameMode, and custom events to the phase |
| Synchronization       | Supports synchronized execution state                   |

***

## Phase State

### Enum

| Name  | Description       |
| ----- | ----------------- |
| None  | Phase is inactive |
| Begin | Phase has started |
| End   | Phase has ended   |

***

## Phase Timing

### Properties

| Name       | Type          | Description                              |
| ---------- | ------------- | ---------------------------------------- |
| Name       | Text          | Display name of the phase                |
| Duration   | Float         | Duration before the phase ends           |
| Iterations | Integer       | Number of times this phase repeats       |
| Tags       | Tag Container | Gameplay tags associated with this phase |

***

### Timing Rules

| Value          | Result                        |
| -------------- | ----------------------------- |
| Duration = 0   | Infinite duration             |
| Iterations = 1 | Phase runs once               |
| Iterations > 1 | Phase repeats that many times |
| Iterations = 0 | Infinite repetition           |

***

### Functions

| Name                  | Type | Description                                      | Outputs |
| --------------------- | ---- | ------------------------------------------------ | ------- |
| Get Current Iteration | Pure | Returns the current iteration index of the phase | Integer |
| Get Begin Time        | Pure | Returns the world time when the phase started    | Double  |
| Get Duration          | Pure | Returns the configured duration of the phase     | Float   |
| Get Remaining Time    | Pure | Returns the time remaining before the phase ends | Double  |

***

## Phase Lifecycle

### Functions

| Name       | Type     | Description                                         | Inputs | Outputs |
| ---------- | -------- | --------------------------------------------------- | ------ | ------- |
| Force Next | Callable | Forces the phase to end and advance to the next one | —      | —       |

***

### Events

| Name                | Type  | Description                                         | Outputs |
| ------------------- | ----- | --------------------------------------------------- | ------- |
| On Begin            | Event | Called when the phase starts                        | —       |
| On End              | Event | Called when the phase ends                          | —       |
| On Check Transition | Event | Called when checking if the phase should transition | Boolean |

***

## Begin and End Actions

These actions are executed automatically during the phase lifecycle.

### Properties

| Name          | Type  | Description                            |
| ------------- | ----- | -------------------------------------- |
| Begin Actions | Array | Actions executed when the phase begins |
| End Actions   | Array | Actions executed when the phase ends   |

***

## Transition System

The phase can end automatically based on configured conditions.

### Properties

| Name                             | Type    | Description                          |
| -------------------------------- | ------- | ------------------------------------ |
| End Conditions                   | Array   | Conditions that can end the phase    |
| Auto Check End Conditions        | Boolean | Enables automatic condition checking |
| Auto Check End Conditions Period | Float   | How often end conditions are checked |

***

### Transition Rules

| Rule                | Description                                          |
| ------------------- | ---------------------------------------------------- |
| End Conditions      | If at least one condition is true, the phase can end |
| Auto Check Enabled  | Conditions are checked automatically                 |
| Auto Check Disabled | Transition checks must be triggered manually         |
| Check Period        | Defines the interval between automatic checks        |

***

## Sub-Phases

A phase can optionally contain its own list of sub-phases.

### Properties

| Name                 | Type    | Description                                  |
| -------------------- | ------- | -------------------------------------------- |
| Has Sub Phases       | Boolean | Enables sub-phase support                    |
| Sub Phase Iterations | Integer | Number of times the sub-phase list repeats   |
| Sub Phase Classes    | Array   | List of sub-phase classes used by this phase |

***

### Sub-Phase Rules

| Value                    | Result                   |
| ------------------------ | ------------------------ |
| Has Sub Phases = false   | No sub-phases are used   |
| Sub Phase Iterations = 1 | Sub-phase list runs once |
| Sub Phase Iterations > 1 | Sub-phase list repeats   |
| Sub Phase Iterations = 0 | Infinite repetition      |

***

### Functions

| Name                   | Type | Description                                     | Inputs         | Outputs |
| ---------------------- | ---- | ----------------------------------------------- | -------------- | ------- |
| Get Parent Phase       | Pure | Returns the parent phase if this is a sub-phase | —              | Phase   |
| Get Sub Phase By Index | Pure | Returns a sub-phase by index                    | Subphase Index | Phase   |
| Get Sub Phases Count   | Pure | Returns the number of sub-phases                | —              | Integer |

***

## Gameplay Event System

A phase can define gameplay event logic locally.

### Player Events

| Name         | Type      | Description                                             |
| ------------ | --------- | ------------------------------------------------------- |
| Player Event | Container | Player-related gameplay events active during this phase |

***

### GameMode Events

| Name           | Type      | Description                                               |
| -------------- | --------- | --------------------------------------------------------- |
| GameMode Event | Container | GameMode-related gameplay events active during this phase |

***

### Custom Events

| Name         | Type      | Description                                     |
| ------------ | --------- | ----------------------------------------------- |
| Custom Event | Container | Custom gameplay events active during this phase |

***

## Synchronization & Execution State

A phase supports synchronized execution behavior.

### Behavior

| State                  | Description                             |
| ---------------------- | --------------------------------------- |
| Synchronizing          | Phase is currently synchronizing        |
| Synchronized           | Phase has completed synchronization     |
| Iteration Synchronized | Current phase iteration is synchronized |
| Simulating             | Phase is currently simulating           |

> These states are useful when the phase flow depends on synchronized execution across systems.

***

## Typical Use Cases

| Use Case                                        | Recommended Setup                                       |
| ----------------------------------------------- | ------------------------------------------------------- |
| Create a timed combat phase                     | Set Duration and Begin / End Actions                    |
| Create a lobby phase that waits for a condition | Use End Conditions                                      |
| Repeat a wave phase multiple times              | Set Iterations                                          |
| Build a multi-step round flow                   | Use Sub Phase Classes                                   |
| Trigger logic when the phase starts             | Use On Begin                                            |
| Trigger cleanup when the phase ends             | Use On End                                              |
| End a phase from Blueprint                      | Use Force Next                                          |
| Run event-specific logic only during one phase  | Configure Player Event, GameMode Event, or Custom Event |

***

## Blueprint Events Summary

| Name                | Description                                        |
| ------------------- | -------------------------------------------------- |
| On Begin            | Called when the phase starts                       |
| On End              | Called when the phase ends                         |
| On Check Transition | Called when the phase checks whether it should end |

***

## Notes

| Topic                | Note                                                       |
| -------------------- | ---------------------------------------------------------- |
| Main Purpose         | Phases are used to structure gameplay flow                 |
| Timed or Conditional | A phase can end by time, by conditions, or manually        |
| Nested Flow          | Sub-phases allow more advanced flow control                |
| Iteration Support    | Both phases and sub-phases can repeat                      |
| Event Scope          | Event containers let you scope logic to one specific phase |

***

## Related Pages

| Page                  | Description                                          |
| --------------------- | ---------------------------------------------------- |
| Reality GameMode      | Uses phases to control game progression              |
| Reality Game Data     | Stores the list of phases used by the GameMode       |
| Reality GameMode Base | Provides phase manager access and phase flow helpers |
| Reality Game Feature  | Can interact with phase-based systems                |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beyond-sandbox.gitbook.io/realitysdk/documentation/gamemode/game-data/game-phase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
