LogoPixi’VN
indexClasses

Class: CharacterStoredClass

Defined in: src/characters/classes/CharacterStoredClass.ts:5

StoredClassModel is a abstract class that contains the methods to store a class in the game. I suggest you extend this class to create your own stored class.

Example

export class CharacterBaseModel extends StoredClassModel implements CharacterBaseModelProps {
    constructor(id: string, props: CharacterBaseModelProps) {
        super("___character___", id)
        this.defaultName = props.name
        this.defaultSurname = props.surname
    }
    readonly defaultName: string = ""
    get name(): string {
        return this.getStorageProperty<string>("name") || this.defaultName
    }
    set name(value: string) {
        this.setStorageProperty("name", value)
    }
    readonly defaultSurname?: string
    get surname(): string | undefined {
        return this.getStorageProperty<string>("surname") || this.defaultSurname
    }
    set surname(value: string | undefined) {
        this.setStorageProperty("surname", value)
    }
}

Extends

Extended by

Constructors

Constructor

> new CharacterStoredClass(id, emotion?): CharacterStoredClass

Defined in: src/characters/classes/CharacterStoredClass.ts:7

Parameters

id

string

emotion?

string = ""

Returns

CharacterStoredClass

Overrides

StoredClassModel.constructor

Properties

id

> readonly id: string

Defined in: src/storage/classes/StoredClassModel.ts:63

Is id of the stored class. is unique for this class.

Inherited from

StoredClassModel.id

Methods

getStorageProperty()

> getStorageProperty<T>(propertyName): T | undefined

Defined in: src/characters/classes/CharacterStoredClass.ts:16

Get a property from the storage.

Type Parameters

T

T

Parameters

propertyName

string

The name of the property to get.

Returns

T | undefined

The value of the property. If the property is not found, returns undefined.

Default

this.id

Overrides

StoredClassModel.getStorageProperty


migrateOldStorage()

> protected migrateOldStorage(oldCategoryId?): void

Defined in: src/storage/classes/StoredClassModel.ts:43

Parameters

oldCategoryId?

string = ...

Returns

void

Inherited from

StoredClassModel.migrateOldStorage


setStorageProperty()

> protected setStorageProperty<T>(propertyName, value): void

Defined in: src/storage/classes/StoredClassModel.ts:71

Update a property in the storage.

Type Parameters

T

T

The type of the value to set. (Deprecated, it is not necessary to specify the type of the value, it will be inferred from the value)

Parameters

propertyName

string

The name of the property to set.

value

StorageElementType

The value to set. If is undefined, the property will be removed from the storage.

Returns

void

Inherited from

StoredClassModel.setStorageProperty

On this page