From afb76f6ac4ba0f6232c40f922c1aca13a2a96e8f Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Fri, 15 Apr 2022 22:36:20 +0200 Subject: [PATCH] Iterated on tabletop --- .../applyPropertyByType/applyDamage.js | 1 - .../components/actions/ActionCard.vue | 37 +++++++++++++++---- app/imports/ui/tabletop/TabletopComponent.vue | 13 ++++++- .../ui/tabletop/TabletopCreatureCard.vue | 12 +++++- app/imports/ui/tabletop/TabletopMap.vue | 1 + 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js b/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js index 0978d07a..6be9e28d 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js @@ -104,7 +104,6 @@ export default function applyDamage(node, { log: { creatureId: target._id, content: [{ - name, value: `Recieved **${damageDealt}** ${suffix}`, }], } diff --git a/app/imports/ui/properties/components/actions/ActionCard.vue b/app/imports/ui/properties/components/actions/ActionCard.vue index be20ce44..01503d28 100644 --- a/app/imports/ui/properties/components/actions/ActionCard.vue +++ b/app/imports/ui/properties/components/actions/ActionCard.vue @@ -13,7 +13,7 @@ class="mr-2" :color="model.color || 'primary'" :loading="doActionLoading" - :disabled="model.insufficientResources || !context.editPermission" + :disabled="model.insufficientResources || !context.editPermission || !!targetingError" :roll-text="rollBonus" :name="model.name" :advantage="model.attackRoll && model.attackRoll.advantage" @@ -35,7 +35,7 @@ class="mr-2" :color="model.color || 'primary'" :loading="doActionLoading" - :disabled="model.insufficientResources || !context.editPermission" + :disabled="model.insufficientResources || !context.editPermission || !!targetingError" @click.stop="doAction" >
-
- {{ model.actionType }} -
-
- {{ model.usesLeft }} uses +
+ {{ targetingError }}
+
@@ -134,6 +142,10 @@ export default { type: Object, required: true, }, + targets: { + type: Array, + default: undefined, + }, }, data(){return { activated: undefined, @@ -163,6 +175,16 @@ export default { actionTypeIcon() { return `$vuetify.icons.${this.model.actionType}`; }, + targetingError(){ + // Can always do an action without a target + if (!this.targets || !this.targets.length) return undefined; + if (this.targets.length > 1 && this.model.target !== 'multipleTargets'){ + return 'Single target'; + } else if (this.model.target === 'self' && this.targets[0] !== this.model.ancestors[0]._id){ + return 'Can only target self'; + } + return undefined; + } }, methods: { click(e){ @@ -173,6 +195,7 @@ export default { this.shwing(); doAction.call({ actionId: this.model._id, + targetIds: this.targets, scope: { $attackAdvantage: advantage, } diff --git a/app/imports/ui/tabletop/TabletopComponent.vue b/app/imports/ui/tabletop/TabletopComponent.vue index a45f65a9..3892126b 100644 --- a/app/imports/ui/tabletop/TabletopComponent.vue +++ b/app/imports/ui/tabletop/TabletopComponent.vue @@ -14,7 +14,10 @@ :key="creature._id" :model="creature" :active="activeCreature === creature._id" - @click="activeCreature = creature._id" + :targeted="targets.includes(creature._id)" + @click="activeCreature = creature._id; targets = []" + @target="targets.push(creature._id)" + @untarget="untarget(creature._id)" />
@@ -114,6 +118,7 @@ export default { }, data(){ return { activeCreature: undefined, + targets: [], }}, meteor: { $subscribe:{ @@ -180,6 +185,12 @@ export default { } event.currentTarget.scrollLeft += event.deltaY + event.deltaX; event.preventDefault(); + }, + untarget(id){ + const index = this.targets.indexOf(id); + if (index > -1) { + this.targets.splice(index, 1); + } } } } diff --git a/app/imports/ui/tabletop/TabletopCreatureCard.vue b/app/imports/ui/tabletop/TabletopCreatureCard.vue index 1cb51cf5..a36c598f 100644 --- a/app/imports/ui/tabletop/TabletopCreatureCard.vue +++ b/app/imports/ui/tabletop/TabletopCreatureCard.vue @@ -1,7 +1,7 @@ @@ -33,6 +42,7 @@ export default { required: true, }, active: Boolean, + targeted: Boolean, }, data(){return { hover: false, diff --git a/app/imports/ui/tabletop/TabletopMap.vue b/app/imports/ui/tabletop/TabletopMap.vue index 605da292..17870705 100644 --- a/app/imports/ui/tabletop/TabletopMap.vue +++ b/app/imports/ui/tabletop/TabletopMap.vue @@ -3,6 +3,7 @@