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[],
|
_decisions?: any[],
|
||||||
creatureId: string;
|
creatureId: string;
|
||||||
rootPropId?: string;
|
rootPropId?: string;
|
||||||
tabletopId: string;
|
tabletopId?: string;
|
||||||
targetIds?: string[];
|
targetIds?: string[];
|
||||||
results: TaskResult[];
|
results: TaskResult[];
|
||||||
taskCount: number;
|
taskCount: number;
|
||||||
|
|||||||
@@ -40,20 +40,20 @@ export default async function applyAction(action: EngineAction, userInput: Input
|
|||||||
action._isSimulation = simulate;
|
action._isSimulation = simulate;
|
||||||
action.taskCount = 0;
|
action.taskCount = 0;
|
||||||
let task = options?.task;
|
let task = options?.task;
|
||||||
console.log('task', task, action.targetIds)
|
|
||||||
if (!task) {
|
if (!task) {
|
||||||
const prop = await getSingleProperty(action.creatureId, action.rootPropId);
|
const prop = await getSingleProperty(action.creatureId, action.rootPropId);
|
||||||
if (!prop) throw new Meteor.Error('Not found', 'Root action property could not be found');
|
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
|
// If the target ids weren't already set, get them from the user
|
||||||
console.log(action.targetIds, prop);
|
if (
|
||||||
if (!action.targetIds && (
|
!action.targetIds
|
||||||
prop.target === 'singleTarget' ||
|
&& action.tabletopId
|
||||||
prop.target === 'multipleTargets'
|
&& (
|
||||||
)) {
|
prop.target === 'singleTarget' ||
|
||||||
console.log('getting targetIds');
|
prop.target === 'multipleTargets'
|
||||||
action.targetIds = await (userInput.targetIds(prop.targets));
|
)
|
||||||
console.log('got targetIds', action.targetIds);
|
) {
|
||||||
|
action.targetIds = await (userInput.targetIds(prop.target));
|
||||||
}
|
}
|
||||||
|
|
||||||
task = {
|
task = {
|
||||||
|
|||||||
@@ -206,7 +206,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// inputProvider methods
|
// inputProvider methods
|
||||||
async targetIds(target) {
|
async targetIds(target) {
|
||||||
console.log('input provider UI targetIds')
|
|
||||||
this.userInput = [];
|
this.userInput = [];
|
||||||
this.activeInputParams = {
|
this.activeInputParams = {
|
||||||
target,
|
target,
|
||||||
|
|||||||
@@ -1,13 +1,41 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="choice-input">
|
<div class="choice-input">
|
||||||
<creature-list-tile
|
<v-list-item
|
||||||
v-for="creature in creatures"
|
v-for="creature in creatures"
|
||||||
:key="creature._id"
|
:key="creature._id"
|
||||||
:model="creature"
|
:class="{
|
||||||
selection
|
'primary--text v-list-item--active': value.includes(creature._id),
|
||||||
:selected="value.includes(creature._id)"
|
}"
|
||||||
|
dense
|
||||||
@click="selectCreature(creature._id)"
|
@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
|
<v-btn
|
||||||
@click="$emit('continue');"
|
@click="$emit('continue');"
|
||||||
>
|
>
|
||||||
@@ -17,13 +45,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import CreatureListTile from '/imports/client/ui/creature/creatureList/CreatureListTile.vue';
|
|
||||||
import Creatures from '/imports/api/creature/creatures/Creatures';
|
import Creatures from '/imports/api/creature/creatures/Creatures';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
|
||||||
CreatureListTile
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ export default {
|
|||||||
'singleCharacter'() {
|
'singleCharacter'() {
|
||||||
return [this.creatureId];
|
return [this.creatureId];
|
||||||
},
|
},
|
||||||
|
'otherTabletopCreatures'() {
|
||||||
|
return [this.creatureId];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
creature() {
|
creature() {
|
||||||
return Creatures.findOne(this.creatureId, {
|
return Creatures.findOne(this.creatureId, {
|
||||||
|
|||||||
@@ -159,7 +159,10 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
activeCreatureId(id) {
|
activeCreatureId(id) {
|
||||||
this.$root.$emit('active-tabletop-character-change', id);
|
this.$root.$emit('active-tabletop-character-change', id);
|
||||||
}
|
},
|
||||||
|
activeActionId(id) {
|
||||||
|
this.targets = [];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
creatures(){
|
creatures(){
|
||||||
@@ -170,7 +173,6 @@ export default {
|
|||||||
},
|
},
|
||||||
moreTargets(){
|
moreTargets(){
|
||||||
const activeAction = CreatureProperties.findOne(this.activeActionId);
|
const activeAction = CreatureProperties.findOne(this.activeActionId);
|
||||||
console.log(this.activeActionId, activeAction)
|
|
||||||
if (!activeAction) return;
|
if (!activeAction) return;
|
||||||
if (activeAction.target === 'singleTarget') {
|
if (activeAction.target === 'singleTarget') {
|
||||||
return this.targets.length === 0;
|
return this.targets.length === 0;
|
||||||
|
|||||||
@@ -78,22 +78,6 @@ Meteor.publish('singleCharacter', function (creatureId) {
|
|||||||
username: 1,
|
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 CreatureVariables from '/imports/api/creature/creatures/CreatureVariables';
|
||||||
import { loadCreature } from '/imports/api/engine/loadCreatures';
|
import { loadCreature } from '/imports/api/engine/loadCreatures';
|
||||||
import EngineActions from '/imports/api/engine/action/EngineActions';
|
import EngineActions from '/imports/api/engine/action/EngineActions';
|
||||||
|
import { assertViewPermission } from '/imports/api/creature/creatures/creaturePermissions';
|
||||||
|
|
||||||
Meteor.publish('tabletops', function () {
|
Meteor.publish('tabletops', function () {
|
||||||
var userId = this.userId;
|
var userId = this.userId;
|
||||||
@@ -39,7 +40,38 @@ Meteor.publish('tabletopUsers', function (tabletopId) {
|
|||||||
},
|
},
|
||||||
limit: 500,
|
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) {
|
Meteor.publish('tabletop', function (tabletopId) {
|
||||||
var userId = this.userId;
|
var userId = this.userId;
|
||||||
|
|||||||
Reference in New Issue
Block a user