Made hiding stats that aren't targeted by effects or proficiencies an option

This commit is contained in:
Thaum Rystra
2020-05-28 21:06:40 +02:00
parent 9236f3e477
commit 36c23e1eb5
7 changed files with 75 additions and 30 deletions

View File

@@ -27,6 +27,11 @@ let CreatureSettingsSchema = new SimpleSchema({
type: Boolean,
optional: true,
},
// Hide all the unused stats
hideUnusedStats: {
type: Boolean,
optional: true,
}
});
let CreatureSchema = new SimpleSchema({

View File

@@ -24,15 +24,19 @@ export default class EffectAggregator{
this.set = undefined;
this.conditional = [];
this.rollBonus = [];
this.hasNoEffects = true;
}
addEffect(effect){
let result = effect.result;
if (this.hasNoEffects) this.hasNoEffects = false;
switch(effect.operation){
case 'base':
// Take the largest base value
this.base = result > this.base ? result : this.base;
if (effect.statBase){
this.statBaseValue = result > this.statBaseValue ? result : this.statBaseValue;
if (this.statBaseValue === undefined || result > this.statBaseValue){
this.statBaseValue = result;
}
}
break;
case 'add':

View File

@@ -36,6 +36,9 @@ function combineAttribute(stat, aggregator){
stat.modifier = Math.floor((stat.value - 10) / 2);
}
stat.currentValue = stat.value - (stat.damage || 0);
stat.hide = aggregator.hasNoEffects &&
stat.baseValue === undefined ||
undefined
}
function combineSkill(stat, aggregator, memo){
@@ -73,7 +76,12 @@ function combineSkill(stat, aggregator, memo){
let result = (stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
if (result < aggregator.min) result = aggregator.min;
if (result > aggregator.max) result = aggregator.max;
result = Math.floor(result);
if (aggregator.set !== undefined) {
result = aggregator.set;
}
if (Number.isFinite(result)){
result = Math.floor(result);
}
stat.value = result;
// Advantage/disadvantage
if (aggregator.advantage && !aggregator.disadvantage){
@@ -93,6 +101,10 @@ function combineSkill(stat, aggregator, memo){
stat.fail = aggregator.fail;
// Rollbonus
stat.rollBonuses = aggregator.rollBonus;
// Hide
stat.hide = aggregator.hasNoEffects &&
stat.proficiency == 0 ||
undefined;
}
function combineDamageMultiplier(stat){