improve display of Special Training attributes

This commit is contained in:
jalensailin
2023-12-09 18:29:12 -05:00
parent 9538e44570
commit 31894a844f
5 changed files with 132 additions and 19 deletions
+3
View File
@@ -66,6 +66,9 @@
"DG.TypeSkills.Other": "Other",
"DG.SpecialTraining.Dialog.CreateSpecialTraining": "Add Special Training",
"DG.SpecialTraining.Dialog.DropDown.CustomSkills": "Custom/Typed Skills",
"DG.SpecialTraining.Dialog.DropDown.Skills": "Skills",
"DG.SpecialTraining.Dialog.DropDown.Statistics": "Statistics",
"DG.SpecialTraining.Dialog.EditSpecialTraining": "Edit Special Training",
"DG.SpecialTraining.Dialog.NameLabel": "Name",
"DG.SpecialTraining.Dialog.SkillLabel": "Skill or Stat",
+53 -10
View File
@@ -1,5 +1,6 @@
/* globals $ game Roll ChatMessage AudioHelper ActorSheet mergeObject Dialog TextEditor ActiveEffect ui duplicate fromUuidSync renderTemplate randomID */
import DG from "../config.js";
import {
DGPercentileRoll,
DGLethalityRoll,
@@ -66,6 +67,32 @@ export default class DeltaGreenActorSheet extends ActorSheet {
this._prepareCharacterItems(data);
}
// Prepare a simplified version of the special training for display on sheet.
const specialTraining = this.actor.system.specialTraining.map(
(training) => {
const simplifiedTraining = {
name: training.name,
id: training.id,
};
// Convert the machine-readable name to a human-readable one.
switch (true) {
case DG.statistics.includes(training.skill):
simplifiedTraining.skill = training.skill.toUpperCase();
break;
case DG.skills.includes(training.skill):
simplifiedTraining.skill =
this.actor.system.skills[training.skill].label;
break;
default:
simplifiedTraining.skill =
this.actor.system.typedSkills[training.skill].label;
break;
}
return simplifiedTraining;
},
);
data.specialTraining = specialTraining;
switch (this.actor.type) {
case "agent":
data.enrichedDescription = await TextEditor.enrichHTML(
@@ -712,28 +739,43 @@ export default class DeltaGreenActorSheet extends ActorSheet {
(training) => training.id === targetID,
);
const skillList = Object.entries(this.actor.system.skills).map(
([k, v]) => ({
key: k,
label: v.label,
targetNumber: v.proficiency,
// Prepare simplified stat list
const statList = Object.entries(this.actor.system.statistics).map(
([key, stat]) => ({
key,
label: game.i18n.localize(`DG.Attributes.${key}`),
targetNumber: stat.value * 5,
}),
);
const typedSkillList = Object.values(this.actor.system.typedSkills).map(
(skill) => ({
key: skill.label,
// Prepare simplified skill list
const skillList = Object.entries(this.actor.system.skills).map(
([key, skill]) => ({
key,
label: skill.label,
targetNumber: skill.proficiency,
}),
);
// Prepare simplified typed/custom skill list
const typedSkillList = Object.entries(this.actor.system.typedSkills).map(
([key, skill]) => ({
key,
group: skill.group,
label: skill.label,
targetNumber: skill.proficiency,
}),
);
const combinedSkillList = [...skillList, ...typedSkillList];
// Prepare the template to feed to Dialog.
const content = await renderTemplate(
"systems/deltagreen/templates/dialog/special-training.html",
{
name: specialTraining?.name || "",
currentSkill: specialTraining?.skill || "",
skillList: combinedSkillList,
statList,
skillList,
typedSkillList,
},
);
@@ -741,6 +783,7 @@ export default class DeltaGreenActorSheet extends ActorSheet {
`DG.SpecialTraining.Dialog.${action}SpecialTraining`,
);
// Prepare and render dialog with above template.
new Dialog({
content,
title: game.i18n.localize("DG.SpecialTraining.Dialog.Title"),
+55
View File
@@ -0,0 +1,55 @@
/**
* In config.js we can create constants that may be used all around the code base.
* I tried to get some of these values from `game.system` but it seems they
* aren't loaded yet when this is called. Oh well, this shouldn't really ever
* change.
*/
const DG = {
// All the base skills
skills: [
"accounting",
"alertness",
"anthropology",
"archeology",
"artillery",
"athletics",
"bureaucracy",
"computer_science",
"criminology",
"demolitions",
"disguise",
"dodge",
"drive",
"firearms",
"first_aid",
"forensics",
"heavy_machiner",
"heavy_weapons",
"history",
"humint",
"law",
"medicine",
"melee_weapons",
"navigate",
"occult",
"persuade",
"pharmacy",
"psychotherapy",
"ride",
"search",
"sigint",
"stealth",
"surgery",
"survival",
"swim",
"unarmed_combat",
"unnatural",
"ritual",
],
// All the base rollable stats.
statistics: ["str", "con", "dex", "int", "pow", "cha"],
};
export default DG;
+1 -1
View File
@@ -22,7 +22,7 @@
</div>
</div>
{{/each}}
{{#each actor.system.specialTraining as |training|}}
{{#each specialTraining as |training|}}
<div class="item flexrow flex-group-center flex-thin-border">
<label class="">
{{training.name}} ({{training.skill}})
+20 -8
View File
@@ -11,15 +11,27 @@
</label>
{{#select currentSkill}}
<select name="special-training-skill">
{{#each skillList as |skill|}}
<option value="{{skill.key}}">
{{#if skill.group}}
{{skill.group}} ({{skill.label}})
{{else}}
<optgroup label="{{localize "DG.SpecialTraining.Dialog.DropDown.Statistics"}}">
{{#each statList as |stat|}}
<option value="{{stat.key}}" data-type="stat">
{{stat.label}}
</option>
{{/each}}
</optgroup>
<optgroup label="{{localize "DG.SpecialTraining.Dialog.DropDown.Skills"}}">
{{#each skillList as |skill|}}
<option value="{{skill.key}}" data-type="skill">
{{skill.label}}
{{/if}}
</option>
{{/each}}
</option>
{{/each}}
</optgroup>
<optgroup label="{{localize "DG.SpecialTraining.Dialog.DropDown.CustomSkills"}}">
{{#each typedSkillList as |skill|}}
<option value="{{skill.key}}" data-type="typedSkill">
{{skill.group}} ({{skill.label}})
</option>
{{/each}}
</optgroup>
</select>
{{/select}}
</div>