began work to get inactive state of properties denormalised
This commit is contained in:
@@ -44,7 +44,13 @@ let CreaturePropertySchema = new SimpleSchema({
|
||||
icon: {
|
||||
type: storedIconsSchema,
|
||||
optional: true,
|
||||
}
|
||||
},
|
||||
// Denormalised flag if this property is inactive on the sheet for any reason
|
||||
// Including being disabled, or a decendent of a disabled property
|
||||
inactive: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let key in propertySchemasIndex){
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function computeToggle(toggle, memo){
|
||||
toggle.toggleResult = !!+toggle.condition;
|
||||
} else {
|
||||
let {value, errors} = evaluateCalculation(toggle.condition, memo);
|
||||
toggle.toggleResult = value;
|
||||
toggle.toggleResult = !!value;
|
||||
if (errors.length){
|
||||
toggle.errors = errors;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||
import ComputationMemo from '/imports/api/creature/computation/ComputationMemo.js';
|
||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||
import computeMemo from '/imports/api/creature/computation/computeMemo.js';
|
||||
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||
import writeAlteredProperties from '/imports/api/creature/computation/writeAlteredProperties.js';
|
||||
import writeCreatureVariables from '/imports/api/creature/computation/writeCreatureVariables.js';
|
||||
import { recomputeDamageMultipliersById } from '/imports/api/creature/damageMultiplierDenormalise/recomputeDamageMultipliers.js';
|
||||
import { recomputeDamageMultipliersById } from '/imports/api/creature/denormalise/recomputeDamageMultipliers.js';
|
||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
|
||||
export const recomputeCreature = new ValidatedMethod({
|
||||
@@ -95,12 +97,18 @@ export function recomputeCreatureById(creatureId){
|
||||
*/
|
||||
export function recomputeCreatureByDoc(creature){
|
||||
const creatureId = creature._id;
|
||||
let props = getActiveProperties({
|
||||
recomputeInactiveProperties(creatureId);
|
||||
let props = CreatureProperties.find({
|
||||
'ancestors.id': creatureId,
|
||||
inactive: {$ne: true},
|
||||
type: {$in: calculationPropertyTypes},
|
||||
}).fetch();
|
||||
/*getActiveProperties({
|
||||
ancestorId: creatureId,
|
||||
filter: {type: {$in: calculationPropertyTypes}},
|
||||
includeUntoggled: true,
|
||||
// TODO filter out expensive fields, particularly icon field
|
||||
});
|
||||
});*/
|
||||
let computationMemo = new ComputationMemo(props, creature);
|
||||
computeMemo(computationMemo);
|
||||
writeAlteredProperties(computationMemo);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||
|
||||
export default function recomputeInactiveProperties(ancestorId){
|
||||
let disabledFilter = {
|
||||
'ancestors.id': ancestorId,
|
||||
$or: [
|
||||
{disabled: true}, // Everything can be disabled
|
||||
{type: 'buff', applied: false}, // Buffs can be applied
|
||||
{type: 'item', equipped: {$ne: true}},
|
||||
{type: 'toggle', toggleResult: false},
|
||||
{type: 'spell', prepared: {$ne: true}, alwaysPrepared: {$ne: true}},
|
||||
],
|
||||
};
|
||||
let disabledIds = CreatureProperties.find(disabledFilter, {
|
||||
fields: {_id: 1},
|
||||
}).map(prop => prop._id);
|
||||
|
||||
// Set all the properties inactive that aren't already inactive but should be
|
||||
CreatureProperties.update({
|
||||
'ancestors.id': ancestorId,
|
||||
$or: [{
|
||||
'_id': {$in: disabledIds}
|
||||
}, {
|
||||
'ancestors.id': {$in: disabledIds}
|
||||
}],
|
||||
inactive: {$ne: true},
|
||||
}, {
|
||||
$set: {inactive: true},
|
||||
}, {
|
||||
multi: true,
|
||||
selector: {type: 'any'},
|
||||
});
|
||||
// Remove inactive from all the properties that are inactive but shouldn't be
|
||||
CreatureProperties.update({
|
||||
'ancestors.id': {$eq: ancestorId, $nin: disabledIds},
|
||||
'_id': {$nin: disabledIds},
|
||||
inactive: true,
|
||||
}, {
|
||||
$unset: {inactive: 1},
|
||||
}, {
|
||||
multi: true,
|
||||
selector: {type: 'any'},
|
||||
});
|
||||
}
|
||||
@@ -25,7 +25,7 @@ const ToggleSchema = new SimpleSchema({
|
||||
const ComputedOnlyToggleSchema = new SimpleSchema({
|
||||
// The computed result of the effect
|
||||
toggleResult: {
|
||||
type: SimpleSchema.oneOf(Number, String, Boolean),
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
// The errors encountered while computing the result
|
||||
|
||||
@@ -34,7 +34,7 @@ Meteor.publish('slotFillers', function(slotId){
|
||||
let filter = {
|
||||
'ancestors.id': {$in: libraryIds},
|
||||
};
|
||||
if (slot.slotTags.length){
|
||||
if (slot.slotTags && slot.slotTags.length){
|
||||
filter.tags = {$all: slot.slotTags};
|
||||
}
|
||||
if (slot.slotType){
|
||||
|
||||
39
app/imports/ui/creature/slots/SlotDetailsDialog.vue
Normal file
39
app/imports/ui/creature/slots/SlotDetailsDialog.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<template lang="html">
|
||||
<dialog-base>
|
||||
<v-toolbar-title slot="toolbar">
|
||||
Slots
|
||||
</v-toolbar-title>
|
||||
<slots creature-id="creatureId" />
|
||||
</dialog-base>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
import Slots from '/imports/ui/creature/slots/Slots.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DialogBase,
|
||||
Slots,
|
||||
},
|
||||
props: {
|
||||
creatureId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
reactiveProvide: {
|
||||
name: 'context',
|
||||
include: ['creature'],
|
||||
},
|
||||
meteor: {
|
||||
creature(){
|
||||
return Creatures.findOne(this.creatureId);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="library-nodes">
|
||||
<v-fade-transition mode="out-in">
|
||||
<column-layout
|
||||
v-if="$subReady.slotFillers && libraryNodes.length"
|
||||
v-if="$subReady.slotFillers && libraryNodes && libraryNodes.length"
|
||||
wide-columns
|
||||
>
|
||||
<div
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
},
|
||||
libraryNodes(){
|
||||
let filter = {};
|
||||
if (this.model.slotTags.length){
|
||||
if (this.model.slotTags && this.model.slotTags.length){
|
||||
filter.tags = {$all: this.model.slotTags};
|
||||
}
|
||||
if (this.model.slotType){
|
||||
|
||||
Reference in New Issue
Block a user