Bookkeeping and tweaking

This commit is contained in:
Kim Ravn Hansen
2025-10-13 15:54:15 +02:00
parent 934160280c
commit f14ec9e09f
3 changed files with 21 additions and 22 deletions

View File

@@ -9,10 +9,13 @@
import { isIdSane, miniUid } from "../utils/id.js"; import { isIdSane, miniUid } from "../utils/id.js";
import { Xorshift32 } from "../utils/random.js"; import { Xorshift32 } from "../utils/random.js";
import { Character } from "./character.js"; import { ItemBlueprint } from "./item.js";
import { ItemAttributes, ItemBlueprint } from "./item.js";
import { Player } from "./player.js"; import { Player } from "./player.js";
/** @typedef {import("./character.js").Character} Character */
/** @typedef {import("./item.js").ItemAttributes} ItemAttributes */
/** @typedef {import("./item.js").ItemBlueprint} ItemBlueprint */
export class Game { export class Game {
_counter = 1_000_000; _counter = 1_000_000;
@@ -117,10 +120,8 @@ export class Game {
*/ */
getItemBlueprint(blueprintId) { getItemBlueprint(blueprintId) {
if (!isIdSane(blueprintId)) { if (!isIdSane(blueprintId)) {
throw new Error(`blueprintId >>${blueprintId}<< is insane!`); throw new Error(`blueprintId >>${blueprintId}<< is not a valid id`);
} }
const tpl = this._itemBlueprints.get(blueprintId); return this._itemBlueprints.get(blueprintId);
return tpl || undefined;
} }
} }

View File

@@ -4,22 +4,20 @@
* Example: two adjacent rooms connected by a door: * Example: two adjacent rooms connected by a door:
* Room A has a portal to Room B, and * Room A has a portal to Room B, and
* Room B has a portal to Room A. * Room B has a portal to Room A.
*
* @todo Add encounters to portals
*/ */
export class Portal { export class Portal {
/** /**
* Target Location. * Target Location.
*/ */
_targetLocationId; _targetLocationId;
/** /**
* Description shown to the player when they inspect the portal from the source location. * Description shown to the player when they inspect the portal from the source location.
*/ */
_description; _description;
/** /**
* Description shown to the player when they traverse the portal. * Description shown to the player when they traverse the portal.
*/ */
_traversalDescription; _traversalDescription;
} }

View File

@@ -1,10 +1,10 @@
import WebSocket from "ws";
import { Player } from "./player.js"; import { Player } from "./player.js";
import { mustBeString, mustBe } from "../utils/mustbe.js"; import { mustBeString, mustBe } from "../utils/mustbe.js";
import { Scene } from "../scenes/scene.js"; import { Scene } from "../scenes/scene.js";
import { gGame } from "./globals.js";
import { formatMessage, MessageType } from "../utils/messages.js"; import { formatMessage, MessageType } from "../utils/messages.js";
/** @typedef {import("ws").WebSocket} WebSocket */
export class Session { export class Session {
/** @type {WebSocket} */ /** @type {WebSocket} */
_websocket; _websocket;