Actions targeting other creatures now works on both tabletop and character sheet
This commit is contained in:
@@ -11,7 +11,7 @@ export interface EngineAction {
|
||||
_decisions?: any[],
|
||||
creatureId: string;
|
||||
rootPropId?: string;
|
||||
tabletopId: string;
|
||||
tabletopId?: string;
|
||||
targetIds?: string[];
|
||||
results: TaskResult[];
|
||||
taskCount: number;
|
||||
|
||||
@@ -40,20 +40,20 @@ export default async function applyAction(action: EngineAction, userInput: Input
|
||||
action._isSimulation = simulate;
|
||||
action.taskCount = 0;
|
||||
let task = options?.task;
|
||||
console.log('task', task, action.targetIds)
|
||||
if (!task) {
|
||||
const prop = await getSingleProperty(action.creatureId, action.rootPropId);
|
||||
if (!prop) throw new Meteor.Error('Not found', 'Root action property could not be found');
|
||||
|
||||
// If the target ids weren't already set, get them from the user
|
||||
console.log(action.targetIds, prop);
|
||||
if (!action.targetIds && (
|
||||
prop.target === 'singleTarget' ||
|
||||
prop.target === 'multipleTargets'
|
||||
)) {
|
||||
console.log('getting targetIds');
|
||||
action.targetIds = await (userInput.targetIds(prop.targets));
|
||||
console.log('got targetIds', action.targetIds);
|
||||
if (
|
||||
!action.targetIds
|
||||
&& action.tabletopId
|
||||
&& (
|
||||
prop.target === 'singleTarget' ||
|
||||
prop.target === 'multipleTargets'
|
||||
)
|
||||
) {
|
||||
action.targetIds = await (userInput.targetIds(prop.target));
|
||||
}
|
||||
|
||||
task = {
|
||||
|
||||
@@ -206,7 +206,6 @@ export default {
|
||||
},
|
||||
// inputProvider methods
|
||||
async targetIds(target) {
|
||||
console.log('input provider UI targetIds')
|
||||
this.userInput = [];
|
||||
this.activeInputParams = {
|
||||
target,
|
||||
|
||||
@@ -1,13 +1,41 @@
|
||||
<template>
|
||||
<div class="choice-input">
|
||||
<creature-list-tile
|
||||
<v-list-item
|
||||
v-for="creature in creatures"
|
||||
:key="creature._id"
|
||||
:model="creature"
|
||||
selection
|
||||
:selected="value.includes(creature._id)"
|
||||
:class="{
|
||||
'primary--text v-list-item--active': value.includes(creature._id),
|
||||
}"
|
||||
dense
|
||||
@click="selectCreature(creature._id)"
|
||||
/>
|
||||
>
|
||||
<v-list-item-avatar
|
||||
:color="value.includes(creature._id) ? 'red darken-1' : creature.color || 'grey'"
|
||||
class="white--text"
|
||||
style="transition: background 0.3s;"
|
||||
>
|
||||
<v-fade-transition leave-absolute>
|
||||
<v-icon v-if="value.includes(creature._id)">
|
||||
mdi-check
|
||||
</v-icon>
|
||||
<img
|
||||
v-else-if="creature.avatarPicture"
|
||||
:src="creature.avatarPicture"
|
||||
:alt="creature.name"
|
||||
>
|
||||
<template v-else>
|
||||
<span>
|
||||
{{ creature.initial }}
|
||||
</span>
|
||||
</template>
|
||||
</v-fade-transition>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
{{ creature.name }}
|
||||
</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-btn
|
||||
@click="$emit('continue');"
|
||||
>
|
||||
@@ -17,13 +45,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import CreatureListTile from '/imports/client/ui/creature/creatureList/CreatureListTile.vue';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CreatureListTile
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
|
||||
@@ -217,6 +217,9 @@ export default {
|
||||
'singleCharacter'() {
|
||||
return [this.creatureId];
|
||||
},
|
||||
'otherTabletopCreatures'() {
|
||||
return [this.creatureId];
|
||||
},
|
||||
},
|
||||
creature() {
|
||||
return Creatures.findOne(this.creatureId, {
|
||||
|
||||
@@ -159,7 +159,10 @@ export default {
|
||||
watch: {
|
||||
activeCreatureId(id) {
|
||||
this.$root.$emit('active-tabletop-character-change', id);
|
||||
}
|
||||
},
|
||||
activeActionId(id) {
|
||||
this.targets = [];
|
||||
},
|
||||
},
|
||||
meteor: {
|
||||
creatures(){
|
||||
@@ -170,7 +173,6 @@ export default {
|
||||
},
|
||||
moreTargets(){
|
||||
const activeAction = CreatureProperties.findOne(this.activeActionId);
|
||||
console.log(this.activeActionId, activeAction)
|
||||
if (!activeAction) return;
|
||||
if (activeAction.target === 'singleTarget') {
|
||||
return this.targets.length === 0;
|
||||
|
||||
@@ -78,22 +78,6 @@ Meteor.publish('singleCharacter', function (creatureId) {
|
||||
username: 1,
|
||||
},
|
||||
}),
|
||||
// Also publish summaries of creatures in the same tabletop
|
||||
Creatures.find({
|
||||
tabletopId: permissionCreature?.tabletopId,
|
||||
}, {
|
||||
fields: {
|
||||
_id: 1,
|
||||
name: 1,
|
||||
picture: 1,
|
||||
avatarPicture: 1,
|
||||
tabletopId: 1,
|
||||
initiativeRoll: 1,
|
||||
settings: 1,
|
||||
propCount: 1,
|
||||
},
|
||||
limit: 110, // Party vs 100 creatures was a fun encounter to run, so let's support that
|
||||
}),
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import CreatureLogs from '/imports/api/creature/log/CreatureLogs';
|
||||
import CreatureVariables from '/imports/api/creature/creatures/CreatureVariables';
|
||||
import { loadCreature } from '/imports/api/engine/loadCreatures';
|
||||
import EngineActions from '/imports/api/engine/action/EngineActions';
|
||||
import { assertViewPermission } from '/imports/api/creature/creatures/creaturePermissions';
|
||||
|
||||
Meteor.publish('tabletops', function () {
|
||||
var userId = this.userId;
|
||||
@@ -39,7 +40,38 @@ Meteor.publish('tabletopUsers', function (tabletopId) {
|
||||
},
|
||||
limit: 500,
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
Meteor.publish('otherTabletopCreatures', function (creatureId) {
|
||||
const permissionCreature = Creatures.findOne({
|
||||
_id: creatureId,
|
||||
}, {
|
||||
fields: {
|
||||
owner: 1,
|
||||
readers: 1,
|
||||
writers: 1,
|
||||
public: 1,
|
||||
computeVersion: 1,
|
||||
tabletopId: 1,
|
||||
}
|
||||
});
|
||||
assertViewPermission(creatureId, this.userId);
|
||||
return Creatures.find({
|
||||
tabletopId: permissionCreature?.tabletopId,
|
||||
}, {
|
||||
fields: {
|
||||
_id: 1,
|
||||
name: 1,
|
||||
picture: 1,
|
||||
avatarPicture: 1,
|
||||
tabletopId: 1,
|
||||
initiativeRoll: 1,
|
||||
settings: 1,
|
||||
propCount: 1,
|
||||
},
|
||||
limit: 110, // Party vs 100 creatures was a fun encounter to run, so let's support that
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('tabletop', function (tabletopId) {
|
||||
var userId = this.userId;
|
||||
|
||||
Reference in New Issue
Block a user