Removed all UI computations from viewers and components
This commit is contained in:
@@ -44,11 +44,22 @@ function combineAttribute(stat, aggregator, memo){
|
||||
stat.dependencies.push(...dependencies);
|
||||
}
|
||||
stat.currentValue = stat.value - (stat.damage || 0);
|
||||
// Ability scores get modifiers
|
||||
if (stat.attributeType === 'ability') {
|
||||
stat.modifier = Math.floor((stat.currentValue - 10) / 2);
|
||||
} else {
|
||||
stat.modifier = undefined;
|
||||
}
|
||||
// Hit dice get constitution modifiers
|
||||
stat.constitutionMod = undefined;
|
||||
if (stat.attributeType === 'hitDice') {
|
||||
let conStat = memo.statsByVariableName['constitution'];
|
||||
if (conStat && 'modifier' in conStat){
|
||||
stat.constitutionMod = conStat.modifier;
|
||||
stat.dependencies.push(conStat._id, ...conStat.dependencies);
|
||||
}
|
||||
}
|
||||
// Stats that have no effects can be hidden based on a sheet setting
|
||||
stat.hide = aggregator.hasNoEffects &&
|
||||
stat.baseValue === undefined ||
|
||||
undefined
|
||||
|
||||
@@ -6,6 +6,10 @@ export default function computeEndStepProperty(prop, memo){
|
||||
case 'spell':
|
||||
computeAction(prop, memo);
|
||||
break;
|
||||
case 'adjustment':
|
||||
case 'damage':
|
||||
computePropertyField(prop, memo, 'amount', 'compile');
|
||||
break;
|
||||
case 'attack':
|
||||
computeAction(prop, memo);
|
||||
computeAttack(prop, memo);
|
||||
|
||||
@@ -122,6 +122,11 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
// The computed creature constitution modifier
|
||||
constitutionMod: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
// Should this attribute hide
|
||||
hide: {
|
||||
type: Boolean,
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<template lang="html">
|
||||
<markdown-text
|
||||
v-if="embedded"
|
||||
:markdown="computedValue"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="computed"
|
||||
:class="{
|
||||
'symbols-are-errors': expectNumber && scope,
|
||||
'code': errors.length,
|
||||
}"
|
||||
v-html="computedValue"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import evaluateString from '/imports/api/creature/computation/afterComputation/evaluateString.js';
|
||||
import evalutateStringWithEmbeddedCalculations from '/imports/api/creature/computation/afterComputation/evalutateStringWithEmbeddedCalculations.js';
|
||||
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MarkdownText,
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
scope: {
|
||||
type: Object,
|
||||
default: undefined,
|
||||
},
|
||||
expectNumber: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
signed: {
|
||||
type: Boolean
|
||||
},
|
||||
embedded: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
data(){return {
|
||||
errors: false,
|
||||
computedValue: '',
|
||||
}},
|
||||
watch: {
|
||||
value(){
|
||||
this.recalculate();
|
||||
},
|
||||
scope(){
|
||||
this.recalculate();
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
this.recalculate();
|
||||
},
|
||||
methods: {
|
||||
recalculate(){
|
||||
if (!this.value) return;
|
||||
if (this.embedded){
|
||||
let result = evalutateStringWithEmbeddedCalculations(this.value, this.scope);
|
||||
this.computedValue = result;
|
||||
} else {
|
||||
let {result, errors} = evaluateString(this.value, this.scope);
|
||||
if (this.signed){
|
||||
result = numberToSignedString(result);
|
||||
}
|
||||
this.computedValue = result;
|
||||
this.errors = errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css">
|
||||
.computed {
|
||||
display: inline-block;
|
||||
}
|
||||
.computed.symbols-are-errors .math-symbol {
|
||||
color: red;
|
||||
}
|
||||
.computed.code {
|
||||
font-family: monospace,monospace;
|
||||
}
|
||||
.computed .math-binary-operator {
|
||||
margin: 0 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,32 +0,0 @@
|
||||
<template lang="html">
|
||||
<computed
|
||||
:value="value"
|
||||
:scope="scope"
|
||||
v-bind="$attrs"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Computed from '/imports/ui/components/computation/Computed.vue';
|
||||
|
||||
export default {
|
||||
inject: {
|
||||
context: { default: {} }
|
||||
},
|
||||
components: {
|
||||
Computed,
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: undefined,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
scope(){
|
||||
return this.context.creature &&
|
||||
this.context.creature.variables;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -56,8 +56,8 @@
|
||||
/>
|
||||
</h3>
|
||||
<property-description
|
||||
v-if="node.description"
|
||||
:value="node.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</v-card-title>
|
||||
|
||||
@@ -71,7 +71,10 @@
|
||||
/>
|
||||
</template>
|
||||
<template v-if="model.summary">
|
||||
<property-description :value="model.summary" />
|
||||
<property-description
|
||||
:string="model.summary"
|
||||
:calculations="model.summaryCalculations"
|
||||
/>
|
||||
<v-divider
|
||||
v-if="children.length"
|
||||
class="my-2"
|
||||
|
||||
@@ -53,22 +53,14 @@
|
||||
@mouseleave="hover = false"
|
||||
>
|
||||
<v-list-tile-title>
|
||||
{{ model.hitDiceSize }} <computed
|
||||
class="d-inline"
|
||||
signed
|
||||
value="constitution.modifier"
|
||||
/>
|
||||
{{ model.hitDiceSize }} {{ model.constitutionMod }}
|
||||
</v-list-tile-title>
|
||||
</v-list-tile-content>
|
||||
</v-list-tile>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
},
|
||||
inject: {
|
||||
context: { default: {} }
|
||||
},
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
{{ model.name }}
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<property-description :value="model.description" />
|
||||
<property-description
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
@@ -10,24 +10,15 @@
|
||||
<div
|
||||
class="text-no-wrap text-truncate"
|
||||
>
|
||||
<computed
|
||||
class="mr-1"
|
||||
:value="model.amount"
|
||||
:expect-number="false"
|
||||
/>
|
||||
{{ model.stat }} damage
|
||||
{{ model.amountResult }} {{ model.stat }} damage
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import treeNodeViewMixin from '/imports/ui/properties/treeNodeViews/treeNodeViewMixin.js';
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
},
|
||||
mixins: [treeNodeViewMixin],
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -11,30 +11,19 @@
|
||||
<div
|
||||
class="text-no-wrap text-truncate"
|
||||
>
|
||||
<computed
|
||||
class="mr-1"
|
||||
:value="model.amount"
|
||||
:expect-number="false"
|
||||
/>
|
||||
<span class="mr-1">
|
||||
{{ model.damageType }}
|
||||
</span>
|
||||
<span v-if="model.damageType !== 'healing'">
|
||||
damage
|
||||
</span>
|
||||
{{ model.amountResult }}
|
||||
{{ model.damageType }}<span
|
||||
v-if="model.damageType !== 'healing'"
|
||||
> damage</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import treeNodeViewMixin from '/imports/ui/properties/treeNodeViews/treeNodeViewMixin.js';
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
import { getPropertyIcon } from '/imports/constants/PROPERTIES.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
},
|
||||
mixins: [treeNodeViewMixin],
|
||||
computed: {
|
||||
icon(){
|
||||
|
||||
@@ -102,13 +102,19 @@
|
||||
class="my-3"
|
||||
/>
|
||||
<template v-if="model.summary">
|
||||
<property-description :value="model.summary" />
|
||||
<property-description
|
||||
:string="model.summary"
|
||||
:calculations="model.summaryCalculations"
|
||||
/>
|
||||
<v-divider
|
||||
v-if="model.description"
|
||||
class="my-3"
|
||||
/>
|
||||
</template>
|
||||
<property-description :value="model.description" />
|
||||
<property-description
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
<template lang="html">
|
||||
<div class="adjustment-viewer layout row align-center">
|
||||
<computed
|
||||
class="mr-2"
|
||||
:value="model.amount"
|
||||
:expect-number="false"
|
||||
/> {{ model.stat }} damage
|
||||
{{ model.amountResult }} {{ model.stat }} damage
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
:value="reset"
|
||||
/>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
|
||||
<effect-viewer
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
:value="model.duration"
|
||||
/>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -17,6 +17,7 @@ export default {
|
||||
case 0: return 'Immunity';
|
||||
case 0.5: return 'Resistance';
|
||||
case 2: return 'Vulnerability';
|
||||
default: return '';
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
<template lang="html">
|
||||
<div class="damage-viewer layout row align-center">
|
||||
<computed
|
||||
class="mr-2"
|
||||
:value="model.amount"
|
||||
:expect-number="false"
|
||||
/>
|
||||
{{ model.damageType }}
|
||||
<span v-if="model.damageType !== 'healing'">
|
||||
damage
|
||||
</span>
|
||||
{{ model.amountResult }}
|
||||
{{ model.damageType }}<span
|
||||
v-if="model.damageType !== 'healing'"
|
||||
> damage</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
<template lang="html">
|
||||
<div class="feature-viewer">
|
||||
<property-name :value="model.name" />
|
||||
<property-description :value="model.summary" />
|
||||
<property-description
|
||||
:string="model.summary"
|
||||
:calculations="model.summaryCalculations"
|
||||
/>
|
||||
<v-divider class="mt-3 mb-3" />
|
||||
<property-description :value="model.description" />
|
||||
<property-description
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template lang="html">
|
||||
<div class="folder-viewer">
|
||||
<property-name :value="model.name"/>
|
||||
</div>
|
||||
<div class="folder-viewer">
|
||||
<property-name :value="model.name" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -109,8 +109,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<div class="note-viewer">
|
||||
<property-name :value="model.name" />
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
<template lang="html">
|
||||
<div class="proficiency-viewer">
|
||||
<div class="headline layout row">
|
||||
{{model.skill}}
|
||||
<proficiency-icon :value="model.value" class="ml-3 mr-1"/>
|
||||
<div>
|
||||
{{proficiencyText}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="headline layout row">
|
||||
{{ model.skill }}
|
||||
<proficiency-icon
|
||||
:value="model.value"
|
||||
class="ml-3 mr-1"
|
||||
/>
|
||||
<div>
|
||||
{{ proficiencyText }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -14,21 +17,19 @@
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||
import ProficiencyIcon from '/imports/ui/properties/shared/ProficiencyIcon.vue';
|
||||
export default {
|
||||
mixins: [propertyViewerMixin],
|
||||
components: {
|
||||
ProficiencyIcon,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
computed: {
|
||||
proficiencyText(){
|
||||
switch (this.model.value){
|
||||
case 0.5: return "Half proficiency bonus";
|
||||
case 1: return "Proficient";
|
||||
case 2: return "Double proficiency bonus";
|
||||
case 0.5: return 'Half proficiency bonus';
|
||||
case 1: return 'Proficient';
|
||||
case 2: return 'Double proficiency bonus';
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
:value="model.baseProficiency"
|
||||
/>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
|
||||
<effect-viewer
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
:value="model.maxPreparedResult"
|
||||
/>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -19,6 +19,3 @@ export default {
|
||||
mixins: [propertyViewerMixin],
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
:value="`${model.level} ${model.school}`"
|
||||
/>
|
||||
<property-description
|
||||
v-if="model.description"
|
||||
:value="model.description"
|
||||
:string="model.description"
|
||||
:calculations="model.descriptionCalculations"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
<template lang="html">
|
||||
<computed
|
||||
v-if="value"
|
||||
v-if="string"
|
||||
class="property-description"
|
||||
embedded
|
||||
:value="value"
|
||||
:string="string"
|
||||
:calculations="calculations"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
||||
import EmbedInlineComputations from 'imports/ui/components/computation/EmbedInlineComputations.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Computed: ComputedForCreature,
|
||||
Computed: EmbedInlineComputations,
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
string: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
calculations: {
|
||||
type: Array,
|
||||
default(){
|
||||
return [];
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user