Skip to content

Commit

Permalink
[foundryvtt#1848] Add ability types & adjust polymorphing to use them
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Oct 6, 2022
1 parent 23ebe96 commit 0270318
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 17 additions & 8 deletions module/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ _______________________________`;
* Configuration data for abilities.
*
* @typedef {object} AbilityConfiguration
* @property {string} label Localized label.
* @property {string} abbreviation Localized abbreviation.
* @property {Object<string, number|string>} defaults Default values for this ability based on actor type.
* If a string is used, the system will attempt to fetch the value of the
* specified ability.
* @property {string} label Localized label.
* @property {string} abbreviation Localized abbreviation.
* @property {string} [type] Whether this is a "physical" or "mental" ability.
* @property {Object<string, number|string>} [defaults] Default values for this ability based on actor type.
* If a string is used, the system will attempt to fetch.
* the value of the specified ability.
*/

/**
Expand All @@ -33,39 +34,47 @@ _______________________________`;
DND5E.abilities = {
str: {
label: "DND5E.AbilityStr",
abbreviation: "DND5E.AbilityStrAbbr"
abbreviation: "DND5E.AbilityStrAbbr",
type: "physical"
},
dex: {
label: "DND5E.AbilityDex",
abbreviation: "DND5E.AbilityDexAbbr"
abbreviation: "DND5E.AbilityDexAbbr",
type: "physical"
},
con: {
label: "DND5E.AbilityCon",
abbreviation: "DND5E.AbilityConAbbr"
abbreviation: "DND5E.AbilityConAbbr",
type: "physical"
},
int: {
label: "DND5E.AbilityInt",
abbreviation: "DND5E.AbilityIntAbbr",
type: "mental",
defaults: { vehicle: 0 }
},
wis: {
label: "DND5E.AbilityWis",
abbreviation: "DND5E.AbilityWisAbbr",
type: "mental",
defaults: { vehicle: 0 }
},
cha: {
label: "DND5E.AbilityCha",
abbreviation: "DND5E.AbilityChaAbbr",
type: "mental",
defaults: { vehicle: 0 }
},
hon: {
label: "DND5E.AbilityHon",
abbreviation: "DND5E.AbilityHonAbbr",
type: "mental",
defaults: { npc: "cha", vehicle: 0 }
},
san: {
label: "DND5E.AbilitySan",
abbreviation: "DND5E.AbilitySanAbbr",
type: "mental",
defaults: { npc: "wis", vehicle: 0 }
}
};
Expand Down
4 changes: 2 additions & 2 deletions module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,8 @@ export default class Actor5e extends Actor {
for ( let k of Object.keys(abilities) ) {
const oa = o.system.abilities[k];
const prof = abilities[k].proficient;
if ( keepPhysical && ["str", "dex", "con"].includes(k) ) abilities[k] = oa;
else if ( keepMental && ["int", "wis", "cha"].includes(k) ) abilities[k] = oa;
if ( keepPhysical && (CONFIG.DND5E.abilities[k]?.type === "physical") ) abilities[k] = oa;
else if ( keepMental && (CONFIG.DND5E.abilities[k]?.type === "mental") ) abilities[k] = oa;
if ( keepSaves ) abilities[k].proficient = oa.proficient;
else if ( mergeSaves ) abilities[k].proficient = Math.max(prof, oa.proficient);
}
Expand Down

0 comments on commit 0270318

Please sign in to comment.