-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
base: master
Are you sure you want to change the base?
Map plugDef.investmentStats to a more elaborated form containing plug stat activity rule and data fixes #9974
Conversation
… stat activity rule and data fixes
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' }; |
There was a problem hiding this comment.
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?
export const mapAndFilterInvestmentStats = weakMemoize( | ||
(itemDef: PluggableInventoryItemDefinition): readonly Readonly<DimPlugInvestmentStat>[] => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Feel free to merge whenever you feel comfortable. |
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 useDimPlug
everywhere, then these preprocessed stats can be conveniently available as a property on DimPlug.