Skill base values now work in a way consistent with attribute base values

This commit is contained in:
Stefan Zermatten
2020-05-30 12:32:05 +02:00
parent 56cd48da9d
commit 51845c62a7
3 changed files with 28 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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: {

View File

@@ -46,12 +46,11 @@
<div class="layout row justify-center">
<text-field
label="Base Value"
type="number"
class="base-value-field text-xs-center large-format no-flex"
:value="model.baseValue"
class="base-value-field no-flex"
:value="model.baseValueCalculation"
hint="This is the value of the skill before effects are applied"
:error-messages="errors.baseValue"
@change="change('baseValue', ...arguments)"
:error-messages="errors.baseValueCalculation"
@change="change('baseValueCalculation', ...arguments)"
/>
<proficiency-select
style="flex-basis: 300px;"
@@ -61,6 +60,7 @@
@change="change('baseProficiency', ...arguments)"
/>
</div>
<calculation-error-list :errors="model.baseValueErrors" />
</form-section>
</div>
</template>
@@ -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{