UI work to improve look and feel of Viewers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import _variable from './computeByType/computeVariable.js';
|
||||
import action from './computeByType/computeAction.js';
|
||||
import attribute from './computeByType/computeAttribute.js';
|
||||
import skill from './computeByType/computeSkill.js';
|
||||
import slot from './computeByType/computeSlot.js';
|
||||
import container from './computeByType/computeContainer.js';
|
||||
|
||||
@@ -9,6 +10,7 @@ export default Object.freeze({
|
||||
action,
|
||||
attribute,
|
||||
container,
|
||||
skill,
|
||||
slot,
|
||||
spell: action,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// If we compute this skill without a variable name, it just
|
||||
// uses its base value, proficiency, and damage since no effects can target it
|
||||
// If this skill does have a variable name, it is recomputed later
|
||||
// by computeVariableAsSkill
|
||||
export default function computeSkill(computation, node){
|
||||
const prop = node.data;
|
||||
prop.proficiency = prop.baseProficiency;
|
||||
let profBonus = computation.scope['proficiencyBonus']?.value || 0;
|
||||
// Multiply the proficiency bonus by the actual proficiency
|
||||
if(prop.proficiency === 0.49){
|
||||
// Round down proficiency bonus in the special case
|
||||
profBonus = Math.floor(profBonus * 0.5);
|
||||
} else {
|
||||
profBonus = Math.ceil(profBonus * prop.proficiency);
|
||||
}
|
||||
|
||||
const ability = computation.scope[prop.ability];
|
||||
prop.abilityMod = ability?.modifier || 0;
|
||||
|
||||
const base = prop.baseValue?.value || 0;
|
||||
|
||||
let result = base + prop.abilityMod + profBonus;
|
||||
if (Number.isFinite(result)){
|
||||
result = Math.floor(result);
|
||||
}
|
||||
|
||||
prop.value = result;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ export default function(){
|
||||
assert.equal(scope('strength').modifier, 1);
|
||||
assert.equal(prop('referencesDexId').value, 4);
|
||||
assert.equal(prop('hitDiceId').constitutionMod, 5);
|
||||
assert.equal(prop('overriddenDexId').overridden, true, 'override properties with the same variable name');
|
||||
assert.equal(
|
||||
prop('parseErrorId').baseValue.value, null,
|
||||
'Parse errors should null the value'
|
||||
@@ -44,11 +45,22 @@ var testProperties = [
|
||||
calculation: '12'
|
||||
},
|
||||
}),
|
||||
clean({
|
||||
_id: 'overriddenDexId',
|
||||
variableName: 'dexterity',
|
||||
type: 'attribute',
|
||||
attributeType: 'ability',
|
||||
order: 1,
|
||||
baseValue: {
|
||||
calculation: '15'
|
||||
},
|
||||
}),
|
||||
clean({
|
||||
_id: 'dexterityId',
|
||||
variableName: 'dexterity',
|
||||
type: 'attribute',
|
||||
attributeType: 'ability',
|
||||
order: 2,
|
||||
baseValue: {
|
||||
calculation: '15'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user