Attribute Item Subtype #76

Merged
Oliver merged 50 commits from feature/attribute-items into main 2026-04-27 02:12:56 +00:00
Showing only changes of commit 71fce2c0ca - Show all commits

View file

@ -1,3 +1,5 @@
import { __ID__ } from "../../consts.mjs";
export class PlayerData extends foundry.abstract.TypeDataModel { export class PlayerData extends foundry.abstract.TypeDataModel {
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
@ -38,12 +40,11 @@ export class PlayerData extends foundry.abstract.TypeDataModel {
*/ */
async _preCreate(data, options, user) { async _preCreate(data, options, user) {
// Assign the defaults from the world setting if they exist // Assign the default items from the world setting if required
const defaults = game.settings.get(__ID__, `actorDefaultAttributes`) ?? {}; const items = this.parent._source.items;
if (!hasProperty(data, `system.attr`)) { if (items == null || items.length === 0) {
// Remove with issue: Foundry/taf#55 const defaults = game.settings.get(__ID__, `actorDefaultAttributes`) ?? [];
const value = game.release.generation > 13 ? _replace(defaults) : defaults; this.parent.updateSource({ items: defaults });
this.updateSource({ "system.==attr": value });
}; };
return super._preCreate(data, options, user); return super._preCreate(data, options, user);