arcadible.players
Who's playing: the player the game runs for, logged in or a guest, and players' pictures. How to use it, and what a game is and isn't given: Players. Each code a call fails with is in Codes, and the limits are in Limits.
interface Players {
readonly primary: Player | null | undefined;
pictures(players: readonly (Player | string)[]): Promise<(Blob | null)[]>;
}
interface Player {
readonly id: string;
readonly guest: boolean;
readonly name: string | null;
}
Members
| Member | Description |
|---|---|
primary | The player the game runs for, a Player |
pictures(players) | Players' pictures, as images |
primary
readonly primary: Player | null | undefined;
The player the game runs for, fixed for the run: when the player changes (a log-out, another log-in), Arcadible pauses the game and starts it again.
await arcadible.initStart();
const player = arcadible.players.primary;
- Set once
initStart()orreadyhas resolved;undefinedbefore. nullwhere no page says, such as off Arcadible.- Under
arc serve, a guest.
Player
interface Player {
readonly id: string;
readonly guest: boolean;
readonly name: string | null;
}
| Field | Value |
|---|---|
id | This player in this game: a UUID, in lowercase, the same on every run, version, channel, and device, and different in every game |
guest | Whether they're logged out: a guest's id is kept on the device, so it's another in another browser, or once its data is cleared |
name | Their name, as Arcadible shows it, up to 200 characters, as it was when the run started; null for a guest, or a player with none |
- The object is frozen.
- An
idisn't proof of who's playing: a game's own server can't check one yet. - A
nameis the player's own words: show it as text, never as HTML.
pictures(players)
pictures(players: readonly (Player | string)[]): Promise<(Blob | null)[]>
Each player's picture, for players or their ids, in the order given.
const [picture] = await arcadible.players.pictures([arcadible.players.primary]);
- Resolves with a list as long as the one given: for each, a
Blob(image/webp, 256 × 256), ornullfor a player with no picture, as a guest always is, and for an id that's no one's. - Fails with
too_manyfor more than 50 players;invalid, before anything is asked, whenplayersisn't an array, or an entry is neither a player nor an id; andunavailablewhen the pictures can't be reached, such as offline. - One that fails among many is
null, and the console says so. - Off Arcadible, every entry is
null.