Foundry V10 Compatability and Skill Calculations
This commit is contained in:
@ -50,6 +50,4 @@ rmss.stats = {
|
||||
fullname: "Strength",
|
||||
shortname: "St"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export class RMSSActor extends Actor {
|
||||
|
||||
|
||||
/** @override */
|
||||
prepareData() {
|
||||
// Prepare data for the actor. Calling the super version of this executes
|
||||
@ -8,87 +8,92 @@ export class RMSSActor extends Actor {
|
||||
// prepareDerivedData().
|
||||
super.prepareData();
|
||||
}
|
||||
|
||||
|
||||
prepareDerivedData() {
|
||||
const actorData = this.data;
|
||||
const data = actorData.data;
|
||||
const actorData = this;
|
||||
const systemData = actorData.system;
|
||||
const flags = actorData.flags.rmss || {};
|
||||
|
||||
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||
// things organized.
|
||||
this._prepareCharacterData(actorData);
|
||||
this._prepareNpcData(actorData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare Character type specific data
|
||||
*/
|
||||
* Prepare Character type specific data
|
||||
*/
|
||||
_prepareCharacterData(actorData) {
|
||||
if (actorData.type !== 'character') return;
|
||||
|
||||
// Calculate Stat Bonuses in Actor
|
||||
this.prepareStatBonuses(actorData)
|
||||
|
||||
// Calculate Resistance Rolls in Actor
|
||||
|
||||
// Calculate Stat Bonuses for the Actor
|
||||
this.prepareStatBonuses(actorData);
|
||||
|
||||
// Calculate Resistance Rolls for the Actor
|
||||
this.prepareResistanceRolls(actorData);
|
||||
|
||||
|
||||
// Iterate through and apply Stat bonuses for Skill Category Items
|
||||
this.prepareSkillCatStatBonuses();
|
||||
this.prepareSkillCategoryStatBonuses();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare NPC type specific data.
|
||||
*/
|
||||
* Prepare NPC type specific data.
|
||||
*/
|
||||
_prepareNpcData(actorData) {
|
||||
if (actorData.type !== 'npc') return;
|
||||
|
||||
|
||||
// Make modifications to data here. For example:
|
||||
const data = actorData.data;
|
||||
data.xp = (data.cr * data.cr) * 100;
|
||||
}
|
||||
|
||||
|
||||
// Tally each stat bonus and populate the total field.
|
||||
prepareStatBonuses(actorData) {
|
||||
|
||||
const data = actorData.data;
|
||||
|
||||
actorData.data.stats.agility.stat_bonus = Number(data.stats.agility.racial_bonus)+Number(data.stats.agility.special_bonus)+Number(data.stats.agility.basic_bonus);
|
||||
actorData.data.stats.constitution.stat_bonus = Number(data.stats.constitution.racial_bonus)+Number(data.stats.constitution.special_bonus)+Number(data.stats.constitution.basic_bonus);
|
||||
actorData.data.stats.memory.stat_bonus = Number(data.stats.memory.racial_bonus)+Number(data.stats.memory.special_bonus)+Number(data.stats.memory.basic_bonus);
|
||||
actorData.data.stats.reasoning.stat_bonus = Number(data.stats.reasoning.racial_bonus)+Number(data.stats.reasoning.special_bonus)+Number(data.stats.reasoning.basic_bonus);
|
||||
actorData.data.stats.self_discipline.stat_bonus = Number(data.stats.self_discipline.racial_bonus)+Number(data.stats.self_discipline.special_bonus)+Number(data.stats.self_discipline.basic_bonus);
|
||||
actorData.data.stats.empathy.stat_bonus = Number(data.stats.empathy.racial_bonus)+Number(data.stats.empathy.special_bonus)+Number(data.stats.empathy.basic_bonus);
|
||||
actorData.data.stats.intuition.stat_bonus = Number(data.stats.intuition.racial_bonus)+Number(data.stats.intuition.special_bonus)+Number(data.stats.intuition.basic_bonus);
|
||||
actorData.data.stats.presence.stat_bonus = Number(data.stats.presence.racial_bonus)+Number(data.stats.presence.special_bonus)+Number(data.stats.presence.basic_bonus);
|
||||
actorData.data.stats.quickness.stat_bonus = Number(data.stats.quickness.racial_bonus)+Number(data.stats.quickness.special_bonus)+Number(data.stats.quickness.basic_bonus);
|
||||
actorData.data.stats.strength.stat_bonus = Number(data.stats.strength.racial_bonus)+Number(data.stats.strength.special_bonus)+Number(data.stats.strength.basic_bonus);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
prepareResistanceRolls(actorData) {
|
||||
|
||||
const data = actorData.data;
|
||||
|
||||
actorData.data.resistance_rolls.essence = Number(actorData.data.stats.empathy.stat_bonus * 3)
|
||||
actorData.data.resistance_rolls.channeling = Number(actorData.data.stats.intuition.stat_bonus * 3)
|
||||
actorData.data.resistance_rolls.mentalism = Number(actorData.data.stats.presence.stat_bonus * 3)
|
||||
actorData.data.resistance_rolls.fear = Number(actorData.data.stats.self_discipline.stat_bonus * 3)
|
||||
actorData.data.resistance_rolls.poison_disease = Number(actorData.data.stats.constitution.stat_bonus * 3)
|
||||
actorData.data.resistance_rolls.chann_ess = Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.empathy.stat_bonus)
|
||||
actorData.data.resistance_rolls.chann_ment = Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
|
||||
actorData.data.resistance_rolls.ess_ment = Number(actorData.data.stats.empathy.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
|
||||
actorData.data.resistance_rolls.arcane = Number(actorData.data.stats.empathy.stat_bonus) + Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
|
||||
// Calculate each Resistance Roll with the formula on the character sheet.
|
||||
prepareResistanceRolls(actorData) { // TODO: Add Racial modifiers to resistance
|
||||
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);
|
||||
}
|
||||
|
||||
prepareSkillCatStatBonuses() {
|
||||
console.log("Getting Items");
|
||||
/*prepareSkillCategoryBonuses() {
|
||||
for (const item of this.items) {
|
||||
if (item.type === "skill") {
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// Tallys the bonus for each Stat that is applicable to the Skill Category and then updates the total
|
||||
prepareSkillCategoryStatBonuses() {
|
||||
for (const item of this.items) {
|
||||
if (item.type === "skill_category") {
|
||||
|
||||
|
||||
// Get all the applicable stats for this skill category
|
||||
var app_stat_1 = item.data.data.app_stat_1;
|
||||
var app_stat_2 = item.data.data.app_stat_2;
|
||||
var app_stat_3 = item.data.data.app_stat_3;
|
||||
console.log(item.name + " " + app_stat_1 + " " + app_stat_2 + " " + app_stat_3);
|
||||
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;
|
||||
|
||||
// If the first one is None we don't need to do anything further
|
||||
if (app_stat_1 === "None") {
|
||||
@ -97,7 +102,7 @@ export class RMSSActor extends Actor {
|
||||
else
|
||||
{
|
||||
var applicable_stat_bonus = 0;
|
||||
|
||||
|
||||
var app_stat_1_found = false;
|
||||
var app_stat_2_found = false;
|
||||
var app_stat_3_found = false;
|
||||
@ -106,39 +111,42 @@ export class RMSSActor extends Actor {
|
||||
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) {
|
||||
console.log("Found first stat: " + stat);
|
||||
app_stat_1_found = true;
|
||||
// Get the Stat Bonus
|
||||
console.log(this.data.data.stats[stat].stat_bonus);
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
|
||||
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
||||
}
|
||||
if (app_stat_2 === CONFIG.rmss.stats[stat].shortname) {
|
||||
console.log("Found second stat: " + stat);
|
||||
app_stat_2_found = true;
|
||||
console.log(this.data.data.stats[stat].stat_bonus);
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
|
||||
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
||||
}
|
||||
if (app_stat_3 === CONFIG.rmss.stats[stat].shortname) {
|
||||
console.log("Found third stat: " + stat);
|
||||
app_stat_3_found = true;
|
||||
console.log(this.data.data.stats[stat].stat_bonus);
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
|
||||
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
|
||||
applicable_stat_bonus = applicable_stat_bonus + this.system.stats[stat].stat_bonus;
|
||||
}
|
||||
}
|
||||
console.log("Applicable Stat Bonus: " + applicable_stat_bonus)
|
||||
//console.log("Applicable Stat Bonus: " + applicable_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.data.data.stat_bonus = applicable_stat_bonus;
|
||||
item.system.stat_bonus = applicable_stat_bonus;
|
||||
|
||||
// Update the total in the Item
|
||||
item.calculateSkillCatTotalBonus(item.data);
|
||||
item.calculateSkillCategoryTotalBonus(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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"};
|
||||
for (const item of this.items) {
|
||||
if (item.type === "skill_category") {
|
||||
ownedSkillCategories[item._id] = item.name;
|
||||
}
|
||||
}
|
||||
return(ownedSkillCategories);
|
||||
}
|
||||
}
|
@ -9,45 +9,47 @@ export class RMSSItem extends Item {
|
||||
super.prepareData();
|
||||
}
|
||||
|
||||
// Set the images for newly created images (need to fix for copied images).
|
||||
// Set the icon images for newly created images.
|
||||
async _preCreate(data, options, userId) {
|
||||
await super._preCreate(data, options, userId);
|
||||
if (!data.img) {
|
||||
if (this.data.type == "armor") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/armor.svg"});
|
||||
|
||||
// Do not set on copied items if they have a custom Icon.
|
||||
if (!data.name.includes("(Copy)"))
|
||||
{
|
||||
if (this.type == "armor") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/armor.svg"});
|
||||
}
|
||||
else if (this.data.type == "weapon") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/weapon.svg"});
|
||||
else if (this.type == "weapon") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/weapon.svg"});
|
||||
}
|
||||
else if (this.data.type == "skill") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/skill.svg"});
|
||||
else if (this.type == "skill") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/skill.svg"});
|
||||
}
|
||||
else if (this.data.type == "skill_category") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/skill_category.svg"});
|
||||
else if (this.type == "skill_category") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/skill_category.svg"});
|
||||
}
|
||||
else if (this.data.type == "spell") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/spell.svg"});
|
||||
else if (this.type == "spell") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/spell.svg"});
|
||||
}
|
||||
else if (this.data.type == "herb_or_poison") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/herb_or_poison.svg"});
|
||||
else if (this.type == "herb_or_poison") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/herb_or_poison.svg"});
|
||||
}
|
||||
else if (this.data.type == "transport") {
|
||||
await this.data.update({img: "systems/rmss/assets/default/transport.svg"});
|
||||
else if (this.type == "transport") {
|
||||
await this.updateSource({img: "systems/rmss/assets/default/transport.svg"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
calculateSkillCatTotalBonus(itemData) {
|
||||
// Calculate Stat Bonuses
|
||||
|
||||
const data = itemData.data;
|
||||
|
||||
itemData.data.total_bonus = Number(data.rank_bonus)+Number(data.stat_bonus)+Number(data.prof_bonus)+Number(data.special_bonus_1)+Number(data.special_bonus_2);
|
||||
calculateSkillCategoryTotalBonus(itemData) {
|
||||
if (this.type === "skill_category") {
|
||||
const systemData = itemData.system;
|
||||
itemData.system.total_bonus = Number(systemData.rank_bonus)+Number(systemData.stat_bonus)+Number(systemData.prof_bonus)+Number(systemData.special_bonus_1)+Number(systemData.special_bonus_2);
|
||||
}
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
const itemData = this.data;
|
||||
const data = itemData.data;
|
||||
const itemData = this;
|
||||
const systemData = itemData.system;
|
||||
const flags = itemData.flags.rmss || {};
|
||||
|
||||
// Make separate methods for each item type to keep things organized.
|
||||
@ -62,16 +64,16 @@ export class RMSSItem extends Item {
|
||||
//const data = itemData.data;
|
||||
|
||||
// Calculate Stat Bonuses
|
||||
this.calculateSkillCatTotalBonus(itemData);
|
||||
this.calculateSkillCategoryTotalBonus(itemData);
|
||||
}
|
||||
|
||||
_prepareSkillData(itemData) {
|
||||
if (itemData.type !== 'skill') return;
|
||||
|
||||
// Make modifications to data here. For example:
|
||||
const data = itemData.data;
|
||||
const systemData = itemData.system;
|
||||
|
||||
// Calculate Stat Bonuses
|
||||
itemData.data.total_bonus = Number(data.rank_bonus)+Number(data.category_bonus)+Number(data.item_bonus)+Number(data.special_bonus_1)+Number(data.special_bonus_2);
|
||||
itemData.system.total_bonus = Number(systemData.rank_bonus)+Number(systemData.category_bonus)+Number(systemData.item_bonus)+Number(systemData.special_bonus_1)+Number(systemData.special_bonus_2);
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
||||
const context = super.getData();
|
||||
|
||||
// Use a safe clone of the actor data for further operations.
|
||||
const actorData = this.actor.data.toObject(false);
|
||||
const actorData = this.actor.toObject(false);
|
||||
|
||||
// Add the actor's data to context.data for easier access, as well as flags.
|
||||
context.data = actorData.data;
|
||||
context.system = actorData.system;
|
||||
context.flags = actorData.flags;
|
||||
|
||||
// Prepare character data and items.
|
||||
@ -29,11 +29,38 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
||||
// Prepare NPC data and items.
|
||||
if (actorData.type == 'npc') {
|
||||
this._prepareItems(context);
|
||||
}
|
||||
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
//Override this method to check for duplicates when things are dragged to the sheet
|
||||
// We don't want duplicate skills and skill categories.
|
||||
async _onDropItem(event, data) {
|
||||
|
||||
// Reconstruct the item from the event
|
||||
const newitem = await Item.implementation.fromDropData(data);
|
||||
const itemData = newitem.toObject();
|
||||
|
||||
if (itemData.type === "skill_category" || itemData.type === "skill"){
|
||||
|
||||
// Get the already owned Items from the actor and push into an array
|
||||
const owneditems = this.object.getOwnedSkillCategories();
|
||||
|
||||
console.log(owneditems);
|
||||
|
||||
var owneditemslist = Object.values(owneditems);
|
||||
|
||||
// Check if the dragged item is not in the array and not owned
|
||||
if (!owneditemslist.includes(itemData.name)) {
|
||||
console.log("Not Owned!");
|
||||
super._onDropItem(event, data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
super._onDropItem(event, data);
|
||||
}
|
||||
}
|
||||
|
||||
_prepareCharacterData(context) {
|
||||
}
|
||||
|
||||
@ -96,7 +123,7 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
||||
// Render the item sheet for viewing/editing prior to the editable check.
|
||||
html.find('.item-edit').click(ev => {
|
||||
const item = this.actor.items.get(ev.currentTarget.getAttribute("data-item-id"));
|
||||
console.log(this);
|
||||
//console.log(this);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
@ -110,7 +137,7 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
||||
// Delete Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const item = this.actor.items.get(ev.currentTarget.getAttribute("data-item-id"));
|
||||
console.log(ev.currentTarget.getAttribute("data-item-id"));
|
||||
//console.log(ev.currentTarget.getAttribute("data-item-id"));
|
||||
item.delete();
|
||||
});
|
||||
}
|
||||
@ -131,8 +158,8 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
||||
data: data
|
||||
};
|
||||
// Remove the type from the dataset since it's in the itemData.type prop.
|
||||
delete itemData.data["type"];
|
||||
|
||||
//delete itemData.data["type"];
|
||||
delete itemData.data.type;
|
||||
// Finally, create the item!
|
||||
return await Item.create(itemData, {parent: this.actor});
|
||||
}
|
||||
|
@ -17,15 +17,18 @@ export default class RMSSArmorSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
@ -17,15 +17,18 @@ export default class RMSSHerbAndPoisonSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
@ -17,15 +17,18 @@ export default class RMSSItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
@ -17,15 +17,18 @@ export default class RMSSTransportSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
@ -17,15 +17,18 @@ export default class RMSSWeaponSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
@ -17,36 +17,36 @@ export default class RMSSSkillCategorySheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const context = await super.getData();
|
||||
|
||||
// Get a list of stats that can be used as applicable stats
|
||||
var applicable_stat_list = this.prepareApplicableStatValues(CONFIG);
|
||||
|
||||
|
||||
//Get the currently selected value for all three applicable stats
|
||||
var applicable_stat_1_selected = this.prepareApplicableSelectedStat("app_stat_1");
|
||||
var applicable_stat_2_selected = this.prepareApplicableSelectedStat("app_stat_2");
|
||||
var applicable_stat_3_selected = this.prepareApplicableSelectedStat("app_stat_3");
|
||||
|
||||
// Build the string for Applicable Stats
|
||||
var applicable_stat_text = this.buildApplicableStatsText(applicable_stat_1_selected, applicable_stat_2_selected, applicable_stat_3_selected)
|
||||
baseData.item.data.data['applicable_stats'] = applicable_stat_text
|
||||
// Build and apply the display string for Applicable Stats
|
||||
var applicable_stat_text = this.buildApplicableStatsText(applicable_stat_1_selected, applicable_stat_2_selected, applicable_stat_3_selected);
|
||||
//context.item.system['applicable_stats'] = applicable_stat_text;
|
||||
context.item.system.applicable_stats = applicable_stat_text;
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
item: context.item,
|
||||
system: context.item.system,
|
||||
config: CONFIG.rmss,
|
||||
applicable_stat_list: applicable_stat_list,
|
||||
applicable_stat_1_selected: applicable_stat_1_selected,
|
||||
applicable_stat_2_selected: applicable_stat_2_selected,
|
||||
applicable_stat_3_selected: applicable_stat_3_selected
|
||||
applicable_stat_3_selected: applicable_stat_3_selected,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
console.log(this.item)
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
@ -60,19 +60,19 @@ export default class RMSSSkillCategorySheet extends ItemSheet {
|
||||
}
|
||||
|
||||
prepareApplicableStatValues(CONFIG) {
|
||||
var applicable_stat_1_list = {None: "None"}
|
||||
var applicable_stat_list = {None: "None"};
|
||||
|
||||
// Get a list of stat shortnames from the config
|
||||
for (const item in CONFIG.rmss.stats) {
|
||||
applicable_stat_1_list[CONFIG.rmss.stats[item]['shortname']] = CONFIG.rmss.stats[item]['shortname'];
|
||||
applicable_stat_list[CONFIG.rmss.stats[item].shortname] = CONFIG.rmss.stats[item].shortname;
|
||||
}
|
||||
return applicable_stat_1_list;
|
||||
return applicable_stat_list;
|
||||
}
|
||||
|
||||
// Determine which Stat is selected for applicable stats
|
||||
prepareApplicableSelectedStat(app_stat) {
|
||||
var applicable_stat_selected = "";
|
||||
applicable_stat_selected = this.item.data.data[app_stat];
|
||||
applicable_stat_selected = this.item.system[app_stat];
|
||||
return applicable_stat_selected;
|
||||
}
|
||||
|
||||
@ -80,19 +80,19 @@ export default class RMSSSkillCategorySheet extends ItemSheet {
|
||||
buildApplicableStatsText(app_stat_1, app_stat_2, app_stat_3) {
|
||||
|
||||
if (app_stat_1 === "None") {
|
||||
return("None")
|
||||
return("None");
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 === "None") {
|
||||
return(app_stat_1)
|
||||
return(app_stat_1);
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 !== "None" && app_stat_3 === "None" ) {
|
||||
return(app_stat_1 + "/" + app_stat_2 )
|
||||
return(app_stat_1 + "/" + app_stat_2 );
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 !== "None" && app_stat_3 !== "None" ) {
|
||||
return(app_stat_1 + "/" + app_stat_2 + "/" + app_stat_3 )
|
||||
return(app_stat_1 + "/" + app_stat_2 + "/" + app_stat_3 );
|
||||
}
|
||||
else {
|
||||
return("None")
|
||||
return("None");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,17 +17,74 @@ export default class RMSSSkillSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
// Get a list of the parent item's skill categories for the dropdown
|
||||
var owned_skillcats = this.prepareSkillCategoryValues();
|
||||
|
||||
// Figure out if a valid Skill Category is already selected
|
||||
var selected_skillcat = this.prepareSelectedSkillCategory(owned_skillcats, this.object.system.category);
|
||||
|
||||
this.prepareSelectedSkillCategoryBonus(selected_skillcat);
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
owned_skillcats: owned_skillcats,
|
||||
enrichedDescription: enrichedDescription,
|
||||
selected_skillcat: selected_skillcat
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
prepareSkillCategoryValues() {
|
||||
// If there is no player owning this Skill then we cannot assign a category.
|
||||
var skillcat_list = {None: "Skill Has No Owner", };
|
||||
|
||||
if (this.item.isEmbedded === null) {
|
||||
return(skillcat_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
const skillcats = this.item.parent.getOwnedSkillCategories();
|
||||
return(skillcats);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine which Stat is selected and test that it is in the current list of categories.
|
||||
prepareSelectedSkillCategory(ownedskillcats, selected_category) {
|
||||
|
||||
// Start By setting the owned category to None, if nothing happens this will be the default
|
||||
var default_selected_category = "None";
|
||||
|
||||
// Get a list of keys from the currently owned skill categories and compare to the current value
|
||||
if (Object.keys(ownedskillcats).includes(selected_category)) {
|
||||
return(selected_category);
|
||||
} else {
|
||||
return(default_selected_category);
|
||||
}
|
||||
}
|
||||
|
||||
prepareSelectedSkillCategoryBonus(selected_skillcat) {
|
||||
if (this.item.isEmbedded === null) {
|
||||
console.log("Skill has no owner");
|
||||
}
|
||||
else
|
||||
{
|
||||
const items = this.object.parent.items;
|
||||
|
||||
for (const item of items) {
|
||||
if (item.type === "skill_category" && item._id === selected_skillcat) {
|
||||
this.object.system.category_bonus = item.system.total_bonus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,15 +16,18 @@ export default class RMSSSpellSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
async getData() {
|
||||
const baseData = await super.getData();
|
||||
|
||||
var enrichedDescription = await TextEditor.enrichHTML(this.item.system.description, {async: true});
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
system: baseData.item.system,
|
||||
config: CONFIG.rmss,
|
||||
enrichedDescription: enrichedDescription
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
|
Reference in New Issue
Block a user