special training custom roll logic implemented

This commit is contained in:
jalensailin
2023-12-09 18:29:12 -05:00
parent 8210ba8ae7
commit 6330fc1ec3
3 changed files with 24 additions and 3 deletions
+5 -2
View File
@@ -75,22 +75,23 @@ export default class DeltaGreenActorSheet extends ActorSheet {
name: training.name,
id: training.id,
key: training.attribute,
rollType: "skill",
};
// Convert the machine-readable name to a human-readable one.
switch (true) {
// Stats
case DG.statistics.includes(training.attribute):
simplifiedTraining.attribute = training.attribute.toUpperCase();
simplifiedTraining.targetNumber =
this.actor.system.statistics[training.attribute].value;
simplifiedTraining.rollType = "stat";
break;
// Skills
case DG.skills.includes(training.attribute):
simplifiedTraining.attribute =
this.actor.system.skills[training.attribute].label;
simplifiedTraining.targetNumber =
this.actor.system.skills[training.attribute].proficiency;
break;
// Typed Skills
default:
simplifiedTraining.attribute =
this.actor.system.typedSkills[training.attribute].label;
@@ -910,6 +911,7 @@ export default class DeltaGreenActorSheet extends ActorSheet {
rollType: dataset.rolltype,
key: dataset.key,
actor: this.actor,
specialTrainingName: dataset?.name || null, // Only applies to Special Training Rolls
item,
};
@@ -919,6 +921,7 @@ export default class DeltaGreenActorSheet extends ActorSheet {
case "stat":
case "skill":
case "sanity":
case "special-training":
case "weapon":
roll = new DGPercentileRoll("1D100", {}, rollOptions);
break;
+18
View File
@@ -97,6 +97,24 @@ export class DGPercentileRoll extends DGRoll {
this.localizedKey = `${skill.group} (${skill.label})`;
}
break;
case "special-training": {
this.specialTrainingName = options.specialTrainingName;
if (statKeys.includes(this.key)) {
this.target = this.actor.system.statistics[this.key].x5;
this.localizedKey = game.i18n.localize(`DG.Attributes.${this.key}`);
}
if (skillKeys.includes(this.key)) {
this.target = this.actor.system.skills[this.key].proficiency;
this.localizedKey = game.i18n.localize(`DG.Skills.${this.key}`);
}
if (typedSkillKeys.includes(this.key)) {
const skill = this.actor.system.typedSkills[this.key];
this.target = skill.proficiency;
this.localizedKey = `${skill.group} (${skill.label})`;
}
this.localizedKey = `${this.specialTrainingName} - (${this.localizedKey})`;
break;
}
case "sanity":
this.target = this.actor.system.sanity.value;
this.localizedKey = game.i18n.localize("DG.Attributes.SAN");
+1 -1
View File
@@ -28,7 +28,7 @@
{{/each}}
{{#each specialTraining as |training|}}
<div class="item flexrow flex-group-center flex-thin-border special-training-box">
<label class="{{if_gt training.targetNumber 0 'rollable' 'not-rollable'}}" data-key="{{training.key}}" data-rolltype="{{training.rollType}}">
<label class="{{if_gt training.targetNumber 0 'rollable' 'not-rollable'}}" data-key="{{training.key}}" data-name="{{training.name}}" data-rolltype="special-training">
{{training.name}} ({{training.attribute}} - {{training.targetNumber}})
</label>
<div class="item-controls skill-and-training-controls">