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

Object-oriented refactor of Suggest Gems #4083

Merged
merged 10 commits into from
Dec 7, 2023

Conversation

NerdEgghead
Copy link
Contributor

No description provided.

NerdEgghead added 9 commits December 5, 2023 22:12
to facilitate flexible use by other sims.

 Changes to be committed:
	new file:   ui/core/components/suggest_gems_action.ts
	modified:   ui/core/proto_utils/equipped_item.ts
	modified:   ui/core/proto_utils/gear.ts
	modified:   ui/feral_druid/sim.ts
 Changes to be committed:
	modified:   ui/core/components/suggest_gems_action.ts
 Changes to be committed:
	modified:   ui/core/components/suggest_gems_action.ts
	modified:   ui/core/proto_utils/gear.ts
copy-pasted code.

Changes to be committed:
	modified:   ui/warrior/sim.ts
 Changes to be committed:
	modified:   ui/warrior/sim.ts
 Changes to be committed:
	modified:   ui/hunter/sim.ts
	modified:   ui/warrior/sim.ts
 Changes to be committed:
	modified:   ui/feral_tank_druid/sim.ts
@NerdEgghead
Copy link
Contributor Author

@1337LutZ @TheGroxEmpire Finally finished the Suggest Gems refactor to make it object-oriented and extensible to different types of sims without copy-pasting code. Would appreciate if you can take a look before I merge.

this.sim = simUI.sim;

// Initialize empty arrays of gem priorities for each socket color
this.gemPriorityByColor = {} as Record<GemColor, Array<GemCapsData>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Cant this be a empty object by default on line 23?

protected readonly gemPriorityByColor: Record<GemColor, Array<GemCapsData>> = {};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to initialize all the keys explicitly with empty Arrays, since I query the length elsewhere, such as on line 82.

if (itemSlot != null) {
const item = gear.getEquippedItem(itemSlot);

for (const [socketIdx, socketColor] of item!.allSocketColors().entries()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of item! do we want do just return early if !item on line 149-150?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial assumption was that item would always be non-null if itemSlot is non-null, since findStrongestSocketBonus() already has a null check in it. But I added the early return anyway just for completeness.

this.arpStackDetected = this.detectArpStackConfiguration(ungemmedGear);

// Update red gem priority
const redGemCaps = new Array<GemCapsData>();
Copy link
Contributor

Choose a reason for hiding this comment

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

The priority of adding the gems on line 328 and below can be different per class/spec. Is there a way to also make that dynamic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have an example of a physical DPS spec that would use a different priority than the one listed here? My thought was to generalize code like this on an as-needed basis, as more sims start to implement GemOptimizer subclasses.

@1337LutZ
Copy link
Contributor

1337LutZ commented Dec 7, 2023

Super nice work <3 Added some comments in regards of TS / gem orders.
Will build it locally and see if it behaves the same as the current one :)

@1337LutZ
Copy link
Contributor

1337LutZ commented Dec 7, 2023

Created a build and looks like it is gemming sometimes even better (esp prioing the tear socket) for most specs 👍

 Changes to be committed:
	modified:   ui/core/components/suggest_gems_action.ts
@NerdEgghead
Copy link
Contributor Author

Will go ahead and merge this for now, and if there is a need to further compartmentalize the updateGemPriority() method to support additional physical DPS sims, we can tackle that then.

@NerdEgghead NerdEgghead merged commit be034c3 into wowsims:master Dec 7, 2023
1 check passed
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