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: make EquipmentManager slots an enum #1510

Merged
merged 8 commits into from
Feb 13, 2023

Conversation

midgleyc
Copy link
Member

@midgleyc midgleyc commented Feb 8, 2023

Pieces of code using

(int slot = EquipmentManager.HAT; slot <= EquipmentManager.FAMILIAR + 1; ++slot)

were changed to omit the crown of thrones. I don't think it's necessary (and I don't know why they were written this way to begin with).

UnequipCommand was hat -> sticker3. It was also changed to omit the crown.

There are a couple of outstanding things to check on the Maximizer (e.g. CLI calls that equip as they go along) but this should be mostly done.

@midgleyc midgleyc requested a review from a team as a code owner February 8, 2023 12:17
@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #1510 (73d45df) into main (de89c58) will increase coverage by 0.07%.
The diff coverage is 53.70%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1510      +/-   ##
============================================
+ Coverage     34.90%   34.98%   +0.07%     
- Complexity    17555    17585      +30     
============================================
  Files          1065     1067       +2     
  Lines        163430   163590     +160     
  Branches      34938    34950      +12     
============================================
+ Hits          57043    57224     +181     
+ Misses        96828    96817      -11     
+ Partials       9559     9549      -10     
Impacted Files Coverage Δ
src/net/sourceforge/kolmafia/EdServantData.java 34.19% <0.00%> (ø)
src/net/sourceforge/kolmafia/Modeable.java 100.00% <ø> (ø)
src/net/sourceforge/kolmafia/MonsterData.java 57.27% <0.00%> (+0.05%) ⬆️
src/net/sourceforge/kolmafia/RequestEditorKit.java 28.79% <ø> (ø)
...rc/net/sourceforge/kolmafia/moods/MoodManager.java 59.45% <0.00%> (ø)
...forge/kolmafia/persistence/ConcoctionDatabase.java 53.56% <0.00%> (ø)
...ourceforge/kolmafia/persistence/DebugDatabase.java 11.86% <0.00%> (ø)
...ourceforge/kolmafia/persistence/SkillDatabase.java 44.16% <0.00%> (ø)
.../sourceforge/kolmafia/request/BeerPongRequest.java 17.89% <0.00%> (ø)
...ge/kolmafia/request/CargoCultistShortsRequest.java 8.20% <0.00%> (ø)
... and 84 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de89c58...73d45df. Read the comment docs.

Copy link
Contributor

@gausie gausie 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 the most important enum-ization of all to me and I'm so happy to see it in a PR! Some initial thoughts, but there's a lot to read

src/net/sourceforge/kolmafia/SpecialOutfit.java Outdated Show resolved Hide resolved
src/net/sourceforge/kolmafia/session/EquipmentManager.java Outdated Show resolved Hide resolved
src/net/sourceforge/kolmafia/session/EquipmentManager.java Outdated Show resolved Hide resolved
import java.util.function.Function;
import java.util.stream.Collectors;

public class EquipmentSlot {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why contain slot within equipment slot? Can you store the sets as statics on Slot?

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 could do, but I think it looks better to only have CAPITALS be the enum values, and anything else to be out of it. So e.g. Slot.NONE is a slot, but Slot.SLOTS would not be, so I've put the latter at EquipmentSlot.SLOTS.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there are ways to achieve that goal without making Slot a subclass. It's annoying DX that I want to move away from in (for example) AscensionPath.Path

Copy link
Member Author

Choose a reason for hiding this comment

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

Why do you think it's annoying DX? I rather like it.

@midgleyc midgleyc force-pushed the equipment-manager-enum branch 5 times, most recently from e7a7fe3 to f56077b Compare February 13, 2023 10:32
Copy link
Contributor

@gausie gausie 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 a huge improvement to the codebase. I can't be certain that nothing breaks here, but I think our users can let us know pretty quickly :)

@midgleyc midgleyc merged commit 77a167d into kolmafia:main Feb 13, 2023
@midgleyc midgleyc deleted the equipment-manager-enum branch February 13, 2023 11:11
@midgleyc midgleyc added the enum-conversion Converting `public static final int`s to enums label Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enum-conversion Converting `public static final int`s to enums
Projects
None yet
2 participants