import { S as StoredClassModel } from './StoredClassModel-Bykjdn8S.cjs'; import { CharacterInterface as CharacterInterface$1 } from '@drincs/pixi-vn'; import './StorageElementType-C7ETezlL.cjs'; declare class CharacterStoredClass extends StoredClassModel { private sourceId; constructor(id: string, emotion?: string); getStorageProperty(propertyName: string): T | undefined; } /** * CharacterBaseModelProps is an interface that is used to create a character model. */ interface CharacterBaseModelProps { /** * The character's name. */ name?: string; /** * The character's surname. */ surname?: string; /** * The character's age. */ age?: number; /** * The character's icon image URL. */ icon?: string; /** * The character's color. */ color?: string; } /** * An empty interface that can be augmented via `declare module '@drincs/pixi-vn/characters'` * to constrain the set of valid character IDs to a known union of string literals. * * When this interface has no keys (the default), {@link CharacterIdType} resolves to `string`, * preserving full backwards compatibility. Once you augment it, {@link CharacterIdType} becomes * the union of the declared keys and the compiler will reject any unknown character ID. * * The augmentation is typically written into an auto-generated declaration file by the * Vite plugin (see the `typeFilePath` option of `vitePluginPixivn`), but it can * also be written by hand. * * @example * ```ts * // pixi-vn.gen.d.ts (auto-generated — do not edit manually) * declare module "@drincs/pixi-vn/characters" { * interface PixivnCharacterIds { * liam: never; * emma: never; * } * } * export {}; * ``` */ interface PixivnCharacterIds { } /** * The type used wherever a character ID is expected (e.g. `RegisteredCharacters.get`, * `RegisteredCharacters.has`, character constructors, …). * * - **Default** — resolves to `string` so that existing code that passes arbitrary strings * continues to compile without any changes. * - **Augmented** — when {@link PixivnCharacterIds} has been extended via * `declare module "@drincs/pixi-vn/characters"`, this type resolves to the union of the * declared keys, giving you compile-time safety against typos and unknown character IDs. */ type CharacterIdType = [keyof PixivnCharacterIds] extends [never] ? string : keyof PixivnCharacterIds; /** * CharacterEmotionId is used to identify a character together with an emotion. */ interface CharacterEmotionId { id: CharacterIdType; emotion: string; } /** * CharacterBaseModel is a class that is used to create a character model. * You must use the {@link RegisteredCharacters.add} function to save the character in the game. * It is raccomended to create your own class Character, read more here: https://pixi-vn.com/start/character.html#custom-character * @example * ```ts * import { CharacterBaseModel, RegisteredCharacters } from "@drincs/pixi-vn"; * * export const liam = new CharacterBaseModel("liam", { * name: "Liam", * surname: "Smith", * age: 25, * icon: "https://example.com/liam.png", * color: "#9e2e12", * }); * * export const emma = new CharacterBaseModel("emma", { * name: "Emma", * surname: "Johnson", * age: 23, * icon: "https://example.com/emma.png", * color: "#9e2e12", * }); * * RegisteredCharacters.add([liam, emma]); * ``` */ declare class CharacterBaseModel extends CharacterStoredClass { /** * @param id A unique identifier (string). It is used to reference the character in the game (must be unique). If you want to create a character with an "emotion", you can pass an object. * @param props The properties of the character. */ constructor(id: string | CharacterEmotionId, props: CharacterBaseModelProps); readonly defaultName?: string; /*** * The name of the character. * If you set undefined, it will return the default name. */ get name(): string; set name(value: string | undefined); readonly defaultSurname?: string; /** * The surname of the character. * If you set undefined, it will return the default surname. */ get surname(): string | undefined; set surname(value: string | undefined); readonly defaultAge?: number | undefined; /** * The age of the character. * If you set undefined, it will return the default age. */ get age(): number | undefined; set age(value: number | undefined); /** * The icon of the character. */ readonly icon?: string; /** * The color of the character. */ readonly color?: string | undefined; } declare namespace RegisteredCharacters { /** * is a function that returns the character by the id * @param id is the id of the character * @returns the character * @example * ```ts * const liam = RegisteredCharacters.get('liam'); * ``` */ function get(id: T2): T | undefined; /** * Is a function that saves the character. If the character already exists, it will be overwritten. * @param characters is the character(s) to save * @returns * @example * ```ts * export const liam = new CharacterBaseModel('liam', { name: 'Liam'}); * export const alice = new CharacterBaseModel('alice', { name: 'Alice'}); * RegisteredCharacters.add(liam, alice); * RegisteredCharacters.add([liam, alice]); * ``` */ function add(...characters: (CharacterInterface$1 | CharacterInterface$1[])[]): void; /** * is a function that returns all characters * @returns all characters * @example * ```ts * const allCharacters = RegisteredCharacters.values(); * ``` */ function values(): T[]; /** * Check if a character is registered. * @param id is the id of the character * @returns true if the character exists, false otherwise */ function has(id: string): boolean; /** * Get a list of all character ids registered. * @returns An array of character ids. */ function keys(): CharacterIdType[]; /** * Removes all registered characters. */ function clear(): void; } /** * CharacterInterface is the interface that character must implement or extend. * So if you want to create your own Character, you must override this interface, implement or extend it and extend the {@link CharacterStoredClass} class. * You can override this interface to add your own props. * @example * ```ts * // pixi-vn.d.ts * declare module '@drincs/pixi-vn' { * interface CharacterInterface { * name: string * surname?: string * age?: number * icon?: string * color?: string * } * } * // You Character class * export class Character extends CharacterStoredClass implements CharacterInterface { * constructor(id: string, props: CharacterProps) { * super(id) * this.defaultName = props.name * this.defaultSurname = props.surname * this.defaultAge = props.age * this.icon = props.icon * this.color = props.color * } * readonly defaultName: string = "" * get name(): string { * return this.getStorageProperty("name") || this.defaultName * } * set name(value: string | undefined) { * this.setStorageProperty("name", value) * } * readonly defaultSurname?: string * get surname(): string | undefined { * return this.getStorageProperty("surname") || this.defaultSurname * } * set surname(value: string | undefined) { * this.setStorageProperty("surname", value) * } * readonly defaultAge?: number | undefined * get age(): number | undefined { * return this.getStorageProperty("age") || this.defaultAge * } * set age(value: number | undefined) { * this.setStorageProperty("age", value) * } * readonly icon?: string * get icon(): string | undefined { * return this._icon * } * readonly color?: string | undefined * } * ``` */ interface CharacterInterface { /** * The id of the character. It must be unique. */ id: string; } export { CharacterBaseModel, type CharacterEmotionId, type CharacterIdType, type CharacterInterface, CharacterStoredClass, type PixivnCharacterIds, RegisteredCharacters };