fix vehicles

This commit is contained in:
TheLastScrub
2025-02-15 23:18:33 -08:00
parent 996a1a377d
commit 0789d3741f
+66 -56
View File
@@ -70,38 +70,43 @@ export default class DeltaGreenActorSheet extends ActorSheet {
// Make it easy for the sheet handlebars to understand how to sort the skills.
data.sortSkillsSetting = game.settings.get("deltagreen", "sortSkills");
let sortedSkills = [];
for (const [key, skill] of Object.entries(this.actor.system.skills)) {
skill.key = key;
skill.sortLabel = game.i18n.localize(`DG.Skills.${key}`);
if (this.actor.type !== "vehicle") {
// fill an array that is sorted based on the appropriate localized entry
let sortedSkills = [];
for (const [key, skill] of Object.entries(this.actor.system.skills)) {
skill.key = key;
skill.sortLabel = game.i18n.localize(`DG.Skills.${key}`);
if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) {
skill.sortLabel = skill.label;
if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) {
skill.sortLabel = skill.label;
}
// if the actor is an NPC or Unnatural, and they have 'hide untrained skills' active,
// it will break the sorting logic, so we have to skip over these
if (
!(
(this.actor.type == "npc" || this.actor.type == "unnatural") &&
this.actor.system.showUntrainedSkills == true &&
skill.proficiency < 1
)
) {
sortedSkills.push(skill);
}
}
if (
!(
(this.actor.type == "npc" || this.actor.type == "unnatural") &&
this.actor.system.showUntrainedSkills == true &&
skill.proficiency < 1
)
) {
sortedSkills.push(skill);
sortedSkills.sort(function (a, b) {
return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang);
});
// if sorting by columns, re-arrange the array to be columns first, then rows
if (game.settings.get("deltagreen", "sortSkills")) {
let columnSortedSkills = this.reorderForColumnSorting(sortedSkills, 3);
this.actor.system.sortedSkills = columnSortedSkills;
} else {
this.actor.system.sortedSkills = sortedSkills;
}
}
sortedSkills.sort(function (a, b) {
return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang);
});
if (game.settings.get("deltagreen", "sortSkills")) {
let columnSortedSkills = this.reorderForColumnSorting(sortedSkills, 3);
this.actor.system.sortedSkills = columnSortedSkills;
} else {
this.actor.system.sortedSkills = sortedSkills;
}
// Prepare a simplified version of the special training for display on sheet.
if (this.actor.type !== "vehicle") {
const specialTraining = this.actor.system.specialTraining.map(
@@ -141,45 +146,50 @@ export default class DeltaGreenActorSheet extends ActorSheet {
data.specialTraining = specialTraining;
}
// try to make a combined array of both typed skills and special trainings, so that it can be sorted neatly on the sheet
let sortedCustomSkills = [];
// try to make a combined array of both typed skills and special trainings,
// so that it can be sorted together neatly on the sheet
if (this.actor.type !== "vehicle") {
let sortedCustomSkills = [];
for (const [key, skill] of Object.entries(this.actor.system.typedSkills)) {
skill.type = "typeSkill";
skill.key = key;
skill.sortLabel = skill.group + "." + skill.label;
for (const [key, skill] of Object.entries(
this.actor.system.typedSkills
)) {
skill.type = "typeSkill";
skill.key = key;
skill.sortLabel = skill.group + "." + skill.label;
skill.sortLabel = skill.sortLabel.toUpperCase();
skill.sortLabel = skill.sortLabel.toUpperCase();
if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) {
skill.sortLabel = skill.label;
if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) {
skill.sortLabel = skill.label;
}
sortedCustomSkills.push(skill);
}
sortedCustomSkills.push(skill);
}
for (var i = 0; i < data.specialTraining.length; i++) {
let training = data.specialTraining[i];
for (var i = 0; i < data.specialTraining.length; i++) {
let training = data.specialTraining[i];
training.type = "training";
training.sortLabel = training.name.toUpperCase();
training.type = "training";
training.sortLabel = training.name.toUpperCase();
sortedCustomSkills.push(training);
}
sortedCustomSkills.push(training);
}
sortedCustomSkills.sort(function (a, b) {
return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang);
});
sortedCustomSkills.sort(function (a, b) {
return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang);
});
if (game.settings.get("deltagreen", "sortSkills")) {
let columnSortedSkills = this.reorderForColumnSorting(
sortedCustomSkills,
2
);
if (game.settings.get("deltagreen", "sortSkills")) {
let columnSortedSkills = this.reorderForColumnSorting(
sortedCustomSkills,
2
);
this.actor.system.sortedCustomSkills = columnSortedSkills;
} else {
this.actor.system.sortedCustomSkills = sortedCustomSkills;
this.actor.system.sortedCustomSkills = columnSortedSkills;
} else {
this.actor.system.sortedCustomSkills = sortedCustomSkills;
}
}
switch (this.actor.type) {