UNPKG

narraleaf-react

Version:

A React visual novel player framework

57 lines (56 loc) 2.6 kB
import { LogicAction } from "../game"; import { Color } from "../types"; import { DeepPartial } from "../../../util/data"; import { Actionable } from "../action/actionable"; import { Chained, Proxied } from "../action/chain"; import { Sentence, SentencePrompt, SentenceUserConfig, SingleWord } from "../elements/character/sentence"; export type CharacterConfig = { color?: Color; }; export interface Character { (content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; (content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>; (content: SentencePrompt, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; (texts: TemplateStringsArray, ...words: SingleWord[]): Proxied<Character, Chained<LogicAction.Actions>>; } export declare class Character extends Actionable<CharacterStateData, Character> { constructor(name: string | null, config?: DeepPartial<CharacterConfig>); /** * Say something * @example * ```typescript * character.say("Hello, world!"); * ``` * @example * ```typescript * character * .say("Hello, world!") * .say("Hello, world!"); * ``` * @example * ```typescript * character.say(new Sentence(character, [ * "Hello, ", * new Word("world", {color: "#f00"}), // Some words can be colored * ])); * @example * ```typescript * character.say`Hello, ${Word.color("world", "#f00")}!`; * ``` * @example * ```typescript * character`Hello, ${Word.color("world", "#f00")}!`; * ``` * @chainable */ say(content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; say(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>; say(content: SentencePrompt, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; say(texts: TemplateStringsArray, ...words: SingleWord[]): Proxied<Character, Chained<LogicAction.Actions>>; setName(name: string): Proxied<Character, Chained<LogicAction.Actions>>; apply(content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; apply(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>; apply(content: SentencePrompt, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>; apply(texts: TemplateStringsArray, ...words: SingleWord[]): Proxied<Character, Chained<LogicAction.Actions>>; } export declare const Narrator: Character;