five-on-it / apps/server/src/mission-host / MissionHost
Class: MissionHost
Defined in: apps/server/src/mission-host.ts:370
Runs a game's missions in one room.
Constructors
Constructor
new MissionHost(
ai,game,log?,run?,hooks?):MissionHost
Defined in: apps/server/src/mission-host.ts:444
Parameters
ai
game
blurb?
string = ...
id
string = ...
level
string = ...
missions
object[] = ...
paths
Record<string, { gates: string[]; laps: number; } | { loop: boolean; patrol: string[]; }> = ...
places
Record<string, { name?: string; role?: "players" | "police" | "traffic" | "guards" | "hospital"; tags?: string[]; x: number; y?: number; yaw?: number; z: number; }> = ...
rules
{ clock?: { pace: number; start: string; }; dropMissionItems: boolean; fallDamage: boolean; garages?: { respray?: number; store?: number; }; ghostSeconds: number; loadout?: object[]; maxPlayers: number; partyRewards: "split" | "shared"; phone: boolean; playerDamage: "on" | "off" | "rivals"; police: boolean; prices?: Record<string, number>; respawn: "hospital" | "mission"; safeZones: string[]; traffic: number; vehicleFire: boolean; weather?: { changes: boolean; climate?: "none" | "temperate" | "meadow" | "forest" | "alpine" | "farmland" | "steppe" | "desert" | "autumn" | "coast"; intensity: number; start?: "clear" | "overcast" | "rain" | "storm" | "fog" | "snow"; }; } = ...
rules.clock?
{ pace: number; start: string; } = ...
The room clock (GAME_DESIGN §5.7): the time the room starts at and its pace, game minutes per real second (1 is an hour a minute, a day in 24 minutes; 0 stops it; up to 60 for a day in 24 seconds).
rules.clock.pace
number = ...
rules.clock.start
string = ...
rules.dropMissionItems
boolean = ...
Whether a character that dies drops the items a mission defined that it carried, where it fell (GAME_DESIGN §7.4).
rules.fallDamage
boolean = ...
Whether a long fall hurts (from about 4 m) and a very long one kills (from about 12 m).
rules.garages?
{ respray?: number; store?: number; } = ...
What every garage of the level charges ($), over the level's own prices (GAME_DESIGN §5.5).
rules.garages.respray?
number = ...
rules.garages.store?
number = ...
rules.ghostSeconds
number = ...
Seconds a player is a ghost after coming back (passing through cars and people, taking no harm).
rules.loadout?
object[] = ...
What every player starts with (GAME_DESIGN §7.4): stacks of items by id (weapons and their ammunition are items), each in the slot of the strip it names (1 to 16; the number keys select the first nine, and the slot a key selects is the weapon held) or the first free one. Absent: free roam's arsenal, the fists' slot 1 left empty, the pistol, shotgun, rifle, rocket launcher, grenades and tranquilizer on 2 to 7 and the guns' ammunition from 9 on; an empty list: nothing but the phone.
rules.maxPlayers
number = ...
How many players a room of this game takes.
rules.partyRewards
"split" | "shared" = ...
How a party's mission reward is paid: each member the whole of it (shared), or the reward divided among them (split).
rules.phone
boolean = ...
Whether every character starts with a phone (GAME_DESIGN §7.5); a mission may give one.
rules.playerDamage
"on" | "off" | "rivals" = ...
Whether players hurt each other: never, only rivals (players outside one's party), or always.
rules.police
boolean = ...
Whether the room has police: crimes raise a Wanted level and police cars come (GAME_DESIGN §12).
rules.prices?
Record<string, number> = ...
What the shops charge ($), by item id, over the items' own prices (GAME_DESIGN §14).
rules.respawn
"hospital" | "mission" = ...
Where a player who went down comes back: the nearest spawn point (hospital), or where their mission started (mission).
rules.safeZones
string[] = ...
The game's zones where players cannot hurt each other and no car is carjacked.
rules.traffic
number = ...
Ambient cars driving the level's roads around the players: none unless the game asks (at most 64).
rules.vehicleFire
boolean = ...
Whether a car brought low catches fire, burns and blows up, its blast lighting the cars beside it.
rules.weather?
{ changes: boolean; climate?: "none" | "temperate" | "meadow" | "forest" | "alpine" | "farmland" | "steppe" | "desert" | "autumn" | "coast"; intensity: number; start?: "clear" | "overcast" | "rain" | "storm" | "fog" | "snow"; } = ...
The room's weather (GAME_DESIGN §5.7): its climate (the level's by default: a region's biome, temperate for a town; none is always clear), the weather it opens with (start, at an intensity), and whether it changes on its own from there (a front every half an hour, by the climate's odds) or holds. Missions change it (setWeather).
rules.weather.changes
boolean = ...
rules.weather.climate?
"none" | "temperate" | "meadow" | "forest" | "alpine" | "farmland" | "steppe" | "desert" | "autumn" | "coast" = ...
rules.weather.intensity
number = ...
rules.weather.start?
"clear" | "overcast" | "rain" | "storm" | "fog" | "snow" = ...
schemaVersion?
number = ...
The document's format (migrate.ts): 1 when absent; a newer one is migrated away before this reads it.
title
string = ...
zones
Record<string, { kind?: "pickup" | "spawn" | "restricted" | "race_gate" | "safe" | "checkpoint" | "dropoff"; place: string; radius: number; raises?: "alert" | "heat"; role?: "players" | "police" | "traffic" | "guards" | "hospital"; }> = ...
log?
(message) => void
run?
hooks?
MissionHostHooks = {}
Returns
MissionHost
Properties
guardSpawns
guardSpawns: readonly
SpawnPoint[] =[]
Defined in: apps/server/src/mission-host.ts:410
Where a mission's groups of enemies come out: the room's guards' spawn points (the level's and the game's places of that role).
runtime
readonlyruntime:MissionRuntime
Defined in: apps/server/src/mission-host.ts:372
The interpreter.
Accessors
enemies
Get Signature
get enemies():
number
Defined in: apps/server/src/mission-host.ts:470
How many mission enemies are still standing.
Returns
number
game
Get Signature
get game():
object
Defined in: apps/server/src/mission-host.ts:460
The game being played.
Returns
blurb?
optionalblurb?:string
id
id:
string
level
level:
string
missions
missions:
object[]
paths
paths:
Record<string, {gates:string[];laps:number; } | {loop:boolean;patrol:string[]; }>
places
places:
Record<string, {name?:string;role?:"players"|"police"|"traffic"|"guards"|"hospital";tags?:string[];x:number;y?:number;yaw?:number;z:number; }>
rules
rules:
object
rules.clock?
optionalclock?:object
The room clock (GAME_DESIGN §5.7): the time the room starts at and its pace, game minutes per real second (1 is an hour a minute, a day in 24 minutes; 0 stops it; up to 60 for a day in 24 seconds).
rules.clock.pace
pace:
number
rules.clock.start
start:
string
rules.dropMissionItems
dropMissionItems:
boolean
Whether a character that dies drops the items a mission defined that it carried, where it fell (GAME_DESIGN §7.4).
rules.fallDamage
fallDamage:
boolean
Whether a long fall hurts (from about 4 m) and a very long one kills (from about 12 m).
rules.garages?
optionalgarages?:object
What every garage of the level charges ($), over the level's own prices (GAME_DESIGN §5.5).
rules.garages.respray?
optionalrespray?:number
rules.garages.store?
optionalstore?:number
rules.ghostSeconds
ghostSeconds:
number
Seconds a player is a ghost after coming back (passing through cars and people, taking no harm).
rules.loadout?
optionalloadout?:object[]
What every player starts with (GAME_DESIGN §7.4): stacks of items by id (weapons and their ammunition are items), each in the slot of the strip it names (1 to 16; the number keys select the first nine, and the slot a key selects is the weapon held) or the first free one. Absent: free roam's arsenal, the fists' slot 1 left empty, the pistol, shotgun, rifle, rocket launcher, grenades and tranquilizer on 2 to 7 and the guns' ammunition from 9 on; an empty list: nothing but the phone.
rules.maxPlayers
maxPlayers:
number
How many players a room of this game takes.
rules.partyRewards
partyRewards:
"split"|"shared"
How a party's mission reward is paid: each member the whole of it (shared), or the reward divided among them (split).
rules.phone
phone:
boolean
Whether every character starts with a phone (GAME_DESIGN §7.5); a mission may give one.
rules.playerDamage
playerDamage:
"on"|"off"|"rivals"
Whether players hurt each other: never, only rivals (players outside one's party), or always.
rules.police
police:
boolean
Whether the room has police: crimes raise a Wanted level and police cars come (GAME_DESIGN §12).
rules.prices?
optionalprices?:Record<string,number>
What the shops charge ($), by item id, over the items' own prices (GAME_DESIGN §14).
rules.respawn
respawn:
"hospital"|"mission"
Where a player who went down comes back: the nearest spawn point (hospital), or where their mission started (mission).
rules.safeZones
safeZones:
string[]
The game's zones where players cannot hurt each other and no car is carjacked.
rules.traffic
traffic:
number
Ambient cars driving the level's roads around the players: none unless the game asks (at most 64).
rules.vehicleFire
vehicleFire:
boolean
Whether a car brought low catches fire, burns and blows up, its blast lighting the cars beside it.
rules.weather?
optionalweather?:object
The room's weather (GAME_DESIGN §5.7): its climate (the level's by default: a region's biome, temperate for a town; none is always clear), the weather it opens with (start, at an intensity), and whether it changes on its own from there (a front every half an hour, by the climate's odds) or holds. Missions change it (setWeather).
rules.weather.changes
changes:
boolean
rules.weather.climate?
optionalclimate?:"none"|"temperate"|"meadow"|"forest"|"alpine"|"farmland"|"steppe"|"desert"|"autumn"|"coast"
rules.weather.intensity
intensity:
number
rules.weather.start?
optionalstart?:"clear"|"overcast"|"rain"|"storm"|"fog"|"snow"
schemaVersion?
optionalschemaVersion?:number
The document's format (migrate.ts): 1 when absent; a newer one is migrated away before this reads it.
title
title:
string
zones
zones:
Record<string, {kind?:"pickup"|"spawn"|"restricted"|"race_gate"|"safe"|"checkpoint"|"dropoff";place:string;radius:number;raises?:"alert"|"heat";role?:"players"|"police"|"traffic"|"guards"|"hospital"; }>
vehicles
Get Signature
get vehicles():
number
Defined in: apps/server/src/mission-host.ts:465
How many mission vehicles stand in the world.
Returns
number
Methods
addSeat()
addSeat(
seat):number
Defined in: apps/server/src/mission-host.ts:485
A seat added to the run under way (a late joiner's, joinInProgress): its index on the missions' roster.
Parameters
seat
Returns
number
arrested()
arrested(
clientId):void
Defined in: apps/server/src/mission-host.ts:611
The police arrested a player: their mission hears of it on its next step.
Parameters
clientId
number
Returns
void
checkpointSpot()
checkpointSpot(): {
x:number;yaw:number;z:number; } |undefined
Defined in: apps/server/src/mission-host.ts:494
Where a late joiner of a co-op run comes in: the run's last checkpoint (where its first player stood when it was saved); none in a hub, in versus (a team's spawn instead), or before the run saved one (its start then).
Returns
{ x: number; yaw: number; z: number; } | undefined
join()
join(
clientId,party?,seat?):void
Defined in: apps/server/src/mission-host.ts:480
A player joined, in a party when they have one (in a run, in their seat): their first mission (their party's, the run's) starts on the next mission step.
Parameters
clientId
number
party?
string
seat?
number
Returns
void
leave()
leave(
clientId):void
Defined in: apps/server/src/mission-host.ts:518
A player left: their mission's actors go.
Parameters
clientId
number
Returns
void
observe()
observe(
events):void
Defined in: apps/server/src/mission-host.ts:538
The events of the step just taken: the carjacks and the players' item events among them reach the next mission step; an item actor's items picked up are marked so.
Parameters
events
readonly SimEvent[]
Returns
void
phoneInput()
phoneInput(
clientId,command):void
Defined in: apps/server/src/mission-host.ts:603
A player's phone command (a text frame they sent), for the next mission step; a photo is framed now.
Parameters
clientId
number
command
app?
string = ...
button?
string = ...
choice?
string = ...
contact?
string = ...
message?
number = ...
op
"open" | "call" | "close" | "photo" | "read" | "waypoint" | "press" | "reply" | "answer" | "decline" | "hangUp" | "choose" | "clearWaypoint" = ...
type
"phone" = ...
values?
Record<string, string> = ...
x?
number = ...
z?
number = ...
Returns
void
rebind()
rebind(
from,to):void
Defined in: apps/server/src/mission-host.ts:502
A run's player came back as another client: their seat, and the checkpoint's record of them, are the new client's.
Parameters
from
number
to
number
Returns
void
reset()
reset():
void
Defined in: apps/server/src/mission-host.ts:528
The level was reset: every mission actor goes and every player starts over.
Returns
void
takeRunEnded()
takeRunEnded():
RunView|undefined
Defined in: apps/server/src/mission-host.ts:511
The run the last mission step ended (once), for the run's room to report.
Returns
RunView | undefined
takeSkips()
takeSkips():
object[]
Defined in: apps/server/src/mission-host.ts:523
The time skips a mission made since the last call (each to be told to every player), and forgets them.
Returns
object[]
tick()
tick(
players):void
Defined in: apps/server/src/mission-host.ts:707
Steps the missions on their ticks: facts in, commands carried out, trackers and notices out.
Parameters
players
readonly MissionPlayer[]
Returns
void