Skip to content

SessionView beta ​

Class of @v12-engine/engine

ts
export declare class SessionView

A seat's side of a world: whose it is, and what they may know of it now. What the rules that tell a player of the world ask (replicateEvent, SnapshotField, an event of a game's own's replicate), and what a seat keeps for them (keep)

Members ​

constructor ​

ts
constructor(
    world: World, 
    player: PlayerId, options?: {
        observer?: boolean;
        forComputer?: boolean;
        mostEffects?: number;
    });

Constructs a new instance of the SessionView class

events ​

ts
events: SessionEvent[];

What the seat was told since its last snapshot, for the next one

forComputer ​

ts
readonly forComputer: boolean;

Whether the seat is a computer player's, which is told only what a brain reads (LocalSession.forComputer)

isAlly ​

ts
readonly isAlly: (owner: PlayerId) => boolean;

Whether an owner is the player or an ally of theirs: an observer's is everyone

keep ​

ts
keep<S>(key: object, make: () => S): S;

What the seat keeps under a key for what tells it things (the effects it was shown, the score last told): made the first time

knows ​

ts
readonly knows: (entity: Entity) => boolean;

Whether the player's team can see the entity right now: its side's always

memory ​

ts
get memory(): TeamMemory;

What the player's team remembers of what it saw (teamMemory: the structures out of sight as last seen, the camps seen empty), or an observer's own. Looked up again each time: the player may have moved to another team since

mostEffects ​

ts
readonly mostEffects: number;

How many effects of the rules are kept for their stop to be told (LocalSession options' mostEffects)

observer ​

ts
readonly observer: boolean;

Who only watches, and sees everything (LocalSession.observer)

player ​

ts
readonly player: PlayerId;

The seat's player: from whose side it sees, an observer's too

sees ​

ts
readonly sees: (x: number, z: number) => boolean;

Whether the player's team sees a spot of the map right now: an observer sees all of it

takeEvents ​

ts
takeEvents(): SessionEvent[];

Takes what the seat was told since the last snapshot

team ​

ts
get team(): number;

The player's team: theirs now, as the rules may move them to another (setTeam)

world ​

ts
readonly world: World;

The world the session view is a seat's window onto