Fixed regression in applying buffs

This commit is contained in:
ThaumRystra
2024-12-01 22:10:53 +02:00
parent 75fe3e8fe2
commit e76ad64a7d
2 changed files with 9 additions and 13 deletions

View File

@@ -28,7 +28,7 @@ export default async function applyBuffProperty(
// Log the buff and return if there are no targets // Log the buff and return if there are no targets
if (!targetIds.length) { if (!targetIds.length) {
logBuff(prop, targetIds, action, userInput, result); await logBuff(prop, targetIds, action, userInput, result);
await applyAfterTasksSkipChildren(action, prop, targetIds, userInput); await applyAfterTasksSkipChildren(action, prop, targetIds, userInput);
return; return;
} }
@@ -39,12 +39,12 @@ export default async function applyBuffProperty(
...getPropertyDescendants(action.creatureId, prop._id), ...getPropertyDescendants(action.creatureId, prop._id),
]; ];
// Crystalize the variables // Crystallize the variables
if (!prop.skipCrystalization) { if (!prop.skipCrystalization) {
await crystalizeVariables(action, propList, task, result); await crystallizeVariables(action, propList, task, result);
} }
targetIds.forEach(target => { for (const target of targetIds) {
// Create a per-target mutation // Create a per-target mutation
const mutation: Mutation = { targetIds: [target], contents: [] }; const mutation: Mutation = { targetIds: [target], contents: [] };
@@ -62,7 +62,7 @@ export default async function applyBuffProperty(
}); });
//Log the buff //Log the buff
logBuff(prop, targetIds, action, userInput, result); await logBuff(prop, targetIds, action, userInput, result);
// remove all the computed fields // remove all the computed fields
targetPropList = cleanProps(targetPropList); targetPropList = cleanProps(targetPropList);
@@ -72,7 +72,7 @@ export default async function applyBuffProperty(
// Add the mutation to the results // Add the mutation to the results
result.mutations.push(mutation); result.mutations.push(mutation);
}); }
await applyAfterTasksSkipChildren(action, prop, targetIds, userInput); await applyAfterTasksSkipChildren(action, prop, targetIds, userInput);
} }
@@ -94,16 +94,12 @@ async function logBuff(prop, targetIds, action, userInput, result) {
* Replaces all variables with their resolved values * Replaces all variables with their resolved values
* except variables of the form `~target.thing.total` become `thing.total` * except variables of the form `~target.thing.total` become `thing.total`
*/ */
async function crystalizeVariables( async function crystallizeVariables(
action: EngineAction, propList: any[], task: PropTask, result: TaskResult action: EngineAction, propList: any[], task: PropTask, result: TaskResult
) { ) {
const scope = await getEffectiveActionScope(action); const scope = await getEffectiveActionScope(action);
for (const prop of propList) { for (const prop of propList) {
if (prop._skipCrystalize) { // Iterate through all the calculations and crystallize them
delete prop._skipCrystalize;
return;
}
// Iterate through all the calculations and crystalize them
for (const calcKey of computedSchemas[prop.type].computedFields()) { for (const calcKey of computedSchemas[prop.type].computedFields()) {
await applyFnToKeyAsync(prop, calcKey, async (prop, key) => { await applyFnToKeyAsync(prop, calcKey, async (prop, key) => {
const calcObj = get(prop, key); const calcObj = get(prop, key);

View File

@@ -30,7 +30,7 @@ const actionTestCreature = {
], ],
} }
describe.only('Built in dice functions', function () { describe('Built in dice functions', function () {
// Increase timeout // Increase timeout
this.timeout(8000); this.timeout(8000);