113 - Character Data Model (#114)

* Improved Character datamodel

* Removed additional unneccessary getters

* Preliminary cleanup in the class sheet

* Cleanup of 'pc' references

* Corrected Duality rolling from Character

* Fix to damage roll
This commit is contained in:
WBHarry 2025-06-09 13:36:48 +02:00 committed by GitHub
parent 02f16f7363
commit 70382df63c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1135 additions and 2001 deletions

View file

@ -13,6 +13,7 @@ import { dualityRollEnricher } from './module/enrichers/DualityRollEnricher.mjs'
import { getCommandTarget, rollCommandToJSON, setDiceSoNiceForDualityRoll } from './module/helpers/utils.mjs';
import { abilities } from './module/config/actorConfig.mjs';
import Resources from './module/applications/resources.mjs';
import DHDualityRoll from './module/data/chat-message/dualityRoll.mjs';
globalThis.SYSTEM = SYSTEM;
@ -40,7 +41,7 @@ Hooks.once('init', () => {
CONFIG.Item.dataModels = models.items.config;
const { Items, Actors } = foundry.documents.collections;
Items.unregisterSheet('core', foundry.appv1.sheets.ItemSheet);
Items.unregisterSheet('core', foundry.applications.sheets.ItemSheetV2);
Items.registerSheet(SYSTEM.id, applications.DhpAncestry, { types: ['ancestry'], makeDefault: true });
Items.registerSheet(SYSTEM.id, applications.DhpCommunity, { types: ['community'], makeDefault: true });
Items.registerSheet(SYSTEM.id, applications.DhpClassSheet, { types: ['class'], makeDefault: true });
@ -54,12 +55,12 @@ Hooks.once('init', () => {
CONFIG.Actor.documentClass = documents.DhpActor;
CONFIG.Actor.dataModels = {
pc: models.DhpPC,
character: models.DhCharacter,
adversary: models.DhpAdversary,
environment: models.DhpEnvironment
};
Actors.unregisterSheet('core', foundry.appv1.sheets.ActorSheet);
Actors.registerSheet(SYSTEM.id, applications.DhpPCSheet, { types: ['pc'], makeDefault: true });
Actors.unregisterSheet('core', foundry.applications.sheets.ActorSheetV2);
Actors.registerSheet(SYSTEM.id, applications.DhCharacterSheet, { types: ['character'], makeDefault: true });
Actors.registerSheet(SYSTEM.id, applications.DhpAdversarySheet, { types: ['adversary'], makeDefault: true });
Actors.registerSheet(SYSTEM.id, applications.DhpEnvironment, { types: ['environment'], makeDefault: true });
@ -137,22 +138,28 @@ const renderDualityButton = async event => {
title: button.dataset.label,
value: rollModifier
});
const systemData = new DHDualityRoll({
title: button.dataset.label,
origin: target.id,
roll: roll._formula,
modifiers: modifiers,
hope: hope,
fear: fear,
advantage: advantage,
disadvantage: disadvantage
});
const cls = getDocumentClass('ChatMessage');
const msgData = {
type: 'dualityRoll',
sound: CONFIG.sounds.dice,
system: {
title: button.dataset.label,
origin: target.id,
roll: roll._formula,
modifiers: modifiers,
hope: hope,
fear: fear,
advantage: advantage,
disadvantage: disadvantage
},
system: systemData,
user: game.user.id,
content: 'systems/daggerheart/templates/chat/duality-roll.hbs',
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/duality-roll.hbs',
systemData
),
rolls: [roll]
};
@ -226,29 +233,34 @@ Hooks.on('chatMessage', (_, message) => {
: undefined,
title
});
}).then(({ roll, attribute, title }) => {
}).then(async ({ roll, attribute, title }) => {
const cls = getDocumentClass('ChatMessage');
const systemData = new DHDualityRoll({
title: title,
origin: target?.id,
roll: roll._formula,
modifiers: attribute ? [attribute] : [],
hope: { dice: rollCommand.hope ?? 'd12', value: roll.dice[0].total },
fear: { dice: rollCommand.fear ?? 'd12', value: roll.dice[1].total },
advantage:
rollCommand.advantage && !rollCommand.disadvantage
? { dice: 'd6', value: roll.dice[2].total }
: undefined,
disadvantage:
rollCommand.disadvantage && !rollCommand.advantage
? { dice: 'd6', value: roll.dice[2].total }
: undefined
});
const msgData = {
type: 'dualityRoll',
sound: CONFIG.sounds.dice,
system: {
title: title,
origin: target?.id,
roll: roll._formula,
modifiers: attribute ? [attribute] : [],
hope: { dice: rollCommand.hope ?? 'd12', value: roll.dice[0].total },
fear: { dice: rollCommand.fear ?? 'd12', value: roll.dice[1].total },
advantage:
rollCommand.advantage && !rollCommand.disadvantage
? { dice: 'd6', value: roll.dice[2].total }
: undefined,
disadvantage:
rollCommand.disadvantage && !rollCommand.advantage
? { dice: 'd6', value: roll.dice[2].total }
: undefined
},
system: systemData,
user: game.user.id,
content: 'systems/daggerheart/templates/chat/duality-roll.hbs',
content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/chat/duality-roll.hbs',
systemData
),
rolls: [roll]
};
@ -275,10 +287,10 @@ const preloadHandlebarsTemplates = async function () {
'systems/daggerheart/templates/sheets/parts/heritage.hbs',
'systems/daggerheart/templates/sheets/parts/subclassFeature.hbs',
'systems/daggerheart/templates/sheets/parts/effects.hbs',
'systems/daggerheart/templates/sheets/pc/sections/inventory.hbs',
'systems/daggerheart/templates/sheets/pc/sections/loadout.hbs',
'systems/daggerheart/templates/sheets/pc/parts/heritageCard.hbs',
'systems/daggerheart/templates/sheets/pc/parts/advancementCard.hbs',
'systems/daggerheart/templates/sheets/character/sections/inventory.hbs',
'systems/daggerheart/templates/sheets/character/sections/loadout.hbs',
'systems/daggerheart/templates/sheets/character/parts/heritageCard.hbs',
'systems/daggerheart/templates/sheets/character/parts/advancementCard.hbs',
'systems/daggerheart/templates/components/card-preview.hbs',
'systems/daggerheart/templates/views/levelup/parts/selectable-card-preview.hbs',
'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs',