From 84febb847386e6623fbbf80b2f5483877d2cc9c8 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Thu, 24 Jul 2025 14:55:08 -0400 Subject: [PATCH 1/7] WIP: improve _applySkillImprovements --- lang/en.json | 10 +++--- module/config.js | 4 +++ module/sheets/agent-sheet.js | 36 ++++++++----------- module/sheets/base-sheet.js | 5 ++- .../actor/partials/custom-skills-partial.html | 2 +- .../dialog/apply-skill-improvements.html | 9 +++++ 6 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 templates/dialog/apply-skill-improvements.html diff --git a/lang/en.json b/lang/en.json index 8058879..e076da4 100644 --- a/lang/en.json +++ b/lang/en.json @@ -86,11 +86,11 @@ "DG.Skills.AddTypedOrCustomSkill": "Add Typed/Custom Skill", "DG.Skills.AddSkill": "Add Skill", "DG.Skills.Apply": "Apply", - "DG.Skills.ApplySkillImprovements": "Apply Skill Improvements", - "DG.Skills.ApplySkillImprovementsChatFlavor": "Improved the following skills by", - "DG.Skills.ApplySkillImprovementsDialogLabel": "Improve skills by the following formula:", - "DG.Skills.ApplySkillImprovementsDialogEffectsFollowing": "Effects the following skills:", - "DG.Skills.ApplySkillImprovementsWarning": "No failed skills to improve.", + "DG.Skills.ApplySkillImprovements.Title": "Apply Skill Improvements", + "DG.Skills.ApplySkillImprovements.ChatFlavor": "Improved the following skills by", + "DG.Skills.ApplySkillImprovements.DialogLabel": "Improve skills by the following formula: {formula}", + "DG.Skills.ApplySkillImprovements.DialogEffectsFollowing": "Effects the following skills: {skillList}", + "DG.Skills.ApplySkillImprovements.Warning": "No failed skills to improve.", "DG.Skills.EditTypedOrCustomSkill": "Edit Typed or Custom Skill", "DG.Skills.EditSkill": "Edit Skill", "DG.Skills.SkillGroup": "Skill Group", diff --git a/module/config.js b/module/config.js index 9e06eae..e2b54eb 100644 --- a/module/config.js +++ b/module/config.js @@ -54,4 +54,8 @@ const DG = /** @type {const} */ ({ statistics: ["str", "con", "dex", "int", "pow", "cha"], }); +// Set base template path for single source of truth for hbs locations. +const BASE_TEMPLATE_PATH = /** @type {const} */ (`systems/${DG.ID}/templates`); + export default DG; +export { DG, BASE_TEMPLATE_PATH }; diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index 4d713b7..5708a38 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -1,5 +1,8 @@ +import { DG, BASE_TEMPLATE_PATH } from "../config.js"; import DGActorSheet from "./base-actor-sheet.js"; +const { renderTemplate } = foundry.applications.handlebars; + /** @extends {DGActorSheet} */ export default class DGAgentSheet extends DGActorSheet { /** @override */ @@ -84,7 +87,7 @@ export default class DGAgentSheet extends DGActorSheet { /* -------------------------------------------- */ - static _applySkillImprovements(event, target) { + static async _applySkillImprovements(event, target) { const failedSkills = Object.entries(this.actor.system.skills).filter( (skill) => skill[1].failure, ); @@ -92,11 +95,10 @@ export default class DGAgentSheet extends DGActorSheet { this.actor.system.typedSkills, ).filter((skill) => skill[1].failure); if (failedSkills.length === 0 && failedTypedSkills.length === 0) { - ui.notifications.warn("No Skills to Increase"); + ui.notifications.warn("DG.Skills.ApplySkillImprovements.Warning"); return; } - let htmlContent = ""; let failedSkillNames = ""; failedSkills.forEach(([skill], value) => { if (value === 0) { @@ -117,30 +119,20 @@ export default class DGAgentSheet extends DGActorSheet { } }); - const baseRollFormula = game.settings.get( - "deltagreen", - "skillImprovementFormula", + const baseRollFormula = game.settings.get(DG.ID, "skillImprovementFormula"); + + const content = await renderTemplate( + `${BASE_TEMPLATE_PATH}/dialog/apply-skill-improvements.html`, + { failedSkillNames, baseRollFormula }, ); - htmlContent += `
`; - htmlContent += ` `; - htmlContent += `
`; - htmlContent += ` ${game.i18n.localize( - "DG.Skills.ApplySkillImprovementsDialogEffectsFollowing", - )} ${failedSkillNames} `; - htmlContent += `
`; - new Dialog({ - content: htmlContent, - title: - game.i18n.translations.DG?.Skills?.ApplySkillImprovements ?? - "Apply Skill Improvements", + content, + title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title"), default: "add", buttons: { apply: { - label: game.i18n.translations.DG?.Skills?.Apply ?? "Apply", + label: game.i18n.localize("DG.Skills.Apply"), callback: (btn) => { this._applySkillImprovements( baseRollFormula, @@ -286,7 +278,7 @@ export default class DGAgentSheet extends DGActorSheet { }), content: html, flavor: `${game.i18n.localize( - "DG.Skills.ApplySkillImprovementsChatFlavor", + "DG.Skills.ApplySkillImprovements.ChatFlavor", )} +${baseRollFormula}%:`, type: baseRollFormula === "1" ? 0 : 5, // 0 = CHAT_MESSAGE_TYPES.OTHER, 5 = CHAT_MESSAGE_TYPES.ROLL rolls: baseRollFormula === "1" ? [] : [roll], // If adding flat +1, there is no roll. diff --git a/module/sheets/base-sheet.js b/module/sheets/base-sheet.js index de42d33..ad48f9b 100644 --- a/module/sheets/base-sheet.js +++ b/module/sheets/base-sheet.js @@ -1,4 +1,4 @@ -import DG from "../config.js"; +import { DG, BASE_TEMPLATE_PATH } from "../config.js"; const HbsAppMixin = foundry.applications.api.HandlebarsApplicationMixin; @@ -11,8 +11,7 @@ const DGSheetMixin = (Base) => { form: { submitOnChange: true }, }); - /** @inheritdoc */ - static TEMPLATE_PATH = /** @type {const} */ (`systems/${DG.ID}/templates`); + static TEMPLATE_PATH = BASE_TEMPLATE_PATH; static get THEME() { return game.settings.get(DG.ID, "characterSheetStyle"); diff --git a/templates/actor/partials/custom-skills-partial.html b/templates/actor/partials/custom-skills-partial.html index 4d01753..fd0df26 100644 --- a/templates/actor/partials/custom-skills-partial.html +++ b/templates/actor/partials/custom-skills-partial.html @@ -14,7 +14,7 @@ {{#if_eq actor.type "agent" }} - {{localize 'DG.Skills.ApplySkillImprovements'}} + {{localize 'DG.Skills.ApplySkillImprovements.Title'}} {{/if_eq}} diff --git a/templates/dialog/apply-skill-improvements.html b/templates/dialog/apply-skill-improvements.html new file mode 100644 index 0000000..a430a4d --- /dev/null +++ b/templates/dialog/apply-skill-improvements.html @@ -0,0 +1,9 @@ +
+ +
+ + {{{localize "DG.Skills.ApplySkillImprovements.DialogEffectsFollowing" skillList=failedSkillNames}}} + +
From be273620789abbd25e93f7b8346273a2f3ca07ab Mon Sep 17 00:00:00 2001 From: jalensailin Date: Thu, 24 Jul 2025 15:55:38 -0400 Subject: [PATCH 2/7] WIP 2: improve _applySkillImprovements --- module/sheets/agent-sheet.js | 75 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index 5708a38..be711be 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -87,37 +87,36 @@ export default class DGAgentSheet extends DGActorSheet { /* -------------------------------------------- */ - static async _applySkillImprovements(event, target) { - const failedSkills = Object.entries(this.actor.system.skills).filter( - (skill) => skill[1].failure, + static async _applySkillImprovements() { + const { skills, typedSkills } = this.actor.system; + + const failedSkills = Object.values(skills).filter((data) => data.failure); + + const failedTypedSkills = Object.values(typedSkills).filter( + (data) => data.failure, ); - const failedTypedSkills = Object.entries( - this.actor.system.typedSkills, - ).filter((skill) => skill[1].failure); + + const localizedFailedSkills = failedSkills.map((skill) => + game.i18n.localize(`DG.Skills.${skill.key}`), + ); + + const localizedFailedTypedSkills = failedTypedSkills.map((skill) => { + const groupKey = `DG.TypeSkills.${skill.group.replace(/\s+/g, "")}`; + const groupLabel = game.i18n.localize(groupKey); + return `${groupLabel} (${skill.label})`; + }); + if (failedSkills.length === 0 && failedTypedSkills.length === 0) { - ui.notifications.warn("DG.Skills.ApplySkillImprovements.Warning"); + ui.notifications.warn("DG.Skills.ApplySkillImprovements.Warning", { + localize: true, + }); return; } - let failedSkillNames = ""; - failedSkills.forEach(([skill], value) => { - if (value === 0) { - failedSkillNames += game.i18n.localize(`DG.Skills.${skill}`); - } else { - failedSkillNames += `, ${game.i18n.localize(`DG.Skills.${skill}`)}`; - } - }); - failedTypedSkills.forEach(([skillName, skillData], value) => { - if (value === 0 && failedSkillNames === "") { - failedSkillNames += `${game.i18n.localize( - `DG.TypeSkills.${skillData.group.split(" ").join("")}`, - )} (${skillData.label})`; - } else { - failedSkillNames += `, ${game.i18n.localize( - `DG.TypeSkills.${skillData.group.split(" ").join("")}`, - )} (${skillData.label})`; - } - }); + const failedSkillNames = [ + ...localizedFailedSkills, + ...localizedFailedTypedSkills, + ].join(", "); const baseRollFormula = game.settings.get(DG.ID, "skillImprovementFormula"); @@ -219,42 +218,42 @@ export default class DGAgentSheet extends DGActorSheet { // Get copy of current system data, will update this and then apply all changes at once synchronously at the end. const updatedData = foundry.utils.duplicate(actorData); - failedSkills.forEach(([skill], value) => { - updatedData.skills[skill].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. - updatedData.skills[skill].failure = false; + failedSkills.forEach((skill, value) => { + updatedData.skills[skill.key].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. + updatedData.skills[skill.key].failure = false; // So we can record the regular skills improved and how much they were increased by in chat. // The if statement tells us whether to add a comma before the term or not. if (value === 0) { improvedSkillList += `${game.i18n.localize( - `DG.Skills.${skill}`, + `DG.Skills.${skill.key}`, )}: +${resultList[value] ?? 1}%`; } else { improvedSkillList += `, ${game.i18n.localize( - `DG.Skills.${skill}`, + `DG.Skills.${skill.key}`, )}: +${resultList[value] ?? 1}%`; } }); - failedTypedSkills.forEach(([skillName, skillData], value) => { + failedTypedSkills.forEach((skill, value) => { // We must increase value in the following line by the length of failedSkills, so that we index the entire resultList. // Otherwise we would be adding the same die results to regular skills and typed skills. - updatedData.typedSkills[skillName].proficiency += + updatedData.typedSkills[skill.key].proficiency += resultList[value + failedSkills.length] ?? 1; - updatedData.typedSkills[skillName].failure = false; + updatedData.typedSkills[skill.key].failure = false; // So we can record the typed skills improved and how much they were increased by in chat. // The if statement tells us whether to add a comma before the term or not. if (value === 0 && improvedSkillList === "") { improvedSkillList += `${game.i18n.localize( - `DG.TypeSkills.${skillData.group.split(" ").join("")}`, - )} (${skillData.label}): +${ + `DG.TypeSkills.${skill.group.split(" ").join("")}`, + )} (${skill.label}): +${ resultList[value + failedSkills.length] ?? 1 }%`; } else { improvedSkillList += `, ${game.i18n.localize( - `DG.TypeSkills.${skillData.group.split(" ").join("")}`, - )} (${skillData.label}): +${ + `DG.TypeSkills.${skill.group.split(" ").join("")}`, + )} (${skill.label}): +${ resultList[value + failedSkills.length] ?? 1 }%`; } From c511a37a433427750674a76e8504fed4429bb657 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Thu, 24 Jul 2025 16:18:54 -0400 Subject: [PATCH 3/7] WIP 3: improve _applySkillImprovements --- module/sheets/agent-sheet.js | 65 ++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index be711be..bdb2871 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -213,7 +213,6 @@ export default class DGAgentSheet extends DGActorSheet { } // This will be end up being a list of skills and how much each were improved by. It gets modified in the following loops. - let improvedSkillList = ""; // Get copy of current system data, will update this and then apply all changes at once synchronously at the end. const updatedData = foundry.utils.duplicate(actorData); @@ -221,18 +220,6 @@ export default class DGAgentSheet extends DGActorSheet { failedSkills.forEach((skill, value) => { updatedData.skills[skill.key].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. updatedData.skills[skill.key].failure = false; - - // So we can record the regular skills improved and how much they were increased by in chat. - // The if statement tells us whether to add a comma before the term or not. - if (value === 0) { - improvedSkillList += `${game.i18n.localize( - `DG.Skills.${skill.key}`, - )}: +${resultList[value] ?? 1}%`; - } else { - improvedSkillList += `, ${game.i18n.localize( - `DG.Skills.${skill.key}`, - )}: +${resultList[value] ?? 1}%`; - } }); failedTypedSkills.forEach((skill, value) => { @@ -241,32 +228,32 @@ export default class DGAgentSheet extends DGActorSheet { updatedData.typedSkills[skill.key].proficiency += resultList[value + failedSkills.length] ?? 1; updatedData.typedSkills[skill.key].failure = false; - - // So we can record the typed skills improved and how much they were increased by in chat. - // The if statement tells us whether to add a comma before the term or not. - if (value === 0 && improvedSkillList === "") { - improvedSkillList += `${game.i18n.localize( - `DG.TypeSkills.${skill.group.split(" ").join("")}`, - )} (${skill.label}): +${ - resultList[value + failedSkills.length] ?? 1 - }%`; - } else { - improvedSkillList += `, ${game.i18n.localize( - `DG.TypeSkills.${skill.group.split(" ").join("")}`, - )} (${skill.label}): +${ - resultList[value + failedSkills.length] ?? 1 - }%`; - } }); - // Probably not worth triggering the update if the user didn't pick any skills - if (improvedSkillList !== "") { - await this.actor.update({ system: updatedData }); - } + const localizedFailedSkills = failedSkills.map( + (skill, value) => + `${game.i18n.localize(`DG.Skills.${skill.key}`)}: +${ + resultList[value] ?? 1 + }%`, + ); + + const localizedFailedTypedSkills = failedTypedSkills.map( + (skill, value) => + `${game.i18n.localize( + `DG.TypeSkills.${skill.group.replace(/\s+/g, "")}`, + )} (${skill.label}): +${ + resultList[value + failedSkills.length] ?? 1 + }%`, + ); + + const failedSkillList = [ + ...localizedFailedSkills, + ...localizedFailedTypedSkills, + ].join(", "); let html; html = `
`; - html += `
${improvedSkillList}
`; + html += `
${failedSkillList}
`; html += `
`; const chatData = { @@ -285,9 +272,13 @@ export default class DGAgentSheet extends DGActorSheet { }; // Create a message from this roll, if there is one. - if (roll) return roll.toMessage(chatData); + if (roll) { + await roll.toMessage(chatData); + } else { + // If no roll, create a chat message directly. + return ChatMessage.create(chatData, {}); + } - // If no roll, create a chat message directly. - return ChatMessage.create(chatData, {}); + return this.actor.update({ system: updatedData }); } } From c03171e8213528568c1623a2658bab99f3fe5465 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Thu, 24 Jul 2025 16:26:42 -0400 Subject: [PATCH 4/7] WIP 4: improve _applySkillImprovements --- module/sheets/agent-sheet.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index bdb2871..bcbedff 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -212,10 +212,11 @@ export default class DGAgentSheet extends DGActorSheet { ); } - // This will be end up being a list of skills and how much each were improved by. It gets modified in the following loops. - // Get copy of current system data, will update this and then apply all changes at once synchronously at the end. - const updatedData = foundry.utils.duplicate(actorData); + const updatedData = { + skills: foundry.utils.duplicate(actorData.skills), + typedSkills: foundry.utils.duplicate(actorData.typedSkills), + }; failedSkills.forEach((skill, value) => { updatedData.skills[skill.key].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. @@ -246,15 +247,12 @@ export default class DGAgentSheet extends DGActorSheet { }%
`, ); - const failedSkillList = [ + const improvedSkillList = [ ...localizedFailedSkills, ...localizedFailedTypedSkills, ].join(", "); - let html; - html = `
`; - html += `
${failedSkillList}
`; - html += `
`; + const content = `
${improvedSkillList}
`; const chatData = { speaker: ChatMessage.getSpeaker({ @@ -262,7 +260,7 @@ export default class DGAgentSheet extends DGActorSheet { token: this.token, alias: this.actor.name, }), - content: html, + content, flavor: `${game.i18n.localize( "DG.Skills.ApplySkillImprovements.ChatFlavor", )} +${baseRollFormula}%:`, From c79cb7658ba08001813c82deed47deff7e818999 Mon Sep 17 00:00:00 2001 From: jalensailin Date: Thu, 24 Jul 2025 18:20:33 -0400 Subject: [PATCH 5/7] WIP 5: improve _applySkillImprovements --- .eslintrc.yml | 1 + lang/en.json | 2 +- module/sheets/agent-sheet.js | 106 +++++++++++++++++------------------ 3 files changed, 53 insertions(+), 56 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 7001ee9..4bb014b 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -47,6 +47,7 @@ globals: ActiveEffect: readonly Actor: readonly CONFIG: readonly + CONST: readonly ChatMessage: readonly Combat: readonly Combatant: readonly diff --git a/lang/en.json b/lang/en.json index e076da4..ba0d360 100644 --- a/lang/en.json +++ b/lang/en.json @@ -87,7 +87,7 @@ "DG.Skills.AddSkill": "Add Skill", "DG.Skills.Apply": "Apply", "DG.Skills.ApplySkillImprovements.Title": "Apply Skill Improvements", - "DG.Skills.ApplySkillImprovements.ChatFlavor": "Improved the following skills by", + "DG.Skills.ApplySkillImprovements.ChatFlavor": "Improved the following skills by {formula}:", "DG.Skills.ApplySkillImprovements.DialogLabel": "Improve skills by the following formula: {formula}", "DG.Skills.ApplySkillImprovements.DialogEffectsFollowing": "Effects the following skills: {skillList}", "DG.Skills.ApplySkillImprovements.Warning": "No failed skills to improve.", diff --git a/module/sheets/agent-sheet.js b/module/sheets/agent-sheet.js index bcbedff..1c58afd 100644 --- a/module/sheets/agent-sheet.js +++ b/module/sheets/agent-sheet.js @@ -182,78 +182,71 @@ export default class DGAgentSheet extends DGActorSheet { failedTypedSkills, ) { const actorData = this.actor.system; + const totalFailures = failedSkills.length + failedTypedSkills.length; const resultList = []; - let rollFormula; - // Define the amount of dice being rolled, if any. + // Determine roll formula + let rollFormula; switch (baseRollFormula) { case "1": rollFormula = 1; break; case "1d3": - rollFormula = `${failedSkills.length + failedTypedSkills.length}d3`; - break; case "1d4": case "1d4-1": - rollFormula = `${failedSkills.length + failedTypedSkills.length}d4`; + rollFormula = `${totalFailures}${baseRollFormula.replace(/-.*/, "")}`; break; default: + throw new Error(`Unknown baseRollFormula: ${baseRollFormula}`); } let roll; if (rollFormula !== 1) { roll = new Roll(rollFormula, actorData); await roll.evaluate(); - // Put the results into a list. - roll.terms[0].results.forEach((result) => - resultList.push( - baseRollFormula === "1d4-1" ? result.result - 1 : result.result, - ), + + const modifier = baseRollFormula === "1d4-1" ? -1 : 0; + resultList.push( + ...roll.terms[0].results.map((result) => result.result + modifier), ); } - // Get copy of current system data, will update this and then apply all changes at once synchronously at the end. - const updatedData = { - skills: foundry.utils.duplicate(actorData.skills), - typedSkills: foundry.utils.duplicate(actorData.typedSkills), + const updatedSkills = foundry.utils.duplicate(actorData.skills); + const updatedTypedSkills = foundry.utils.duplicate(actorData.typedSkills); + + const applyImprovements = (skillsArray, updatedTarget, offset = 0) => { + return skillsArray.map((skill, i) => { + const index = i + offset; + const increment = resultList[index] ?? 1; + updatedTarget[skill.key].proficiency += increment; + updatedTarget[skill.key].failure = false; + + const label = + skill.label ?? game.i18n.localize(`DG.Skills.${skill.key}`); // fallback for regular skills + const groupLabel = skill.group + ? `${game.i18n.localize( + `DG.TypeSkills.${skill.group.replace(/\s+/g, "")}`, + )} (${label})` + : label; + + return `${groupLabel}: +${increment}%`; + }); }; - failedSkills.forEach((skill, value) => { - updatedData.skills[skill.key].proficiency += resultList[value] ?? 1; // Increase proficiency by die result or by 1 if there is no dice roll. - updatedData.skills[skill.key].failure = false; - }); - - failedTypedSkills.forEach((skill, value) => { - // We must increase value in the following line by the length of failedSkills, so that we index the entire resultList. - // Otherwise we would be adding the same die results to regular skills and typed skills. - updatedData.typedSkills[skill.key].proficiency += - resultList[value + failedSkills.length] ?? 1; - updatedData.typedSkills[skill.key].failure = false; - }); - - const localizedFailedSkills = failedSkills.map( - (skill, value) => - `${game.i18n.localize(`DG.Skills.${skill.key}`)}: +${ - resultList[value] ?? 1 - }%`, + const failedSkillTexts = applyImprovements(failedSkills, updatedSkills); + const failedTypedSkillTexts = applyImprovements( + failedTypedSkills, + updatedTypedSkills, + failedSkills.length, ); - const localizedFailedTypedSkills = failedTypedSkills.map( - (skill, value) => - `${game.i18n.localize( - `DG.TypeSkills.${skill.group.replace(/\s+/g, "")}`, - )} (${skill.label}): +${ - resultList[value + failedSkills.length] ?? 1 - }%`, + const content = [...failedSkillTexts, ...failedTypedSkillTexts].join(", "); + + const flavor = game.i18n.format( + "DG.Skills.ApplySkillImprovements.ChatFlavor", + { formula: rollFormula }, ); - const improvedSkillList = [ - ...localizedFailedSkills, - ...localizedFailedTypedSkills, - ].join(", "); - - const content = `
${improvedSkillList}
`; - const chatData = { speaker: ChatMessage.getSpeaker({ actor: this.actor, @@ -261,22 +254,25 @@ export default class DGAgentSheet extends DGActorSheet { alias: this.actor.name, }), content, - flavor: `${game.i18n.localize( - "DG.Skills.ApplySkillImprovements.ChatFlavor", - )} +${baseRollFormula}%:`, - type: baseRollFormula === "1" ? 0 : 5, // 0 = CHAT_MESSAGE_TYPES.OTHER, 5 = CHAT_MESSAGE_TYPES.ROLL - rolls: baseRollFormula === "1" ? [] : [roll], // If adding flat +1, there is no roll. + flavor, + type: roll + ? CONST.CHAT_MESSAGE_TYPES.ROLL + : CONST.CHAT_MESSAGE_TYPES.OTHER, + rolls: roll ? [roll] : [], rollMode: game.settings.get("core", "rollMode"), }; - // Create a message from this roll, if there is one. if (roll) { await roll.toMessage(chatData); } else { - // If no roll, create a chat message directly. - return ChatMessage.create(chatData, {}); + await ChatMessage.create(chatData); } - return this.actor.update({ system: updatedData }); + return this.actor.update({ + system: { + skills: updatedSkills, + typedSkills: updatedTypedSkills, + }, + }); } } From 9745b4230808c7e183902352d36a7f17608d18bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lozano?= Date: Fri, 25 Jul 2025 18:39:33 +0200 Subject: [PATCH 6/7] Some fixes to css and to statistics header --- css/deltagreen.css | 11 ++++++++--- module/sheets/base-actor-sheet.js | 2 +- templates/actor/parts/motivations-tab.html | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/css/deltagreen.css b/css/deltagreen.css index 90db638..ce6d242 100644 --- a/css/deltagreen.css +++ b/css/deltagreen.css @@ -130,7 +130,8 @@ } input.breaking-point-hit { - color: rgb(117, 0, 0); + color: rgb(255, 255, 255); + background-color: rgb(117, 0, 0); font-weight: bold; } @@ -603,7 +604,7 @@ div span.bio-grid-label { .breaking-point-grid-3col { display: grid; - grid-template-columns: 100px 70px 65px; + grid-template-columns: 20% 70px 65px; border-top: 0px solid #aaa; margin-bottom: 10px; border-bottom: 1px solid #aaa; @@ -616,7 +617,7 @@ div span.bio-grid-label { .adaptation-grid-5col { display: grid; - grid-template-columns: 100px 50px 50px 50px 200px; + grid-template-columns: 30% 50px 50px 50px 200px; margin-top: 10px; margin-bottom: 10px; align-content: center; @@ -671,11 +672,15 @@ div .bottom-left-justified-resource { } div .first-aid-received-section { + display: grid; + grid-template-columns: 40% 70px; border-bottom: 1px solid #aaa; margin-bottom: 10px; } div .exhausted-section { + display: grid; + grid-template-columns: 40% 70px; border-bottom: 1px solid #aaa; margin-bottom: 10px; } diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index f800dff..cb21676 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -90,7 +90,7 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) { // Set title for Physical Attributes. context.physicalAttributesTitle = game.i18n.localize( - "DG.Sheet.BlockHeaders.Attributes", + "DG.Sheet.BlockHeaders.Statistics", ); // Whether to append the notes section to the skills. diff --git a/templates/actor/parts/motivations-tab.html b/templates/actor/parts/motivations-tab.html index 208c82b..2f80f02 100644 --- a/templates/actor/parts/motivations-tab.html +++ b/templates/actor/parts/motivations-tab.html @@ -41,7 +41,7 @@ data-dtype="Boolean" />