Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the damage and resource pipelines #189

Merged

Conversation

Azurelol
Copy link
Collaborator

@Azurelol Azurelol commented Dec 25, 2024

Refactors the damage and resource pipelines to be standardized and to provide a sequence of steps

  • Adds a new pipelines module, which now has the damage and resource pipelines
  • The damage pipeline has been broken into sequence of discrete steps
  • Adds support for using flags set by active effects for edge cases like Zero Shield
  • Provides 3 hooks for the damage pipeline: before affinities, after affinities and at the very end
  • Expands on the BonusesDataModel, DamageBonusesDataModel models to support skills such as Defensive Mastery, Symbol of Weakness.

@Azurelol Azurelol changed the base branch from main to dev December 25, 2024 18:25
@Azurelol
Copy link
Collaborator Author

After this latest iteration I feel more confident on the architecture, so I believe it's worth taking a look and now and giving feedback in order to improve the design.

@Azurelol Azurelol marked this pull request as ready for review December 27, 2024 16:12
[FU.affValue.vulnerability]: (damage) => damage * 2,
[FU.affValue.none]: (damage) => damage,
[FU.affValue.resistance]: (damage, { shift }) => (shift ? damage : Math.floor(damage / 2)),
[FU.affValue.immunity]: (damage, { shift, ctrl }) => (shift && ctrl ? damage : 0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping we'd address the key modifiers on the next refactor.
I don't feel like modifier keys have any business being in logic layers. It's a UI-related issue and should be handled by the event consumer/hook. If in the future we somehow have other means of expressing "ignore resistance" that comes from a keyboard command rather than shift+click, we'd have to add more handler code in this logic layer.
The UI should be handled and the intent of "ignore resistance" is what should be passed to a pipeline imho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree with you and would like to strip this out on the next pass. I think with a "traits" system we should be able to express intents in an uniform way that both UI and other procedures can use.

* @param {?} message
* @param {jQuery} jQuery
*/
function onRenderChatMessage(message, jQuery) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Feels like it ought to be in some UI helper method instead of pipeline but I also don't have any concrete suggestions. Not a big deal since it's purely organizational

@Azurelol Azurelol requested a review from KSops December 30, 2024 16:23
module/hooks.mjs Outdated
* @description Modify the result after it's been calculated.
* @example callback(context) { context.result += 42; return true; }
*/
DAMAGE_PIPELINE_CALCULATE: 'projectfu.pipelines.damage.calculate',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: naming might imply the step is for calculating. either change to past tense (calculated) or both steps to pre_calculate and post_calculate

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well; I was on the fence too on which tense to use for these hooks. But we can go with past-tense convention for the system.

},
).render(true);
}
// import { FUActor } from '../documents/actors/actor.mjs';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover from refactor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, yes. Thanks.

@Azurelol Azurelol requested a review from KSops December 30, 2024 21:00
}

// TODO: Remove once users have migrated from legacy hooks
const beforeApplyHookData = new BeforeApplyHookData(request);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use the result of the modified damage? The point of the hook is to be able to make changes to the calculation

module/hooks.mjs Outdated
* @example callback(context) { context.modifiers.set("foobar", 42); return true; }
* @example callback(context) { context.modifiers.delete("affinity"); return true; }
*/
DAMAGE_PIPELINE_PRE_CALCULATE: 'projectfu.pipelines.damage.collect',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Change the underlying value to more closely match the const name. same with post

@Azurelol Azurelol requested a review from KSops December 31, 2024 09:43
Copy link
Collaborator

@KSops KSops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't check all the nitty gritty stuff but the design looks good to me. Thank you for all the hard work!

@Azurelol Azurelol merged commit 8de494e into League-of-Fabulous-Developers:dev Jan 2, 2025
@Azurelol Azurelol deleted the refactor/dmg_res_pipeline branch January 2, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants