-
Notifications
You must be signed in to change notification settings - Fork 191
Improvement: #6867 Added Weapons as a separate autologistics category #6943
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
Changes from all commits
6406083
d7a3032
0e266b6
1482881
fcc1b4e
6a55a25
337885d
e289ca7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -55,12 +55,15 @@ | |||||||
import java.util.stream.Stream; | ||||||||
|
||||||||
import megamek.common.Dropship; | ||||||||
import megamek.common.Entity; | ||||||||
import megamek.common.EquipmentType; | ||||||||
import megamek.common.Mek; | ||||||||
import megamek.common.WeaponType; | ||||||||
import megamek.common.enums.SkillLevel; | ||||||||
import mekhq.campaign.enums.CampaignTransportType; | ||||||||
import mekhq.campaign.parts.*; | ||||||||
import mekhq.campaign.parts.equipment.AmmoBin; | ||||||||
import mekhq.campaign.parts.equipment.EquipmentPart; | ||||||||
import mekhq.campaign.parts.equipment.HeatSink; | ||||||||
import mekhq.campaign.parts.equipment.JumpJet; | ||||||||
import mekhq.campaign.personnel.Person; | ||||||||
|
@@ -410,6 +413,21 @@ public void testGetSetStockPercentEngines() { | |||||||
assertEquals(SECOND_DESIRED_STOCK, secondStockLevel); | ||||||||
} | ||||||||
|
||||||||
@Test | ||||||||
public void testGetSetStockPercentWeapons() { | ||||||||
// Act | ||||||||
campaign.getCampaignOptions().setAutoLogisticsWeapons(FIRST_DESIRED_STOCK); | ||||||||
int firstStockLevel = campaign.getCampaignOptions().getAutoLogisticsWeapons(); | ||||||||
|
||||||||
// Let's change the stock level to something else so we can make sure it properly changes | ||||||||
campaign.getCampaignOptions().setAutoLogisticsWeapons(SECOND_DESIRED_STOCK); | ||||||||
int secondStockLevel = campaign.getCampaignOptions().getAutoLogisticsWeapons(); | ||||||||
|
||||||||
// Assert | ||||||||
assertEquals(FIRST_DESIRED_STOCK, firstStockLevel); | ||||||||
assertEquals(SECOND_DESIRED_STOCK, secondStockLevel); | ||||||||
} | ||||||||
|
||||||||
@Test | ||||||||
public void testGetSetStockPercentOther() { | ||||||||
// Act | ||||||||
|
@@ -479,6 +497,7 @@ void beforeEach() { | |||||||
when(mockCampaignOptions.getAutoLogisticsActuators()).thenReturn(INCORRECT_STOCK_LEVEL); | ||||||||
when(mockCampaignOptions.getAutoLogisticsJumpJets()).thenReturn(INCORRECT_STOCK_LEVEL); | ||||||||
when(mockCampaignOptions.getAutoLogisticsEngines()).thenReturn(INCORRECT_STOCK_LEVEL); | ||||||||
when(mockCampaignOptions.getAutoLogisticsWeapons()).thenReturn(INCORRECT_STOCK_LEVEL); | ||||||||
when(mockCampaignOptions.getAutoLogisticsOther()).thenReturn(INCORRECT_STOCK_LEVEL); | ||||||||
} | ||||||||
|
||||||||
|
@@ -813,6 +832,37 @@ public void testGetDefaultStockPercentEngines() { | |||||||
assertEquals(1, afterChangeAllPercents.stream().filter(i -> i == DESIRED_STOCK_LEVEL).toArray().length); | ||||||||
} | ||||||||
|
||||||||
@Test | ||||||||
public void testGetDefaultStockPercentWeapons() { | ||||||||
// Arrange | ||||||||
WeaponType mockWeaponType = mock(WeaponType.class); | ||||||||
part = new EquipmentPart(1, mockWeaponType, Entity.LOC_NONE, 1.0, false, campaign); | ||||||||
|
||||||||
// Act | ||||||||
try { | ||||||||
initialStockPercent = (int) method.invoke(campaign, part); | ||||||||
initialAllPercents = getAllDefaultStockPercents(); | ||||||||
|
||||||||
// Let's change it and make sure that it uses the new value | ||||||||
when(mockCampaignOptions.getAutoLogisticsWeapons()).thenReturn(DESIRED_STOCK_LEVEL); //TODO | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider removing or resolving the TODO comment once the intended behavior for weapon autologistics is finalized.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, it's nice to see Copilot bullying someone else for a change! :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No that was actually something I missed. The //TODO tag itself just needed removed. It was originally commented out during the development process. I left the //TODO flag so I'd uncomment it once it's implemented it. Just forgot to remove the todo :clown: |
||||||||
|
||||||||
desiredStockPercent = (int) method.invoke(campaign, part); | ||||||||
afterChangeAllPercents = getAllDefaultStockPercents(); | ||||||||
} catch (IllegalAccessException | InvocationTargetException e) { | ||||||||
throw new RuntimeException(e); | ||||||||
} | ||||||||
|
||||||||
// Assert | ||||||||
assertEquals(INCORRECT_STOCK_LEVEL, initialStockPercent); | ||||||||
assertEquals(DESIRED_STOCK_LEVEL, desiredStockPercent); | ||||||||
|
||||||||
// None of the initial defaults should contain the desired stock percent | ||||||||
assertFalse(initialAllPercents.contains(desiredStockPercent)); | ||||||||
|
||||||||
// Only one of these should be the desired stock percent | ||||||||
assertEquals(1, afterChangeAllPercents.stream().filter(i -> i == DESIRED_STOCK_LEVEL).toArray().length); | ||||||||
} | ||||||||
|
||||||||
@ParameterizedTest | ||||||||
@MethodSource(value = "otherUnhandledDefaultStockPercentParts") | ||||||||
public void testGetDefaultStockPercentOtherUnhandled(Part otherPart) { | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.