Added background and connection questions (#1109)

This commit is contained in:
WBHarry 2025-08-29 01:26:22 +02:00 committed by GitHub
parent 8fd63d5963
commit c6741b1c7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 201 additions and 39 deletions

View file

@ -49,6 +49,8 @@ export default class DHClass extends BaseDataItem {
suggestedSecondaryWeapon: new ForeignDocumentUUIDField({ type: 'Item' }),
suggestedArmor: new ForeignDocumentUUIDField({ type: 'Item' })
}),
backgroundQuestions: new fields.ArrayField(new fields.StringField(), { initial: ['', '', ''] }),
connections: new fields.ArrayField(new fields.StringField(), { initial: ['', '', ''] }),
isMulticlass: new fields.BooleanField({ initial: false })
};
}
@ -96,6 +98,20 @@ export default class DHClass extends BaseDataItem {
}
}
}
if (!data.system.isMulticlass) {
const addQuestions = (base, questions) => {
return `${base}${questions.map(q => `<p><strong>${q}</strong></p>`).join('<br/>')}`;
};
const backgroundQuestions = data.system.backgroundQuestions.filter(x => x);
const connections = data.system.connections.filter(x => x);
await this.actor.update({
'system.biography': {
background: addQuestions(this.actor.system.biography.background, backgroundQuestions),
connections: addQuestions(this.actor.system.biography.connections, connections)
}
});
}
}
const allowed = await super._preCreate(data, options, user);