Class levels can now have conditions
This commit is contained in:
@@ -23,6 +23,11 @@ let ClassLevelSchema = new SimpleSchema({
|
||||
'nextLevelTags.$': {
|
||||
type: String,
|
||||
},
|
||||
// Same as in SlotFillers.js
|
||||
slotFillerCondition: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export { ClassLevelSchema };
|
||||
|
||||
@@ -179,17 +179,18 @@ export default {
|
||||
// Filter out slotFillers whose condition isn't met or are too big to fit
|
||||
// the quantity to fill
|
||||
nodes = nodes.filter(node => {
|
||||
if (node.type === 'slotFiller'){
|
||||
if (node.slotFillerCondition){
|
||||
let context = new CompilationContext();
|
||||
let conditionResult = parse(node.slotFillerCondition)
|
||||
.reduce(this.creature.variables, context);
|
||||
if (conditionResult && !conditionResult.value) return false;
|
||||
}
|
||||
console.log({numToFill: this.numToFill, node});
|
||||
if (this.numToFill > 0 && node.slotQuantityFilled > this.numToFill){
|
||||
return false;
|
||||
}
|
||||
if (node.slotFillerCondition){
|
||||
let context = new CompilationContext();
|
||||
let conditionResult = parse(node.slotFillerCondition)
|
||||
.reduce(this.creature.variables, context);
|
||||
if (conditionResult && !conditionResult.value) return false;
|
||||
}
|
||||
if (
|
||||
node.type === 'slotFiller' &&
|
||||
this.numToFill > 0 &&
|
||||
node.slotQuantityFilled > this.numToFill
|
||||
){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
@change="change('variableName', ...arguments)"
|
||||
/>
|
||||
</div>
|
||||
<text-field
|
||||
label="Condition"
|
||||
hint="A caclulation to determine if this can be added to the character"
|
||||
placeholder="Always active"
|
||||
:value="model.slotFillerCondition"
|
||||
:error-messages="errors.slotFillerCondition"
|
||||
@change="change('slotFillerCondition', ...arguments)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user