From 51845c62a7ff05a02516a301aebfbf698d6171c4 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Sat, 30 May 2020 12:32:05 +0200 Subject: [PATCH] Skill base values now work in a way consistent with attribute base values --- .../api/creature/computation/combineStat.js | 6 +++++- app/imports/api/properties/Skills.js | 19 ++++++++++++++++--- app/imports/ui/properties/forms/SkillForm.vue | 12 +++++++----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/app/imports/api/creature/computation/combineStat.js b/app/imports/api/creature/computation/combineStat.js index be1ed6a0..6192c31d 100644 --- a/app/imports/api/creature/computation/combineStat.js +++ b/app/imports/api/creature/computation/combineStat.js @@ -72,8 +72,11 @@ function combineSkill(stat, aggregator, memo){ } // Multiply the proficiency bonus by the actual proficiency profBonus *= stat.proficiency; + // Base value + stat.baseValue = aggregator.statBaseValue; + stat.baseValueErrors = aggregator.baseValueErrors; // Combine everything to get the final result - let result = (stat.abilityMod + profBonus + aggregator.add) * aggregator.mul; + let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul; if (result < aggregator.min) result = aggregator.min; if (result > aggregator.max) result = aggregator.max; if (aggregator.set !== undefined) { @@ -103,6 +106,7 @@ function combineSkill(stat, aggregator, memo){ stat.rollBonuses = aggregator.rollBonus; // Hide stat.hide = aggregator.hasNoEffects && + stat.baseValue === undefined && stat.proficiency == 0 || undefined; } diff --git a/app/imports/api/properties/Skills.js b/app/imports/api/properties/Skills.js index 9a4a807f..af176d84 100644 --- a/app/imports/api/properties/Skills.js +++ b/app/imports/api/properties/Skills.js @@ -1,5 +1,6 @@ import SimpleSchema from 'simpl-schema'; import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js'; +import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js'; /* * Skills are anything that results in a modifier to be added to a D20 @@ -37,9 +38,9 @@ let SkillSchema = new SimpleSchema({ ], defaultValue: 'skill', }, - // If the baseValue is higher than the computed value, it will be used as `value` - baseValue: { - type: Number, + // The starting value, before effects + baseValueCalculation: { + type: String, optional: true, }, // The base proficiency of this skill @@ -59,6 +60,18 @@ let ComputedOnlySkillSchema = new SimpleSchema({ value: { type: Number, defaultValue: 0, + }, + // The result of baseValueCalculation + baseValue: { + type: SimpleSchema.oneOf(Number, String, Boolean), + optional: true, + }, + baseValueErrors: { + type: Array, + optional: true, + }, + 'baseValueErrors.$': { + type: ErrorSchema, }, // Computed value added by the ability abilityMod: { diff --git a/app/imports/ui/properties/forms/SkillForm.vue b/app/imports/ui/properties/forms/SkillForm.vue index 5d1595e6..b72a4b94 100644 --- a/app/imports/ui/properties/forms/SkillForm.vue +++ b/app/imports/ui/properties/forms/SkillForm.vue @@ -46,12 +46,11 @@
+ @@ -70,11 +70,13 @@ import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue'; import createListOfProperties from '/imports/ui/properties/forms/shared/lists/createListOfProperties.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; + import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue'; export default { components: { ProficiencySelect, FormSection, + CalculationErrorList, }, mixins: [propertyFormMixin], data(){return{