Actions targeting other creatures now works on both tabletop and character sheet

This commit is contained in:
ThaumRystra
2024-06-12 20:50:18 +02:00
parent 621f284cff
commit 6742b4bc00
8 changed files with 83 additions and 39 deletions

View File

@@ -11,7 +11,7 @@ export interface EngineAction {
_decisions?: any[],
creatureId: string;
rootPropId?: string;
tabletopId: string;
tabletopId?: string;
targetIds?: string[];
results: TaskResult[];
taskCount: number;

View File

@@ -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 = {