Added tag-targeted profs to calculation viewers
This commit is contained in:
@@ -3,6 +3,9 @@ import evaluateCalculation from '../../utility/evaluateCalculation.js';
|
||||
export default function computeCalculation(computation, node) {
|
||||
const calcObj = node.data;
|
||||
evaluateCalculation(calcObj, computation.scope);
|
||||
if (calcObj.effects || calcObj.proficiencies) {
|
||||
calcObj.baseValue = calcObj.value;
|
||||
}
|
||||
aggregateCalculationEffects(node, computation);
|
||||
aggregateCalculationProficiencies(node, computation);
|
||||
}
|
||||
@@ -36,7 +39,6 @@ function aggregateCalculationEffects(node, computation) {
|
||||
true // enumerate only outbound links
|
||||
);
|
||||
if (calcObj.effects && typeof calcObj.value === 'number') {
|
||||
calcObj.baseValue = calcObj.value;
|
||||
calcObj.effects.forEach(effect => {
|
||||
if (
|
||||
effect.operation === 'add' &&
|
||||
@@ -71,23 +73,28 @@ function aggregateCalculationProficiencies(node, computation) {
|
||||
},
|
||||
true // enumerate only outbound links
|
||||
);
|
||||
if (calcObj.proficiencies) {
|
||||
if (calcObj.proficiencies && typeof calcObj.value === 'number') {
|
||||
calcObj.proficiency = 0;
|
||||
let currentProf;
|
||||
calcObj.proficiencies.forEach(prof => {
|
||||
if (prof.value > calcObj.proficiency) {
|
||||
if (currentProf) currentProf.overridden = true;
|
||||
calcObj.proficiency = prof.value;
|
||||
} else {
|
||||
prof.overridden = true;
|
||||
}
|
||||
});
|
||||
// Get the character's proficiency bonus to apply
|
||||
let profBonus = computation.scope['proficiencyBonus']?.value || 0;
|
||||
|
||||
calcObj.proficiencyBonus = profBonus;
|
||||
let totalBonus;
|
||||
// Multiply the proficiency bonus by the actual proficiency
|
||||
if (calcObj.proficiency === 0.49) {
|
||||
// Round down proficiency bonus in the special case
|
||||
calcObj.proficiencyBonus = Math.floor(profBonus * 0.5);
|
||||
totalBonus = Math.floor(profBonus * 0.5);
|
||||
} else {
|
||||
calcObj.proficiencyBonus = Math.ceil(profBonus * calcObj.proficiency);
|
||||
totalBonus = Math.ceil(profBonus * calcObj.proficiency);
|
||||
}
|
||||
calcObj.value += calcObj.proficiencyBonus;
|
||||
calcObj.value += totalBonus;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user