Fixed slots and slot fillers not calculating their conditions correctly
Also fixes slot fullness calculation
This commit is contained in:
@@ -14,7 +14,7 @@ const linkDependenciesByType = {
|
|||||||
effect: linkEffects,
|
effect: linkEffects,
|
||||||
proficiency: linkProficiencies,
|
proficiency: linkProficiencies,
|
||||||
roll: linkRoll,
|
roll: linkRoll,
|
||||||
slot: linkSlot,
|
propertySlot: linkSlot,
|
||||||
skill: linkSkill,
|
skill: linkSkill,
|
||||||
spell: linkAction,
|
spell: linkAction,
|
||||||
spellList: linkSpellList,
|
spellList: linkSpellList,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import _variable from './computeByType/computeVariable.js';
|
|||||||
import action from './computeByType/computeAction.js';
|
import action from './computeByType/computeAction.js';
|
||||||
import attribute from './computeByType/computeAttribute.js';
|
import attribute from './computeByType/computeAttribute.js';
|
||||||
import skill from './computeByType/computeSkill.js';
|
import skill from './computeByType/computeSkill.js';
|
||||||
import slot from './computeByType/computeSlot.js';
|
import propertySlot from './computeByType/computeSlot.js';
|
||||||
import container from './computeByType/computeContainer.js';
|
import container from './computeByType/computeContainer.js';
|
||||||
import _calculation from './computeByType/computeCalculation.js';
|
import _calculation from './computeByType/computeCalculation.js';
|
||||||
|
|
||||||
@@ -13,6 +13,6 @@ export default Object.freeze({
|
|||||||
attribute,
|
attribute,
|
||||||
container,
|
container,
|
||||||
skill,
|
skill,
|
||||||
slot,
|
propertySlot,
|
||||||
spell: action,
|
spell: action,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export default function computSlot(computation, node){
|
export default function computSlot(computation, node){
|
||||||
const prop = node.data;
|
const prop = node.data;
|
||||||
if (prop.quantityExpected){
|
if (prop.quantityExpected && prop.quantityExpected.value){
|
||||||
prop.spaceLeft = prop.quantityExpected - prop.totalFilled;
|
prop.spaceLeft = prop.quantityExpected.value - prop.totalFilled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,8 @@ import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
|||||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
|
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
|
||||||
import PropertyDescription from '/imports/ui/properties/viewers/shared/PropertyDescription.vue'
|
import PropertyDescription from '/imports/ui/properties/viewers/shared/PropertyDescription.vue'
|
||||||
|
import resolve, { toString } from '/imports/parser/resolve.js';
|
||||||
|
import { prettifyParseError, parse } from '/imports/parser/parser.js';
|
||||||
// import evaluateString from '/imports/api/creature/computation/afterComputation/evaluateString.js';
|
// import evaluateString from '/imports/api/creature/computation/afterComputation/evaluateString.js';
|
||||||
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js'
|
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js'
|
||||||
import Libraries from '/imports/api/library/Libraries.js';
|
import Libraries from '/imports/api/library/Libraries.js';
|
||||||
@@ -291,8 +293,9 @@ export default {
|
|||||||
return CreatureProperties.findOne(this.slotId);
|
return CreatureProperties.findOne(this.slotId);
|
||||||
} else if (this.dummySlot) {
|
} else if (this.dummySlot) {
|
||||||
let model = clone(this.dummySlot)
|
let model = clone(this.dummySlot)
|
||||||
model.quantityExpectedResult = +model.quantityExpected;
|
if (!model.quantityExpected) model.quantityExpected = {};
|
||||||
model.spaceLeft = model.quantityExpectedResult;
|
model.quantityExpected.value = +model.quantityExpected.calculation;
|
||||||
|
model.spaceLeft = model.quantityExpected.value;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -342,7 +345,7 @@ export default {
|
|||||||
return quantitySelected;
|
return quantitySelected;
|
||||||
},
|
},
|
||||||
spaceLeft(){
|
spaceLeft(){
|
||||||
if (this.model.quantityExpectedResult === 0) return undefined;
|
if (!this.model.quantityExpected || this.model.quantityExpected.value === 0) return undefined;
|
||||||
return this.model.spaceLeft - this.totalQuantitySelected;
|
return this.model.spaceLeft - this.totalQuantitySelected;
|
||||||
},
|
},
|
||||||
libraryNames(){
|
libraryNames(){
|
||||||
@@ -360,13 +363,23 @@ export default {
|
|||||||
// the quantity to fill
|
// the quantity to fill
|
||||||
nodes.forEach(node => {
|
nodes.forEach(node => {
|
||||||
if (node.slotFillerCondition){
|
if (node.slotFillerCondition){
|
||||||
let {result} = evaluateString({
|
try {
|
||||||
string: node.slotFillerCondition,
|
let parseNode = parse(node.slotFillerCondition);
|
||||||
scope: this.creature.variables,
|
const {result: resultNode} = resolve('reduce', parseNode, this.creature.variables);
|
||||||
fn: 'reduce',
|
if (resultNode?.parseType === 'constant'){
|
||||||
});
|
if (!resultNode.value){
|
||||||
if (!result.value){
|
node._disabledBySlotFillerCondition = true;
|
||||||
|
disabledNodeCount += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
node._disabledBySlotFillerCondition = true;
|
||||||
|
node._conditionError = toString(resultNode);
|
||||||
|
disabledNodeCount += 1;
|
||||||
|
}
|
||||||
|
} catch (e){
|
||||||
|
let error = prettifyParseError(e);
|
||||||
node._disabledBySlotFillerCondition = true;
|
node._disabledBySlotFillerCondition = true;
|
||||||
|
node._conditionError = error;
|
||||||
disabledNodeCount += 1;
|
disabledNodeCount += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
<h3 class="layout align-center">
|
<h3 class="layout align-center">
|
||||||
{{ slot.name }}
|
{{ slot.name }}
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<span v-if="slot.quantityExpectedResult > 1">
|
<span v-if="slot.quantityExpected && slot.quantityExpected.value > 1">
|
||||||
{{ slot.totalFilled }} / {{ slot.quantityExpectedResult }}
|
{{ slot.totalFilled }} / {{ slot.quantityExpected.value }}
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<v-list v-if="slot.children.length">
|
<v-list v-if="slot.children.length">
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="!slot.quantityExpectedResult || slot.spaceLeft"
|
v-if="!slot.quantityExpected || !slot.quantityExpected.value || slot.spaceLeft"
|
||||||
icon
|
icon
|
||||||
:data-id="`slot-add-button-${slot._id}`"
|
:data-id="`slot-add-button-${slot._id}`"
|
||||||
class="slot-add-button"
|
class="slot-add-button"
|
||||||
@@ -120,8 +120,8 @@ export default {
|
|||||||
'ancestors.id': this.creatureId,
|
'ancestors.id': this.creatureId,
|
||||||
type: 'propertySlot',
|
type: 'propertySlot',
|
||||||
$or: [
|
$or: [
|
||||||
{slotConditionResult: {$nin: [false, 0, '']}},
|
{'slotCondition.value': {$nin: [false, 0, '']}},
|
||||||
{slotConditionResult: {$exists: false}},
|
{'slotCondition.value': {$exists: false}},
|
||||||
],
|
],
|
||||||
removed: {$ne: true},
|
removed: {$ne: true},
|
||||||
inactive: {$ne: true},
|
inactive: {$ne: true},
|
||||||
@@ -130,7 +130,7 @@ export default {
|
|||||||
}).map(slot => {
|
}).map(slot => {
|
||||||
if (
|
if (
|
||||||
!this.showHiddenSlots &&
|
!this.showHiddenSlots &&
|
||||||
slot.quantityExpectedResult === 0 &&
|
(slot.quantityExpected && slot.quantityExpected.value) === 0 &&
|
||||||
slot.hideWhenFull
|
slot.hideWhenFull
|
||||||
){
|
){
|
||||||
slot.children = []
|
slot.children = []
|
||||||
@@ -146,7 +146,7 @@ export default {
|
|||||||
}).filter(slot => !( // Hide full and ignored slots
|
}).filter(slot => !( // Hide full and ignored slots
|
||||||
!this.showHiddenSlots && (
|
!this.showHiddenSlots && (
|
||||||
slot.hideWhenFull &&
|
slot.hideWhenFull &&
|
||||||
slot.quantityExpectedResult > 0 &&
|
(slot.quantityExpected && slot.quantityExpected.value) > 0 &&
|
||||||
slot.spaceLeft <= 0 ||
|
slot.spaceLeft <= 0 ||
|
||||||
slot.ignored
|
slot.ignored
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<markdown-text
|
<markdown-text
|
||||||
v-if="text"
|
v-if="text && model"
|
||||||
:markdown="model.value || model.text"
|
:markdown="model.value || model.text"
|
||||||
/>
|
/>
|
||||||
<property-field
|
<property-field
|
||||||
|
|||||||
Reference in New Issue
Block a user