Merge pull request #3 from Cynicide/Calculate-Skill-Totals
Calculate skill total bonuses
This commit is contained in:
commit
08fd1f0fd6
10
rmss/TODO
10
rmss/TODO
@ -1,22 +1,26 @@
|
|||||||
Small
|
Small
|
||||||
|
|
||||||
1. Add Relationship between skills and skill categories
|
1. DONE - Add Relationship between skills and skill categories
|
||||||
2. Remove Tables and replace with CSS Grid
|
2. Remove Tables and replace with CSS Grid
|
||||||
3. Fix unaligned CSS
|
3. Fix unaligned CSS
|
||||||
4. Prevent Duplication on Drag and Drop for Skills and Skill Categories, possibly spells too.
|
4. Prevent Duplication on Drag and Drop for Skills and Skill Categories, possibly spells too.
|
||||||
DONE - Overriden _onDropItem on Player Sheet
|
DONE - Overriden _onDropItem on Player Sheet
|
||||||
DONE - Skill Categories cannot be renamed if they are owned.
|
DONE - Skill Categories cannot be renamed if they are owned.
|
||||||
|
DONE - Skills and Skill Categories are now seperate checks for Drag and Drop as some share names
|
||||||
|
Spells ?
|
||||||
|
5. Fix New Ranks Clickboxes - https://discord.com/channels/170995199584108546/670336275496042502/1018530650980102195
|
||||||
|
6. Fix Favorites Clickboxes on Actor Page
|
||||||
|
|
||||||
Medium
|
Medium
|
||||||
|
|
||||||
4. Inventory sorted by types
|
4. Inventory sorted by types
|
||||||
i. Drag and drop should add an item if it already exists.
|
i. Drag and drop should increment an item if it already exists.
|
||||||
ii. Equipables
|
ii. Equipables
|
||||||
iii. Favorites
|
iii. Favorites
|
||||||
5. Creature Sheet
|
5. Creature Sheet
|
||||||
|
6. Finish Character Sheet
|
||||||
|
|
||||||
Large
|
Large
|
||||||
|
|
||||||
6. Dice Roller
|
6. Dice Roller
|
||||||
7. Initiative System
|
7. Initiative System
|
||||||
|
|
@ -27,14 +27,16 @@ export class RMSSActor extends Actor {
|
|||||||
if (actorData.type !== 'character') return;
|
if (actorData.type !== 'character') return;
|
||||||
|
|
||||||
// Calculate Stat Bonuses for the Actor
|
// Calculate Stat Bonuses for the Actor
|
||||||
this.prepareStatBonuses(actorData);
|
this.calculateStatBonuses(actorData);
|
||||||
|
|
||||||
// Calculate Resistance Rolls for the Actor
|
// Calculate Resistance Rolls for the Actor
|
||||||
this.prepareResistanceRolls(actorData);
|
this.calculateResistanceRolls(actorData);
|
||||||
|
|
||||||
// Iterate through and apply Stat bonuses for Skill Category Items
|
// Iterate through and apply Stat bonuses for Skill Category Items
|
||||||
this.prepareSkillCategoryStatBonuses();
|
this.calculateSkillCategoryStatBonuses();
|
||||||
|
|
||||||
|
// Iterate through and apply Skill Category Bonuses for Skill items
|
||||||
|
this.calculateSkillBonuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,11 +47,10 @@ export class RMSSActor extends Actor {
|
|||||||
|
|
||||||
// Make modifications to data here. For example:
|
// Make modifications to data here. For example:
|
||||||
const data = actorData.data;
|
const data = actorData.data;
|
||||||
data.xp = (data.cr * data.cr) * 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tally each stat bonus and populate the total field.
|
// Tally each stat bonus and populate the total field.
|
||||||
prepareStatBonuses(actorData) {
|
calculateStatBonuses(actorData) {
|
||||||
const systemData = actorData.system;
|
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.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.constitution.stat_bonus = Number(systemData.stats.constitution.racial_bonus)+Number(systemData.stats.constitution.special_bonus)+Number(systemData.stats.constitution.basic_bonus);
|
||||||
@ -64,7 +65,7 @@ export class RMSSActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate each Resistance Roll with the formula on the character sheet.
|
// Calculate each Resistance Roll with the formula on the character sheet.
|
||||||
prepareResistanceRolls(actorData) { // TODO: Add Racial modifiers to resistance
|
calculateResistanceRolls(actorData) { // TODO: Add Racial modifiers to resistance
|
||||||
const systemData = actorData.system;
|
const systemData = actorData.system;
|
||||||
actorData.system.resistance_rolls.essence = Number(systemData.stats.empathy.stat_bonus * 3);
|
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.channeling = Number(systemData.stats.intuition.stat_bonus * 3);
|
||||||
@ -77,19 +78,24 @@ export class RMSSActor extends Actor {
|
|||||||
actorData.system.resistance_rolls.arcane = Number(systemData.stats.empathy.stat_bonus) + Number(systemData.stats.intuition.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*prepareSkillCategoryBonuses() {
|
calculateSkillBonuses() {
|
||||||
for (const item of this.items) {
|
for (const item of this.items) {
|
||||||
if (item.type === "skill") {
|
if (item.type === "skill") {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Tallys the bonus for each Stat that is applicable to the Skill Category and then updates the total
|
// Tallys the bonus for each Stat that is applicable to the Skill Category and then updates the total
|
||||||
prepareSkillCategoryStatBonuses() {
|
calculateSkillCategoryStatBonuses() {
|
||||||
for (const item of this.items) {
|
for (const item of this.items) {
|
||||||
if (item.type === "skill_category") {
|
if (item.type === "skill_category") {
|
||||||
|
|
||||||
|
console.log("rmss | actor.js | Calculating Skill Category Stat Bonuses for: " + item.name);
|
||||||
// Get all the applicable stats for this skill category
|
// Get all the applicable stats for this skill category
|
||||||
var app_stat_1 = item.system.app_stat_1;
|
var app_stat_1 = item.system.app_stat_1;
|
||||||
var app_stat_2 = item.system.app_stat_2;
|
var app_stat_2 = item.system.app_stat_2;
|
||||||
@ -142,11 +148,24 @@ export class RMSSActor extends Actor {
|
|||||||
// This is the format that the select helper on the skill sheet needs
|
// This is the format that the select helper on the skill sheet needs
|
||||||
getOwnedSkillCategories() {
|
getOwnedSkillCategories() {
|
||||||
var ownedSkillCategories = {None: "None"};
|
var ownedSkillCategories = {None: "None"};
|
||||||
for (const item of this.items) {
|
console.log("rmss | actor.js | Getting owned skill categories for: " + this.name);
|
||||||
|
for (const item of this.items) {
|
||||||
if (item.type === "skill_category") {
|
if (item.type === "skill_category") {
|
||||||
ownedSkillCategories[item._id] = item.name;
|
ownedSkillCategories[item._id] = item.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(ownedSkillCategories);
|
return(ownedSkillCategories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ export class RMSSItem extends Item {
|
|||||||
// the following, in order: data reset (to clear active effects),
|
// the following, in order: data reset (to clear active effects),
|
||||||
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
||||||
// prepareDerivedData().
|
// prepareDerivedData().
|
||||||
|
console.log("rmss | item.js | prepareData for:" + this.name);
|
||||||
super.prepareData();
|
super.prepareData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,40 +41,77 @@ export class RMSSItem extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
prepareDerivedData() {
|
||||||
const itemData = this;
|
const itemData = this;
|
||||||
const systemData = itemData.system;
|
const systemData = itemData.system;
|
||||||
const flags = itemData.flags.rmss || {};
|
const flags = itemData.flags.rmss || {};
|
||||||
|
|
||||||
// Make separate methods for each item type to keep things organized.
|
// Make separate methods for each item type to keep things organized.
|
||||||
this._prepareSkillCategoryData(itemData);
|
|
||||||
this._prepareSkillData(itemData);
|
if (itemData.type === 'skill') {
|
||||||
|
this._prepareSkillCategoryData(itemData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemData.type === 'skill') {
|
||||||
|
this._prepareSkillData(itemData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_prepareSkillCategoryData(itemData) {
|
_prepareSkillCategoryData(itemData) {
|
||||||
if (itemData.type !== 'skill_category') return;
|
if (itemData.type !== 'skill_category') return;
|
||||||
|
console.log("rmss | item.js | Preparing Skill Category Data for: " + itemData.name);
|
||||||
// Make modifications to data here. For example:
|
// Calculate Skill Category Total Bonus
|
||||||
//const data = itemData.data;
|
|
||||||
|
|
||||||
// Calculate Stat Bonuses
|
|
||||||
this.calculateSkillCategoryTotalBonus(itemData);
|
this.calculateSkillCategoryTotalBonus(itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
_prepareSkillData(itemData) {
|
_prepareSkillData(itemData) {
|
||||||
if (itemData.type !== 'skill') return;
|
if (itemData.type !== 'skill') return;
|
||||||
|
|
||||||
|
console.log("rmss | item.js | Preparing Skill Data for: " + itemData.name);
|
||||||
|
|
||||||
// Make modifications to data here. For example:
|
// Make modifications to data here. For example:
|
||||||
const systemData = itemData.system;
|
const systemData = itemData.system;
|
||||||
|
|
||||||
|
// Calculate Skill Category Bonus
|
||||||
|
this.calculateSelectedSkillCategoryBonus(itemData);
|
||||||
|
|
||||||
// Calculate Stat Bonuses
|
// Calculate Skill Total Bonus
|
||||||
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);
|
this.calculateSkillTotalBonus(itemData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
calculateSkillCategoryTotalBonus(itemData) {
|
||||||
|
if (this.type === "skill_category") {
|
||||||
|
console.log("rmss | item.js | Calculating Skill Category Total Bonus for: " + itemData.name);
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateSkillTotalBonus(itemData) {
|
||||||
|
if (this.type === "skill") {
|
||||||
|
const systemData = itemData.system;
|
||||||
|
|
||||||
|
console.log("rmss | item.js | Calculating Skill Total Bonus for: " + itemData.name)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateSelectedSkillCategoryBonus(itemData) {
|
||||||
|
if (this.isEmbedded === null) {
|
||||||
|
console.log("rmss | item.js | Skill " + this.name + " has no owner. Not calculating Skill Category bonus");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,8 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
|||||||
const newitem = await Item.implementation.fromDropData(data);
|
const newitem = await Item.implementation.fromDropData(data);
|
||||||
const itemData = newitem.toObject();
|
const itemData = newitem.toObject();
|
||||||
|
|
||||||
if (itemData.type === "skill_category" || itemData.type === "skill"){
|
// To Do: Seperate Skills and Skill Categories. Increment Counts for items
|
||||||
|
if (itemData.type === "skill_category"){
|
||||||
|
|
||||||
// Get the already owned Items from the actor and push into an array
|
// Get the already owned Items from the actor and push into an array
|
||||||
const owneditems = this.object.getOwnedSkillCategories();
|
const owneditems = this.object.getOwnedSkillCategories();
|
||||||
@ -55,6 +56,19 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
|||||||
console.log("Not Owned!");
|
console.log("Not Owned!");
|
||||||
super._onDropItem(event, data);
|
super._onDropItem(event, data);
|
||||||
}
|
}
|
||||||
|
} else if ( itemData.type === "skill") {
|
||||||
|
// Get the already owned Items from the actor and push into an array
|
||||||
|
const owneditems = this.object.getOwnedSkills();
|
||||||
|
|
||||||
|
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 {
|
else {
|
||||||
super._onDropItem(event, data);
|
super._onDropItem(event, data);
|
||||||
@ -65,6 +79,7 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_prepareItems(context) {
|
_prepareItems(context) {
|
||||||
|
console.log("rmss | rmss_player_sheet.js | Preparing items for: "+ this.name);
|
||||||
// Initialize containers.
|
// Initialize containers.
|
||||||
const gear = [];
|
const gear = [];
|
||||||
const playerskill= [];
|
const playerskill= [];
|
||||||
@ -145,12 +160,16 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
|||||||
async _onItemCreate(event) {
|
async _onItemCreate(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const header = event.currentTarget;
|
const header = event.currentTarget;
|
||||||
|
|
||||||
// Get the type of item to create.
|
// Get the type of item to create.
|
||||||
const type = header.dataset.type;
|
const type = header.dataset.type;
|
||||||
|
|
||||||
// Grab any data associated with this control.
|
// Grab any data associated with this control.
|
||||||
const data = duplicate(header.dataset);
|
const data = duplicate(header.dataset);
|
||||||
|
|
||||||
// Initialize a default name.
|
// Initialize a default name.
|
||||||
const name = `New ${type.capitalize()}`;
|
const name = `New ${type.capitalize()}`;
|
||||||
|
|
||||||
// Prepare the item object.
|
// Prepare the item object.
|
||||||
const itemData = {
|
const itemData = {
|
||||||
name: name,
|
name: name,
|
||||||
@ -158,7 +177,6 @@ export default class RMSSPlayerSheet extends ActorSheet {
|
|||||||
data: data
|
data: data
|
||||||
};
|
};
|
||||||
// Remove the type from the dataset since it's in the itemData.type prop.
|
// 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!
|
// Finally, create the item!
|
||||||
return await Item.create(itemData, {parent: this.actor});
|
return await Item.create(itemData, {parent: this.actor});
|
||||||
|
@ -28,7 +28,7 @@ export default class RMSSSkillSheet extends ItemSheet {
|
|||||||
// Figure out if a valid Skill Category is already selected
|
// Figure out if a valid Skill Category is already selected
|
||||||
var selected_skillcat = this.prepareSelectedSkillCategory(owned_skillcats, this.object.system.category);
|
var selected_skillcat = this.prepareSelectedSkillCategory(owned_skillcats, this.object.system.category);
|
||||||
|
|
||||||
this.prepareSelectedSkillCategoryBonus(selected_skillcat);
|
//this.prepareSelectedSkillCategoryBonus(selected_skillcat);
|
||||||
|
|
||||||
let sheetData = {
|
let sheetData = {
|
||||||
owner: this.item.isOwner,
|
owner: this.item.isOwner,
|
||||||
@ -82,6 +82,7 @@ export default class RMSSSkillSheet extends ItemSheet {
|
|||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item.type === "skill_category" && item._id === selected_skillcat) {
|
if (item.type === "skill_category" && item._id === selected_skillcat) {
|
||||||
|
console.log("rmss | rmss_skill_sheet | Calculating Skill Category bonus for skill: " + this.object.name);
|
||||||
this.object.system.category_bonus = item.system.total_bonus;
|
this.object.system.category_bonus = item.system.total_bonus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user