From 247353f0ed919cf15649a5ae090141b7e789d2b0 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Sat, 16 Oct 2021 19:05:35 +0200 Subject: [PATCH] Small progress on tabletop --- .../computeByType/computeAction.js | 4 +- app/imports/api/properties/Buffs.js | 2 +- .../subSchemas/AttributeConsumedSchema.js | 54 ---------------- .../subSchemas/ItemConsumedSchema.js | 64 ------------------- app/imports/api/tabletop/Tabletops.js | 4 ++ .../api/tabletop/methods/removeTabletop.js | 2 +- .../creature/character/CharacterSheetFab.vue | 2 +- .../AddCreaturePropertyDialog.vue | 10 +-- app/imports/ui/pages/Tabletop.vue | 53 +++++++++------ app/imports/ui/pages/Tabletops.vue | 7 +- .../ui/properties/forms/ActionForm.vue | 2 - .../forms/AttributeConsumedForm.vue | 48 ++++++++------ .../forms/AttributesConsumedListForm.vue | 1 + .../ui/properties/forms/ItemConsumedForm.vue | 48 ++++++++------ .../forms/ItemsConsumedListForm.vue | 1 + .../ui/properties/forms/ResourcesForm.vue | 12 ++-- app/imports/ui/router.js | 2 + .../ui/tabletop/SelectCreaturesDialog.vue | 14 ++-- app/imports/ui/tabletop/TabletopComponent.vue | 38 ++++++----- .../ui/tabletop/TabletopCreatureCard.vue | 17 ++++- .../ui/tabletop/TabletopRightDrawer.vue | 32 ++++++++++ app/imports/ui/tabletop/TabletopToolbar.vue | 9 ++- 22 files changed, 202 insertions(+), 224 deletions(-) delete mode 100644 app/imports/api/properties/subSchemas/AttributeConsumedSchema.js delete mode 100644 app/imports/api/properties/subSchemas/ItemConsumedSchema.js create mode 100644 app/imports/ui/tabletop/TabletopRightDrawer.vue diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeAction.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeAction.js index 70cdae63..c52dec00 100644 --- a/app/imports/api/engine/computation/computeComputation/computeByType/computeAction.js +++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeAction.js @@ -10,13 +10,13 @@ export default function computeAction(computation, node){ if (!prop.resources) return; prop.resources.itemsConsumed.forEach(itemConsumed => { if (!itemConsumed.itemId) return; - if (itemConsumed.available < itemConsumed.quantity.value){ + if (itemConsumed.available < itemConsumed.quantity?.value){ prop.insufficientResources = true; } }); prop.resources.attributesConsumed.forEach(attConsumed => { if (!attConsumed.variableName) return; - if (attConsumed.available < attConsumed.quantity.value){ + if (attConsumed.available < attConsumed.quantity?.value){ prop.insufficientResources = true; } }); diff --git a/app/imports/api/properties/Buffs.js b/app/imports/api/properties/Buffs.js index 2c169972..4fc01a7a 100644 --- a/app/imports/api/properties/Buffs.js +++ b/app/imports/api/properties/Buffs.js @@ -28,7 +28,7 @@ let BuffSchema = createPropertySchema({ 'self', 'target', ], - defaultValue: 'every', + defaultValue: 'target', }, }); diff --git a/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js b/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js deleted file mode 100644 index 9acc8931..00000000 --- a/app/imports/api/properties/subSchemas/AttributeConsumedSchema.js +++ /dev/null @@ -1,54 +0,0 @@ -import SimpleSchema from 'simpl-schema'; -import { Random } from 'meteor/random'; -import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js'; -import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js'; - -const AttributeConsumedSchema = createPropertySchema({ - _id: { - type: String, - regEx: SimpleSchema.RegEx.Id, - autoValue(){ - if (!this.isSet) return Random.id(); - } - }, - variableName: { - type: String, - optional: true, - max: STORAGE_LIMITS.variableName, - }, - quantity: { - type: 'fieldToCompute', - optional: true, - }, -}); - -const ComputedOnlyAttributeConsumedSchema = createPropertySchema({ - quantity: { - type: 'computedOnlyField', - optional: true, - }, - available: { - type: Number, - optional: true, - }, - statId: { - type: String, - regEx: SimpleSchema.RegEx.Id, - optional: true, - }, - statName: { - type: String, - optional: true, - max: STORAGE_LIMITS.name, - }, -}); - -const ComputedAttributeConsumedSchema = new SimpleSchema() - .extend(AttributeConsumedSchema) - .extend(ComputedOnlyAttributeConsumedSchema); - -export { - AttributeConsumedSchema, - ComputedOnlyAttributeConsumedSchema, - ComputedAttributeConsumedSchema -}; diff --git a/app/imports/api/properties/subSchemas/ItemConsumedSchema.js b/app/imports/api/properties/subSchemas/ItemConsumedSchema.js deleted file mode 100644 index 2290649d..00000000 --- a/app/imports/api/properties/subSchemas/ItemConsumedSchema.js +++ /dev/null @@ -1,64 +0,0 @@ -import SimpleSchema from 'simpl-schema'; -import { Random } from 'meteor/random'; -import { storedIconsSchema } from '/imports/api/icons/Icons.js'; -import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js'; -import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js'; - -const ItemConsumedSchema = createPropertySchema({ - _id: { - type: String, - regEx: SimpleSchema.RegEx.Id, - autoValue(){ - if (!this.isSet) return Random.id(); - } - }, - tag: { - type: String, - optional: true, - }, - quantity: { - type: 'fieldToCompute', - optional: true, - }, - itemId: { - type: String, - regEx: SimpleSchema.RegEx.Id, - optional: true, - }, -}); - -const ComputedOnlyItemConsumedSchema = new SimpleSchema({ - available: { - type: Number, - optional: true, - }, - quantity: { - type: 'computedOnlyField', - optional: true, - }, - itemName: { - type: String, - max: STORAGE_LIMITS.name, - optional: true, - }, - itemIcon: { - type: storedIconsSchema, - optional: true, - max: STORAGE_LIMITS.icon, - }, - itemColor: { - type: String, - optional: true, - regEx: /^#([a-f0-9]{3}){1,2}\b$/i, - }, -}); - -const ComputedItemConsumedSchema = new SimpleSchema() - .extend(ItemConsumedSchema) - .extend(ComputedOnlyItemConsumedSchema); - -export { - ItemConsumedSchema, - ComputedOnlyItemConsumedSchema, - ComputedItemConsumedSchema -}; diff --git a/app/imports/api/tabletop/Tabletops.js b/app/imports/api/tabletop/Tabletops.js index 59ad1de9..5c81986c 100644 --- a/app/imports/api/tabletop/Tabletops.js +++ b/app/imports/api/tabletop/Tabletops.js @@ -48,4 +48,8 @@ let TabletopSchema = new SimpleSchema({ Tabletops.attachSchema(TabletopSchema); +import '/imports/api/tabletop/methods/removeTabletop.js'; +import '/imports/api/tabletop/methods/insertTabletop.js'; +import '/imports/api/tabletop/methods/addCreaturesToTabletop.js'; + export default Tabletops; diff --git a/app/imports/api/tabletop/methods/removeTabletop.js b/app/imports/api/tabletop/methods/removeTabletop.js index 8341e73b..633cc6d0 100644 --- a/app/imports/api/tabletop/methods/removeTabletop.js +++ b/app/imports/api/tabletop/methods/removeTabletop.js @@ -4,7 +4,7 @@ import { RateLimiterMixin } from 'ddp-rate-limiter-mixin'; import Tabletops from '../Tabletops.js'; import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js'; import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js'; -import { assertUserIsTabletopOwner } from './shared/tabletopPermissions/js'; +import { assertUserIsTabletopOwner } from './shared/tabletopPermissions.js'; import Creatures from '/imports/api/creature/creatures/Creatures.js'; const removeTabletop = new ValidatedMethod({ diff --git a/app/imports/ui/creature/character/CharacterSheetFab.vue b/app/imports/ui/creature/character/CharacterSheetFab.vue index 13948fca..b9e789b2 100644 --- a/app/imports/ui/creature/character/CharacterSheetFab.vue +++ b/app/imports/ui/creature/character/CharacterSheetFab.vue @@ -130,7 +130,7 @@ return this.speedDialsByTab[tabs[this.tabNumber]]; }, speedDialsByTab() { return { - 'stats': ['attribute', 'skill', 'action', 'attack', 'buff'], + 'stats': ['attribute', 'skill', 'action', 'buff'], 'features': ['feature'], 'inventory': ['item', 'container'], 'spells': ['spellList', 'spell'], diff --git a/app/imports/ui/creature/creatureProperties/AddCreaturePropertyDialog.vue b/app/imports/ui/creature/creatureProperties/AddCreaturePropertyDialog.vue index 14f8715f..9ca7838a 100644 --- a/app/imports/ui/creature/creatureProperties/AddCreaturePropertyDialog.vue +++ b/app/imports/ui/creature/creatureProperties/AddCreaturePropertyDialog.vue @@ -17,7 +17,7 @@ @change="propertyHelpChanged" /> -
-
- -
- -
+ + + + + + + + -

This tabletop was not found

-

Either it does not exist, or you do not have permission to view it

-
-
+ +

This tabletop was not found

+

Either it does not exist, or you do not have permission to view it

+
+ + diff --git a/app/imports/ui/tabletop/TabletopRightDrawer.vue b/app/imports/ui/tabletop/TabletopRightDrawer.vue new file mode 100644 index 00000000..9d5fc55f --- /dev/null +++ b/app/imports/ui/tabletop/TabletopRightDrawer.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/app/imports/ui/tabletop/TabletopToolbar.vue b/app/imports/ui/tabletop/TabletopToolbar.vue index 6d735619..6c0d0af3 100644 --- a/app/imports/ui/tabletop/TabletopToolbar.vue +++ b/app/imports/ui/tabletop/TabletopToolbar.vue @@ -1,16 +1,18 @@