chore: improve private sanity logic readability

This commit is contained in:
Tobias Frölich
2025-09-29 08:11:45 +02:00
committed by Tobias Frölich
parent ed54e2dbd8
commit e377bda644
2 changed files with 57 additions and 93 deletions
-6
View File
@@ -1,11 +1,5 @@
# Release/Patch Notes
## Version 1.7.0 - ????-??-??
### **Tech Debt**
- [#267](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/pull/267) - Moved private sanity logic out of templates.
## Version 1.6.1 - 2025-09-09
> Thanks to the following new contributor: [Tobifroe](https://github.com/tobifroe).
+57 -87
View File
@@ -99,15 +99,11 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
"deltagreen",
"keepSanityPrivate",
);
if (keepSanityPrivate && !game.user.isGM) {
context.maxSan = "???";
context.currentSan = "???";
context.keepSanityPrivate = true;
} else {
context.maxSan = this.actor.system.sanity.max;
context.currentSan = this.actor.system.sanity.value;
context.keepSanityPrivate = false;
}
const hideSan = keepSanityPrivate && !game.user.isGM;
context.maxSan = hideSan ? "???" : this.actor.system.sanity.max;
context.currentSan = hideSan ? "???" : this.actor.system.sanity.value;
context.keepSanityPrivate = keepSanityPrivate;
// Set sanity block per actor type.
context.sanityInputs = await foundry.applications.handlebars.renderTemplate(
@@ -784,110 +780,94 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
const currentGroup = typedSkills[targetSkill].group;
let htmlContent = `<div>`;
htmlContent += ` <label>${
game.i18n.translations.DG?.Skills?.SkillGroup ?? "Skill Group"
}:</label>`;
htmlContent += ` <label>${game.i18n.translations.DG?.Skills?.SkillGroup ?? "Skill Group"
}:</label>`;
htmlContent += ` <select name="new-type-skill-group" />`;
if (currentGroup === game.i18n.translations.DG?.TypeSkills?.Art ?? "Art") {
htmlContent += ` <option value="Art" selected>${
game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
htmlContent += ` <option value="Art" selected>${game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
} else {
htmlContent += ` <option value="Art">${
game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
htmlContent += ` <option value="Art">${game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.Craft ??
"Craft"
) {
htmlContent += ` <option value="Craft" selected>${
game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
htmlContent += ` <option value="Craft" selected>${game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
} else {
htmlContent += ` <option value="Craft">${
game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
htmlContent += ` <option value="Craft">${game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
"Foreign Language"
) {
htmlContent += ` <option value="ForeignLanguage" selected>${
game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
htmlContent += ` <option value="ForeignLanguage" selected>${game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
"Foreign Language"
}</option>`;
}</option>`;
} else {
htmlContent += ` <option value="ForeignLanguage">${
game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
htmlContent += ` <option value="ForeignLanguage">${game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
"Foreign Language"
}</option>`;
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
"Military Science"
) {
htmlContent += ` <option value="MilitaryScience" selected>${
game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
htmlContent += ` <option value="MilitaryScience" selected>${game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
"Military Science"
}</option>`;
}</option>`;
} else {
htmlContent += ` <option value="MilitaryScience">${
game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
htmlContent += ` <option value="MilitaryScience">${game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
"Military Science"
}</option>`;
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.Pilot ??
"Pilot"
) {
htmlContent += ` <option value="Pilot" selected>${
game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
htmlContent += ` <option value="Pilot" selected>${game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
} else {
htmlContent += ` <option value="Pilot">${
game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
htmlContent += ` <option value="Pilot">${game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.Science ??
"Science"
) {
htmlContent += ` <option value="Science" selected>${
game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
htmlContent += ` <option value="Science" selected>${game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
} else {
htmlContent += ` <option value="Science">${
game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
htmlContent += ` <option value="Science">${game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
}
if (
currentGroup === game.i18n.translations.DG?.TypeSkills?.Other ??
"Other"
) {
htmlContent += ` <option value="Other" selected>${
game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
htmlContent += ` <option value="Other" selected>${game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
} else {
htmlContent += ` <option value="Other">${
game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
htmlContent += ` <option value="Other">${game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
}
htmlContent += ` </select>`;
htmlContent += `</div>`;
htmlContent += `<div>`;
htmlContent += ` <label>${
game.i18n.translations.DG?.Skills.SkillName ?? "Skill Name"
}</label>`;
htmlContent += ` <label>${game.i18n.translations.DG?.Skills.SkillName ?? "Skill Name"
}</label>`;
htmlContent += ` <input type="text" name="new-type-skill-label" value="${currentLabel}" />`;
htmlContent += `</div>`;
@@ -925,40 +905,31 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
let htmlContent = "";
htmlContent += `<div>`;
htmlContent += ` <label>${
game.i18n.translations.DG?.Skills?.SkillGroup ?? "Skill Group"
}:</label>`;
htmlContent += ` <label>${game.i18n.translations.DG?.Skills?.SkillGroup ?? "Skill Group"
}:</label>`;
htmlContent += ` <select name="new-type-skill-group" />`;
htmlContent += ` <option value="Art">${
game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
htmlContent += ` <option value="Craft">${
game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
htmlContent += ` <option value="ForeignLanguage">${
game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
htmlContent += ` <option value="Art">${game.i18n.translations.DG?.TypeSkills?.Art ?? "Art"
}</option>`;
htmlContent += ` <option value="Craft">${game.i18n.translations.DG?.TypeSkills?.Craft ?? "Craft"
}</option>`;
htmlContent += ` <option value="ForeignLanguage">${game.i18n.translations.DG?.TypeSkills?.ForeignLanguage ??
"Foreign Language"
}</option>`;
htmlContent += ` <option value="MilitaryScience">${
game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
}</option>`;
htmlContent += ` <option value="MilitaryScience">${game.i18n.translations.DG?.TypeSkills?.MilitaryScience ??
"Military Science"
}</option>`;
htmlContent += ` <option value="Pilot">${
game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
htmlContent += ` <option value="Science">${
game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
htmlContent += ` <option value="Other">${
game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
}</option>`;
htmlContent += ` <option value="Pilot">${game.i18n.translations.DG?.TypeSkills?.Pilot ?? "Pilot"
}</option>`;
htmlContent += ` <option value="Science">${game.i18n.translations.DG?.TypeSkills?.Science ?? "Science"
}</option>`;
htmlContent += ` <option value="Other">${game.i18n.translations.DG?.TypeSkills?.Other ?? "Other"
}</option>`;
htmlContent += ` </select>`;
htmlContent += `</div>`;
htmlContent += `<div>`;
htmlContent += ` <label>${
game.i18n.translations.DG?.Skills.SkillName ?? "Skill Name"
}</label>`;
htmlContent += ` <label>${game.i18n.translations.DG?.Skills.SkillName ?? "Skill Name"
}</label>`;
htmlContent += ` <input type="text" name="new-type-skill-label" />`;
htmlContent += `</div>`;
@@ -1096,9 +1067,8 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
([key, skill]) => ({
value: key,
group: optionGroups.typedSkills,
label: `${game.i18n.localize(`DG.TypeSkills.${skill.group}`)} (${
skill.label
})`,
label: `${game.i18n.localize(`DG.TypeSkills.${skill.group}`)} (${skill.label
})`,
targetNumber: skill.proficiency,
}),
);