UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

98 lines (95 loc) 2.88 kB
import 'crypto-js/sha1'; var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; function checkIfStepsIsEqual(step1, step2) { return step1 === step2; } // src/classes/LabelAbstract.ts var LabelAbstract = class { /** * @param id is the id of the label * @param props is the properties of the label */ constructor(id, props) { this._id = id; this._onStepStart = props == null ? void 0 : props.onStepStart; this._onLoadStep = props == null ? void 0 : props.onLoadStep; this._onStepEnd = props == null ? void 0 : props.onStepEnd; this._choiseIndex = props == null ? void 0 : props.choiseIndex; } /** * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById} */ get id() { return this._id; } /** * Get the corresponding steps number * @param externalSteps * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1 */ getCorrespondingStepsNumber(externalSteps) { if (externalSteps.length === 0) { return 0; } let res = 0; externalSteps.forEach((step, index) => { if (checkIfStepsIsEqual(step, this.steps[index])) { res = index; } }); return res; } /** * Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file. * @returns Promise<void> or void */ get onStepStart() { return (stepIndex, label) => __async(this, null, function* () { if (this._onLoadStep) { yield this._onLoadStep(stepIndex, label); } if (this._onStepStart) { return yield this._onStepStart(stepIndex, label); } }); } /** * Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file. * @returns Promise<void> or void */ get onLoadStep() { return this._onLoadStep; } /** * Is a function that will be executed when the step ends. * @returns Promise<void> or void */ get onStepEnd() { return this._onStepEnd; } get choiseIndex() { return this._choiseIndex; } }; export { LabelAbstract as default }; //# sourceMappingURL=LabelAbstract.mjs.map //# sourceMappingURL=LabelAbstract.mjs.map