Merge dice-roller branch
This commit is contained in:
@ -27,6 +27,8 @@ export class RMSSActor extends Actor {
|
||||
_prepareCharacterData(actorData) {
|
||||
if (actorData.type !== "character") return;
|
||||
|
||||
this.calculateBasicStatBonus(actorData);
|
||||
|
||||
// Calculate Stat Bonuses for the Actor
|
||||
this.calculateStatBonuses(actorData);
|
||||
|
||||
@ -51,6 +53,56 @@ export class RMSSActor extends Actor {
|
||||
const data = actorData.data;
|
||||
}
|
||||
|
||||
// This checks to see if you have a Rollable Table called "Basic Stat Bonus Table" and uses it to calculate the basic stat bonuses.
|
||||
calculateBasicStatBonus(actorData) {
|
||||
const systemData = actorData.system;
|
||||
for (const table of game.tables) {
|
||||
if (table.name === "Basic Stat Bonus Table") {
|
||||
for (const result of table.results) {
|
||||
if (actorData.system.stats.agility.temp >= Number(result.range[0]) && actorData.system.stats.agility.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.agility.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.constitution.temp >= Number(result.range[0]) && actorData.system.stats.constitution.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.constitution.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.memory.temp >= Number(result.range[0]) && actorData.system.stats.memory.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.memory.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.reasoning.temp >= Number(result.range[0]) && actorData.system.stats.reasoning.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.reasoning.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.self_discipline.temp >= Number(result.range[0]) && actorData.system.stats.self_discipline.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.self_discipline.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.empathy.temp >= Number(result.range[0]) && actorData.system.stats.empathy.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.empathy.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.intuition.temp >= Number(result.range[0]) && actorData.system.stats.intuition.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.intuition.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.presence.temp >= Number(result.range[0]) && actorData.system.stats.presence.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.presence.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.quickness.temp >= Number(result.range[0]) && actorData.system.stats.quickness.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.quickness.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
|
||||
if (actorData.system.stats.strength.temp >= Number(result.range[0]) && actorData.system.stats.strength.basic_bonus <= Number(result.range[1])) {
|
||||
actorData.system.stats.strength.basic_bonus = parseInt(result.text, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tally each stat bonus and populate the total field.
|
||||
calculateStatBonuses(actorData) {
|
||||
const systemData = actorData.system;
|
||||
|
@ -105,12 +105,14 @@ export class RMSSItem extends Item {
|
||||
}
|
||||
else
|
||||
{
|
||||
const items = this.parent.items;
|
||||
const items = this.parent?.items;
|
||||
console.log(`rmss | item.js | Skill ${this.name} has owner, calculating skill category bonus.`);
|
||||
for (const item of items) {
|
||||
if (item.type === "skill_category" && item._id === itemData.system.category) {
|
||||
console.log(`rmss | item.js | Calculating Skill Category bonus for skill: ${this.name}`);
|
||||
this.system.category_bonus = item.system.total_bonus;
|
||||
if (items) {
|
||||
for (const item of items) {
|
||||
if (item.type === "skill_category" && item._id === itemData.system.category) {
|
||||
console.log(`rmss | item.js | Calculating Skill Category bonus for skill: ${this.name}`);
|
||||
this.system.category_bonus = item.system.total_bonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user