Slot quantity is now a computed value, added property viewer for slots

This commit is contained in:
Stefan Zermatten
2021-02-23 14:53:47 +02:00
parent 858915b25b
commit d69ada0db4
9 changed files with 59 additions and 15 deletions

View File

@@ -23,6 +23,7 @@ export default function computeEndStepProperty(prop, memo){
computePropertyField(prop, memo, 'maxPrepared');
break;
case 'propertySlot':
computePropertyField(prop, memo, 'quantityExpected');
computePropertyField(prop, memo, 'slotCondition');
break;
case 'roll':

View File

@@ -21,6 +21,9 @@ export default function evaluateCalculation({
context,
dependencies,
};
if (typeof string !== 'string'){
string = string.toString();
}
// Parse the string
let calc;
try {

View File

@@ -23,10 +23,14 @@ export default function recomputeSlotFullness(ancestorId){
}
});
let spaceLeft;
if (slot.quantityExpected === 0){
let expected = slot.quantityExpectedResult;
if (typeof expected !== 'number'){
expected = 1;
}
if (expected === 0){
spaceLeft = null;
} else {
spaceLeft = slot.quantityExpected - totalFilled;
spaceLeft = expected - totalFilled;
}
if (slot.totalFilled !== totalFilled || slot.spaceLeft !== spaceLeft){
CreatureProperties.update(slot._id, {

View File

@@ -22,9 +22,9 @@ let SlotSchema = new SimpleSchema({
type: String,
},
quantityExpected: {
type: SimpleSchema.Integer,
defaultValue: 1,
min: 0,
type: String,
optional: true,
defaultValue: '1',
},
ignored: {
type: Boolean,

View File

@@ -8,8 +8,8 @@
<h3 class="layout row align-center">
{{ slot.name }}
<v-spacer />
<span v-if="slot.quantityExpected > 1">
{{ slot.totalFilled }} / {{ slot.quantityExpected }}
<span v-if="slot.quantityExpectedResult > 1">
{{ slot.totalFilled }} / {{ slot.quantityExpectedResult }}
</span>
</h3>
<v-list v-if="slot.children.length">
@@ -38,7 +38,7 @@
</v-list-tile>
</v-list>
<v-btn
v-if="!slot.quantityExpected || slot.spaceLeft"
v-if="!slot.quantityExpectedResult || slot.spaceLeft"
icon
:data-id="`slot-add-button-${slot._id}`"
class="slot-add-button"

View File

@@ -28,8 +28,6 @@
/>
<text-field
label="Quantity"
type="number"
min="0"
hint="How many matching properties must be used to fill this slot, 0 is unlimited"
:value="model.quantityExpected"
:error-messages="errors.quantityExpected"

View File

@@ -0,0 +1,36 @@
<template lang="html">
<div class="buff-viewer">
<property-name :value="model.name" />
<property-field
name="Type"
:value="model.slotType"
/>
<property-field
name="Quantity"
:value="'quantityExpectedResult' in model ? model.quantityExpectedResult : model.quantityExpected"
/>
<property-field
name="Condition"
:value="'slotConditionResult' in model ? model.slotConditionResult : model.slotCondition"
/>
<template v-if="model.tags.length">
<div class="caption">
Tags
</div>
<property-tags :tags="model.tags" />
</template>
<property-description
:string="model.description"
:calculations="model.descriptionCalculations"
:inactive="model.inactive"
/>
</div>
</template>
<script>
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'
export default {
mixins: [propertyViewerMixin],
}
</script>

View File

@@ -1,11 +1,11 @@
<template lang="html">
<div v-if="value !== undefined || $slots.default">
<div class="caption">
{{name}}
</div>
<div class="caption">
{{ name }}
</div>
<p class="ml-2 subheading">
<slot>
{{value}}
{{ value }}
</slot>
</p>
</div>
@@ -15,7 +15,7 @@
export default {
props: {
name: String,
value: [String, Number],
value: [String, Number, Boolean],
}
}
</script>

View File

@@ -17,6 +17,7 @@ import ProficiencyViewer from '/imports/ui/properties/viewers/ProficiencyViewer.
import RollViewer from '/imports/ui/properties/viewers/RollViewer.vue';
import SkillViewer from '/imports/ui/properties/viewers/SkillViewer.vue';
import SavingThrowViewer from '/imports/ui/properties/viewers/SavingThrowViewer.vue';
import SlotViewer from '/imports/ui/properties/viewers/SlotViewer.vue';
import SpellListViewer from '/imports/ui/properties/viewers/SpellListViewer.vue';
import SpellViewer from '/imports/ui/properties/viewers/SpellViewer.vue';
@@ -39,6 +40,7 @@ export default {
proficiency: ProficiencyViewer,
roll: RollViewer,
savingThrow: SavingThrowViewer,
propertySlot: SlotViewer,
skill: SkillViewer,
spellList: SpellListViewer,
spell: SpellViewer,