wyrm-engine
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -77,2 +77,18 @@ "use strict"; | ||
}; | ||
Encounter.prototype.getState = function () { | ||
var teamA = this.encounterConfig.teamA | ||
.map(function (character) { return lodash_1.omit(character, 'controllerCallback'); }) | ||
.map(lodash_1.cloneDeep); | ||
var teamB = this.encounterConfig.teamB | ||
.map(function (character) { return lodash_1.omit(character, 'controllerCallback'); }) | ||
.map(lodash_1.cloneDeep); | ||
return { | ||
id: this.encounterConfig.id, | ||
teamA: teamA, | ||
teamB: teamB, | ||
}; | ||
}; | ||
Encounter.prototype.loadState = function (state) { | ||
this.encounterConfig = lodash_1.cloneDeep(state); | ||
}; | ||
Encounter.prototype.getRoundOrder = function () { | ||
@@ -79,0 +95,0 @@ var allCharacters = __spreadArrays(this.encounterConfig.teamA.filter(function (char) { return char.currentHp > 0; }), this.encounterConfig.teamB.filter(function (char) { return char.currentHp > 0; })); |
import { IAction } from './interfaces/IAction'; | ||
import { IEncounterConfig } from './interfaces/IEncounterConfig'; | ||
import { IEcounterLog } from './interfaces/IEncounterLog'; | ||
import { IEncounterState } from './interfaces/IEncounterState'; | ||
export declare class Encounter { | ||
@@ -14,2 +15,4 @@ private encounterConfig; | ||
getEncounterLogs(): IEcounterLog; | ||
getState(): IEncounterState; | ||
loadState(state: IEncounterConfig): void; | ||
private getRoundOrder; | ||
@@ -16,0 +19,0 @@ private pickCharacterBasingOnInitiative; |
@@ -6,2 +6,3 @@ export * from './IAction'; | ||
export * from './IEncounterLog'; | ||
export * from './IEncounterState'; | ||
export * from './IEngineCharacter'; | ||
@@ -8,0 +9,0 @@ export * from './IEngineConfig'; |
import { IAction } from './interfaces/IAction'; | ||
import { IEncounterConfig } from './interfaces/IEncounterConfig'; | ||
import { IEcounterLog } from './interfaces/IEncounterLog'; | ||
import { IEncounterState } from './interfaces/IEncounterState'; | ||
export declare class Encounter { | ||
@@ -14,2 +15,4 @@ private encounterConfig; | ||
getEncounterLogs(): IEcounterLog; | ||
getState(): IEncounterState; | ||
loadState(state: IEncounterConfig): void; | ||
private getRoundOrder; | ||
@@ -16,0 +19,0 @@ private pickCharacterBasingOnInitiative; |
@@ -6,2 +6,3 @@ export * from './IAction'; | ||
export * from './IEncounterLog'; | ||
export * from './IEncounterState'; | ||
export * from './IEngineCharacter'; | ||
@@ -8,0 +9,0 @@ export * from './IEngineConfig'; |
@@ -5,3 +5,3 @@ { | ||
"email": "momatoku@gmail.com", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Fully typed game engine library designed to simulate battles between virtual characters", | ||
@@ -8,0 +8,0 @@ "main": "./bundles/index.umd.js", |
@@ -471,2 +471,15 @@ # wyrm-engine | ||
#### Encounter state | ||
It is possible to obtain/load the encounter's state via `getState` and `loadState` functions. | ||
Please note that state does not include callbacks defined during creation of encounter. | ||
Those can be re-added during load: | ||
```typescript | ||
const state = encounter.getState(); | ||
encounter.loadState({ | ||
...state, | ||
logMessageCallback: console.log | ||
}) | ||
``` | ||
## Customising engine | ||
@@ -473,0 +486,0 @@ Work in progress :) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3135449
142
35182
492