123456789101112131415161718192021222324252627282930313233343536373839 |
- /// <reference path="StoredVariable.ts" />
- interface SavedEventOptions<T> extends StoredVariableOptions<T> {
- description : string;
- valueDescription : (value : T) => string;
- }
- class SavedEvent<T> extends StoredVariable<T> {
- private description : string;
- public getValueDescription : (value : T) => string;
- public constructor (options : SavedEventOptions<T>) {
- super(options);
- this.description = options.description;
- this.getValueDescription = options.valueDescription;
- }
- public getDescription () {
- return this.description;
- }
- }
- //Example
- let EVENT_ORC_CHIEF_KILLED = new SavedEvent<boolean>(
- <SavedEventOptions<boolean>> {
- id: "EVENT_ORC_CHIEF_KILLED",
- description: "Describer whether the orc chief is alive or dead.",
- value: false,
- valueDescription: (value: boolean) => {
- if (EVENT_ORC_CHIEF_KILLED.value) {
- return "The orc chief has been killed.";
- } else {
- return "The orc chief is alive."
- }
- }
- }
- );
|