split powercasting

Split where powercasting is done so that it can be changed by DAE.
This commit is contained in:
supervj 2021-06-28 12:57:06 -04:00
parent 53064c0e09
commit 74d841e9e1
2 changed files with 2077 additions and 1 deletions

View file

@ -144,7 +144,7 @@ export default class Actor5e extends Actor {
}
// Prepare power-casting data
this._computePowercastingProgression(this.data);
this._computeDerivedPowercasting(this.data);
}
/* -------------------------------------------- */
@ -309,6 +309,9 @@ export default class Actor5e extends Actor {
const required = xp.max - prior;
const pct = Math.round((xp.value - prior) * 100 / required);
xp.pct = Math.clamped(pct, 0, 100);
// Add base Powercasting attributes
this._computeBasePowercasting(actorData);
}
/* -------------------------------------------- */
@ -325,6 +328,8 @@ export default class Actor5e extends Actor {
// Proficiency
data.attributes.prof = Math.floor((Math.max(data.details.cr, 1) + 7) / 4);
this._computeBasePowercasting(actorData);
// Powercaster Level
if ( data.attributes.powercasting && !Number.isNumeric(data.details.powerLevel) ) {
data.details.powerLevel = Math.max(data.details.cr, 1);
@ -650,6 +655,37 @@ export default class Actor5e extends Actor {
/* -------------------------------------------- */
/**
* Prepare data related to the power-casting capabilities of the Actor
* @private
*/
_computeDerivedPowercasting (actorData) {
if ((actorData.type === 'actor') || (actorData.type === 'npc')) return;
ad = actorData.data;
// Powercasting DC for Actors and NPCs
// TODO: Consider an option for using the variant rule of all powers use the same value
ad.attributes.powerForceLightDC = 8 + ad.abilities.wis.mod + ad.attributes.prof ?? 10;
ad.attributes.powerForceDarkDC = 8 + ad.abilities.cha.mod + ad.attributes.prof ?? 10;
ad.attributes.powerForceUnivDC = Math.max(ad.attributes.powerForceLightDC,ad.attributes.powerForceDarkDC) ?? 10
ad.attributes.powerTechDC = 8 + ad.abilities.int.mod + ad.attributes.prof ?? 10;
if (actorData.type !== 'actor') return;
// Set Force and tech bonus points for PC Actors
if (!!ad.attributes.force.level){
ad.attributes.force.points.max += Math.max(ad.abilities.wis.mod,ad.abilities.cha.mod);
}
if (!!ad.attributes.tech.level){
ad.attributes.tech.points.max += ad.abilities.int.mod;
}
}
/* -------------------------------------------- */
/**
* Compute the level and percentage of encumbrance for an Actor.
*

2040
module/actor/old_entity.js Normal file

File diff suppressed because it is too large Load diff