Fixed some issues with skill display

This commit is contained in:
Stefan Zermatten
2022-08-19 14:03:03 +02:00
parent 6d42eb62f0
commit 28307e26c3
5 changed files with 16 additions and 40 deletions

View File

@@ -4,7 +4,7 @@
// by computeVariableAsSkill // by computeVariableAsSkill
export default function computeSkill(computation, node){ export default function computeSkill(computation, node){
const prop = node.data; const prop = node.data;
prop.proficiency = prop.baseProficiency; prop.proficiency = prop.baseProficiency || 0;
let profBonus = computation.scope['proficiencyBonus']?.value || 0; let profBonus = computation.scope['proficiencyBonus']?.value || 0;
// Multiply the proficiency bonus by the actual proficiency // Multiply the proficiency bonus by the actual proficiency
if(prop.proficiency === 0.49){ if(prop.proficiency === 0.49){

View File

@@ -33,6 +33,9 @@ export default function computeVariableAsSkill(computation, node, prop){
const aggregator = node.data.effectAggregator; const aggregator = node.data.effectAggregator;
const aggregatorBase = aggregator?.base || 0; const aggregatorBase = aggregator?.base || 0;
// Store effects
prop.effects = node.data.effects;
// If there is no aggregator, determine if the prop can hide, then exit // If there is no aggregator, determine if the prop can hide, then exit
if (!aggregator){ if (!aggregator){
prop.hide = statBase === undefined && prop.hide = statBase === undefined &&
@@ -71,8 +74,6 @@ export default function computeVariableAsSkill(computation, node, prop){
prop.fail = aggregator.fail; prop.fail = aggregator.fail;
// Rollbonus // Rollbonus
prop.rollBonuses = aggregator.rollBonus; prop.rollBonuses = aggregator.rollBonus;
// Store effects
prop.effects = node.data.effects;
} }
function aggregateAbilityEffects({computation, skillNode, abilityNode}){ function aggregateAbilityEffects({computation, skillNode, abilityNode}){

View File

@@ -135,6 +135,7 @@ let ComputedOnlySkillSchema = createPropertySchema({
effects: { effects: {
type: Array, type: Array,
optional: true, optional: true,
removeBeforeCompute: true,
}, },
'effects.$': { 'effects.$': {
type: Object, type: Object,

View File

@@ -8,7 +8,7 @@
<v-list-item-title class="d-flex align-center"> <v-list-item-title class="d-flex align-center">
<roll-popup <roll-popup
v-if="!hideModifier" v-if="!hideModifier"
class="prof-mod mr-1" class="prof-mod mr-1 flex-shrink-0"
button-class="pl-3 pr-2" button-class="pl-3 pr-2"
text text
:roll-text="displayedModifier" :roll-text="displayedModifier"
@@ -43,7 +43,7 @@
:value="model.proficiency" :value="model.proficiency"
class="prof-icon ml-3 mr-2" class="prof-icon ml-3 mr-2"
/> />
<div> <div class="text-truncate">
{{ model.name }} {{ model.name }}
<template v-if="model.conditionalBenefits && model.conditionalBenefits.length"> <template v-if="model.conditionalBenefits && model.conditionalBenefits.length">
* *

View File

@@ -47,6 +47,12 @@
name="Passive score" name="Passive score"
:value="passiveScore" :value="passiveScore"
/> />
<property-field
v-if="model.overridden"
:cols="{cols: 6, md: 12}"
name="Overridden"
value="Overriden by another property with the same variable name"
/>
</v-row> </v-row>
<v-row dense> <v-row dense>
<property-description <property-description
@@ -55,7 +61,7 @@
/> />
</v-row> </v-row>
<v-row <v-row
v-if="baseEffects.length || ability || effects.length" v-if="ability || (effects && effects.length)"
dense dense
> >
<property-field <property-field
@@ -63,14 +69,6 @@
name="Effects" name="Effects"
> >
<v-list style="width: 100%"> <v-list style="width: 100%">
<attribute-effect
v-for="effect in baseEffects"
:key="effect._id === model._id ? 'this_base' : effect._id"
:model="effect"
:hide-breadcrumbs="effect._id === model._id"
:data-id="effect._id"
@click="effect._id !== model._id && clickEffect(effect._id)"
/>
<attribute-effect <attribute-effect
v-if="ability" v-if="ability"
:key="ability._id" :key="ability._id"
@@ -188,32 +186,8 @@ export default {
variables(){ variables(){
return CreatureVariables.findOne({_creatureId: this.context.creatureId}) || {}; return CreatureVariables.findOne({_creatureId: this.context.creatureId}) || {};
}, },
baseEffects(){
if (this.context.creatureId){
let creatureId = this.context.creatureId;
return CreatureProperties.find({
'ancestors.id': creatureId,
type: 'skill',
variableName: this.model.variableName,
removed: {$ne: true},
inactive: {$ne: true},
}).map( prop => ({
_id: prop._id,
name: 'Skill base value',
operation: 'base',
calculation: prop.baseValueCalculation,
amount: {value: prop.baseValue?.value},
stats: [prop.variableName],
ancestors: prop.ancestors,
}) ).filter(effect => effect.amount?.value);
} else {
return [];
}
},
effects() { effects() {
return CreatureProperties.find({ return this.model.effects;
_id: { $in: this.model.effects?.map(e => e._id) || [] }
});
}, },
baseProficiencies(){ baseProficiencies(){
if (this.context.creatureId){ if (this.context.creatureId){
@@ -265,7 +239,7 @@ export default {
return { return {
_id: abilityProp._id, _id: abilityProp._id,
name: abilityProp.name, name: abilityProp.name,
operation: 'base', operation: 'add',
amount: {value: abilityProp.modifier}, amount: {value: abilityProp.modifier},
stats: [this.model.variableName], stats: [this.model.variableName],
ancestors: abilityProp.ancestors, ancestors: abilityProp.ancestors,