Skip to content

Commit

Permalink
Fixed regression in applying buffs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaumRystra committed Dec 1, 2024
1 parent 75fe3e8 commit e76ad64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 8 additions & 12 deletions app/imports/api/engine/action/applyProperties/applyBuffProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async function applyBuffProperty(

// Log the buff and return if there are no targets
if (!targetIds.length) {
logBuff(prop, targetIds, action, userInput, result);
await logBuff(prop, targetIds, action, userInput, result);
await applyAfterTasksSkipChildren(action, prop, targetIds, userInput);
return;
}
Expand All @@ -39,12 +39,12 @@ export default async function applyBuffProperty(
...getPropertyDescendants(action.creatureId, prop._id),
];

// Crystalize the variables
// Crystallize the variables
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
const mutation: Mutation = { targetIds: [target], contents: [] };

Expand All @@ -62,7 +62,7 @@ export default async function applyBuffProperty(
});

//Log the buff
logBuff(prop, targetIds, action, userInput, result);
await logBuff(prop, targetIds, action, userInput, result);

// remove all the computed fields
targetPropList = cleanProps(targetPropList);
Expand All @@ -72,7 +72,7 @@ export default async function applyBuffProperty(

// Add the mutation to the results
result.mutations.push(mutation);
});
}
await applyAfterTasksSkipChildren(action, prop, targetIds, userInput);
}

Expand All @@ -94,16 +94,12 @@ async function logBuff(prop, targetIds, action, userInput, result) {
* Replaces all variables with their resolved values
* 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
) {
const scope = await getEffectiveActionScope(action);
for (const prop of propList) {
if (prop._skipCrystalize) {
delete prop._skipCrystalize;
return;
}
// Iterate through all the calculations and crystalize them
// Iterate through all the calculations and crystallize them
for (const calcKey of computedSchemas[prop.type].computedFields()) {
await applyFnToKeyAsync(prop, calcKey, async (prop, key) => {
const calcObj = get(prop, key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const actionTestCreature = {
],
}

describe.only('Built in dice functions', function () {
describe('Built in dice functions', function () {
// Increase timeout
this.timeout(8000);

Expand Down

0 comments on commit e76ad64

Please sign in to comment.