@v12-engine/engine/server
Core
What a game meets first.
| Name | Kind | What |
|---|---|---|
| GameMode | interface | What 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 |
| GameRooms | class | Many 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 |
| mapMode | function | A 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 |
| startServer | function | Starts 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
| Name | What |
|---|---|
| GameServer beta | A 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 beta | A server that relays a game from the one who shares it to the watchers who connect to it |
Interfaces
| Name | What |
|---|---|
| CheatReport beta | A player whose client sent what an honest one never does (GameServerOptions.onCheat) |
| Connection beta | A connection, with what it came with: the address it was asked at, and who from |
| ConnectionSource beta | Where 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 beta | What GameRooms is started with: the shared port, the rooms, the kinds players may make and matchmaking |
| GameServerOptions beta | What 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 beta | How 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 beta | How a mode is made from a map (mapMode) |
| ModeSeat beta | A seat a mode has: a player of the world, by default for whoever joins, or for the computer |
| RatedPlayer beta | A player in a list of the best: their standing, their rated id (ratedId), and their place, from 1 |
| Rating beta | A player's standing in a mode |
| Ratings beta | Where 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 beta | What a WatchRelay is started with: the port, compression and the log |
| RoomKind beta | A 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 beta | Who asks for a seat (GameServerOptions.seat) |
| ServerHttpOptions beta | Where the addresses are, and who may read the numbers (GameServerOptions.http) |
| ServerMetrics beta | What a game server says of itself: the numbers of /metrics (GameServer.metrics) |
| SocketServer beta | A WebSocket server: onConnection is told of each connection made. close stops it, and closes them all |
| SocketServerOptions beta | What startSocketServer is started with: the port, the log and the limits and compression of its connections |
| StartServerOptions beta | What a game server is started with: the game, where its worlds come from, and the server's own options |
| WatchRequest beta | Who asks to watch a game (GameServerOptions.watch) |
Functions
| Name | What |
|---|---|
| againstTheRest beta | A 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 beta | Ratings 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 beta | A 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 beta | The teams and colours chosen in the lobby (seatLooksOf), by player, where they are not the map's: what MapWorldOptions.teams and colors take |
| mergePackFiles beta | A server's game with its packs of content composed in (readPacks, composeGame): the game as is with none |
| nodeNavigationBuilder beta | A 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 beta | The race chosen for each seat in the lobby, by player: none where nobody chose one, or the game has no races |
| ratedId beta | The 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 beta | The 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 beta | What 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 beta | What 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 beta | The seats a map has room for: a seat for each of its players with a start, the creeps apart |
| startSocketServer beta | Starts a WebSocket server, and resolves once it listens |
Values
| Name | What |
|---|---|
| PLAYER_COLOR_NAMES beta | The names of the players' colours (PLAYER_COLORS), in their order, as a lobby shows them |
Types
| Name | What |
|---|---|
| CheatAnswer beta | What the server does about it (GameServerOptions.onCheat): nothing, a warning in the log, let them go, or end the game |
| ModeBrain beta | Which brain plays a seat of the computer on a server (GameMode.brain): a brain, its id, or one chosen by seat |
| RoomOptions beta | A room's game server: all of GameServerOptions but what the port they share says once for all |
| SeatAnswer beta | Where 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 beta | What a server may be given to log with: a logger, or a function that takes each line as text |