From b7cb97c32378156b5d43ac83e126c1609b511981 Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Sat, 2 Aug 2025 05:15:08 +0200 Subject: [PATCH] Good for now --- .../applications/sheets/actors/adversary.mjs | 10 +- module/data/action/damageAction.mjs | 38 --- module/data/chat-message/_modules.mjs | 18 +- module/data/chat-message/adversaryRoll.mjs | 8 +- module/data/chat-message/damageRoll.mjs | 65 ---- module/data/chat-message/dualityRoll.mjs | 7 - module/dice/d20Roll.mjs | 5 +- module/dice/damageRoll.mjs | 2 - module/dice/dhRoll.mjs | 3 - module/systemRegistration/handlebars.mjs | 2 - styles/less/ui/chat/chat.less | 306 +++++++++--------- templates/ui/chat/adversary-attack-roll.hbs | 47 --- templates/ui/chat/adversary-roll.hbs | 61 ---- templates/ui/chat/parts/damage-chat.hbs | 33 -- templates/ui/chat/parts/target-chat.hbs | 38 --- 15 files changed, 167 insertions(+), 476 deletions(-) delete mode 100644 module/data/chat-message/damageRoll.mjs delete mode 100644 module/data/chat-message/dualityRoll.mjs delete mode 100644 templates/ui/chat/adversary-attack-roll.hbs delete mode 100644 templates/ui/chat/adversary-roll.hbs delete mode 100644 templates/ui/chat/parts/damage-chat.hbs delete mode 100644 templates/ui/chat/parts/target-chat.hbs diff --git a/module/applications/sheets/actors/adversary.mjs b/module/applications/sheets/actors/adversary.mjs index f6324881..e21f1773 100644 --- a/module/applications/sheets/actors/adversary.mjs +++ b/module/applications/sheets/actors/adversary.mjs @@ -108,17 +108,15 @@ export default class AdversarySheet extends DHBaseActorSheet { */ static #reactionRoll(event) { const config = { - event: event, + event, title: `Reaction Roll: ${this.actor.name}`, headerTitle: 'Adversary Reaction Roll', roll: { type: 'reaction' }, - chatMessage: { - type: 'adversaryRoll', - template: 'systems/daggerheart/templates/ui/chat/adversary-roll.hbs', - mute: true - } + type: 'trait', + hasRoll: true, + data: this.actor.getRollData() }; this.actor.diceRoll(config); diff --git a/module/data/action/damageAction.mjs b/module/data/action/damageAction.mjs index ee47df00..3cfa7a5a 100644 --- a/module/data/action/damageAction.mjs +++ b/module/data/action/damageAction.mjs @@ -61,43 +61,5 @@ export default class DHDamageAction extends DHBaseAction { } return CONFIG.Dice.daggerheart.DamageRoll.build(config); - - /* const systemData = data.system ?? data; - - let formulas = this.damage.parts.map(p => ({ - formula: this.getFormulaValue(p, data).getFormula(this.actor), - damageTypes: p.applyTo === 'hitPoints' && !p.type.size ? new Set(['physical']) : p.type, - applyTo: p.applyTo - })); - - if (!formulas.length) return; - - formulas = this.formatFormulas(formulas, systemData); - - const config = { - title: game.i18n.format(`DAGGERHEART.UI.Chat.${this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, { - damage: game.i18n.localize(this.name) - }), - roll: formulas, - targets: systemData.targets?.filter(t => t.hit) ?? data.targets, - hasSave: this.hasSave, - isCritical: systemData.roll?.isCritical ?? false, - isHealing: this.type === 'healing', - hasDamage: this.type !== 'healing', - hasHealing: this.type === 'healing', - hasTarget: true, - source: systemData.source, - data: this.getRollData(), - event - }; - if (this.hasSave) config.onSave = this.save.damageMod; - if (data.system) { - config.source.message = data._id; - config.directDamage = false; - } else { - config.directDamage = true; - } - - return CONFIG.Dice.daggerheart.DamageRoll.build(config); */ } } diff --git a/module/data/chat-message/_modules.mjs b/module/data/chat-message/_modules.mjs index 84f75c1b..2612622c 100644 --- a/module/data/chat-message/_modules.mjs +++ b/module/data/chat-message/_modules.mjs @@ -1,21 +1,11 @@ import DHAbilityUse from "./abilityUse.mjs"; -import DHAdversaryRoll from "./adversaryRoll.mjs"; -import DHDamageRoll from "./damageRoll.mjs"; -import DHDualityRoll from "./dualityRoll.mjs"; +import DHActorRoll from "./adversaryRoll.mjs"; import DHApplyEffect from './applyEffects.mjs' -export { - DHAbilityUse, - DHAdversaryRoll, - DHDamageRoll, - DHDualityRoll, - DHApplyEffect -} - export const config = { abilityUse: DHAbilityUse, - adversaryRoll: DHAdversaryRoll, - damageRoll: DHDamageRoll, - dualityRoll: DHDualityRoll, + adversaryRoll: DHActorRoll, + damageRoll: DHActorRoll, + dualityRoll: DHActorRoll, applyEffect: DHApplyEffect }; diff --git a/module/data/chat-message/adversaryRoll.mjs b/module/data/chat-message/adversaryRoll.mjs index bb205521..24cac3d7 100644 --- a/module/data/chat-message/adversaryRoll.mjs +++ b/module/data/chat-message/adversaryRoll.mjs @@ -1,6 +1,6 @@ const fields = foundry.data.fields; -export default class DHAdversaryRoll extends foundry.abstract.TypeDataModel { +export default class DHActorRoll extends foundry.abstract.TypeDataModel { static defineSchema() { return { title: new fields.StringField(), @@ -27,13 +27,17 @@ export default class DHAdversaryRoll extends foundry.abstract.TypeDataModel { hasEffect: new fields.BooleanField({ initial: false }), hasSave: new fields.BooleanField({ initial: false }), hasTarget: new fields.BooleanField({ initial: false }), + isCritical: new fields.BooleanField({ initial: false }), onSave: new fields.StringField(), source: new fields.SchemaField({ actor: new fields.StringField(), item: new fields.StringField(), action: new fields.StringField() }), - damage: new fields.ObjectField() + damage: new fields.ObjectField(), + costs: new fields.ArrayField( + new fields.ObjectField() + ) }; } diff --git a/module/data/chat-message/damageRoll.mjs b/module/data/chat-message/damageRoll.mjs deleted file mode 100644 index 71de2280..00000000 --- a/module/data/chat-message/damageRoll.mjs +++ /dev/null @@ -1,65 +0,0 @@ -export default class DHDamageRoll extends foundry.abstract.TypeDataModel { - static defineSchema() { - const fields = foundry.data.fields; - - return { - messageType: new fields.StringField({ initial: 'damage' }), - title: new fields.StringField(), - roll: new fields.DataField({}), - targets: new fields.ArrayField( - new fields.SchemaField({ - id: new fields.StringField({ required: true }), - actorId: new fields.StringField({}), - name: new fields.StringField(), - img: new fields.StringField(), - hit: new fields.BooleanField({ initial: false }), - saved: new fields.SchemaField({ - result: new fields.NumberField(), - success: new fields.BooleanField({ nullable: true, initial: null }) - }) - }) - ), - targetSelection: new fields.BooleanField({ initial: false }), - hasSave: new fields.BooleanField({ initial: false }), - isHealing: new fields.BooleanField({ initial: false }), - onSave: new fields.StringField(), - source: new fields.SchemaField({ - actor: new fields.StringField(), - item: new fields.StringField(), - action: new fields.StringField(), - message: new fields.StringField() - }), - directDamage: new fields.BooleanField({ initial: true }), - damage: new fields.ObjectField(), - hasRoll: new fields.BooleanField({ initial: false }), - hasDamage: new fields.BooleanField({ initial: false }), - hasHealing: new fields.BooleanField({ initial: false }), - hasEffect: new fields.BooleanField({ initial: false }) - }; - } - - get messageTemplate() { - return `systems/daggerheart/templates/ui/chat/roll.hbs`; - // return `systems/daggerheart/templates/ui/chat/${this.messageType}-roll.hbs`; - } - - prepareDerivedData() { - this.hasHitTarget = this.targets.filter(t => t.hit === true).length > 0; - this.currentTargets = - this.targetSelection !== true - ? Array.from(game.user.targets).map(t => - game.system.api.fields.ActionFields.TargetField.formatTarget(t) - ) - : this.targets; - if(this.targetSelection === true) { - this.targetShort = this.targets.reduce((a,c) => { - if(c.hit) a.hit += 1; - else c.miss += 1; - return a; - }, {hit: 0, miss: 0}) - } - this.pendingSaves = this.targets.filter( - target => target.hit && target.saved.success === null - ).length > 0; - } -} diff --git a/module/data/chat-message/dualityRoll.mjs b/module/data/chat-message/dualityRoll.mjs deleted file mode 100644 index d1bc7866..00000000 --- a/module/data/chat-message/dualityRoll.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import DHAdversaryRoll from './adversaryRoll.mjs'; - -export default class DHDualityRoll extends DHAdversaryRoll { - get messageTemplate() { - return 'systems/daggerheart/templates/ui/chat/roll.hbs'; - } -} diff --git a/module/dice/d20Roll.mjs b/module/dice/d20Roll.mjs index d93ce01f..28f7ecf7 100644 --- a/module/dice/d20Roll.mjs +++ b/module/dice/d20Roll.mjs @@ -13,8 +13,6 @@ export default class D20Roll extends DHRoll { DISADVANTAGE: -1 }; - static messageType = 'adversaryRoll'; - static CRITICAL_TRESHOLD = 20; static DefaultDialog = D20RollDialog; @@ -153,7 +151,6 @@ export default class D20Roll extends DHRoll { data.difficulty = config.roll.difficulty; data.success = roll.isCritical || roll.total >= config.roll.difficulty; } - data.type = config.roll.type; data.advantage = { type: config.roll.advantage, dice: roll.dAdvantage?.denomination, @@ -167,7 +164,7 @@ export default class D20Roll extends DHRoll { rerolls: dice.results.filter(x => x.rerolled) } })); - data.isCritical = roll.isCritical; + data.isCritical = config.isCritical = roll.isCritical; data.extra = roll.dice .filter(d => !roll.baseTerms.includes(d)) .map(d => { diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index d6321105..bab685b4 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -6,8 +6,6 @@ export default class DamageRoll extends DHRoll { super(formula, data, options); } - static messageType = 'dualityRoll'; - static DefaultDialog = DamageDialog; static async buildEvaluate(roll, config = {}, message = {}) { diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 6fd69c1d..1b490921 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -92,11 +92,8 @@ export default class DHRoll extends Roll { system: config, rolls: [roll] }; - // msg.applyRollMode(config.selectedRollMode); - // return msg; if(roll._evaluated) return await cls.create(msg, { rollMode: config.selectedRollMode }); return msg; - // return await cls.create(msg); } static applyKeybindings(config) { diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index 1afbf7bd..48a99735 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -26,8 +26,6 @@ export const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/actionTypes/effect.hbs', 'systems/daggerheart/templates/actionTypes/beastform.hbs', 'systems/daggerheart/templates/settings/components/settings-item-line.hbs', - 'systems/daggerheart/templates/ui/chat/parts/damage-chat.hbs', - 'systems/daggerheart/templates/ui/chat/parts/target-chat.hbs', 'systems/daggerheart/templates/ui/tooltip/parts/tooltipChips.hbs', 'systems/daggerheart/templates/ui/tooltip/parts/tooltipTags.hbs', 'systems/daggerheart/templates/dialogs/downtime/activities.hbs', diff --git a/styles/less/ui/chat/chat.less b/styles/less/ui/chat/chat.less index 874f0b25..3c5a25f6 100644 --- a/styles/less/ui/chat/chat.less +++ b/styles/less/ui/chat/chat.less @@ -364,7 +364,7 @@ } } -.daggerheart { +.daggerheart, #chat-notifications { .chat-message { --text-color: light-dark(@dark-blue, @golden); --bg-color: light-dark(@dark-blue-40, @golden-40); @@ -489,186 +489,184 @@ } } - .roll-dice { + .roll-dice { + display: flex; + align-items: center; + justify-content: center; + gap: 5px; + font-weight: 700; + font-family: 'Cinzel', sans-serif; + flex-wrap: wrap; + + .roll-die { + display: flex; + flex-direction: column; + gap: 3px; + + label { + text-align: center; + height: var(--font-size-12); + } + + > div { display: flex; align-items: center; justify-content: center; gap: 5px; - font-weight: 700; - font-family: 'Cinzel', sans-serif; - flex-wrap: wrap; - - .roll-die { - display: flex; - flex-direction: column; - gap: 3px; - - label { - text-align: center; - height: var(--font-size-12); - } - - > div { - display: flex; - align-items: center; - justify-content: center; - gap: 5px; - // font-size: var(--font-size-20); - } - } + // font-size: var(--font-size-20); } + } + } - fieldset { - display: flex; - flex-direction: column; - // gap: 10px; - border-color: var(--text-color); - border-radius: 5px; + fieldset { + display: flex; + flex-direction: column; + // gap: 10px; + border-color: var(--text-color); + border-radius: 5px; - legend { - display: flex; - align-items: center; - gap: 10px; - padding: 0 5px; - color: var(--text-color); - } - } + legend { + display: flex; + align-items: center; + gap: 10px; + padding: 0 5px; + color: var(--text-color); + } + } - .target-selector { - + .roll-part-extra { - margin: 0; - } + .target-selector { + + .roll-part-extra { + margin: 0; + } - .target-choice { - display: flex; - font-size: var(--font-size-14); - color: var(--text-color); - padding: 5px 0; + .target-choice { + display: flex; + font-size: var(--font-size-14); + color: var(--text-color); + padding: 5px 0; - .button-target-selection { - flex: 1; - text-align: center; - } - - .button-target-selection:hover, .target-selected { - font-weight: bold; - text-shadow: 0px 0px 8px var(--text-color); - } - } - } - - i { + .button-target-selection { + flex: 1; text-align: center; } - .roll-target { + .button-target-selection:hover, .target-selected { + font-weight: bold; + text-shadow: 0px 0px 8px var(--text-color); + } + } + } + + i { + text-align: center; + } + + .roll-target { + display: flex; + width: 100%; + gap: 10px; + align-items: center; + + .target-img { + border-radius: 50%; + width: 40px; + height: 40px; + object-fit: cover; + } + + .target-data { + flex: 1; + } + + .target-save { + display: flex; + align-items: center; + justify-content: center; + width: 22px; + height: 22px; + &:hover > i { + scale: 1.2; + } + + i { + &.fa-check { + color: @green; + } + &.fa-xmark { + color: @medium-red; + } + } + } + } + + .roll-formula { + background-color: var(--bg-color); + color: var(--text-color); + border-radius: 4px; + padding: 3px 5px; + width: fit-content; + margin: auto; + } + + .roll-difficulty, .target-hit-status { + color: @green; + background-color: @green-10; + border: 1px solid currentColor; + border-radius: 4px; + padding: 3px 5px; + text-transform: uppercase; + font-weight: 600; + + &.is-miss { + color: @medium-red; + background-color: @medium-red-10; + } + } + + .target-hit-status { + width: fit-content; + margin-top: 2px; + } + + div[data-action="expandRoll"] { + .roll-part-header > div > span { + &:before, &:after { + content: '\f078'; + font-family: var(--font-awesome); + color: var(--text-color); + transition: all 0.3s ease; + } + } + + .on-reduced { + display: grid; + overflow: hidden; + grid-template-rows: 1fr; + transition: grid-template-rows 250ms ease; + + .wrapper { display: flex; - width: 100%; gap: 10px; - align-items: center; - - .target-img { - border-radius: 50%; - width: 40px; - height: 40px; - object-fit: cover; - } - - .target-data { - flex: 1; - } - - .target-save { - display: flex; - align-items: center; - justify-content: center; - width: 22px; - height: 22px; - &:hover > i { - scale: 1.2; - } - - i { - &.fa-check { - color: @green; - } - &.fa-xmark { - color: @medium-red; - } - } - } - } - // } - - .roll-formula { - background-color: var(--bg-color); - color: var(--text-color); - border-radius: 4px; - padding: 3px 5px; - width: fit-content; - margin: auto; - } - - .roll-difficulty, .target-hit-status { - color: @green; - background-color: @green-10; - border: 1px solid currentColor; - border-radius: 4px; - padding: 3px 5px; - text-transform: uppercase; - font-weight: 600; - - &.is-miss { - color: @medium-red; - background-color: @medium-red-10; + overflow: hidden; } } - .target-hit-status { - width: fit-content; - margin-top: 2px; - } - - div[data-action="expandRoll"] { + &.expanded { .roll-part-header > div > span { &:before, &:after { - content: '\f078'; - font-family: var(--font-awesome); - color: var(--text-color); - transition: all 0.3s ease; + transform: rotate(180deg); } } .on-reduced { - display: grid; - overflow: hidden; - grid-template-rows: 1fr; - transition: grid-template-rows 250ms ease; - - .wrapper { - display: flex; - gap: 10px; - overflow: hidden; - } - } - - &.expanded { - .roll-part-header > div > span { - &:before, &:after { - transform: rotate(180deg); - } - } - - .on-reduced { - grid-template-rows: 0fr; - } + grid-template-rows: 0fr; } } + } - .roll-part + .roll-part { - margin-top: 0; - } - // } + .roll-part + .roll-part { + margin-top: 0; + } .target-section { .roll-part-content { diff --git a/templates/ui/chat/adversary-attack-roll.hbs b/templates/ui/chat/adversary-attack-roll.hbs deleted file mode 100644 index b948bd3d..00000000 --- a/templates/ui/chat/adversary-attack-roll.hbs +++ /dev/null @@ -1,47 +0,0 @@ -
-
{{localize "DAGGERHEART.UI.Chat.attackRoll.title" attack=this.title}}
-
-
{{roll.formula}}
-
-
-
-
- {{#each dice}} -
- {{number}}{{denomination}} - {{total}} -
-
-
    - {{#each results}} -
  1. {{result}}
  2. - {{/each}} -
-
{{#if ../advantageState}}{{localize "DAGGERHEART.GENERAL.Advantage.full"}}{{/if}}{{#if (eq ../advantageState false)}}{{localize "DAGGERHEART.GENERAL.Disadvantage.full"}}{{/if}}
-
- {{/each}} -
-
-
-
- -
-
{{roll.total}}
-
- {{#if (gt targets.length 0)}} -
- {{#each targets as |target|}} -
- -
- {{#if target.hit}}{{localize "Hit"}}{{else}}{{localize "Miss"}}{{/if}} -
-
- {{/each}} -
- {{/if}} -
- -
-
-
\ No newline at end of file diff --git a/templates/ui/chat/adversary-roll.hbs b/templates/ui/chat/adversary-roll.hbs deleted file mode 100644 index 70307ef1..00000000 --- a/templates/ui/chat/adversary-roll.hbs +++ /dev/null @@ -1,61 +0,0 @@ -
-
{{title}}
-
-
{{roll.formula}}
-
-
-
-
- {{#each roll.dice as | dice index |}} -
- {{formula}} - {{total}} -
-
-
    - {{#if dice.rerolled.any}} - - {{/if}} - -
-
- {{/each}} -
-
-
-
-
-
{{roll.total}}
-
-
-
-
- {{localize "DAGGERHEART.GENERAL.damage"}} -
-
-
- {{> 'systems/daggerheart/templates/ui/chat/parts/damage-chat.hbs' damage=damage noTitle=true}} -
-
-
-
-{{> 'systems/daggerheart/templates/ui/chat/parts/target-chat.hbs'}} -{{#if hasDamage}} -
-
- {{#if damage.roll}} -
- -
- {{else}} -
- -
- {{/if}} -
-
-{{/if}} \ No newline at end of file diff --git a/templates/ui/chat/parts/damage-chat.hbs b/templates/ui/chat/parts/damage-chat.hbs deleted file mode 100644 index 91bee4e7..00000000 --- a/templates/ui/chat/parts/damage-chat.hbs +++ /dev/null @@ -1,33 +0,0 @@ -
- {{#unless noTitle}}
{{damage.title}}
{{/unless}} -
- {{#each damage.roll as | roll index | }} -
{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')}}
-
{{roll.formula}}
-
-
- {{#each roll.parts}} -
-
-
- {{formula}} - {{total}} -
-
    - {{#each dice}} - {{#each results}} -
  1. {{result}}
  2. - {{/each}} - {{/each}} -
-
- {{#if modifierTotal}}
{{#if (gt modifierTotal 0)}}+{{/if}}{{modifierTotal}}
{{/if}} -
{{localize "DAGGERHEART.GENERAL.total"}}: {{total}}
-
- {{/each}} -
-
-
{{roll.total}}
- {{/each}} -
-
\ No newline at end of file diff --git a/templates/ui/chat/parts/target-chat.hbs b/templates/ui/chat/parts/target-chat.hbs deleted file mode 100644 index a5844c04..00000000 --- a/templates/ui/chat/parts/target-chat.hbs +++ /dev/null @@ -1,38 +0,0 @@ -{{#if (gt currentTargets.length 0)}} -
- {{localize "DAGGERHEART.GENERAL.Target.plural"}} -
-
-
-
- - -
- {{#if (and hasSave @root.targetSelection @root.hasHitTarget)}} - - {{/if}} -
- {{#each currentTargets as |target|}} -
- -
- {{#if (or ../directDamage (not @root.targetSelection))}} -
{{target.name}}
- {{else}} - {{#if target.hit}}{{localize "Hit"}}{{else}}{{#if (not ../total.alternate)}}{{localize "Miss"}}{{else}}?{{/if}}{{/if}} - {{/if}} -
- {{#if (and ../hasSave target.hit @root.targetSelection)}} - - {{/if}} -
- {{/each}} -
-
-
-
-
-{{/if}} \ No newline at end of file