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

Map plugDef.investmentStats to a more elaborated form containing plug stat activity rule and data fixes #9974

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robojumper
Copy link
Member

This is an alternative to patching the defs like it is done in #9953. In some ways there's not much of a difference between patching defs directly and mapping the investmentStats array separately but there is a connection to #9076 here, I think - if we ever do use DimPlug everywhere, then these preprocessed stats can be conveniently available as a property on DimPlug.

Copy link
Contributor

@bhollis bhollis left a comment

Choose a reason for hiding this comment

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

This is great. I like how you separate the conditional stat rule from its application.

| /** always active */ undefined
| {
/** never active */
rule: 'never';
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use strings over a const enum?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could flatten the classType case and just use a single const enum, no objects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even if you don't do that, the discriminator could be an enum.

defHash === modsWithConditionalStats.elementalCapacitor ||
defHash === modsWithConditionalStats.enhancedElementalCapacitor
) {
return { rule: 'never' };
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this sets us up to actually implement elemental capacitor?

Comment on lines +145 to +146
export const mapAndFilterInvestmentStats = weakMemoize(
(itemDef: PluggableInventoryItemDefinition): readonly Readonly<DimPlugInvestmentStat>[] => {
Copy link
Contributor

Choose a reason for hiding this comment

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

weakMemoize doesn't really do anything here unless we were to swap out the manifest in the future. It doesn't hurt, but it's not going to cause anything to get garbage collected.

Copy link
Member Author

Choose a reason for hiding this comment

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

weakMemoize includes the lookup-object-as-cache boilerplate so I used it for that, with the idea that if we do swap out the manifest at some point, this is handled correctly.

) {
hasDupes =
uniqBy(itemDef.investmentStats, (s) => s.statTypeHash).length !==
itemDef.investmentStats.length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth sorting the investment stats by stat hash? Should allow for a fast duplicate scan both here and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe - we'd have to move the Enhanced Bipod code above this though, or make it more targeted because it'll change the indices that the fix relies on.

@bhollis
Copy link
Contributor

bhollis commented Nov 6, 2023

Feel free to merge whenever you feel comfortable.

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.

None yet

2 participants