Rework roll window

This commit is contained in:
2024-07-29 09:28:42 +02:00
parent 3ba8fdd641
commit e25c51a570
21 changed files with 449 additions and 373 deletions

View File

@ -40,6 +40,31 @@ export class RMSSActor extends Actor {
// Iterate through and apply Skill Category Bonuses for Skill items
this.calculateSkillBonuses();
this.computeWoundsMalus();
}
getStunnedModifier() {
if (this.system.state.stunned) {
return Math.min(-50 + (3*this.system.stats.self_discipline.stat_bonus), 0)
} else {
return 0;
}
}
computeWoundsMalus() {
// Compute % of wounds
let percent = 100 - (this.system.attributes.hits.current*100/this.system.attributes.hits.max);
let modifier = 0;
if (percent > 25 && percent < 50) {
modifier = -10;
} else if (percent >= 51 && percent < 75) {
modifier = -20;
} else if (percent >= 76) {
modifier = -30;
}
this.system.modifiers.woundsModifier = modifier;
console.log(`rmss | actor.js | Wounds Malus: ${this.system.modifiers.woundsModifier} ${percent}`);
}
/**
@ -233,51 +258,35 @@ export class RMSSActor extends Actor {
}
else
{
let applicable_stat_bonus = 0;
let app_stat_1_found = false;
let app_stat_2_found = false;
let app_stat_3_found = false;
let applicable_stat_bonuses = [];
// Iterate through the applicable stats and find their full names
for (const stat in CONFIG.rmss.stats) {
// If the configured App Stat matches the one of the stats in config
if (app_stat_1 === CONFIG.rmss.stats[stat].shortname) {
app_stat_1_found = true;
// Get the Stat Bonus
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
// Add the Stat Bonus to the array
applicable_stat_bonuses.push(this.system.stats[stat].stat_bonus);
}
if (app_stat_2 === CONFIG.rmss.stats[stat].shortname) {
app_stat_2_found = true;
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
// Add the Stat Bonus to the array
applicable_stat_bonuses.push(this.system.stats[stat].stat_bonus);
}
if (app_stat_3 === CONFIG.rmss.stats[stat].shortname) {
app_stat_3_found = true;
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
// Add the Stat Bonus to the array
applicable_stat_bonuses.push(this.system.stats[stat].stat_bonus);
}
}
if (app_stat_1_found === true && app_stat_2_found === true && app_stat_3_found === true) {
// Apply the update if we found stat bonuses for every applicable stat
item.system.stat_bonus = applicable_stat_bonus;
// Update the total in the Item
item.calculateSkillCategoryTotalBonus(item);
// Compute the total bonus for the applicable stats
let applicable_stat_bonus = 0;
for (const bonus of applicable_stat_bonuses) {
applicable_stat_bonus += bonus;
}
else if (app_stat_1_found === true && app_stat_2_found === true && app_stat_3_found === false) {
// Apply the update if we found stat bonuses for the first two applicable stats
// Apply the update if we found stat bonuses for every applicable stat
if ( item.system.stat_bonus != applicable_stat_bonus ) {
item.system.stat_bonus = applicable_stat_bonus;
// Update the total in the Item
item.calculateSkillCategoryTotalBonus(item);
}
else if (app_stat_1_found === true && app_stat_2_found === false && app_stat_3_found === false) {
// Apply the update if we found stat bonuses for the first applicable stat
item.system.stat_bonus = applicable_stat_bonus;
// Update the total in the Item
item.calculateSkillCategoryTotalBonus(item);
}
// Update the total in the Item
item.calculateSkillCategoryTotalBonus(item);
}
}
}