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

Adjusted Sale Value for Infantry and Battle Armor Units #4572

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

IllianiCBT
Copy link
Collaborator

@IllianiCBT IllianiCBT commented Aug 8, 2024

Adjusted the sale value calculation for infantry (and BA) units by using their alternate cost method. This ensures that the sale of infantry is computed correctly and appropriately matches their purchase value.

Whether this final value is entirely correct is a matter for bigger brains than mine to debate. However, this at least matches the equipment value without factoring in personnel training. As you're selling the equipment, not the personnel.

This change will affect any instance where we use the sale value of an infantry or battle armor unit. Salvage immediately comes to mind, but likewise so does the campaign option to use unit sale value when calculating contract pay.

Closes #1795 & #2552 & #4473

Adjusted the sale value calculation for infantry (and BA) units by using their alternate cost method. This ensures that the sale of infantry is computed correctly and appropriately matches their purchase value.
@IllianiCBT
Copy link
Collaborator Author

While I was in Unit.java I did a little light refactoring, but I did spot a lot of unparameterized uses of Mounted alongside a number of unused methods that seem to have been supplanted by Entity.java at some point in the distant past. I opted to leave these alone as I didn't want to remove an unused method, incase this was a false-positive; and I left the Mounted instances alone as I don't know enough about that class to make a reasonable judgement for how it should be used.

@IllianiCBT IllianiCBT changed the title Addressed Sale Value for Infantry and Battle Armor Units Adjusted Sale Value for Infantry and Battle Armor Units Aug 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.32%. Comparing base (b5ff179) to head (ebb507d).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4572   +/-   ##
=========================================
  Coverage     10.32%   10.32%           
  Complexity     5816     5816           
=========================================
  Files           935      935           
  Lines        128792   128775   -17     
  Branches      18951    18948    -3     
=========================================
- Hits          13296    13295    -1     
+ Misses       114220   114204   -16     
  Partials       1276     1276           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Moved the infantry-specific sell value logic to the beginning of the getSellValue() method. This refactoring aims to simplify code flow and ensure that infantry units use an alternative cost calculation without proceeding through the general parts value computation block.
Increased the copyright range from 2021 to 2024 in Unit.java.
return new TargetRoll(0, "unknown location");
}
return switch (site) {
case SITE_FIELD -> new TargetRoll(2, "in the field");
Copy link
Member

Choose a reason for hiding this comment

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

PG 193 of CO has the new names for these. It would be nice to move to these with a seperate PR.

image

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'll address that in a separate PR, but gimme a couple of minutes and I'll see it done

@IllianiCBT IllianiCBT merged commit a7a4911 into MegaMek:master Aug 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hanger Value of Battle Armor much greater than Purchase Price
3 participants