Progress on action choices

This commit is contained in:
Thaum Rystra
2024-03-30 21:12:35 +02:00
parent 6c3d4b91eb
commit 6138be8083
33 changed files with 210 additions and 55 deletions

View File

@@ -1,7 +1,8 @@
import { EngineAction } from '/imports/api/engine/action/EngineActions';
import { getSingleProperty } from '/imports/api/engine/loadCreatures';
import applyTask from '/imports/api/engine/action/tasks/applyTask'
import InputProvider from '/imports/api/engine/action/functions/InputProvider';
import InputProvider from '/imports/api/engine/action/functions/userInput/InputProvider';
import saveInputChoices from './userInput/saveInputChoices';
// TODO create a function to get the effective value of a property,
// simulating all the result updates in the action so far
@@ -17,6 +18,16 @@ export default async function applyAction(action: EngineAction, userInput: Input
if (!simulate && stepThrough) throw 'Cannot step through unless simulating';
if (simulate && !userInput) throw 'Must provide a function to get user input when simulating';
if (action._isSimulation || action._stepThrough) {
console.error('_isSimulation and _stepThrough should not be set on the action, rather call\
applyAction with the appropriate options');
}
// If we are simulating, save the user input choices
if (simulate) {
userInput = saveInputChoices(action, userInput);
}
action._stepThrough = stepThrough;
action._isSimulation = simulate;
action.taskCount = 0;