Add way to set default attributes now that we no longer have the AttributeManager (closes #83)
This commit is contained in:
parent
a9567c200a
commit
504a91bb9c
3 changed files with 45 additions and 0 deletions
|
|
@ -155,4 +155,30 @@ export class TAFActor extends Actor {
|
|||
};
|
||||
};
|
||||
// #endregion Data Migration
|
||||
|
||||
// #region Static API
|
||||
/**
|
||||
* Sets the default attributes that are created when a new Actor is created,
|
||||
* this uses all of the existing values that are a part of the items, it does
|
||||
* not prompt for default values.
|
||||
*/
|
||||
static async setDefaultAttributes(actor) {
|
||||
if (!game.user.isGM) { return };
|
||||
const minifiedData = [];
|
||||
|
||||
const attrs = actor.itemTypes.attribute ?? [];
|
||||
for (const attr of attrs) {
|
||||
const raw = attr.toObject();
|
||||
minifiedData.push({
|
||||
img: raw.img, // doesn't really matter but ¯\_(ツ)_/¯
|
||||
name: raw.name,
|
||||
type: raw.type,
|
||||
system: raw.system,
|
||||
});
|
||||
};
|
||||
|
||||
game.settings.set(__ID__, `actorDefaultAttributes`, minifiedData);
|
||||
ui.notifications.success(_loc(`taf.notifs.success.saved-default-attributes`));
|
||||
};
|
||||
// #endregion Static API
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue