mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.198.1
This commit is contained in:
37
js/bestiary/bestiary-encounterbuilder-component.js
Normal file
37
js/bestiary/bestiary-encounterbuilder-component.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import {EncounterBuilderComponent} from "../encounterbuilder/encounterbuilder-component.js";
|
||||
|
||||
export class EncounterBuilderComponentBestiary extends EncounterBuilderComponent {
|
||||
getSublistPluginState () {
|
||||
return {
|
||||
// region Special handling for `creatureMetas`
|
||||
items: this._state.creatureMetas
|
||||
.map(creatureMeta => ({
|
||||
h: creatureMeta.getHash(),
|
||||
c: creatureMeta.count,
|
||||
customHashId: creatureMeta.customHashId || undefined,
|
||||
l: creatureMeta.isLocked,
|
||||
})),
|
||||
sources: this._state.creatureMetas
|
||||
.map(creatureMeta => creatureMeta.creature.source)
|
||||
.unique(),
|
||||
// endregion
|
||||
|
||||
...Object.fromEntries(
|
||||
Object.entries(this._state)
|
||||
.filter(([k]) => k !== "creatureMetas")
|
||||
.map(([k, v]) => [k, MiscUtil.copyFast(v)]),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/** Get a generic representation of the encounter, which can be used elsewhere. */
|
||||
static getStateFromExportedSublist ({exportedSublist}) {
|
||||
exportedSublist = MiscUtil.copyFast(exportedSublist);
|
||||
|
||||
const out = this._getDefaultState();
|
||||
Object.keys(out)
|
||||
.filter(k => exportedSublist[k] != null)
|
||||
.forEach(k => out[k] = exportedSublist[k]);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user