Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@savanik
Copy link
Contributor

@savanik savanik commented May 16, 2025

This should more closely represent the rules in CO 4th p17.

@savanik savanik requested a review from a team as a code owner May 16, 2025 18:37
@codecov
Copy link

codecov bot commented May 16, 2025

Codecov Report

❌ Patch coverage is 0% with 58 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@75495e7). Learn more about missing BASE report.

Files with missing lines Patch % Lines
MekHQ/src/mekhq/campaign/unit/UnitOrder.java 0.00% 58 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7030   +/-   ##
=======================================
  Coverage        ?   12.03%           
  Complexity      ?     6885           
=======================================
  Files           ?     1102           
  Lines           ?   142253           
  Branches        ?    22002           
=======================================
  Hits            ?    17117           
  Misses          ?   123301           
  Partials        ?     1835           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +228 to +234
//FIXME ?
/* In theory, these should be the base target numbers of these vehicles. The base TNs in the book are
* static and don't adjust for Admin skill or anything. This doesn't match our usage of skills such as
* Administration to find vehicles. Instead, we're going to just kind of assume they 'intended'
* a base TN of 7 and adjust for windage.
*
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest this be discussed before implemented.

Comment on lines +248 to +270
// Since the actual rules are ambiguous, I'm using the tech level as a stand-in for 'uniqueness'
// 1 is 'common' and 5 is 'experimental' according to enums
// However, almost all Dropships are 'D' techlevel, so... a better solution could be found.

int techLevel = entity.getTechLevel(getCampaign().getGameYear());
switch (techLevel) {
case 1:
target.addModifier(-1, "Common");
break;
case 2:
target.addModifier(0, "Average");
break;
case 3:
target.addModifier(3, "Rare");
break;
case 4:
target.addModifier(6, "Very Rare");
break;
case 5:
default:
target.addModifier(10, "Unique");

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another one that needs discussion, coming up with a solution is fine, but any unnoficial value should really be at least talked about with other devs onto why you are thining of adding it this way, and sometimes also it is worth to bring up those as really valid questions on how to most closely to implement the rules as written on MekHQ, alot of contributors can give great advice and sometimes even have access to erratas on how things changed its workings since release/publication

Comment on lines +285 to +306
int year = getCampaign().getGameYear();
if (year > 3084) {
target.addModifier(0, "Era");
} else if (year > 3068) {
target.addModifier(-2, "Era");
} else if (year > 3050) {
target.addModifier(-1, "Era");
} else if (year > 2901) {
target.addModifier(+0, "Era");
} else if (year > 2821) {
target.addModifier(-2, "Era");
} else if (year > 2751) {
target.addModifier(-6, "Era");
} else if (year > 2651) {
target.addModifier(-6, "Era");
} else if (year > 2571) {
target.addModifier(-5, "Era");
} else if (year > 2412) {
target.addModifier(-4, "Era");
} else {
target.addModifier(-3, "Era");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

            int year = getCampaign().getGameYear();
            int eraModifier = getTargetModifierForEra(getCampaign().getGameYear());
            target.addModifier(eraModifier, I18n.getText("unitOrder.eraModifier")); 
            return target;
        }    
        
        private int getTargetModifierForEra(int year) {
            if (year > 3084) {
                modifier = 0;
            } else if (year > 3068) {
                modifier = -2;
            } else if (year > 3050) {
                modifier = -1;
            } else if (year > 2901) {
                modifier = +0;
            } else if (year > 2821) {
                modifier = -2;
            } else if (year > 2751) {
                modifier = -6;
            } else if (year > 2651) {
                modifier = -6;
            } else if (year > 2571) {
                modifier = -5;
            } else if (year > 2412) {
                modifier = -4;
            } else {
                modifier = -3;
            }
            return modifier;
        }

@Scoppio
Copy link
Collaborator

Scoppio commented May 17, 2025

Too many decisions on how to implement book rules were made but the comments seen to imply that there were no discussion around the decisions that were taken

@HammerGS HammerGS requested a review from Copilot May 17, 2025 03:55
Copy link
Contributor

Copilot AI left a comment

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 updates the dropship acquisition target numbers (TNs) in UnitOrder to more closely follow the rules in CO 4th p17. Key changes include reordering the XML import statements, reformatting the HTML string concatenations in the find and failToFind methods, and introducing a new block for calculating TN modifiers for Dropship and Jumpship entities.

Comment on lines +228 to +246
//FIXME ?
/* In theory, these should be the base target numbers of these vehicles. The base TNs in the book are
* static and don't adjust for Admin skill or anything. This doesn't match our usage of skills such as
* Administration to find vehicles. Instead, we're going to just kind of assume they 'intended'
* a base TN of 7 and adjust for windage.
*
*/
if (entity instanceof SpaceStation) {
target.addModifier((int) Math.ceil(entity.getCost(false) / 50000000) + 5 - 7, "Spacestation Base");
} else if (entity instanceof Warship) {
double collars = ((Warship) entity).getDockingCollars().size();
target.addModifier((int) (Math.ceil(Math.sqrt(entity.getWeight() / 5000)) +
Math.ceil(Math.sqrt(collars))) - 7, "Warship Base");
} else if (entity instanceof Dropship) {
target.addModifier((int) Math.ceil(entity.getCost(false) / 50000000) + 5 - 7, "Dropship Base");
} else {
int collars = ((Jumpship) entity).getDockingCollars().size();
target.addModifier((int) Math.ceil(entity.getCost(false) / 100000000) + collars - 7, "Jumpship Base");
}
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider refactoring the lengthy acquisition modifiers computation block into helper methods to improve code readability and maintainability.

