import { RpgWritableSignal, Hooks } from '@rpgjs/common'; import { RpgPlayer } from '../Player/Player'; /** * Base class for rooms that need database functionality * * This class provides common database management functionality that is shared * between RpgMap and LobbyRoom. It includes methods for adding and managing * items, classes, and other game data in the room's database. * * ## Architecture * * Both RpgMap and LobbyRoom need to store game entities (items, classes, skills, etc.) * in a database. This base class provides the common implementation to avoid code duplication. * * @example * ```ts * class MyCustomRoom extends BaseRoom { * // Your custom room implementation * } * ``` */ export declare abstract class BaseRoom { /** * Signal containing the room's database of items, classes, and other game data * * This database can be dynamically populated using `addInDatabase()` and * `removeInDatabase()` methods. It's used to store game entities like items, * classes, skills, etc. that are available in this room. * * @example * ```ts * // Add data to database * room.addInDatabase('Potion', PotionClass); * * // Access database * const potion = room.database()['Potion']; * ``` */ database: RpgWritableSignal>; onStart(): Promise; /** * Add data to the room's database * * Adds an item, class, or other game entity to the room's database. * If the ID already exists and `force` is not enabled, the addition is ignored. * * ## Architecture * * This method is used by the item management system to store item definitions * in the room's database. When a player adds an item, the system first checks * if the item exists in the database, and if not, adds it using this method. * * @param id - Unique identifier for the data * @param data - The data to add (can be a class, object, etc.) * @param options - Optional configuration * @param options.force - If true, overwrites existing data with the same ID * @returns `true` if data was added, `false` if it was ignored (ID already exists) * * @example * ```ts * // Add a class to the database * room.addInDatabase('Potion', PotionClass); * * // Add an item object to the database * room.addInDatabase('custom-item', { * name: 'Custom Item', * price: 100 * }); * * // Force overwrite existing data * room.addInDatabase('Potion', UpdatedPotionClass, { force: true }); * ``` */ addInDatabase(id: string, data: any, options?: { force?: boolean; }): boolean; /** * Remove data from the room's database * * This method allows you to remove items or data from the room's database. * * @param id - Unique identifier of the data to remove * @returns `true` if data was removed, `false` if ID didn't exist * * @example * ```ts * // Remove an item from the database * room.removeInDatabase('Potion'); * * // Check if removal was successful * const removed = room.removeInDatabase('custom-item'); * if (removed) { * console.log('Item removed successfully'); * } * ``` */ removeInDatabase(id: string): boolean; /** * Get the hooks system for this map * * Returns the dependency-injected Hooks instance that allows you to trigger * and listen to various game events. * * @returns The Hooks instance for this map * * @example * ```ts * // Trigger a custom hook * map.hooks.callHooks('custom-event', data).subscribe(); * ``` */ get hooks(): Hooks; /** * Resolve complex snapshot entries (e.g. inventory items) before load. */ onSessionRestore({ userSnapshot, user }: { userSnapshot: any; user?: RpgPlayer; }): Promise; listSaveSlots(player: RpgPlayer, value: { requestId: string; }): Promise; saveSlot(player: RpgPlayer, value: { requestId: string; index: number; meta?: any; }): Promise; loadSlot(player: RpgPlayer, value: { requestId: string; index: number; }): Promise; }