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
}
private defaultName: string = ""
get name(): string {
return this.getStorageProperty<string>("name") || this.defaultName
}
set name(value: string) {
this.setStorageProperty<string>("name", value)
}
private defaultSurname?: string
get surname(): string | undefined {
return this.getStorageProperty<string>("surname") || this.defaultSurname
}
set surname(value: string | undefined) {
this.setStorageProperty<string>("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
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
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:68
Type Parameters
T
T
Parameters
propertyName
string
value
Returns
void
Deprecated
Remove the type parameter, it is not needed and it is not used in the implementation.