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

Refactored Cargo Capacity Calculations and Reporting. #5339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IllianiCBT
Copy link
Collaborator

Campaign cargo capacity was not correctly reporting cargo units stored in non-bays. For example, many industrial 'Meks have parts labeled 'cargo'. Mechanically, these are not cargo containers so do not get picked up as available cargo. I believe the intent is that at TW level these units are always presumed to be carrying cargo of some description. Rather than this being available cargo space.

I went ahead and modified how we fetch total cargo capacity from a unit, so now these amorphous 'cargo' parts are considered cargo capacity. This uses string comparison which is not my favorite method, but after a while searching through our codebase it doesn't seem we have a better option as these 'cargo' parts are not treated as special equipment so we don't have another way to confirm whether the part we're looking at is 'cargo'.

I also adjusted cargo capacity so that units that are not fully crewed do not contribute cargo capacity. No more filling the hangar with empty cargo trucks.

Finally, I adjusted the cargo report displayed on the command center so that it's rounded to 1 decimal place, rather than nearest whole number. This will prevent users mistakenly bug reporting 0.5t capacity displaying as 1t.

Closes #5324

Simplified and improved cargo capacity calculations by using `BigDecimal` for rounding and added regex support for parsing additional cargo parts. Enhanced the HTML cargo capacity report to include color-coded thresholds and updated logic for better readability and maintainability.
@IllianiCBT IllianiCBT added the Bug label Dec 11, 2024
@IllianiCBT IllianiCBT self-assigned this Dec 11, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.45%. Comparing base (7ddb24c) to head (3db9183).
Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5339      +/-   ##
============================================
- Coverage     10.47%   10.45%   -0.02%     
+ Complexity     6069     6056      -13     
============================================
  Files           959      959              
  Lines        135559   135571      +12     
  Branches      19750    19751       +1     
============================================
- Hits          14204    14180      -24     
- Misses       119997   120033      +36     
  Partials       1358     1358              

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

@gsparks3
Copy link
Collaborator

I believe the intent is that at TW level these units are always presumed to be carrying cargo of some description. Rather than this being available cargo space.

Going by TechManual page 239, the "Cargo" crits on a mek explicitly are for Cargo Bays, which can be emptied or filled as desired (this can even be done at combat-relevant speeds if Lift Hoists are also present). The primary difference between the mek version and the vehicle version is that a bay requires 1 critical slot per ton on the former, but only 1 slot total on the latter (as vehicles track item slots differently). This can also involve distinguishing between e.g. 5 tons worth of "Cargo" split into five 1-ton bays, or a single 5-ton bay that occupies 5 crits in a contiguous, linked block (with the primary difference there being that a critical hit to any slot of the 5-ton, 5-crit bay destroys all cargo in said bay).

This is provided primarily for informational reasons, as it does not change that this is the easiest fix at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants