Skip to content

five-on-it / packages/protocol/src/cops / encodeCops

Function: encodeCops() ​

encodeCops(message): string

Defined in: packages/protocol/src/cops.ts:214

Serializes a player's view of the cops as a text frame.

Parameters ​

message ​

bounties ​

{ list: object[]; on: boolean; } = ...

Whether their bounty board is on, and the room's bounties when it is.

bounties.list ​

object[] = ...

bounties.on ​

boolean = ...

cop? ​

{ budget: number; costs: number[]; cuff?: { client: number; progress: number; }; dispatcher: boolean; last?: { answer: "rate" | "cooldown" | "failed" | "budget" | "ok" | "notCop" | "dispatcherOnly" | "noSuspect" | "noRoad" | "noBuilding" | "room"; n: number; order: "swat" | "roadblock" | "drone" | "cruiser"; }; max: number; ready: number[]; suspects: object[]; units: object[]; } = ...

Their dispatch, when they play the police.

cop.budget ​

number = count

The team's budget now and at most (points).

cop.costs ​

number[] = ...

What each order costs (points), in COP_ORDERS' order.

cop.cuff? ​

{ client: number; progress: number; } = ...

The cuffs under way: the robber's client id and how far along (0 to 1).

cop.cuff.client ​

number = ...

cop.cuff.progress ​

number = ...

cop.dispatcher ​

boolean = ...

Whether they took the Dispatcher's role (P2: orders at a point of the map).

cop.last? ​

{ answer: "rate" | "cooldown" | "failed" | "budget" | "ok" | "notCop" | "dispatcherOnly" | "noSuspect" | "noRoad" | "noBuilding" | "room"; n: number; order: "swat" | "roadblock" | "drone" | "cruiser"; } = ...

The answer to the cop's last order, and its number (one more each order).

cop.last.answer ​

"rate" | "cooldown" | "failed" | "budget" | "ok" | "notCop" | "dispatcherOnly" | "noSuspect" | "noRoad" | "noBuilding" | "room" = ...

cop.last.n ​

number = count

cop.last.order ​

"swat" | "roadblock" | "drone" | "cruiser" = ...

cop.max ​

number = count

cop.ready ​

number[] = ...

The seconds before each order is the team's again, in COP_ORDERS' order.

cop.suspects ​

object[] = ...

The robbers the police know of: where they last placed them (m), their stars, how long ago (s).

cop.units ​

object[] = ...

The backup the team called that is still out: what, where (m), its seconds left.

transports ​

object[] = ...

The transports they ride or could stop.

type ​

"cops" = ...

Returns ​

string