Class: StoredClassModel
Defined in: src/storage/classes/StoredClassModel.ts:33
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)
}
}
Extended by
Constructors
Constructor
> new StoredClassModel(categoryId, id): StoredClassModel
Defined in: src/storage/classes/StoredClassModel.ts:38
Parameters
categoryId
string
The id of the category. For example if you are storing a character class, you can use "characters" as categoryId. so all instances of the character class will be stored in the "characters" category.
id
string
The id of instance of the class. This id must be unique for the category.
Returns
StoredClassModel
Properties
id
> readonly id: string
Defined in: src/storage/classes/StoredClassModel.ts:63
Is id of the stored class. is unique for this class.
Methods
getStorageProperty()
> protected getStorageProperty<T>(propertyName, idToUse?): T | undefined
Defined in: src/storage/classes/StoredClassModel.ts:83
Get a property from the storage.
Type Parameters
T
Parameters
propertyName
string
The name of the property to get.
idToUse?
string = ...
The id of the instance to get the property.
Returns
T | undefined
The value of the property. If the property is not found, returns undefined.
Default
this.id
migrateOldStorage()
> protected migrateOldStorage(oldCategoryId?): void
Defined in: src/storage/classes/StoredClassModel.ts:43
Parameters
oldCategoryId?
string = ...
Returns
void
~~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.