Suggested change
//FIXME ?
/* In theory, these should be the base target numbers of these vehicles. The base TNs in the book are
* static and don't adjust for Admin skill or anything. This doesn't match our usage of skills such as
* Administration to find vehicles. Instead, we're going to just kind of assume they 'intended'
* a base TN of 7 and adjust for windage.
*
*/
if (entity instanceof SpaceStation) {
target.addModifier((int) Math.ceil(entity.getCost(false) / 50000000) + 5 - 7, "Spacestation Base");
} else if (entity instanceof Warship) {
double collars = ((Warship) entity).getDockingCollars().size();
target.addModifier((int) (Math.ceil(Math.sqrt(entity.getWeight() / 5000)) +
Math.ceil(Math.sqrt(collars))) - 7, "Warship Base");
} else if (entity instanceof Dropship) {
target.addModifier((int) Math.ceil(entity.getCost(false) / 50000000) + 5 - 7, "Dropship Base");
} else {
int collars = ((Jumpship) entity).getDockingCollars().size();
target.addModifier((int) Math.ceil(entity.getCost(false) / 100000000) + collars - 7, "Jumpship Base");
}
handleAcquisitionModifiersForSpaceEntities(target);

Copilot uses AI. Check for mistakes.
// TODO: Fix weight classes
// TODO: aero large craft
if (entity instanceof Dropship || entity instanceof Jumpship) {
//FIXME ?
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Clarify the 'FIXME' comment with specific details on what needs to be fixed or remove it if it is no longer applicable.

Copilot uses AI. Check for mistakes.
Comment on lines +196 to +212
return "<font color='" +
MekHQ.getMHQOptions().getFontColorPositiveHexColor() +
"'><b> unit found</b>.</font> It will be delivered in " +
transitDays +
" days.";
} else {
return "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor()
+ "'><b> You cannot afford this unit. Transaction cancelled</b>.</font>";
return "<font color='" +
MekHQ.getMHQOptions().getFontColorNegativeHexColor() +
"'><b> You cannot afford this unit. Transaction cancelled</b>.</font>";
}
}

@Override
public String failToFind() {
return "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor()
+ "'><b> unit not found</b>.</font>";
return "<font color='" +
MekHQ.getMHQOptions().getFontColorNegativeHexColor() +
"'><b> unit not found</b>.</font>";
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using String.format to construct the HTML message strings instead of manual concatenation for better readability.

Copilot uses AI. Check for mistakes.
@savanik savanik marked this pull request as draft May 21, 2025 04:20
@HammerGS HammerGS added the Draft Work in Progress label Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Draft Work in Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants