Foundry V10 Compatability and Skill Calculations
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user