mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Refactor/84 data models structure (#131)
* - Move all DataModel item files to a new 'items' subfolder for better organization - Add _module.mjs file to simplify imports - Update all import paths - Rename class for use the new acronym DH * FIX: remove unnecessary import * FEAT: BaseDataItem class add TODO comments for future improvements FIX: Remove effect field on template FIX: remove unused DhpEffects file * FEAT: new FormulaField class FEAT: add getRollData on BaseDataItem Class FEAT: weapon FIX: remove inventoryWeapon field on Weapon Data Model * FEAT: add class prepareBaseData for domains * FEAT: new ForeignDocumentUUIDField FIX: Remove unnecessary fields FEAT: use ForeignDocumentUUIDField in the Item Class DataModel * FIX: remove wrong option in String Field * FIX: remove unused import * FIX: ADD htmlFields description in manifest * FIX: minor fixes * REFACTOR: rename folder `data/items` -> `data/item` REFACTOR: rename folder `data/messages` -> `data/chat-message`. * FIX: imports FIX: items sheet new paths FIX: ItemDataModelMetadata type jsdoc * FEAT: formatting code FIX: fix fields used FEAT: add jsdoc * 110 - Class Data Model (#111) * Added PreCreate/Create/Delete logic for Class/Subclass and set it as foreignUUID fields in PC * Moved methods into TypedModelData * Simplified Subclass * Fixed up data model and a basic placeholder template (#117) * 118 - adversary data model (#119) * Fixed datamodel and set up basic template in new style * Added in a temp attack button, because why not * Restored HitPoints counting up * 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 * Added a basic BaseDataActor data model * Gathered exports * getRollData recursion fix * Feature/112 items use action datamodel (#127) * Create new actions classes * actions types - attack roll * fixes before merge * First PR * Add daggerheart.css to gitignore * Update ToDo * Remove console log * Fixed chat /dr roll * Remove jQuery * Fixed so the different chat themes work again * Fixed duality roll buttons * Fix to advantage/disadvantage shortcut * Extand action to other item types * Roll fixes * Fixes to adversary rolls * resources * Fixed adversary dice --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> * Feature/116-implementation-of-pseudo-documents (#125) * FEAT: add baseDataModel logic * FEAT: new PseudoDocumentsField FIX: BasePseudoDocument 's getEmbeddedDocument * FEAT: PseudoDocument class * FEAT: add TypedPseudoDocument REFACTOR: PreudoDocument FIX: Typos Bug * FIX: CONFIG types * FEAT: basic PseudoDocumentSheet * FIX: remove schema ADD: input of example --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com> * Levelup Followup (#126) * Levelup applies bonuses to character * Added visualisation of domain card levels * Fixed domaincard level max for selections in a tier * A trait can now only be level up once within the same tier --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: joaquinpereyra98 <24190917+joaquinpereyra98@users.noreply.github.com> Co-authored-by: Dapoulp <74197441+Dapoulp@users.noreply.github.com>
This commit is contained in:
parent
90bc2dc488
commit
187ee3e1bd
153 changed files with 5481 additions and 4829 deletions
161
daggerheart.mjs
161
daggerheart.mjs
|
|
@ -13,11 +13,13 @@ 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;
|
||||
|
||||
Hooks.once('init', () => {
|
||||
CONFIG.daggerheart = SYSTEM;
|
||||
|
||||
game.system.api = {
|
||||
applications,
|
||||
models,
|
||||
|
|
@ -35,21 +37,12 @@ Hooks.once('init', () => {
|
|||
}));
|
||||
|
||||
CONFIG.Item.documentClass = documents.DhpItem;
|
||||
CONFIG.Item.dataModels = {
|
||||
ancestry: models.DhpAncestry,
|
||||
community: models.DhpCommunity,
|
||||
class: models.DhpClass,
|
||||
subclass: models.DhpSubclass,
|
||||
feature: models.DhpFeature,
|
||||
domainCard: models.DhpDomainCard,
|
||||
miscellaneous: models.DhpMiscellaneous,
|
||||
consumable: models.DhpConsumable,
|
||||
weapon: models.DhpWeapon,
|
||||
armor: models.DhpArmor
|
||||
};
|
||||
|
||||
//Registering the Item DataModel
|
||||
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 });
|
||||
|
|
@ -62,13 +55,10 @@ Hooks.once('init', () => {
|
|||
Items.registerSheet(SYSTEM.id, applications.DhpArmor, { types: ['armor'], makeDefault: true });
|
||||
|
||||
CONFIG.Actor.documentClass = documents.DhpActor;
|
||||
CONFIG.Actor.dataModels = {
|
||||
pc: models.DhpPC,
|
||||
adversary: models.DhpAdversary,
|
||||
environment: models.DhpEnvironment
|
||||
};
|
||||
Actors.unregisterSheet('core', foundry.appv1.sheets.ActorSheet);
|
||||
Actors.registerSheet(SYSTEM.id, applications.DhpPCSheet, { types: ['pc'], makeDefault: true });
|
||||
CONFIG.Actor.dataModels = models.actors.config;
|
||||
|
||||
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 });
|
||||
|
||||
|
|
@ -90,12 +80,7 @@ Hooks.once('init', () => {
|
|||
base: models.DhCombatant
|
||||
};
|
||||
|
||||
CONFIG.ChatMessage.dataModels = {
|
||||
dualityRoll: models.DhpDualityRoll,
|
||||
adversaryRoll: models.DhpAdversaryRoll,
|
||||
damageRoll: models.DhpDamageRoll,
|
||||
abilityUse: models.DhpAbilityUse
|
||||
};
|
||||
CONFIG.ChatMessage.dataModels = models.messages.config;
|
||||
CONFIG.ChatMessage.documentClass = applications.DhpChatMessage;
|
||||
|
||||
CONFIG.Canvas.rulerClass = DhpRuler;
|
||||
|
|
@ -150,37 +135,24 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
|
|||
});
|
||||
|
||||
const renderDualityButton = async event => {
|
||||
const button = event.currentTarget;
|
||||
const attributeValue = button.dataset.attribute?.toLowerCase();
|
||||
|
||||
const target = getCommandTarget();
|
||||
const button = event.currentTarget,
|
||||
traitValue = button.dataset.trait?.toLowerCase(),
|
||||
target = getCommandTarget();
|
||||
if (!target) return;
|
||||
|
||||
const rollModifier = attributeValue ? target.system.attributes[attributeValue].data.value : null;
|
||||
const { roll, hope, fear, advantage, disadvantage, modifiers } = await target.diceRoll({
|
||||
title: button.dataset.label,
|
||||
value: rollModifier
|
||||
});
|
||||
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
|
||||
const config = {
|
||||
event: event,
|
||||
title: button.dataset.title,
|
||||
roll: {
|
||||
modifier: traitValue ? target.system.traits[traitValue].value : null,
|
||||
label: button.dataset.label,
|
||||
type: button.dataset.actionType ?? null // Need check
|
||||
},
|
||||
user: game.user.id,
|
||||
content: 'systems/daggerheart/templates/chat/duality-roll.hbs',
|
||||
rolls: [roll]
|
||||
chatMessage: {
|
||||
template: 'systems/daggerheart/templates/chat/duality-roll.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
await cls.create(msgData);
|
||||
await target.diceRoll(config);
|
||||
};
|
||||
|
||||
Hooks.on('renderChatMessageHTML', (_, element) => {
|
||||
|
|
@ -209,68 +181,60 @@ Hooks.on('chatMessage', (_, message) => {
|
|||
return false;
|
||||
}
|
||||
|
||||
const attributeValue = rollCommand.attribute?.toLowerCase();
|
||||
const traitValue = rollCommand.trait?.toLowerCase();
|
||||
const advantageState = rollCommand.advantage ? true : rollCommand.disadvantage ? false : null;
|
||||
|
||||
// Target not required if an attribute is not used.
|
||||
const target = attributeValue ? getCommandTarget() : undefined;
|
||||
if (target || !attributeValue) {
|
||||
const target = traitValue ? getCommandTarget() : undefined;
|
||||
if (target || !traitValue) {
|
||||
new Promise(async (resolve, reject) => {
|
||||
const attribute = target ? target.system.attributes[attributeValue] : undefined;
|
||||
if (attributeValue && !attribute) {
|
||||
const trait = target ? target.system.traits[traitValue] : undefined;
|
||||
if (traitValue && !trait) {
|
||||
ui.notifications.error(game.i18n.localize('DAGGERHEART.Notification.Error.AttributeFaulty'));
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
const title = attributeValue
|
||||
const title = traitValue
|
||||
? game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', {
|
||||
ability: game.i18n.localize(abilities[attributeValue].label)
|
||||
ability: game.i18n.localize(abilities[traitValue].label)
|
||||
})
|
||||
: game.i18n.localize('DAGGERHEART.General.Duality');
|
||||
|
||||
const hopeAndFearRoll = `1${rollCommand.hope ?? 'd12'}+1${rollCommand.fear ?? 'd12'}`;
|
||||
const advantageRoll = `${rollCommand.advantage && !rollCommand.disadvantage ? '+d6' : rollCommand.disadvantage && !rollCommand.advantage ? '-d6' : ''}`;
|
||||
const attributeRoll = `${attribute?.data?.value ? `${attribute.data.value > 0 ? `+${attribute.data.value}` : `${attribute.data.value}`}` : ''}`;
|
||||
const roll = new Roll(`${hopeAndFearRoll}${advantageRoll}${attributeRoll}`);
|
||||
await roll.evaluate();
|
||||
const advantageRoll = `${advantageState === true ? '+d6' : advantageState === false ? '-d6' : ''}`;
|
||||
const attributeRoll = `${trait?.value ? `${trait.value > 0 ? `+${trait.value}` : `${trait.value}`}` : ''}`;
|
||||
const roll = await Roll.create(`${hopeAndFearRoll}${advantageRoll}${attributeRoll}`).evaluate();
|
||||
|
||||
setDiceSoNiceForDualityRoll(
|
||||
roll,
|
||||
rollCommand.advantage && !rollCommand.disadvantage,
|
||||
rollCommand.disadvantage && !rollCommand.advantage
|
||||
);
|
||||
setDiceSoNiceForDualityRoll(roll, advantageState);
|
||||
|
||||
resolve({
|
||||
roll,
|
||||
attribute: attribute
|
||||
trait: trait
|
||||
? {
|
||||
value: attribute.data.value,
|
||||
label: `${game.i18n.localize(abilities[attributeValue].label)} ${attribute.data.value >= 0 ? `+` : ``}${attribute.data.value}`
|
||||
value: trait.value,
|
||||
label: `${game.i18n.localize(abilities[traitValue].label)} ${trait.value >= 0 ? `+` : ``}${trait.value}`
|
||||
}
|
||||
: undefined,
|
||||
title
|
||||
});
|
||||
}).then(({ roll, attribute, title }) => {
|
||||
}).then(async ({ roll, trait, title }) => {
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const systemData = new DHDualityRoll({
|
||||
title: title,
|
||||
origin: target?.id,
|
||||
roll: roll,
|
||||
modifiers: trait ? [trait] : [],
|
||||
hope: { dice: rollCommand.hope ?? 'd12', value: roll.dice[0].total },
|
||||
fear: { dice: rollCommand.fear ?? 'd12', value: roll.dice[1].total },
|
||||
advantage: advantageState !== null ? { dice: 'd6', value: roll.dice[2].total } : undefined,
|
||||
advantageState
|
||||
});
|
||||
|
||||
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',
|
||||
rolls: [roll]
|
||||
|
|
@ -299,13 +263,22 @@ 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',
|
||||
'systems/daggerheart/templates/ui/combat/combatTrackerSection.hbs'
|
||||
'systems/daggerheart/templates/ui/combat/combatTrackerSection.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/damage.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/healing.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/resource.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/uuid.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/uses.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/roll.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/cost.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/range-target.hbs',
|
||||
'systems/daggerheart/templates/views/actionTypes/effect.hbs'
|
||||
]);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue