Skip to content

@v12-engine/engine/server ​

Core ​

What a game meets first.

NameKindWhat
GameModeinterfaceWhat a server runs: a game module, the seats of a game of it, and how its world is made. Each game starts from a world made anew, with the lobby's settings
GameRoomsclassMany games in a process (S58): game servers that share a port, each a room reached at its name, as a server of its own would be at its port. One process, one thread: each room's games step in turn, so the rooms of a process are as many as its ticks have time for (/metrics says how long they take). A connection to a room there is not is told so and closed. Rooms are added in code (add), or made by players of the kinds it offers (kinds, POST /games) and closed once empty
mapModefunctionA game on a map of it: a seat for each player the map has a start for, and a world made from the map for each game. The game (createGame) or its module (Rules): a game's start (Game.onStart) runs where onStart is left out
startServerfunctionStarts a server of a game, and resolves once it listens: a lobby that seats who joins, then games of it, one after the other, each on a world made anew. const server = await startServer( game ) const server = await startServer( rules, map, onStart: (world) = startMission(world) ) // server.port, server.close() The parts are there on their own: GameServer.start with a GameMode, mapMode, SessionHost

Advanced ​

Classes ​

NameWhat
GameServer betaA server of a game: its connections, who joins and where they go (Doorman), its lobby (Lobby: the seats, the settings, when a game starts) and its game while one is on (Match)
WatchRelay betaA server that relays a game from the one who shares it to the watchers who connect to it

Interfaces ​

NameWhat
CheatReport betaA player whose client sent what an honest one never does (GameServerOptions.onCheat)
Connection betaA connection, with what it came with: the address it was asked at, and who from
ConnectionSource betaWhere a game server's connections come from (GameServer.attach): onConnection is told of each one made, close closes them all. A socket server, or a room of a port that several share (GameRooms)
GameRoomsOptions betaWhat GameRooms is started with: the shared port, the rooms, the kinds players may make and matchmaking
GameServerOptions betaWhat a GameServer is made with: the mode it runs, the port, which seats the computer plays and the limits and hooks of the server
GeneratedModeOptions betaHow a mode on a generated map is made (generatedMode): the generator's options (the seed a new one each time when left out), and what a mode on a map takes
MapModeOptions betaHow a mode is made from a map (mapMode)
ModeSeat betaA seat a mode has: a player of the world, by default for whoever joins, or for the computer
RatedPlayer betaA player in a list of the best: their standing, their rated id (ratedId), and their place, from 1
Rating betaA player's standing in a mode
Ratings betaWhere a server keeps ratings (GameServerOptions.ratings): what it reads to show in the lobby and the list, and what it tells of every game that ended. createRatings keeps them in a file, or in memory; a game's own keeps them where it likes (a database)
RelayOptions betaWhat a WatchRelay is started with: the port, compression and the log
RoomKind betaA kind of game a player may make a room of (features-plan H2): what a "New game" makes (POST /games), with the settings asked for (the map) where the game offers them
SeatRequest betaWho asks for a seat (GameServerOptions.seat)
ServerHttpOptions betaWhere the addresses are, and who may read the numbers (GameServerOptions.http)
ServerMetrics betaWhat a game server says of itself: the numbers of /metrics (GameServer.metrics)
SocketServer betaA WebSocket server: onConnection is told of each connection made. close stops it, and closes them all
SocketServerOptions betaWhat startSocketServer is started with: the port, the log and the limits and compression of its connections
StartServerOptions betaWhat a game server is started with: the game, where its worlds come from, and the server's own options
WatchRequest betaWho asks to watch a game (GameServerOptions.watch)

Functions ​

NameWhat
againstTheRest betaA computer player that goes for everyone else's base: what a seat of the computer does when the server says nothing else. As hard as its seat's difficulty says and of the personality it says, where the game offers them to choose (ServerHooks.seatSettings, seatSettingsOf); a name the game does not have is left to the defaults
createRatings betaRatings kept in a file (file, JSON, read once and written after every game) or in memory: Elo, each side's players against the average of the other's, k 32, starting at 1500. The computer counts as start, and is not rated; a game with no winner, or with players of one side only, changes nothing
generatedMode betaA game on a map made by a generator (generateMap): the map made once, with the seed given or a new one, and a game of it as on any map (mapMode): a seat for each start, the world made from it for each game. For a room of a random map (RoomKind.room as a function: a new map for each room made)
looksOfSeats betaThe teams and colours chosen in the lobby (seatLooksOf), by player, where they are not the map's: what MapWorldOptions.teams and colors take
mergePackFiles betaA server's game with its packs of content composed in (readPacks, composeGame): the game as is with none
nodeNavigationBuilder betaA builder of navigations in a worker thread of this process (S37): what a server builds with, so that the world of one game being made does not hold up the ticks of the others (two seconds for a map of 512 cells a side). One thread, made the first time and kept, which keeps the process alive only while it builds. Nothing where the worker's file is not there: in this repository, which runs the engine as it is written, it builds on the thread that asks
racesOfSeats betaThe race chosen for each seat in the lobby, by player: none where nobody chose one, or the game has no races
ratedId betaThe id a player is rated by: a hash of their key or login id, safe to show and keep. The same key, the same id
readPacks betaThe packs of content of a server, read from their files (packs/<id>/pack.json) in the order named: that order is the game's, as a page's createGame({ contentPacks }) is
seatLooksOf betaWhat a lobby offers to choose for each seat of a map's game beside the game's own: a team, of as many as there are seats, and a colour of the players' (PLAYER_COLORS, by PLAYER_COLOR_NAMES), no two seats the same. Each seat has the map's until chosen otherwise (ModeSeat.preset)
seatSettingsOf betaWhat a game offers to choose for each seat in a lobby (ServerHooks.seatSettings), with a race among them where the game has races and does not offer its own choice of one: each race, by its name, and random where there are two or more; only those of races where given (the races a map offers, GameMap.races). The first is chosen until someone does
seatsOf betaThe seats a map has room for: a seat for each of its players with a start, the creeps apart
startSocketServer betaStarts a WebSocket server, and resolves once it listens

Values ​

NameWhat
PLAYER_COLOR_NAMES betaThe names of the players' colours (PLAYER_COLORS), in their order, as a lobby shows them

Types ​

NameWhat
CheatAnswer betaWhat the server does about it (GameServerOptions.onCheat): nothing, a warning in the log, let them go, or end the game
ModeBrain betaWhich brain plays a seat of the computer on a server (GameMode.brain): a brain, its id, or one chosen by seat
RoomOptions betaA room's game server: all of GameServerOptions but what the port they share says once for all
SeatAnswer betaWhere who asked sits (GameServerOptions.seat): a seat by its player (the first free one when left out), the name to use there (theirs, or the seat's, when left out), and who they are (id): one who comes again as the same id gets the seat they hold, from another page or after a drop, and the connection there before is let go. A seat another holds is refused. { refuse } sends them away with the reason, which they are told
ServerLog betaWhat a server may be given to log with: a logger, or a function that takes each line as text