Skip to content

Fix transport cost display and calculation semantics #8635

Merged
HammerGS merged 3 commits into
mainfrom
Fix-Transportation-costs-display
Jan 6, 2026
Merged

Fix transport cost display and calculation semantics #8635
HammerGS merged 3 commits into
mainfrom
Fix-Transportation-costs-display

Conversation

@HammerGS

@HammerGS HammerGS commented Jan 3, 2026

Copy link
Copy Markdown
Member

(Partially addresses #8620)


Summary

  • Fixed transport cost double-counting display bug in contract payment breakdown
  • Changed transportAmount to represent employer's reimbursement (income) instead of player's cost
  • Better transport terms now correctly show improved contract value
  • Renamed "Transportation Amount" to "Transport Reimbursement" for clarity

Background

Transport cost confusion has come up multiple times on Discord, and has been discussed on the official forums:

The Problem

Players were experiencing confusing behavior when reviewing contract proposals:

  1. Double-counting appearance: Transport fees appeared to be subtracted twice - once in the Income section as "Transportation Amount" (showing the full transport cost as negative), and again in the Expenses section as "Transportation Expenses" (showing the player's share as negative). The breakdown values didn't add up to the displayed totals.
  2. Better terms = lower payout paradox: When negotiating better transport compensation (e.g., going from 50% to 75% employer-paid), the displayed payout would actually decrease. This was counterintuitive and made players think something was broken.
  3. Semantic confusion in code: The transportAmount field stored the player's out-of-pocket cost but was being added to income in getTotalAmount(), then subtracted again in getEstimatedTotalProfit(). While these operations cancelled mathematically, the display showed inconsistent values.

Example: Before vs After

Scenario: Full transport cost = 1,000,000 C-bills, Employer pays 50%

Display Section Before (Buggy) After (Fixed)
Income: Transport -1,000,000 (full cost, negative) +500,000 (reimbursement, positive)
Expenses: Transport -500,000 (player's share) -1,000,000 (full cost you pay)
Net effect on profit Confusing, values don't add up Clear: +500k income - 1M expense = -500k (your share)
image

When negotiating better terms (75% employer-paid):

Metric Before (Buggy) After (Fixed)
Displayed payout Goes DOWN (confusing!) Stays similar
Transport Reimbursement Not shown correctly +750,000 (higher = better)
Your transport cost -500,000 shown, -250,000 actual -1,000,000 (full), offset by reimbursement
Net profit effect Unclear Clear: -250,000 (your 25% share)

Regarding Issue #8620

Issue #8620 reported that transport fees were deducted even when the player owns sufficient ships. This PR partially addresses that issue:

  • Fixed: The display now correctly shows what TransportCostCalculations returns. If you own ships, the calculated transport cost should be lower (or zero), and this will now display correctly.
  • Not addressed in this PR: During investigation, we found that ships which are "in transit" (not present at current location) still contribute to transport capacity calculations, even though they're not actually available. This is a separate issue that will be addressed in a follow-up PR.

Test plan

  • Updated existing ContractTest cases for new calculation values
  • Added testGetEmployerTransportReimbursement - verifies employer reimbursement calculation
  • Added testGetPlayerTransportCost - verifies player's out-of-pocket cost
  • Added testGetTotalTransportationFees - verifies full transport cost returned
  • Added testTransportReimbursementWithPartialCompensation - tests 50% compensation
  • Added testBetterTransportTermsIncreaseReimbursement - verifies better terms = higher reimbursement
  • Manual testing: Verify contract proposal UI shows correct breakdown values
  • Manual testing: Verify owned ships reduce displayed transport costs

🤖 Generated with https://claude.com/claude-code

…sses #8620)

  ---
  Summary

  - Fixed transport cost double-counting display bug in contract payment breakdown
  - Changed transportAmount to represent employer's reimbursement (income) instead of player's cost
  - Better transport terms now correctly show improved contract value
  - Renamed "Transportation Amount" to "Transport Reimbursement" for clarity

  Background

  Transport cost confusion has come up multiple times on Discord, and has been discussed on the official forums:
  - https://battletech.com/forums/index.php?topic=90305.0
  - GitHub Issue: #8620 (partially addressed - see below)

  The Problem

  Players were experiencing confusing behavior when reviewing contract proposals:

  1. Double-counting appearance: Transport fees appeared to be subtracted twice - once in the Income section as "Transportation Amount" (showing the full transport cost as negative), and again in the Expenses section as "Transportation Expenses" (showing the player's share as negative). The breakdown values didn't add up to the displayed totals.
  2. Better terms = lower payout paradox: When negotiating better transport compensation (e.g., going from 50% to 75% employer-paid), the displayed payout would actually decrease. This was counterintuitive and made players think something was broken.
  3. Semantic confusion in code: The transportAmount field stored the player's out-of-pocket cost but was being added to income in getTotalAmount(), then subtracted again in getEstimatedTotalProfit(). While these operations cancelled mathematically, the display showed inconsistent values.

  Example: Before vs After

  Scenario: Full transport cost = 1,000,000 C-bills, Employer pays 50%

  | Display Section      | Before (Buggy)                   | After (Fixed)                                         |
  |----------------------|----------------------------------|-------------------------------------------------------|
  | Income: Transport    | -1,000,000 (full cost, negative) | +500,000 (reimbursement, positive)                    |
  | Expenses: Transport  | -500,000 (player's share)        | -1,000,000 (full cost you pay)                        |
  | Net effect on profit | Confusing, values don't add up   | Clear: +500k income - 1M expense = -500k (your share) |

  When negotiating better terms (75% employer-paid):

  | Metric                  | Before (Buggy)                  | After (Fixed)                              |
  |-------------------------|---------------------------------|--------------------------------------------|
  | Displayed payout        | Goes DOWN (confusing!)          | Stays similar                              |
  | Transport Reimbursement | Not shown correctly             | +750,000 (higher = better)                 |
  | Your transport cost     | -500,000 shown, -250,000 actual | -1,000,000 (full), offset by reimbursement |
  | Net profit effect       | Unclear                         | Clear: -250,000 (your 25% share)           |

  Regarding Issue #8620

  Issue #8620 reported that transport fees were deducted even when the player owns sufficient ships. This PR partially addresses that issue:

  - Fixed: The display now correctly shows what TransportCostCalculations returns. If you own ships, the calculated transport cost should be lower (or zero), and this will now display correctly.
  - Not addressed in this PR: During investigation, we found that ships which are "in transit" (not present at current location) still contribute to transport capacity calculations, even though they're not actually available. This is a separate issue that will be addressed in a follow-up PR.

  Test plan

  - Updated existing ContractTest cases for new calculation values
  - Added testGetEmployerTransportReimbursement - verifies employer reimbursement calculation
  - Added testGetPlayerTransportCost - verifies player's out-of-pocket cost
  - Added testGetTotalTransportationFees - verifies full transport cost returned
  - Added testTransportReimbursementWithPartialCompensation - tests 50% compensation
  - Added testBetterTransportTermsIncreaseReimbursement - verifies better terms = higher reimbursement
  - Manual testing: Verify contract proposal UI shows correct breakdown values
  - Manual testing: Verify owned ships reduce displayed transport costs

  🤖 Generated with https://claude.com/claude-code
@HammerGS HammerGS added the AI Generated Code AI-generated fix. Requires human testing and review before merging. label Jan 3, 2026
Copilot AI review requested due to automatic review settings January 3, 2026 04:28
@HammerGS HammerGS requested a review from a team as a code owner January 3, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a transport cost display bug where transport fees appeared to be double-counted in contract payment breakdowns, and changes the semantics of transportAmount from representing the player's cost to representing the employer's reimbursement. The change makes better transport negotiation terms correctly show as increased contract value, and renames the UI label from "Transportation Amount" to "Transport Reimbursement" for clarity.

Key changes:

  • Changed transportAmount field to store employer's transport reimbursement instead of player's out-of-pocket cost
  • Updated contract payment breakdown UI to show employer reimbursement as positive income and full transport cost as expense
  • Added new methods getEmployerTransportReimbursement() and getPlayerTransportCost() for clearer transport cost calculations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
MekHQ/src/mekhq/campaign/mission/Contract.java Core logic change: transportAmount now calculated as employer reimbursement; added new methods for transport cost calculations; updated documentation
MekHQ/src/mekhq/gui/view/ContractPaymentBreakdown.java Updated UI display to show employer reimbursement in income section and full transport cost in expenses section
MekHQ/resources/mekhq/resources/ContractPaymentBreakdown.properties Renamed label from "Transportation Amount" to "Transport Reimbursement"
MekHQ/unittests/mekhq/campaign/mission/ContractTest.java Updated existing test expectations and added comprehensive tests for new transport cost calculation methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MekHQ/src/mekhq/campaign/mission/Contract.java
Comment thread MekHQ/src/mekhq/campaign/mission/Contract.java
Comment thread MekHQ/src/mekhq/gui/view/ContractPaymentBreakdown.java Outdated
Comment thread MekHQ/src/mekhq/campaign/mission/Contract.java Outdated
@HammerGS HammerGS marked this pull request as draft January 3, 2026 04:46
HammerGS and others added 2 commits January 5, 2026 16:16
  ---
  Changes Made:

  | Issue                                 | File                          | Fix                                                                                                                         |
  |---------------------------------------|-------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
  | 1. ContractAutomation breaking change | ContractAutomation.java       | Changed getTransportAmount() → getTotalTransportationFees(campaign) at lines 126 and 156                                    |
  | 2. Save compatibility                 | Contract.java                 | Added version check in loadFieldsFromXmlNode() to recalculate transportAmount for saves < 0.50.12                           |
  | 3. Misleading comment                 | ContractPaymentBreakdown.java | Updated comment to clarify employer reimbursement is shown separately in income section                                     |
  | 4. Duplicate calculation              | Contract.java                 | Changed getPlayerTransportCost() to call getEmployerTransportReimbursement(campaign) instead of duplicating the calculation |

  ---
  Files modified:
  - MekHQ/src/mekhq/campaign/market/contractMarket/ContractAutomation.java
  - MekHQ/src/mekhq/campaign/mission/Contract.java
  - MekHQ/src/mekhq/gui/view/ContractPaymentBreakdown.java
@HammerGS HammerGS marked this pull request as ready for review January 5, 2026 23:46
@HammerGS HammerGS added the AI ready for Review Indicates that is has been in game tested and is ready for review as it can be label Jan 6, 2026

@Sleet01 Sleet01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@HammerGS HammerGS merged commit 3af160c into main Jan 6, 2026
6 checks passed
@HammerGS HammerGS deleted the Fix-Transportation-costs-display branch January 6, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Code AI-generated fix. Requires human testing and review before merging. AI ready for Review Indicates that is has been in game tested and is ready for review as it can be

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants