Add saving and editing of default attributes and their values (closes #29)
This commit is contained in:
parent
5159db3d33
commit
d540cc72f6
6 changed files with 178 additions and 34 deletions
|
|
@ -1,6 +1,24 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
|
||||
const { Actor } = foundry.documents;
|
||||
const { hasProperty } = foundry.utils;
|
||||
|
||||
export class TAFActor extends Actor {
|
||||
|
||||
// #region Lifecycle
|
||||
async _preCreate(data, options, user) {
|
||||
|
||||
// Assign the defaults from the world setting if they exist
|
||||
const defaults = game.settings.get(__ID__, `actorDefaultAttributes`) ?? {};
|
||||
if (!hasProperty(data, `system.attr`)) {
|
||||
const value = game.release.generation > 13 ? _replace(defaults) : defaults;
|
||||
this.updateSource({ "system.==attr": value });
|
||||
};
|
||||
|
||||
return super._preCreate(data, options, user);
|
||||
};
|
||||
// #endregion Lifecycle
|
||||
|
||||
async modifyTokenAttribute(attribute, value, isDelta = false, isBar = true) {
|
||||
const attr = foundry.utils.getProperty(this.system, attribute);
|
||||
const current = isBar ? attr.value : attr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue