2022-08-29 12:22:04 +02:00
|
|
|
export class RMSSActor extends Actor {
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
/** @override */
|
|
|
|
prepareData() {
|
|
|
|
// Prepare data for the actor. Calling the super version of this executes
|
|
|
|
// the following, in order: data reset (to clear active effects),
|
|
|
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
|
|
|
// prepareDerivedData().
|
|
|
|
super.prepareData();
|
|
|
|
}
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
prepareDerivedData() {
|
2022-09-05 02:15:56 +02:00
|
|
|
const actorData = this;
|
|
|
|
const systemData = actorData.system;
|
2022-08-29 12:22:04 +02:00
|
|
|
const flags = actorData.flags.rmss || {};
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
|
|
|
// things organized.
|
|
|
|
this._prepareCharacterData(actorData);
|
|
|
|
this._prepareNpcData(actorData);
|
|
|
|
}
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
/**
|
2022-09-05 02:15:56 +02:00
|
|
|
* Prepare Character type specific data
|
|
|
|
*/
|
2022-08-29 12:22:04 +02:00
|
|
|
_prepareCharacterData(actorData) {
|
|
|
|
if (actorData.type !== 'character') return;
|
2022-09-05 02:15:56 +02:00
|
|
|
|
|
|
|
// Calculate Stat Bonuses for the Actor
|
2022-09-11 22:22:55 +02:00
|
|
|
this.calculateStatBonuses(actorData);
|
2022-09-05 02:15:56 +02:00
|
|
|
|
|
|
|
// Calculate Resistance Rolls for the Actor
|
2022-09-11 22:22:55 +02:00
|
|
|
this.calculateResistanceRolls(actorData);
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
// Iterate through and apply Stat bonuses for Skill Category Items
|
2022-09-11 22:22:55 +02:00
|
|
|
this.calculateSkillCategoryStatBonuses();
|
|
|
|
|
|
|
|
// Iterate through and apply Skill Category Bonuses for Skill items
|
|
|
|
this.calculateSkillBonuses();
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
/**
|
2022-09-05 02:15:56 +02:00
|
|
|
* Prepare NPC type specific data.
|
|
|
|
*/
|
2022-08-29 12:22:04 +02:00
|
|
|
_prepareNpcData(actorData) {
|
|
|
|
if (actorData.type !== 'npc') return;
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
// Make modifications to data here. For example:
|
|
|
|
const data = actorData.data;
|
|
|
|
}
|
2022-09-05 02:15:56 +02:00
|
|
|
|
|
|
|
// Tally each stat bonus and populate the total field.
|
2022-09-11 22:22:55 +02:00
|
|
|
calculateStatBonuses(actorData) {
|
2022-09-05 02:15:56 +02:00
|
|
|
const systemData = actorData.system;
|
|
|
|
actorData.system.stats.agility.stat_bonus = Number(systemData.stats.agility.racial_bonus)+Number(systemData.stats.agility.special_bonus)+Number(systemData.stats.agility.basic_bonus);
|
|
|
|
actorData.system.stats.constitution.stat_bonus = Number(systemData.stats.constitution.racial_bonus)+Number(systemData.stats.constitution.special_bonus)+Number(systemData.stats.constitution.basic_bonus);
|
|
|
|
actorData.system.stats.memory.stat_bonus = Number(systemData.stats.memory.racial_bonus)+Number(systemData.stats.memory.special_bonus)+Number(systemData.stats.memory.basic_bonus);
|
|
|
|
actorData.system.stats.reasoning.stat_bonus = Number(systemData.stats.reasoning.racial_bonus)+Number(systemData.stats.reasoning.special_bonus)+Number(systemData.stats.reasoning.basic_bonus);
|
|
|
|
actorData.system.stats.self_discipline.stat_bonus = Number(systemData.stats.self_discipline.racial_bonus)+Number(systemData.stats.self_discipline.special_bonus)+Number(systemData.stats.self_discipline.basic_bonus);
|
|
|
|
actorData.system.stats.empathy.stat_bonus = Number(systemData.stats.empathy.racial_bonus)+Number(systemData.stats.empathy.special_bonus)+Number(systemData.stats.empathy.basic_bonus);
|
|
|
|
actorData.system.stats.intuition.stat_bonus = Number(systemData.stats.intuition.racial_bonus)+Number(systemData.stats.intuition.special_bonus)+Number(systemData.stats.intuition.basic_bonus);
|
|
|
|
actorData.system.stats.presence.stat_bonus = Number(systemData.stats.presence.racial_bonus)+Number(systemData.stats.presence.special_bonus)+Number(systemData.stats.presence.basic_bonus);
|
|
|
|
actorData.system.stats.quickness.stat_bonus = Number(systemData.stats.quickness.racial_bonus)+Number(systemData.stats.quickness.special_bonus)+Number(systemData.stats.quickness.basic_bonus);
|
|
|
|
actorData.system.stats.strength.stat_bonus = Number(systemData.stats.strength.racial_bonus)+Number(systemData.stats.strength.special_bonus)+Number(systemData.stats.strength.basic_bonus);
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
|
2022-09-05 02:15:56 +02:00
|
|
|
// Calculate each Resistance Roll with the formula on the character sheet.
|
2022-09-11 22:22:55 +02:00
|
|
|
calculateResistanceRolls(actorData) { // TODO: Add Racial modifiers to resistance
|
2022-09-05 02:15:56 +02:00
|
|
|
const systemData = actorData.system;
|
|
|
|
actorData.system.resistance_rolls.essence = Number(systemData.stats.empathy.stat_bonus * 3);
|
|
|
|
actorData.system.resistance_rolls.channeling = Number(systemData.stats.intuition.stat_bonus * 3);
|
|
|
|
actorData.system.resistance_rolls.mentalism = Number(systemData.stats.presence.stat_bonus * 3);
|
|
|
|
actorData.system.resistance_rolls.fear = Number(systemData.stats.self_discipline.stat_bonus * 3);
|
|
|
|
actorData.system.resistance_rolls.poison_disease = Number(systemData.stats.constitution.stat_bonus * 3);
|
|
|
|
actorData.system.resistance_rolls.chann_ess = Number(systemData.stats.intuition.stat_bonus) + Number(systemData.stats.empathy.stat_bonus);
|
|
|
|
actorData.system.resistance_rolls.chann_ment = Number(systemData.stats.intuition.stat_bonus) + Number(systemData.stats.presence.stat_bonus);
|
|
|
|
actorData.system.resistance_rolls.ess_ment = Number(systemData.stats.empathy.stat_bonus) + Number(systemData.stats.presence.stat_bonus);
|
|
|
|
actorData.system.resistance_rolls.arcane = Number(systemData.stats.empathy.stat_bonus) + Number(systemData.stats.intuition.stat_bonus) + Number(systemData.stats.presence.stat_bonus);
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 22:22:55 +02:00
|
|
|
calculateSkillBonuses() {
|
2022-08-29 12:22:04 +02:00
|
|
|
for (const item of this.items) {
|
2022-09-05 02:15:56 +02:00
|
|
|
if (item.type === "skill") {
|
2022-09-11 22:22:55 +02:00
|
|
|
console.log("rmss | actor.js | Calculating skill bonus for Skill: " + item.name);
|
|
|
|
console.log("rmss | actor.js | Updating Skill Category Bonus for Skill: " + item.name);
|
|
|
|
item.calculateSelectedSkillCategoryBonus(item);
|
|
|
|
console.log("rmss | actor.js | Updating Skill Total Bonus for Skill: " + item.name);
|
|
|
|
item.calculateSkillTotalBonus(item);
|
2022-09-05 02:15:56 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-11 22:22:55 +02:00
|
|
|
}
|
2022-08-29 12:22:04 +02:00
|
|
|
|
2022-09-05 02:15:56 +02:00
|
|
|
// Tallys the bonus for each Stat that is applicable to the Skill Category and then updates the total
|
2022-09-11 22:22:55 +02:00
|
|
|
calculateSkillCategoryStatBonuses() {
|
2022-09-05 02:15:56 +02:00
|
|
|
for (const item of this.items) {
|
|
|
|
if (item.type === "skill_category") {
|
|
|
|
|
2022-09-11 22:22:55 +02:00
|
|
|
console.log("rmss | actor.js | Calculating Skill Category Stat Bonuses for: " + item.name);
|
2022-08-29 12:22:04 +02:00
|
|
|
// Get all the applicable stats for this skill category
|
2022-09-05 02:15:56 +02:00
|
|
|
var app_stat_1 = item.system.app_stat_1;
|
|
|
|
var app_stat_2 = item.system.app_stat_2;
|
|
|
|
var app_stat_3 = item.system.app_stat_3;
|
2022-08-29 12:22:04 +02:00
|
|
|
|
|
|
|
// If the first one is None we don't need to do anything further
|
|
|
|
if (app_stat_1 === "None") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var applicable_stat_bonus = 0;
|
2022-09-05 02:15:56 +02:00
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
var app_stat_1_found = false;
|
|
|
|
var app_stat_2_found = false;
|
|
|
|
var app_stat_3_found = false;
|
|
|
|
|
|
|
|
// 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
|
2022-09-05 02:15:56 +02:00
|
|
|
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
if (app_stat_2 === CONFIG.rmss.stats[stat].shortname) {
|
|
|
|
app_stat_2_found = true;
|
2022-09-05 02:15:56 +02:00
|
|
|
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
if (app_stat_3 === CONFIG.rmss.stats[stat].shortname) {
|
|
|
|
app_stat_3_found = true;
|
2022-09-05 02:15:56 +02:00
|
|
|
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-05 02:15:56 +02:00
|
|
|
//console.log("Applicable Stat Bonus: " + applicable_stat_bonus)
|
2022-08-29 12:22:04 +02:00
|
|
|
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
|
2022-09-05 02:15:56 +02:00
|
|
|
item.system.stat_bonus = applicable_stat_bonus;
|
2022-08-29 12:22:04 +02:00
|
|
|
|
|
|
|
// Update the total in the Item
|
2022-09-05 02:15:56 +02:00
|
|
|
item.calculateSkillCategoryTotalBonus(item);
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 02:15:56 +02:00
|
|
|
// For each skill category return an object in this format.
|
|
|
|
// {{ _id: "skill category name"}}
|
|
|
|
// This is the format that the select helper on the skill sheet needs
|
|
|
|
getOwnedSkillCategories() {
|
|
|
|
var ownedSkillCategories = {None: "None"};
|
2022-09-11 22:22:55 +02:00
|
|
|
console.log("rmss | actor.js | Getting owned skill categories for: " + this.name);
|
|
|
|
for (const item of this.items) {
|
2022-09-05 02:15:56 +02:00
|
|
|
if (item.type === "skill_category") {
|
|
|
|
ownedSkillCategories[item._id] = item.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(ownedSkillCategories);
|
|
|
|
}
|
2022-09-11 22:22:55 +02:00
|
|
|
|
|
|
|
getOwnedSkills() {
|
|
|
|
var ownedSkills = {None: "None"};
|
|
|
|
console.log("rmss | actor.js | Getting owned skills for: " + this.name);
|
|
|
|
for (const item of this.items) {
|
|
|
|
if (item.type === "skill") {
|
|
|
|
ownedSkills[item._id] = item.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(ownedSkills);
|
|
|
|
}
|
|
|
|
|
2022-08-29 12:22:04 +02:00
|
|
|
}
|