Tabletop targeted actions now work

This commit is contained in:
Stefan Zermatten
2023-01-15 14:18:17 +02:00
parent 25e6b19b49
commit ceb170cbcf
9 changed files with 188 additions and 201 deletions

View File

@@ -28,20 +28,22 @@
:model="creature"
:active="activeCreatureId === creature._id"
:targeted="targets.includes(creature._id)"
:show-target-btn="!!activeActionId"
@click="() => {
if (activeActionId) {
if (targets.includes(creature._id)) {
untarget(creature._id)
:show-target-btn="targets.includes(creature._id) || moreTargets"
v-on="(!activeActionId || (targets.includes(creature._id) || moreTargets)) ? {
click: () => {
if (activeActionId) {
if (targets.includes(creature._id)) {
untarget(creature._id)
} else {
if (moreTargets) targets.push(creature._id);
}
} else {
targets.push(creature._id);
activeCreatureId = creature._id;
targets = [];
activeActionId = undefined;
}
} else {
activeCreatureId = creature._id;
targets = [];
activeActionId = undefined;
}
}"
} : {}"
@target="targets.push(creature._id)"
@untarget="untarget(creature._id)"
/>
@@ -95,6 +97,7 @@
:key="action._id"
:model="action"
:active="activeActionId === action._id"
:targets="targets"
@activate="activeActionId = action._id"
@deactivate="activeActionId = undefined; targets = [];"
/>
@@ -157,6 +160,11 @@ export default {
targets: [],
}
},
watch: {
activeCreatureId(id) {
this.$root.$emit('active-tabletop-character-change', id);
}
},
meteor: {
$subscribe: {
'tabletop'() {
@@ -169,6 +177,15 @@ export default {
actions(){
return getProperties(this.activeCreatureId, { type: 'action', actionType: { $ne: 'event'} });
},
moreTargets(){
const activeAction = CreatureProperties.findOne(this.activeActionId);
if (!activeAction) return;
if (activeAction.target === 'singleTarget') {
return this.targets.length === 0;
} else if (activeAction.target === 'multipleTargets') {
return true;
}
},
editPermission(){
try {
assertEditPermission(this.activeCreatureId, Meteor.userId());