Skip to main content

Context

Provides a context for the round manager, allowing access to player states, global metrics, and event bus.

Functions

new

Context.new(roundManagerRoundManager) → Context

Constructor method for a new context

GetPlayers

Context:GetPlayers() → table

Returns all players that have a player state in the round

SetMetric

Context:SetMetric(
playerPlayer,
keystring,
valuestring | number
) → ()

Sets a metric for the given player

GetMetric

Context:GetMetric(
playerPlayer,
keystring
) → any

Returns the requested metric for the given player

GetReadyPlayerCount

Context:GetReadyPlayerCount() → number

Returns the total number of players ready in the round

GetElapsedTime

Context:GetElapsedTime() → number

Returns the round phase elapsed time

AddPlayerState

Context:AddPlayerState(playerPlayer) → PlayerRoundState

Adds a player state to the registry

RemovePlayerState

Context:RemovePlayerState(userIdnumber) → ()

Removes a player state from the registry

GetPlayerState

Context:GetPlayerState(userIdnumber) → PlayerRoundState?

Gets a player state from the registry

GetGlobalMetric

Context:GetGlobalMetric(keystring) → any

Gets a value from the registry

SetGlobalMetric

Context:SetGlobalMetric(
keystring,
valueany
) → ()

Sets a value in the registry

TransitionTo

Context:TransitionTo(phaseNamestring) → boolean

Evaluates whetever the current phase can transition to the given phase Fires 'OnPhaseChanged' if the transition is successful.

CheckWinCondition

Context:CheckWinCondition() → WinOutcome?

Checks the win condition and fires the OnWinConditionMet event if it is met. Fires 'OnWinConditionMet' if the win condition is met.

GetCurrentPhase

Context:GetCurrentPhase() → Phase

Returns the current phase from the round manager

Connect

Context:Connect(
eventNamestring,
callbackany
) → RBXScriptConnection

Connects to an event on the event bus, if it does not exist it will be created.

Fire

Context:Fire(
eventNamestring,
...any
) → ()

Fires an event on the event bus.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructor method for a new context",
            "params": [
                {
                    "name": "roundManager",
                    "desc": "",
                    "lua_type": "RoundManager"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Context"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 12,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetPlayers",
            "desc": "Returns all players that have a player state in the round",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 22,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "SetMetric",
            "desc": "Sets a metric for the given player",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "string | number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 35,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetMetric",
            "desc": "Returns the requested metric for the given player",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                },
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 46,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetReadyPlayerCount",
            "desc": "Returns the total number of players ready in the round",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 53,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetElapsedTime",
            "desc": "Returns the round phase elapsed time",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 65,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "AddPlayerState",
            "desc": "Adds a player state to the registry",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerRoundState"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 74,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "RemovePlayerState",
            "desc": "Removes a player state from the registry",
            "params": [
                {
                    "name": "userId",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 80,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetPlayerState",
            "desc": "Gets a player state from the registry",
            "params": [
                {
                    "name": "userId",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerRoundState?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 87,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetGlobalMetric",
            "desc": "Gets a value from the registry",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 96,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "SetGlobalMetric",
            "desc": "Sets a value in the registry",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 104,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "TransitionTo",
            "desc": "Evaluates whetever the current phase can transition to the given phase\nFires 'OnPhaseChanged' if the transition is successful.",
            "params": [
                {
                    "name": "phaseName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 114,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "CheckWinCondition",
            "desc": "Checks the win condition and fires the OnWinConditionMet event if it is met.\nFires 'OnWinConditionMet' if the win condition is met.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "WinOutcome?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 121,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "GetCurrentPhase",
            "desc": "Returns the current phase from the round manager",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Phase"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 127,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "Connect",
            "desc": "Connects to an event on the event bus, if it does not exist it will be created.",
            "params": [
                {
                    "name": "eventName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "callback",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RBXScriptConnection"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 137,
                "path": "src/Systems/Context.lua"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires an event on the event bus.",
            "params": [
                {
                    "name": "eventName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 146,
                "path": "src/Systems/Context.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Context",
    "desc": "Provides a context for the round manager, allowing access to player states, global metrics, and event bus.",
    "source": {
        "line": 6,
        "path": "src/Systems/Context.lua"
    }
}