Fixed spell casting

This commit is contained in:
ThaumRystra
2025-01-25 14:29:26 +02:00
parent 0b499b9c98
commit 4993506ec9
25 changed files with 628 additions and 168 deletions

View File

@@ -35,10 +35,6 @@ type InputProvider = {
* Get the details of a check or save
*/
check(suggestedParams: CheckParams): Promise<CheckParams>;
/**
* Get the details of casting a spell
*/
castSpell(suggestedParams: Partial<CastSpellParams>): Promise<CastSpellParams>;
}
export type Advantage = 0 | 1 | -1;
@@ -53,10 +49,4 @@ export type CheckParams = {
targetAbilityVariableName?: string;
}
export type CastSpellParams = {
spellId: string,
slotId: string | undefined,
ritual: boolean,
}
export default InputProvider;

View File

@@ -28,9 +28,6 @@ export default function getReplayChoicesInputProvider(actionId: string, decision
check() {
return Promise.resolve(decisionStack.pop());
},
castSpell() {
return Promise.resolve(decisionStack.pop());
},
}
return replaySavedInput;
}

View File

@@ -1,4 +1,4 @@
import InputProvider, { CastSpellParams } from '/imports/api/engine/action/functions/userInput/InputProvider';
import InputProvider from '/imports/api/engine/action/functions/userInput/InputProvider';
const inputProviderForTests: InputProvider = {
async targetIds(target, currentTargetIds = []) {
@@ -42,9 +42,6 @@ const inputProviderForTests: InputProvider = {
async check(suggestedParams) {
return suggestedParams;
},
async castSpell(suggestedParams) {
return suggestedParams as CastSpellParams;
},
}
export const critInputProvider: InputProvider = {

View File

@@ -13,8 +13,10 @@ export default function saveInputChoices(action: EngineAction, userInput: InputP
}
// For every function in the given input provider
for (const key in userInput) {
let key: keyof InputProvider;
for (key in userInput) {
const oldFn = userInput[key];
if (!oldFn) continue;
// Make a new function that does the same thing, but saves the result to action._decisions
const newFn = async (...args) => {
const result = await oldFn(...args);