From 71a2801c028a75731a3586d2fb7659095c2ce15c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Apr 2025 11:08:43 -0500 Subject: [PATCH 1/3] Moved Skill Classes to Dedicated Package - Moved all skill-related classes into a discrete package --- MekHQ/src/mekhq/CampaignPreset.java | 2 +- MekHQ/src/mekhq/Utilities.java | 4 +- MekHQ/src/mekhq/campaign/Campaign.java | 4 +- MekHQ/src/mekhq/campaign/CampaignOptions.java | 2 +- MekHQ/src/mekhq/campaign/CampaignSummary.java | 2 +- .../src/mekhq/campaign/MercRosterAccess.java | 25 +- .../againstTheBot/AtBConfiguration.java | 29 +- .../mekhq/campaign/io/CampaignXmlParser.java | 6 +- .../campaign/market/PersonnelMarket.java | 21 +- .../AtbMonthlyContractMarket.java | 2 +- .../contractMarket/CamOpsContractMarket.java | 2 +- .../campaign/mission/AtBDynamicScenario.java | 25 +- .../mission/AtBDynamicScenarioFactory.java | 69 +++-- .../mekhq/campaign/mission/AtBScenario.java | 36 ++- .../atb/AtBScenarioModifierApplicator.java | 21 +- .../mission/resupplyAndCaches/Resupply.java | 48 ++-- .../src/mekhq/campaign/mod/am/InjuryUtil.java | 14 +- .../mekhq/campaign/parts/AeroHeatSink.java | 13 +- .../mekhq/campaign/parts/AeroLifeSupport.java | 15 +- .../src/mekhq/campaign/parts/AeroSensor.java | 16 +- MekHQ/src/mekhq/campaign/parts/Armor.java | 2 +- MekHQ/src/mekhq/campaign/parts/Avionics.java | 16 +- .../mekhq/campaign/parts/BattleArmorSuit.java | 7 +- .../parts/CombatInformationCenter.java | 13 +- .../campaign/parts/DropshipDockingCollar.java | 7 +- .../src/mekhq/campaign/parts/EnginePart.java | 7 +- .../campaign/parts/FireControlSystem.java | 13 +- MekHQ/src/mekhq/campaign/parts/GravDeck.java | 7 +- .../campaign/parts/JumpshipDockingCollar.java | 7 +- .../campaign/parts/KFChargingSystem.java | 7 +- .../src/mekhq/campaign/parts/KFDriveCoil.java | 7 +- .../campaign/parts/KFDriveController.java | 7 +- .../campaign/parts/KFFieldInitiator.java | 7 +- .../mekhq/campaign/parts/KFHeliumTank.java | 7 +- MekHQ/src/mekhq/campaign/parts/KfBoom.java | 7 +- MekHQ/src/mekhq/campaign/parts/LFBattery.java | 7 +- .../src/mekhq/campaign/parts/LandingGear.java | 9 +- .../src/mekhq/campaign/parts/MekActuator.java | 16 +- .../src/mekhq/campaign/parts/MekCockpit.java | 7 +- MekHQ/src/mekhq/campaign/parts/MekGyro.java | 7 +- .../mekhq/campaign/parts/MekLifeSupport.java | 11 +- .../src/mekhq/campaign/parts/MekLocation.java | 7 +- MekHQ/src/mekhq/campaign/parts/MekSensor.java | 11 +- .../src/mekhq/campaign/parts/MissingPart.java | 6 +- MekHQ/src/mekhq/campaign/parts/OmniPod.java | 7 +- MekHQ/src/mekhq/campaign/parts/Part.java | 23 +- MekHQ/src/mekhq/campaign/parts/PodSpace.java | 18 +- .../campaign/parts/ProtoMekArmActuator.java | 7 +- .../mekhq/campaign/parts/ProtoMekJumpJet.java | 9 +- .../campaign/parts/ProtoMekLegActuator.java | 11 +- .../campaign/parts/ProtoMekLocation.java | 7 +- .../mekhq/campaign/parts/ProtoMekSensor.java | 11 +- MekHQ/src/mekhq/campaign/parts/Refit.java | 2 +- .../mekhq/campaign/parts/SVEnginePart.java | 7 +- .../parts/SpacecraftCoolingSystem.java | 7 +- .../campaign/parts/SpacecraftEngine.java | 19 +- .../mekhq/campaign/parts/TankLocation.java | 7 +- MekHQ/src/mekhq/campaign/parts/Thrusters.java | 13 +- MekHQ/src/mekhq/campaign/parts/VeeSensor.java | 2 +- .../mekhq/campaign/parts/VeeStabilizer.java | 2 +- .../src/mekhq/campaign/personnel/Person.java | 7 +- .../campaign/personnel/PersonUtility.java | 3 +- .../campaign/personnel/SkillPerquisite.java | 85 +++--- .../campaign/personnel/SpecialAbility.java | 138 ++++----- .../personnel/autoAwards/SkillAwards.java | 2 +- .../campaign/personnel/education/Academy.java | 2 +- .../education/EducationController.java | 4 +- .../education/TrainingCombatTeams.java | 4 +- .../generator/AbstractPersonnelGenerator.java | 2 +- .../generator/AbstractSkillGenerator.java | 4 +- .../AbstractSpecialAbilityGenerator.java | 2 +- .../generator/DefaultSkillGenerator.java | 5 +- .../personnel/{ => skills}/Skill.java | 3 +- .../{ => skills}/SkillDeprecationTool.java | 3 +- .../personnel/{ => skills}/SkillType.java | 22 +- .../personnel/{ => skills}/Skills.java | 3 +- .../RetirementDefectionTracker.java | 2 +- .../campaign/randomEvents/RoninOffer.java | 2 +- .../prisoners/EventEffectsManager.java | 42 +-- .../prisoners/PrisonEscapeScenario.java | 2 +- .../campaign/rating/AbstractUnitRating.java | 2 +- .../AverageExperienceRating.java | 12 +- .../CamOpsReputation/CommandRating.java | 12 +- .../FieldManualMercRevDragoonsRating.java | 4 +- .../storypoint/CreateCharacterStoryPoint.java | 16 +- .../stratcon/StratconRulesManager.java | 10 +- .../stratcon/SupportPointNegotiation.java | 18 +- MekHQ/src/mekhq/campaign/unit/Unit.java | 2 +- .../unit/actions/HirePersonnelUnitAction.java | 6 +- .../AbstractCompanyGenerator.java | 36 ++- MekHQ/src/mekhq/gui/BriefingTab.java | 2 +- MekHQ/src/mekhq/gui/CampaignGUI.java | 2 +- MekHQ/src/mekhq/gui/CommandCenterTab.java | 161 +++++++---- MekHQ/src/mekhq/gui/RepairTab.java | 4 +- MekHQ/src/mekhq/gui/WarehouseTab.java | 4 +- .../adapter/PersonnelTableMouseAdapter.java | 13 +- .../gui/adapter/TaskTableMouseAdapter.java | 15 +- .../campaignOptions/CampaignOptionsPane.java | 2 +- .../campaignOptions/CreateCampaignPreset.java | 27 +- .../contents/AbilitiesTab.java | 187 ++++++------ .../contents/AdvancementTab.java | 2 +- .../contents/EquipmentAndSuppliesTab.java | 2 +- .../campaignOptions/contents/MarketsTab.java | 2 +- .../contents/PersonnelTab.java | 2 +- .../campaignOptions/contents/RulesetsTab.java | 34 ++- .../campaignOptions/contents/SkillsTab.java | 42 ++- MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java | 4 +- .../gui/dialog/CampaignExportWizard.java | 2 +- .../gui/dialog/CreateCharacterDialog.java | 8 +- .../gui/dialog/CustomizePersonDialog.java | 8 +- .../mekhq/gui/dialog/DataLoadingDialog.java | 42 +-- .../gui/dialog/EditSkillPerquisiteDialog.java | 12 +- .../gui/dialog/EditSpecialAbilityDialog.java | 268 +++++++++--------- MekHQ/src/mekhq/gui/dialog/MRMSDialog.java | 2 +- .../mekhq/gui/dialog/NewContractDialog.java | 2 +- .../gui/enums/PersonnelTableModelColumn.java | 2 +- MekHQ/src/mekhq/gui/model/CrewListModel.java | 16 +- MekHQ/src/mekhq/gui/model/DocTableModel.java | 5 +- MekHQ/src/mekhq/gui/model/TaskTableModel.java | 23 +- MekHQ/src/mekhq/gui/model/TechTableModel.java | 4 +- .../gui/stratcon/StratconScenarioWizard.java | 2 +- .../mekhq/gui/view/ContractSummaryPanel.java | 25 +- MekHQ/src/mekhq/gui/view/ForceViewPanel.java | 2 +- .../mekhq/gui/view/LanceAssignmentView.java | 2 +- MekHQ/src/mekhq/gui/view/PersonViewPanel.java | 18 +- .../mekhq/module/atb/AtBEventProcessor.java | 2 +- .../mekhq/module/atb/PersonnelMarketAtB.java | 2 +- MekHQ/src/mekhq/service/mrms/MRMSOption.java | 7 +- MekHQ/src/mekhq/service/mrms/MRMSService.java | 4 +- .../campaign/autoresolve/ResolverTest.java | 48 +++- .../mekhq/campaign/parts/MekLocationTest.java | 14 +- .../personnel/education/AcademyTests.java | 20 +- .../prisoners/EventEffectsManagerTest.java | 48 ++-- .../PrisonerMissionEndEventTest.java | 28 +- .../FieldManualMercRevDragoonsRatingTest.java | 9 +- .../UntreatedPersonnelNagLogicTest.java | 4 +- 136 files changed, 1244 insertions(+), 1055 deletions(-) rename MekHQ/src/mekhq/campaign/personnel/{ => skills}/Skill.java (99%) rename MekHQ/src/mekhq/campaign/personnel/{ => skills}/SkillDeprecationTool.java (99%) rename MekHQ/src/mekhq/campaign/personnel/{ => skills}/SkillType.java (99%) rename MekHQ/src/mekhq/campaign/personnel/{ => skills}/Skills.java (97%) diff --git a/MekHQ/src/mekhq/CampaignPreset.java b/MekHQ/src/mekhq/CampaignPreset.java index 76574d5344e..257c5d0b8a7 100644 --- a/MekHQ/src/mekhq/CampaignPreset.java +++ b/MekHQ/src/mekhq/CampaignPreset.java @@ -59,9 +59,9 @@ import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.ranks.RankSystem; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Factions; import mekhq.campaign.universe.Planet; diff --git a/MekHQ/src/mekhq/Utilities.java b/MekHQ/src/mekhq/Utilities.java index 07f85b17026..fbb4cf99044 100644 --- a/MekHQ/src/mekhq/Utilities.java +++ b/MekHQ/src/mekhq/Utilities.java @@ -45,7 +45,7 @@ import mekhq.campaign.finances.Money; import mekhq.campaign.mission.IPlayerSettings; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Phenotype; import mekhq.campaign.unit.CrewType; @@ -69,7 +69,7 @@ import java.util.function.Consumer; import static java.lang.Math.max; -import static mekhq.campaign.personnel.SkillType.*; +import static mekhq.campaign.personnel.skills.SkillType.*; public class Utilities { private static final MMLogger logger = MMLogger.create(Utilities.class); diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index a33e8f8bf94..0e472418d11 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -160,8 +160,6 @@ import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; import mekhq.campaign.personnel.RandomDependents; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.autoAwards.AutoAwardsController; import mekhq.campaign.personnel.death.RandomDeath; @@ -191,6 +189,8 @@ import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.RankValidator; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker; import mekhq.campaign.randomEvents.GrayMonday; import mekhq.campaign.randomEvents.RandomEventLibraries; diff --git a/MekHQ/src/mekhq/campaign/CampaignOptions.java b/MekHQ/src/mekhq/campaign/CampaignOptions.java index 0cf1915afed..91a1124befa 100644 --- a/MekHQ/src/mekhq/campaign/CampaignOptions.java +++ b/MekHQ/src/mekhq/campaign/CampaignOptions.java @@ -62,8 +62,8 @@ import mekhq.campaign.market.enums.UnitMarketMethod; import mekhq.campaign.mission.enums.CombatRole; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.*; +import mekhq.campaign.personnel.skills.Skills; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerCaptureStyle; import mekhq.campaign.rating.UnitRatingMethod; import mekhq.gui.campaignOptions.enums.ProcurementPersonnelPick; diff --git a/MekHQ/src/mekhq/campaign/CampaignSummary.java b/MekHQ/src/mekhq/campaign/CampaignSummary.java index 9403a4de192..92d72ed249a 100644 --- a/MekHQ/src/mekhq/campaign/CampaignSummary.java +++ b/MekHQ/src/mekhq/campaign/CampaignSummary.java @@ -51,7 +51,7 @@ import mekhq.campaign.mission.Mission; import mekhq.campaign.mission.enums.MissionStatus; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.CargoStatistics; import mekhq.campaign.unit.HangarStatistics; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/src/mekhq/campaign/MercRosterAccess.java b/MekHQ/src/mekhq/campaign/MercRosterAccess.java index 2df490a171b..c7e48421f00 100644 --- a/MekHQ/src/mekhq/campaign/MercRosterAccess.java +++ b/MekHQ/src/mekhq/campaign/MercRosterAccess.java @@ -27,24 +27,31 @@ */ package mekhq.campaign; +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import javax.swing.SwingWorker; + import megamek.common.UnitType; import megamek.logging.MMLogger; import mekhq.campaign.force.Force; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Profession; import mekhq.campaign.personnel.ranks.Rank; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; -import javax.swing.*; -import java.sql.*; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; - public class MercRosterAccess extends SwingWorker { private static final MMLogger logger = MMLogger.create(MercRosterAccess.class); diff --git a/MekHQ/src/mekhq/campaign/againstTheBot/AtBConfiguration.java b/MekHQ/src/mekhq/campaign/againstTheBot/AtBConfiguration.java index 920554093cd..3fc4de6e6f1 100644 --- a/MekHQ/src/mekhq/campaign/againstTheBot/AtBConfiguration.java +++ b/MekHQ/src/mekhq/campaign/againstTheBot/AtBConfiguration.java @@ -28,15 +28,32 @@ */ package mekhq.campaign.againstTheBot; -import megamek.common.*; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.ResourceBundle; +import java.util.function.Function; +import javax.xml.parsers.DocumentBuilder; + +import megamek.common.Compute; +import megamek.common.EntityWeightClass; +import megamek.common.MekSummary; +import megamek.common.MekSummaryCache; +import megamek.common.TargetRoll; +import megamek.common.UnitType; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.universe.Faction; import mekhq.utilities.MHQXMLUtility; @@ -45,14 +62,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import javax.xml.parsers.DocumentBuilder; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.time.LocalDate; -import java.util.*; -import java.util.function.Function; - /** * @author Neoancient * diff --git a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java index c90df5ff939..9b337ff9ca7 100644 --- a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java +++ b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java @@ -29,7 +29,7 @@ import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; import static mekhq.campaign.force.Force.FORCE_NONE; -import static mekhq.campaign.personnel.SkillDeprecationTool.DEPRECATED_SKILLS; +import static mekhq.campaign.personnel.skills.SkillDeprecationTool.DEPRECATED_SKILLS; import static org.apache.commons.lang3.ObjectUtils.firstNonNull; import java.io.File; @@ -108,13 +108,13 @@ import mekhq.campaign.parts.equipment.MissingMASC; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillDeprecationTool; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.education.EducationController; import mekhq.campaign.personnel.enums.FamilialRelationshipType; import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.RankValidator; +import mekhq.campaign.personnel.skills.SkillDeprecationTool; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.personnel.turnoverAndRetention.RetirementDefectionTracker; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.storyarc.StoryArc; diff --git a/MekHQ/src/mekhq/campaign/market/PersonnelMarket.java b/MekHQ/src/mekhq/campaign/market/PersonnelMarket.java index ba31853ee13..1b9ce39a976 100644 --- a/MekHQ/src/mekhq/campaign/market/PersonnelMarket.java +++ b/MekHQ/src/mekhq/campaign/market/PersonnelMarket.java @@ -28,8 +28,21 @@ */ package mekhq.campaign.market; +import java.io.PrintWriter; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import megamek.Version; -import megamek.common.*; +import megamek.common.Entity; +import megamek.common.MekFileParser; +import megamek.common.MekSummary; +import megamek.common.MekSummaryCache; +import megamek.common.TargetRoll; import megamek.common.event.Subscribe; import megamek.common.loaders.EntityLoadingException; import megamek.logging.MMLogger; @@ -38,8 +51,8 @@ import mekhq.campaign.event.MarketNewPersonnelEvent; import mekhq.campaign.event.OptionsChangedEvent; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.unit.HangarStatistics; import mekhq.campaign.universe.PlanetarySystem; @@ -49,10 +62,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.time.LocalDate; -import java.util.*; - public class PersonnelMarket { private static final MMLogger logger = MMLogger.create(PersonnelMarket.class); diff --git a/MekHQ/src/mekhq/campaign/market/contractMarket/AtbMonthlyContractMarket.java b/MekHQ/src/mekhq/campaign/market/contractMarket/AtbMonthlyContractMarket.java index b7047abbfdf..5b617dd35fd 100644 --- a/MekHQ/src/mekhq/campaign/market/contractMarket/AtbMonthlyContractMarket.java +++ b/MekHQ/src/mekhq/campaign/market/contractMarket/AtbMonthlyContractMarket.java @@ -54,8 +54,8 @@ import mekhq.campaign.mission.enums.AtBContractType; import mekhq.campaign.mission.enums.ContractCommandRights; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.universe.Faction; diff --git a/MekHQ/src/mekhq/campaign/market/contractMarket/CamOpsContractMarket.java b/MekHQ/src/mekhq/campaign/market/contractMarket/CamOpsContractMarket.java index 7b3e3cffb2c..9729f86b451 100644 --- a/MekHQ/src/mekhq/campaign/market/contractMarket/CamOpsContractMarket.java +++ b/MekHQ/src/mekhq/campaign/market/contractMarket/CamOpsContractMarket.java @@ -49,7 +49,7 @@ import mekhq.campaign.mission.enums.AtBContractType; import mekhq.campaign.mission.enums.ContractCommandRights; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.universe.Faction; diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java index 193afb1e0eb..1b532e587d2 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java @@ -27,6 +27,20 @@ */ package mekhq.campaign.mission; +import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerAlignment; +import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerFaction; +import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Allied; +import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.PlanetOwner; + +import java.io.PrintWriter; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import megamek.Version; import megamek.common.Entity; import megamek.common.annotations.Nullable; @@ -39,7 +53,7 @@ import mekhq.campaign.mission.ScenarioForceTemplate.ForceGenerationMethod; import mekhq.campaign.mission.atb.AtBScenarioModifier; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.unit.Unit; import mekhq.utilities.MHQXMLUtility; @@ -48,15 +62,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.text.ParseException; -import java.util.*; - -import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerAlignment; -import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerFaction; -import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Allied; -import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.PlanetOwner; - /** * Data structure intended to hold data relevant to AtB Dynamic Scenarios (AtB 3.0) * @author NickAragua diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java index f3af2a89072..8da857907e2 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java @@ -27,8 +27,35 @@ */ package mekhq.campaign.mission; +import static java.lang.Math.max; +import static java.lang.Math.round; +import static megamek.client.ratgenerator.MissionRole.*; +import static megamek.codeUtilities.MathUtility.clamp; +import static megamek.common.Compute.d6; +import static megamek.common.Compute.randomInt; +import static megamek.common.UnitType.*; +import static megamek.common.planetaryconditions.Wind.TORNADO_F4; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; +import static mekhq.campaign.mission.Scenario.T_GROUND; +import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_AERO_MIX; +import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_CIVILIANS; +import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_MIX; +import static mekhq.campaign.personnel.skills.SkillType.EXP_ELITE; +import static mekhq.campaign.universe.IUnitGenerator.unitTypeSupportsWeightClass; +import static mekhq.utilities.EntityUtilities.getEntityFromUnitId; + +import java.io.File; +import java.time.LocalDate; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + import megamek.client.bot.princess.CardinalEdge; -import megamek.client.generator.*; +import megamek.client.generator.RandomGenderGenerator; +import megamek.client.generator.RandomNameGenerator; +import megamek.client.generator.RandomUnitGenerator; +import megamek.client.generator.ReconfigurationParameters; +import megamek.client.generator.TeamLoadOutGenerator; import megamek.client.generator.skillGenerators.AbstractSkillGenerator; import megamek.client.generator.skillGenerators.ModifiedConstantSkillGenerator; import megamek.client.ratgenerator.MissionRole; @@ -60,42 +87,30 @@ import mekhq.campaign.mission.atb.AtBScenarioModifier; import mekhq.campaign.mission.atb.AtBScenarioModifier.EventTiming; import mekhq.campaign.personnel.Bloodname; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.enums.Phenotype; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; -import mekhq.campaign.stratcon.*; +import mekhq.campaign.stratcon.StratconBiomeManifest; +import mekhq.campaign.stratcon.StratconCampaignState; +import mekhq.campaign.stratcon.StratconContractInitializer; +import mekhq.campaign.stratcon.StratconFacility; import mekhq.campaign.stratcon.StratconFacility.FacilityType; +import mekhq.campaign.stratcon.StratconScenario; +import mekhq.campaign.stratcon.StratconTrackState; import mekhq.campaign.unit.Unit; -import mekhq.campaign.universe.*; +import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Faction.Tag; +import mekhq.campaign.universe.Factions; +import mekhq.campaign.universe.IUnitGenerator; +import mekhq.campaign.universe.Planet; +import mekhq.campaign.universe.PlanetarySystem; +import mekhq.campaign.universe.Systems; +import mekhq.campaign.universe.UnitGeneratorParameters; import mekhq.campaign.universe.enums.EraFlag; import mekhq.campaign.universe.enums.HonorRating; import mekhq.campaign.universe.fameAndInfamy.BatchallFactions; -import java.io.File; -import java.time.LocalDate; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static java.lang.Math.max; -import static java.lang.Math.round; -import static megamek.client.ratgenerator.MissionRole.*; -import static megamek.codeUtilities.MathUtility.clamp; -import static megamek.common.Compute.d6; -import static megamek.common.Compute.randomInt; -import static megamek.common.UnitType.*; -import static megamek.common.planetaryconditions.Wind.TORNADO_F4; -import static mekhq.campaign.force.CombatTeam.getStandardForceSize; -import static mekhq.campaign.mission.Scenario.T_GROUND; -import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_AERO_MIX; -import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_CIVILIANS; -import static mekhq.campaign.mission.ScenarioForceTemplate.SPECIAL_UNIT_TYPE_ATB_MIX; -import static mekhq.campaign.personnel.SkillType.EXP_ELITE; -import static mekhq.campaign.universe.IUnitGenerator.unitTypeSupportsWeightClass; -import static mekhq.utilities.EntityUtilities.getEntityFromUnitId; - /** * This class handles the creation and substantive manipulation of * AtBDynamicScenarios diff --git a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java index 2503f173354..59282c64c7e 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBScenario.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBScenario.java @@ -28,16 +28,35 @@ */ package mekhq.campaign.mission; +import java.io.PrintWriter; +import java.text.ParseException; +import java.time.LocalDate; +import java.util.*; + import megamek.Version; import megamek.client.generator.TeamLoadOutGenerator; import megamek.codeUtilities.ObjectUtility; -import megamek.common.*; +import megamek.common.Board; +import megamek.common.BoardDimensions; +import megamek.common.Compute; +import megamek.common.Entity; +import megamek.common.EntityWeightClass; +import megamek.common.Infantry; +import megamek.common.TargetRoll; +import megamek.common.UnitType; +import megamek.common.WeatherRestriction; import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; import megamek.common.icons.Camouflage; import megamek.common.options.OptionsConstants; import megamek.common.planetaryconditions.Atmosphere; -import megamek.common.planetaryconditions.*; +import megamek.common.planetaryconditions.BlowingSand; +import megamek.common.planetaryconditions.EMI; +import megamek.common.planetaryconditions.Fog; +import megamek.common.planetaryconditions.Light; +import megamek.common.planetaryconditions.PlanetaryConditions; +import megamek.common.planetaryconditions.Weather; +import megamek.common.planetaryconditions.Wind; import megamek.common.util.fileUtils.MegaMekFile; import megamek.logging.MMLogger; import megamek.utilities.BoardClassifier; @@ -53,7 +72,7 @@ import mekhq.campaign.mission.ScenarioObjective.ObjectiveCriterion; import mekhq.campaign.mission.atb.IAtBScenario; import mekhq.campaign.mission.enums.CombatRole; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.stratcon.StratconBiomeManifest; import mekhq.campaign.stratcon.StratconBiomeManifest.MapTypeList; @@ -61,17 +80,16 @@ import mekhq.campaign.stratcon.StratconScenario; import mekhq.campaign.stratcon.StratconTrackState; import mekhq.campaign.unit.Unit; -import mekhq.campaign.universe.*; +import mekhq.campaign.universe.Faction; +import mekhq.campaign.universe.Factions; +import mekhq.campaign.universe.Planet; +import mekhq.campaign.universe.PlanetarySystem; +import mekhq.campaign.universe.Systems; import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.text.ParseException; -import java.time.LocalDate; -import java.util.*; - /** * @author Neoancient */ diff --git a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java index 115d161ba46..0b5b603f5fb 100644 --- a/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java +++ b/MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifierApplicator.java @@ -27,11 +27,21 @@ */ package mekhq.campaign.mission.atb; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; +import static mekhq.campaign.mission.AtBDynamicScenarioFactory.*; + +import java.util.UUID; + import megamek.client.generator.enums.SkillGeneratorType; import megamek.client.generator.skillGenerators.AbstractSkillGenerator; import megamek.client.generator.skillGenerators.ModifiedConstantSkillGenerator; import megamek.codeUtilities.MathUtility; -import megamek.common.*; +import megamek.common.Board; +import megamek.common.Compute; +import megamek.common.Entity; +import megamek.common.HitData; +import megamek.common.Mounted; +import megamek.common.ToHitData; import megamek.common.enums.SkillLevel; import megamek.common.options.OptionsConstants; import megamek.logging.MMLogger; @@ -43,18 +53,13 @@ import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment; import mekhq.campaign.mission.ScenarioObjective; import mekhq.campaign.mission.atb.AtBScenarioModifier.EventTiming; -import mekhq.campaign.personnel.SkillType; -import mekhq.campaign.personnel.Skills; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.campaign.personnel.skills.Skills; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Factions; -import java.util.UUID; - -import static mekhq.campaign.force.CombatTeam.getStandardForceSize; -import static mekhq.campaign.mission.AtBDynamicScenarioFactory.*; - /** * Class that handles the application of scenario modifier actions to * AtBDynamicScenarios diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index b4c28445906..38a216c5e34 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -27,6 +27,28 @@ */ package mekhq.campaign.mission.resupplyAndCaches; +import static java.lang.Math.floor; +import static java.lang.Math.max; +import static java.lang.Math.min; +import static java.lang.Math.round; +import static megamek.common.MiscType.F_SPONSON_TURRET; +import static megamek.common.enums.SkillLevel.NONE; +import static mekhq.campaign.force.CombatTeam.getStandardForceSize; +import static mekhq.campaign.force.ForceType.CONVOY; +import static mekhq.campaign.force.ForceType.STANDARD; +import static mekhq.campaign.market.procurement.Procurement.getFactionTechCode; +import static mekhq.utilities.EntityUtilities.getEntityFromUnitId; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + import megamek.common.Entity; import megamek.common.Mek; import megamek.logging.MMLogger; @@ -38,28 +60,18 @@ import mekhq.campaign.mission.AtBContract; import mekhq.campaign.parts.*; import mekhq.campaign.parts.enums.PartQuality; -import mekhq.campaign.parts.equipment.*; +import mekhq.campaign.parts.equipment.AmmoBin; +import mekhq.campaign.parts.equipment.BattleArmorEquipmentPart; +import mekhq.campaign.parts.equipment.EquipmentPart; +import mekhq.campaign.parts.equipment.HeatSink; +import mekhq.campaign.parts.equipment.JumpJet; +import mekhq.campaign.parts.equipment.MASC; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.Faction; -import java.time.LocalDate; -import java.util.*; - -import static java.lang.Math.floor; -import static java.lang.Math.max; -import static java.lang.Math.min; -import static java.lang.Math.round; -import static megamek.common.MiscType.F_SPONSON_TURRET; -import static megamek.common.enums.SkillLevel.NONE; -import static mekhq.campaign.force.CombatTeam.getStandardForceSize; -import static mekhq.campaign.force.ForceType.CONVOY; -import static mekhq.campaign.force.ForceType.STANDARD; -import static mekhq.campaign.market.procurement.Procurement.getFactionTechCode; -import static mekhq.utilities.EntityUtilities.getEntityFromUnitId; - /** * The {@code Resupply} class manages the resupply process during a campaign. * It calculates the required resupply resources, organizes parts pools (e.g., parts, armor, ammo), diff --git a/MekHQ/src/mekhq/campaign/mod/am/InjuryUtil.java b/MekHQ/src/mekhq/campaign/mod/am/InjuryUtil.java index 29dd6e4fee7..cd0cba0bb92 100644 --- a/MekHQ/src/mekhq/campaign/mod/am/InjuryUtil.java +++ b/MekHQ/src/mekhq/campaign/mod/am/InjuryUtil.java @@ -27,8 +27,13 @@ */ package mekhq.campaign.mod.am; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.IntUnaryOperator; @@ -37,7 +42,8 @@ import megamek.common.Compute; import megamek.common.Entity; import megamek.common.Mek; -import mekhq.campaign.*; +import mekhq.campaign.Campaign; +import mekhq.campaign.GameEffect; import mekhq.campaign.log.MedicalLogger; import mekhq.campaign.log.ServiceLogger; import mekhq.campaign.personnel.BodyLocation; @@ -45,9 +51,9 @@ import mekhq.campaign.personnel.InjuryType; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.GenderDescriptors; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; /** diff --git a/MekHQ/src/mekhq/campaign/parts/AeroHeatSink.java b/MekHQ/src/mekhq/campaign/parts/AeroHeatSink.java index e20e0fd1c29..342cf21d036 100644 --- a/MekHQ/src/mekhq/campaign/parts/AeroHeatSink.java +++ b/MekHQ/src/mekhq/campaign/parts/AeroHeatSink.java @@ -28,17 +28,22 @@ */ package mekhq.campaign.parts; -import megamek.common.*; +import java.io.PrintWriter; + +import megamek.common.Aero; +import megamek.common.Compute; +import megamek.common.Entity; +import megamek.common.EquipmentType; +import megamek.common.TechAdvancement; +import megamek.common.TechConstants; import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; - /** * @author Jay Lawson (jaylawson39 at yahoo.com) */ diff --git a/MekHQ/src/mekhq/campaign/parts/AeroLifeSupport.java b/MekHQ/src/mekhq/campaign/parts/AeroLifeSupport.java index 6c0cf798f05..0237887b995 100644 --- a/MekHQ/src/mekhq/campaign/parts/AeroLifeSupport.java +++ b/MekHQ/src/mekhq/campaign/parts/AeroLifeSupport.java @@ -30,12 +30,6 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import mekhq.campaign.parts.enums.PartRepairType; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Compute; import megamek.common.Dropship; @@ -43,9 +37,14 @@ import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; import megamek.common.TechAdvancement; -import mekhq.utilities.MHQXMLUtility; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/AeroSensor.java b/MekHQ/src/mekhq/campaign/parts/AeroSensor.java index 3adebf3eb46..e693a208ffb 100644 --- a/MekHQ/src/mekhq/campaign/parts/AeroSensor.java +++ b/MekHQ/src/mekhq/campaign/parts/AeroSensor.java @@ -28,18 +28,24 @@ */ package mekhq.campaign.parts; -import megamek.common.*; +import java.io.PrintWriter; + +import megamek.common.Aero; +import megamek.common.Compute; +import megamek.common.Dropship; +import megamek.common.Entity; +import megamek.common.Jumpship; +import megamek.common.SimpleTechLevel; +import megamek.common.TechAdvancement; import megamek.common.annotations.Nullable; -import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; - /** * @author Jay Lawson (jaylawson39 at yahoo.com) */ diff --git a/MekHQ/src/mekhq/campaign/parts/Armor.java b/MekHQ/src/mekhq/campaign/parts/Armor.java index 5bb3dd44a73..61fe619a37f 100644 --- a/MekHQ/src/mekhq/campaign/parts/Armor.java +++ b/MekHQ/src/mekhq/campaign/parts/Armor.java @@ -46,7 +46,7 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.work.IAcquisitionWork; import mekhq.campaign.work.WorkTime; import mekhq.utilities.MHQXMLUtility; diff --git a/MekHQ/src/mekhq/campaign/parts/Avionics.java b/MekHQ/src/mekhq/campaign/parts/Avionics.java index 30d0dba9409..d6e91730177 100644 --- a/MekHQ/src/mekhq/campaign/parts/Avionics.java +++ b/MekHQ/src/mekhq/campaign/parts/Avionics.java @@ -30,23 +30,13 @@ import java.io.PrintWriter; +import megamek.common.*; import megamek.common.annotations.Nullable; +import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; import org.w3c.dom.Node; -import megamek.common.Aero; -import megamek.common.Compute; -import megamek.common.CriticalSlot; -import megamek.common.Dropship; -import megamek.common.Entity; -import megamek.common.EquipmentType; -import megamek.common.IAero; -import megamek.common.Jumpship; -import megamek.common.LandAirMek; -import megamek.common.TechAdvancement; -import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; - /** * @author Jay Lawson (jaylawson39 at yahoo.com) */ diff --git a/MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java b/MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java index 85e7c3a331c..6e6142ed721 100644 --- a/MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java +++ b/MekHQ/src/mekhq/campaign/parts/BattleArmorSuit.java @@ -31,9 +31,6 @@ import java.io.PrintWriter; import java.util.ArrayList; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; @@ -42,10 +39,12 @@ import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.BattleArmorEquipmentPart; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.TestUnit; import mekhq.campaign.unit.Unit; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Battle Armor suits are crazy - you can't crit the equipment in them, so diff --git a/MekHQ/src/mekhq/campaign/parts/CombatInformationCenter.java b/MekHQ/src/mekhq/campaign/parts/CombatInformationCenter.java index afde99402ed..b1951b8a872 100644 --- a/MekHQ/src/mekhq/campaign/parts/CombatInformationCenter.java +++ b/MekHQ/src/mekhq/campaign/parts/CombatInformationCenter.java @@ -29,19 +29,18 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Compute; import megamek.common.Entity; import megamek.common.Jumpship; import megamek.common.TechAdvancement; -import mekhq.utilities.MHQXMLUtility; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/DropshipDockingCollar.java b/MekHQ/src/mekhq/campaign/parts/DropshipDockingCollar.java index 163d5ccfd59..7fe2adb0451 100644 --- a/MekHQ/src/mekhq/campaign/parts/DropshipDockingCollar.java +++ b/MekHQ/src/mekhq/campaign/parts/DropshipDockingCollar.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Dropship; import megamek.common.Entity; @@ -42,8 +39,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/EnginePart.java b/MekHQ/src/mekhq/campaign/parts/EnginePart.java index 1d6f6eabd1d..3d460a914ee 100644 --- a/MekHQ/src/mekhq/campaign/parts/EnginePart.java +++ b/MekHQ/src/mekhq/campaign/parts/EnginePart.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.*; import megamek.common.annotations.Nullable; import megamek.common.verifier.TestEntity; @@ -40,9 +37,11 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/FireControlSystem.java b/MekHQ/src/mekhq/campaign/parts/FireControlSystem.java index 57bcada9e70..fd68d4670b0 100644 --- a/MekHQ/src/mekhq/campaign/parts/FireControlSystem.java +++ b/MekHQ/src/mekhq/campaign/parts/FireControlSystem.java @@ -30,11 +30,6 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Compute; import megamek.common.Dropship; @@ -42,9 +37,13 @@ import megamek.common.Jumpship; import megamek.common.SmallCraft; import megamek.common.TechAdvancement; -import mekhq.utilities.MHQXMLUtility; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/GravDeck.java b/MekHQ/src/mekhq/campaign/parts/GravDeck.java index 11194ab0694..7f0a7b96bcb 100644 --- a/MekHQ/src/mekhq/campaign/parts/GravDeck.java +++ b/MekHQ/src/mekhq/campaign/parts/GravDeck.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Entity; import megamek.common.Jumpship; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/JumpshipDockingCollar.java b/MekHQ/src/mekhq/campaign/parts/JumpshipDockingCollar.java index a971c229e21..5bb4a57bbe3 100644 --- a/MekHQ/src/mekhq/campaign/parts/JumpshipDockingCollar.java +++ b/MekHQ/src/mekhq/campaign/parts/JumpshipDockingCollar.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.DockingCollar; import megamek.common.Entity; @@ -42,8 +39,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KFChargingSystem.java b/MekHQ/src/mekhq/campaign/parts/KFChargingSystem.java index 8f6b04fd81e..cdca8a70c97 100644 --- a/MekHQ/src/mekhq/campaign/parts/KFChargingSystem.java +++ b/MekHQ/src/mekhq/campaign/parts/KFChargingSystem.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KFDriveCoil.java b/MekHQ/src/mekhq/campaign/parts/KFDriveCoil.java index 66d94a19ffa..c68eb6cd71f 100644 --- a/MekHQ/src/mekhq/campaign/parts/KFDriveCoil.java +++ b/MekHQ/src/mekhq/campaign/parts/KFDriveCoil.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KFDriveController.java b/MekHQ/src/mekhq/campaign/parts/KFDriveController.java index c62eef11f10..44a6de11006 100644 --- a/MekHQ/src/mekhq/campaign/parts/KFDriveController.java +++ b/MekHQ/src/mekhq/campaign/parts/KFDriveController.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KFFieldInitiator.java b/MekHQ/src/mekhq/campaign/parts/KFFieldInitiator.java index 77459f35054..5b7785ee84a 100644 --- a/MekHQ/src/mekhq/campaign/parts/KFFieldInitiator.java +++ b/MekHQ/src/mekhq/campaign/parts/KFFieldInitiator.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KFHeliumTank.java b/MekHQ/src/mekhq/campaign/parts/KFHeliumTank.java index facb6113152..bf5fa7adff4 100644 --- a/MekHQ/src/mekhq/campaign/parts/KFHeliumTank.java +++ b/MekHQ/src/mekhq/campaign/parts/KFHeliumTank.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/KfBoom.java b/MekHQ/src/mekhq/campaign/parts/KfBoom.java index 8544e82e8d1..19735a81f04 100644 --- a/MekHQ/src/mekhq/campaign/parts/KfBoom.java +++ b/MekHQ/src/mekhq/campaign/parts/KfBoom.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Dropship; import megamek.common.Entity; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/LFBattery.java b/MekHQ/src/mekhq/campaign/parts/LFBattery.java index ec5afd88de4..22dcb2a7ad5 100644 --- a/MekHQ/src/mekhq/campaign/parts/LFBattery.java +++ b/MekHQ/src/mekhq/campaign/parts/LFBattery.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; import java.util.StringJoiner; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.Jumpship; import megamek.common.SimpleTechLevel; @@ -41,8 +38,10 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author MKerensky diff --git a/MekHQ/src/mekhq/campaign/parts/LandingGear.java b/MekHQ/src/mekhq/campaign/parts/LandingGear.java index 105f03e8fd9..a43725e5c45 100644 --- a/MekHQ/src/mekhq/campaign/parts/LandingGear.java +++ b/MekHQ/src/mekhq/campaign/parts/LandingGear.java @@ -30,10 +30,6 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import org.w3c.dom.Node; - import megamek.common.Aero; import megamek.common.Compute; import megamek.common.CriticalSlot; @@ -42,8 +38,11 @@ import megamek.common.EquipmentType; import megamek.common.LandAirMek; import megamek.common.TechAdvancement; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MekActuator.java b/MekHQ/src/mekhq/campaign/parts/MekActuator.java index 23d5a5b83fc..2a6cf7d345d 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekActuator.java +++ b/MekHQ/src/mekhq/campaign/parts/MekActuator.java @@ -28,18 +28,24 @@ */ package mekhq.campaign.parts; -import megamek.common.*; +import java.io.PrintWriter; + +import megamek.common.BipedMek; +import megamek.common.Compute; +import megamek.common.CriticalSlot; +import megamek.common.Mek; +import megamek.common.SimpleTechLevel; +import megamek.common.TechAdvancement; +import megamek.common.TechConstants; import megamek.common.annotations.Nullable; -import mekhq.utilities.MHQXMLUtility; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; - /** * @author Jay Lawson (jaylawson39 at yahoo.com) */ diff --git a/MekHQ/src/mekhq/campaign/parts/MekCockpit.java b/MekHQ/src/mekhq/campaign/parts/MekCockpit.java index 3d1f463d324..919a7818143 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekCockpit.java +++ b/MekHQ/src/mekhq/campaign/parts/MekCockpit.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.Entity; @@ -43,8 +40,10 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MekGyro.java b/MekHQ/src/mekhq/campaign/parts/MekGyro.java index 404ec000fce..d3ea42d4bec 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekGyro.java +++ b/MekHQ/src/mekhq/campaign/parts/MekGyro.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.Mek; @@ -42,8 +39,10 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MekLifeSupport.java b/MekHQ/src/mekhq/campaign/parts/MekLifeSupport.java index 75cee504fab..ae7da2afcab 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekLifeSupport.java +++ b/MekHQ/src/mekhq/campaign/parts/MekLifeSupport.java @@ -30,18 +30,17 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import mekhq.campaign.parts.enums.PartRepairType; -import org.w3c.dom.Node; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.Entity; import megamek.common.Mek; import megamek.common.TechAdvancement; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MekLocation.java b/MekHQ/src/mekhq/campaign/parts/MekLocation.java index 3556ddc571d..bddfc376f21 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/MekLocation.java @@ -35,9 +35,6 @@ import java.util.StringJoiner; import java.util.stream.IntStream; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.codeUtilities.MathUtility; import megamek.common.*; import megamek.common.annotations.Nullable; @@ -49,11 +46,13 @@ import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.EquipmentPart; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.WorkTime; import mekhq.utilities.MHQXMLUtility; import mekhq.utilities.ReportingUtilities; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MekSensor.java b/MekHQ/src/mekhq/campaign/parts/MekSensor.java index fb73ab0889c..02537ffead8 100644 --- a/MekHQ/src/mekhq/campaign/parts/MekSensor.java +++ b/MekHQ/src/mekhq/campaign/parts/MekSensor.java @@ -30,19 +30,18 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import mekhq.campaign.parts.enums.PartRepairType; -import org.w3c.dom.Node; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.Entity; import megamek.common.Mek; import megamek.common.TechAdvancement; import megamek.common.TechConstants; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/MissingPart.java b/MekHQ/src/mekhq/campaign/parts/MissingPart.java index 04ddfb26726..938aee370eb 100644 --- a/MekHQ/src/mekhq/campaign/parts/MissingPart.java +++ b/MekHQ/src/mekhq/campaign/parts/MissingPart.java @@ -28,6 +28,8 @@ */ package mekhq.campaign.parts; +import java.io.PrintWriter; + import megamek.common.ITechnology; import megamek.common.TargetRoll; import megamek.common.annotations.Nullable; @@ -35,14 +37,12 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.equipment.MissingAmmoBin; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IAcquisitionWork; import mekhq.campaign.work.WorkTime; import mekhq.utilities.ReportingUtilities; -import java.io.PrintWriter; - /** * A missing part is a placeholder on a unit to indicate that a replacement * task needs to be performed diff --git a/MekHQ/src/mekhq/campaign/parts/OmniPod.java b/MekHQ/src/mekhq/campaign/parts/OmniPod.java index 9fc8358c134..e7c57c1395c 100644 --- a/MekHQ/src/mekhq/campaign/parts/OmniPod.java +++ b/MekHQ/src/mekhq/campaign/parts/OmniPod.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Entity; import megamek.common.EquipmentType; @@ -47,8 +44,10 @@ import mekhq.campaign.parts.equipment.HeatSink; import mekhq.campaign.parts.equipment.JumpJet; import mekhq.campaign.parts.equipment.MASC; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * An empty omnipod, which can be purchased or created when equipment is removed diff --git a/MekHQ/src/mekhq/campaign/parts/Part.java b/MekHQ/src/mekhq/campaign/parts/Part.java index 8afad467e93..5c1747e6605 100644 --- a/MekHQ/src/mekhq/campaign/parts/Part.java +++ b/MekHQ/src/mekhq/campaign/parts/Part.java @@ -28,8 +28,24 @@ */ package mekhq.campaign.parts; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.ResourceBundle; +import java.util.StringJoiner; +import java.util.UUID; + import megamek.Version; -import megamek.common.*; +import megamek.common.Entity; +import megamek.common.EquipmentType; +import megamek.common.ITechnology; +import megamek.common.SimpleTechLevel; +import megamek.common.Tank; +import megamek.common.TargetRoll; +import megamek.common.TechAdvancement; +import megamek.common.WeaponType; import megamek.common.annotations.Nullable; import megamek.common.options.OptionsConstants; import megamek.logging.MMLogger; @@ -42,7 +58,7 @@ import mekhq.campaign.parts.equipment.MissingEquipmentPart; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IAcquisitionWork; import mekhq.campaign.work.IPartWork; @@ -54,9 +70,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.util.*; - /** * Parts do the lions share of the work of repairing, salvaging, reloading, * refueling, etc. diff --git a/MekHQ/src/mekhq/campaign/parts/PodSpace.java b/MekHQ/src/mekhq/campaign/parts/PodSpace.java index 5c8ff0bfa9b..51ffca22e18 100644 --- a/MekHQ/src/mekhq/campaign/parts/PodSpace.java +++ b/MekHQ/src/mekhq/campaign/parts/PodSpace.java @@ -27,7 +27,16 @@ */ package mekhq.campaign.parts; -import megamek.common.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import megamek.common.Aero; +import megamek.common.Entity; +import megamek.common.Mek; +import megamek.common.Tank; +import megamek.common.TargetRoll; import megamek.common.annotations.Nullable; import mekhq.MekHQ; import mekhq.campaign.Campaign; @@ -36,16 +45,11 @@ import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.AmmoBin; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IPartWork; import mekhq.utilities.ReportingUtilities; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - /** * An abstraction of all the pod-mounted equipment within a single location of an omni unit. Used * to group them together as recipients of a single tech action. diff --git a/MekHQ/src/mekhq/campaign/parts/ProtoMekArmActuator.java b/MekHQ/src/mekhq/campaign/parts/ProtoMekArmActuator.java index 1fdaae33bcd..e9a3e2d5794 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtoMekArmActuator.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtoMekArmActuator.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.ProtoMek; @@ -43,8 +40,10 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/ProtoMekJumpJet.java b/MekHQ/src/mekhq/campaign/parts/ProtoMekJumpJet.java index a1235099460..2c21ba2800b 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtoMekJumpJet.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtoMekJumpJet.java @@ -30,17 +30,16 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import org.w3c.dom.Node; - import megamek.common.CriticalSlot; import megamek.common.ProtoMek; import megamek.common.SimpleTechLevel; import megamek.common.TechAdvancement; import megamek.common.TechConstants; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * Legacy part that represents standard ProtoMek jump jets. diff --git a/MekHQ/src/mekhq/campaign/parts/ProtoMekLegActuator.java b/MekHQ/src/mekhq/campaign/parts/ProtoMekLegActuator.java index 68da0af5f99..1c37c8752d5 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtoMekLegActuator.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtoMekLegActuator.java @@ -30,18 +30,17 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import mekhq.campaign.parts.enums.PartRepairType; -import org.w3c.dom.Node; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.ProtoMek; import megamek.common.TechAdvancement; import megamek.common.TechConstants; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/ProtoMekLocation.java b/MekHQ/src/mekhq/campaign/parts/ProtoMekLocation.java index 3dd3e0559c7..a09ea7e3260 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtoMekLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtoMekLocation.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.CriticalSlot; import megamek.common.IArmorState; import megamek.common.ILocationExposureStatus; @@ -47,10 +44,12 @@ import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.work.WorkTime; import mekhq.utilities.MHQXMLUtility; import mekhq.utilities.ReportingUtilities; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/ProtoMekSensor.java b/MekHQ/src/mekhq/campaign/parts/ProtoMekSensor.java index dd1834b4368..001a5219f38 100644 --- a/MekHQ/src/mekhq/campaign/parts/ProtoMekSensor.java +++ b/MekHQ/src/mekhq/campaign/parts/ProtoMekSensor.java @@ -30,18 +30,17 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import mekhq.campaign.parts.enums.PartRepairType; -import org.w3c.dom.Node; - import megamek.common.Compute; import megamek.common.CriticalSlot; import megamek.common.ProtoMek; import megamek.common.TechAdvancement; import megamek.common.TechConstants; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import org.w3c.dom.Node; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/Refit.java b/MekHQ/src/mekhq/campaign/parts/Refit.java index 55fa64d63e0..dc5405e8021 100644 --- a/MekHQ/src/mekhq/campaign/parts/Refit.java +++ b/MekHQ/src/mekhq/campaign/parts/Refit.java @@ -62,7 +62,7 @@ import mekhq.campaign.parts.equipment.MissingEquipmentPart; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.unit.cleanup.EquipmentUnscrambler; import mekhq.campaign.unit.cleanup.EquipmentUnscramblerResult; diff --git a/MekHQ/src/mekhq/campaign/parts/SVEnginePart.java b/MekHQ/src/mekhq/campaign/parts/SVEnginePart.java index a7b2db70626..a73b8d7548f 100644 --- a/MekHQ/src/mekhq/campaign/parts/SVEnginePart.java +++ b/MekHQ/src/mekhq/campaign/parts/SVEnginePart.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Engine; import megamek.common.Entity; @@ -45,8 +42,10 @@ import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Engine for a support vehicle. An identical support vehicle engine will have diff --git a/MekHQ/src/mekhq/campaign/parts/SpacecraftCoolingSystem.java b/MekHQ/src/mekhq/campaign/parts/SpacecraftCoolingSystem.java index 000406d7fa6..697bf8453c8 100644 --- a/MekHQ/src/mekhq/campaign/parts/SpacecraftCoolingSystem.java +++ b/MekHQ/src/mekhq/campaign/parts/SpacecraftCoolingSystem.java @@ -29,9 +29,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Entity; import megamek.common.Jumpship; @@ -44,8 +41,10 @@ import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Container for SC/DS/JS/WS/SS heat sinks. Eliminates need for tracking diff --git a/MekHQ/src/mekhq/campaign/parts/SpacecraftEngine.java b/MekHQ/src/mekhq/campaign/parts/SpacecraftEngine.java index ca92de6fd3b..9f55a975815 100644 --- a/MekHQ/src/mekhq/campaign/parts/SpacecraftEngine.java +++ b/MekHQ/src/mekhq/campaign/parts/SpacecraftEngine.java @@ -30,27 +30,16 @@ import java.io.PrintWriter; +import megamek.common.*; import megamek.common.annotations.Nullable; +import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import megamek.common.Aero; -import megamek.common.CriticalSlot; -import megamek.common.Dropship; -import megamek.common.Entity; -import megamek.common.Jumpship; -import megamek.common.Mek; -import megamek.common.SimpleTechLevel; -import megamek.common.SmallCraft; -import megamek.common.TechAdvancement; -import megamek.common.TechConstants; -import megamek.common.Warship; -import mekhq.utilities.MHQXMLUtility; -import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; - /** * @author Jay Lawson (jaylawson39 at yahoo.com) */ diff --git a/MekHQ/src/mekhq/campaign/parts/TankLocation.java b/MekHQ/src/mekhq/campaign/parts/TankLocation.java index 3e19450b62d..3f5bcbdf13a 100644 --- a/MekHQ/src/mekhq/campaign/parts/TankLocation.java +++ b/MekHQ/src/mekhq/campaign/parts/TankLocation.java @@ -30,9 +30,6 @@ import java.io.PrintWriter; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.CriticalSlot; import megamek.common.IArmorState; import megamek.common.ILocationExposureStatus; @@ -47,8 +44,10 @@ import mekhq.campaign.finances.Money; import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/Thrusters.java b/MekHQ/src/mekhq/campaign/parts/Thrusters.java index ce6d9a8c56b..d8b790678b8 100644 --- a/MekHQ/src/mekhq/campaign/parts/Thrusters.java +++ b/MekHQ/src/mekhq/campaign/parts/Thrusters.java @@ -31,20 +31,19 @@ import java.io.PrintWriter; -import megamek.common.annotations.Nullable; -import mekhq.campaign.finances.Money; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.common.Aero; import megamek.common.Compute; import megamek.common.Entity; import megamek.common.Jumpship; import megamek.common.SmallCraft; import megamek.common.TechAdvancement; -import mekhq.utilities.MHQXMLUtility; +import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.finances.Money; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/VeeSensor.java b/MekHQ/src/mekhq/campaign/parts/VeeSensor.java index 6e631d6c284..1c2a1cc8ab8 100644 --- a/MekHQ/src/mekhq/campaign/parts/VeeSensor.java +++ b/MekHQ/src/mekhq/campaign/parts/VeeSensor.java @@ -40,7 +40,7 @@ import megamek.common.Tank; import megamek.common.TechAdvancement; import mekhq.campaign.Campaign; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; /** * @author Jay Lawson (jaylawson39 at yahoo.com) diff --git a/MekHQ/src/mekhq/campaign/parts/VeeStabilizer.java b/MekHQ/src/mekhq/campaign/parts/VeeStabilizer.java index 8801ac28111..3373e2c69c2 100644 --- a/MekHQ/src/mekhq/campaign/parts/VeeStabilizer.java +++ b/MekHQ/src/mekhq/campaign/parts/VeeStabilizer.java @@ -41,7 +41,7 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.finances.Money; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; /** diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java index b8149cd7990..1e0ff34f84e 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Person.java +++ b/MekHQ/src/mekhq/campaign/personnel/Person.java @@ -32,9 +32,9 @@ import static java.lang.Math.round; import static megamek.codeUtilities.MathUtility.clamp; import static megamek.common.Compute.randomInt; -import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup; import static megamek.common.enums.SkillLevel.REGULAR; -import static mekhq.campaign.personnel.SkillType.S_ADMIN; +import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup; +import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; import java.io.PrintWriter; import java.time.LocalDate; @@ -89,6 +89,9 @@ import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.RankValidator; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.campaign.personnel.skills.Skills; import mekhq.campaign.randomEvents.personalities.enums.Aggression; import mekhq.campaign.randomEvents.personalities.enums.Ambition; import mekhq.campaign.randomEvents.personalities.enums.Greed; diff --git a/MekHQ/src/mekhq/campaign/personnel/PersonUtility.java b/MekHQ/src/mekhq/campaign/personnel/PersonUtility.java index 69dd84e3304..4208ce169af 100644 --- a/MekHQ/src/mekhq/campaign/personnel/PersonUtility.java +++ b/MekHQ/src/mekhq/campaign/personnel/PersonUtility.java @@ -29,9 +29,9 @@ import static megamek.codeUtilities.MathUtility.clamp; import static megamek.common.Compute.d6; -import static mekhq.campaign.personnel.SkillType.*; import static mekhq.campaign.personnel.enums.PersonnelRole.*; import static mekhq.campaign.personnel.generator.AbstractSkillGenerator.addSkill; +import static mekhq.campaign.personnel.skills.SkillType.*; import java.util.ArrayList; import java.util.Collections; @@ -46,6 +46,7 @@ import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.generator.AbstractSpecialAbilityGenerator; import mekhq.campaign.personnel.generator.DefaultSpecialAbilityGenerator; +import mekhq.campaign.personnel.skills.Skill; /** * Utility class that provides methods for managing and modifying the skills, loyalty, and advantages of personnel in diff --git a/MekHQ/src/mekhq/campaign/personnel/SkillPerquisite.java b/MekHQ/src/mekhq/campaign/personnel/SkillPerquisite.java index f558b835ebc..5f2e9b609f3 100644 --- a/MekHQ/src/mekhq/campaign/personnel/SkillPerquisite.java +++ b/MekHQ/src/mekhq/campaign/personnel/SkillPerquisite.java @@ -28,43 +28,30 @@ */ package mekhq.campaign.personnel; +import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.Hashtable; + import megamek.common.UnitType; import megamek.logging.MMLogger; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.campaign.personnel.skills.Skills; import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.util.Enumeration; -import java.util.Hashtable; - /** - * This object tracks a specific skill prerequisite for a special ability. This - * object can list more - * than one skill and we will track these skills in a hashmap where the value - * gives the minimum skill - * level. The collection of skills is treated as an OR statement such that a - * person possessing any of the - * skills at the appropriate level will evaluate as eligible. To create AND - * conditions, use multiple skill - * prereqs in the SpecialAbility object. - * - * We are going to limit the skill levels by the Green, Regular, Veteran, Elite - * notation such - * that: - * 0 - Any - * 1 - Green - * 2 - Regular - * 3 - Veteran - * 4 - Elite - * This way, if the user changes the meaning of various skill levels, they won't - * have to redo all of - * their prereqs - we could consider expanding this to allow users to specify a - * more specific numeric - * skill level (to allow for better consistency with AToW) for example + * This object tracks a specific skill prerequisite for a special ability. This object can list more than one skill and + * we will track these skills in a hashmap where the value gives the minimum skill level. The collection of skills is + * treated as an OR statement such that a person possessing any of the skills at the appropriate level will evaluate as + * eligible. To create AND conditions, use multiple skill prereqs in the SpecialAbility object. + *

+ * We are going to limit the skill levels by the Green, Regular, Veteran, Elite notation such that: 0 - Any 1 - Green 2 + * - Regular 3 - Veteran 4 - Elite This way, if the user changes the meaning of various skill levels, they won't have to + * redo all of their prereqs - we could consider expanding this to allow users to specify a more specific numeric skill + * level (to allow for better consistency with AToW) for example * * @author Jay Lawson - * */ public class SkillPerquisite { private static final MMLogger logger = MMLogger.create(SkillPerquisite.class); @@ -102,52 +89,44 @@ public boolean qualifies(Skills s) { } /** - * Determines if the given unit type "qualifies" for this skill pre-requisite. - * For now, we simply check whether the pre-requisite skills are required for - * the unit type + * Determines if the given unit type "qualifies" for this skill pre-requisite. For now, we simply check whether the + * pre-requisite skills are required for the unit type * * @param unitType the type of unit that is being checked + * * @return */ public boolean qualifies(int unitType) { switch (unitType) { case UnitType.AERO: case UnitType.AEROSPACEFIGHTER: - return skillSet.containsKey(SkillType.S_PILOT_AERO) || - skillSet.containsKey(SkillType.S_GUN_AERO); + return skillSet.containsKey(SkillType.S_PILOT_AERO) || skillSet.containsKey(SkillType.S_GUN_AERO); case UnitType.BATTLE_ARMOR: - return skillSet.containsKey(SkillType.S_GUN_BA) || - skillSet.containsKey(SkillType.S_ANTI_MEK); + return skillSet.containsKey(SkillType.S_GUN_BA) || skillSet.containsKey(SkillType.S_ANTI_MEK); case UnitType.CONV_FIGHTER: - return skillSet.containsKey(SkillType.S_GUN_JET) || - skillSet.containsKey(SkillType.S_PILOT_JET); + return skillSet.containsKey(SkillType.S_GUN_JET) || skillSet.containsKey(SkillType.S_PILOT_JET); case UnitType.DROPSHIP: case UnitType.JUMPSHIP: case UnitType.WARSHIP: case UnitType.SPACE_STATION: case UnitType.SMALL_CRAFT: return skillSet.containsKey(SkillType.S_PILOT_SPACE) || - skillSet.containsKey(SkillType.S_GUN_SPACE) || - skillSet.containsKey(SkillType.S_TECH_VESSEL) || - skillSet.containsKey(SkillType.S_NAV); + skillSet.containsKey(SkillType.S_GUN_SPACE) || + skillSet.containsKey(SkillType.S_TECH_VESSEL) || + skillSet.containsKey(SkillType.S_NAV); case UnitType.GUN_EMPLACEMENT: case UnitType.TANK: - return skillSet.containsKey(SkillType.S_PILOT_GVEE) || - skillSet.containsKey(SkillType.S_GUN_VEE); + return skillSet.containsKey(SkillType.S_PILOT_GVEE) || skillSet.containsKey(SkillType.S_GUN_VEE); case UnitType.INFANTRY: - return skillSet.containsKey(SkillType.S_SMALL_ARMS) || - skillSet.containsKey(SkillType.S_ANTI_MEK); + return skillSet.containsKey(SkillType.S_SMALL_ARMS) || skillSet.containsKey(SkillType.S_ANTI_MEK); case UnitType.NAVAL: - return skillSet.containsKey(SkillType.S_PILOT_NVEE) || - skillSet.containsKey(SkillType.S_GUN_VEE); + return skillSet.containsKey(SkillType.S_PILOT_NVEE) || skillSet.containsKey(SkillType.S_GUN_VEE); case UnitType.PROTOMEK: return skillSet.containsKey(SkillType.S_GUN_PROTO); case UnitType.VTOL: - return skillSet.containsKey(SkillType.S_PILOT_VTOL) || - skillSet.containsKey(SkillType.S_GUN_VEE); + return skillSet.containsKey(SkillType.S_PILOT_VTOL) || skillSet.containsKey(SkillType.S_GUN_VEE); case UnitType.MEK: - return skillSet.containsKey(SkillType.S_PILOT_MEK) || - skillSet.containsKey(SkillType.S_GUN_MEK); + return skillSet.containsKey(SkillType.S_PILOT_MEK) || skillSet.containsKey(SkillType.S_GUN_MEK); default: return false; } @@ -190,8 +169,10 @@ public void writeToXML(final PrintWriter pw, int indent) { if (lvl <= 0) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "skill", key); } else { - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "skill", - key + "::" + SkillType.getExperienceLevelName(lvl)); + MHQXMLUtility.writeSimpleXMLTag(pw, + indent, + "skill", + key + "::" + SkillType.getExperienceLevelName(lvl)); } } MHQXMLUtility.writeSimpleXMLCloseTag(pw, --indent, "skillPrereq"); diff --git a/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java b/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java index 1bb53bf663a..7d89a3547f5 100644 --- a/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java +++ b/MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java @@ -40,11 +40,6 @@ import java.util.Map.Entry; import java.util.Vector; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.common.EquipmentType; import megamek.common.Mounted; @@ -63,20 +58,19 @@ import mekhq.Utilities; import mekhq.campaign.CampaignOptions; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.Skills; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** - * This object will serve as a wrapper for a specific pilot special ability. In - * the actual - * person object we will use PersonnelOptions, so these objects will not get - * written to actual - * personnel. Instead, we will keep track of a full static hash of SPAs that - * will contain important - * information on XP costs and pre-reqs that can be looked up to see if a person - * is eligible for a - * particular option. All of this will be customizable via an external XML file - * that can be user - * selected in the campaign options (and possibly user editable). + * This object will serve as a wrapper for a specific pilot special ability. In the actual person object we will use + * PersonnelOptions, so these objects will not get written to actual personnel. Instead, we will keep track of a full + * static hash of SPAs that will contain important information on XP costs and pre-reqs that can be looked up to see if + * a person is eligible for a particular option. All of this will be customizable via an external XML file that can be + * user selected in the campaign options (and possibly user editable). * * @author Jay Lawson (jaylawson39 at yahoo.com) */ @@ -175,8 +169,8 @@ public boolean isEligible(Person p) { } } - return !prereqMisc.containsKey(PREREQ_MISC_CLANPILOT) - || (p.isClanPersonnel() == Boolean.parseBoolean(prereqMisc.get(PREREQ_MISC_CLANPILOT))); + return !prereqMisc.containsKey(PREREQ_MISC_CLANPILOT) || + (p.isClanPersonnel() == Boolean.parseBoolean(prereqMisc.get(PREREQ_MISC_CLANPILOT))); } public boolean isEligible(boolean isClanPilot, Skills skills, PersonnelOptions options) { @@ -200,8 +194,8 @@ public boolean isEligible(boolean isClanPilot, Skills skills, PersonnelOptions o } } - return !prereqMisc.containsKey(PREREQ_MISC_CLANPILOT) - || (isClanPilot == Boolean.parseBoolean(prereqMisc.get(PREREQ_MISC_CLANPILOT))); + return !prereqMisc.containsKey(PREREQ_MISC_CLANPILOT) || + (isClanPilot == Boolean.parseBoolean(prereqMisc.get(PREREQ_MISC_CLANPILOT))); } public boolean isEligible(int unitType) { @@ -280,8 +274,10 @@ public void writeToXML(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "xpCost", xpCost); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "weight", weight); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "prereqAbilities", Utilities.combineString(prereqAbilities, "::")); - MHQXMLUtility.writeSimpleXMLTag(pw, indent, "invalidAbilities", - Utilities.combineString(invalidAbilities, "::")); + MHQXMLUtility.writeSimpleXMLTag(pw, + indent, + "invalidAbilities", + Utilities.combineString(invalidAbilities, "::")); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "removeAbilities", Utilities.combineString(removeAbilities, "::")); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "choiceValues", Utilities.combineString(choiceValues, "::")); for (SkillPerquisite skillpre : prereqSkills) { @@ -351,7 +347,7 @@ public static void generateInstanceFromXML(Node wn, PersonnelOptions options, Ve } public static void generateSeparateInstanceFromXML(Node wn, Map spHash, - PersonnelOptions options) { + PersonnelOptions options) { try { SpecialAbility retVal = new SpecialAbility(); NodeList nl = wn.getChildNodes(); @@ -474,21 +470,19 @@ public static void replaceSpecialAbilities(Map spas) { } /** - * This return a random weapon to specialize in, selected based on weightings. - * Introtech - * weaponry is weighted at 50, standard weaponry at 25, advanced weaponry at 5, - * while experimental - * and unofficial weaponry are both weighted at 1. + * This return a random weapon to specialize in, selected based on weightings. Introtech weaponry is weighted at 50, + * standard weaponry at 25, advanced weaponry at 5, while experimental and unofficial weaponry are both weighted at + * 1. * * @param person the person to generate the weapon specialization for * @param techLevel the maximum tech level to generate a weapon for * @param year the year to generate the specialization for * @param clusterOnly whether to only consider cluster weapons or not - * @return the name of the selected weapon, or null if there are no weapons that - * can be selected + * + * @return the name of the selected weapon, or null if there are no weapons that can be selected */ - public static @Nullable String chooseWeaponSpecialization(final Person person, final int techLevel, - final int year, final boolean clusterOnly) { + public static @Nullable String chooseWeaponSpecialization(final Person person, final int techLevel, final int year, + final boolean clusterOnly) { final WeightedIntMap weapons = new WeightedIntMap<>(); // First try to generate based on the person's unit if ((person.getUnit() != null) && (person.getUnit().getEntity() != null)) { @@ -499,7 +493,7 @@ public static void replaceSpecialAbilities(Map spas) { // If that doesn't generate a valid weapon, then turn to the wider list if (weapons.isEmpty()) { - for (Enumeration e = EquipmentType.getAllTypes(); e.hasMoreElements();) { + for (Enumeration e = EquipmentType.getAllTypes(); e.hasMoreElements(); ) { final EquipmentType equipmentType = e.nextElement(); addValidWeaponryToMap(equipmentType, person, techLevel, year, clusterOnly, weapons); } @@ -508,27 +502,24 @@ public static void replaceSpecialAbilities(Map spas) { } /** - * This is a worker method to add any valid weaponry to the weighted map used to - * generate a - * random weapon specialization + * This is a worker method to add any valid weaponry to the weighted map used to generate a random weapon + * specialization * * @param equipmentType the equipment type to test for validity * @param person the person to generate the weapon specialization for * @param techLevel the maximum tech level to generate a weapon for * @param year the year to generate the specialization for * @param clusterOnly whether to only consider cluster weapons or not - * @param weapons the weighted map of weaponry to add the equipmentType to - * if valid + * @param weapons the weighted map of weaponry to add the equipmentType to if valid */ - private static void addValidWeaponryToMap(final EquipmentType equipmentType, - final Person person, final int techLevel, - final int year, final boolean clusterOnly, - final WeightedIntMap weapons) { + private static void addValidWeaponryToMap(final EquipmentType equipmentType, final Person person, + final int techLevel, final int year, final boolean clusterOnly, + final WeightedIntMap weapons) { // Ensure it is a weapon eligible for the SPA in question, and the tech level is // IS for // IS personnel and Clan for Clan personnel - if (!isWeaponEligibleForSPA(equipmentType, person.getPrimaryRole(), clusterOnly) - || (TechConstants.isClan(equipmentType.getTechLevel(year)) != person.isClanPersonnel())) { + if (!isWeaponEligibleForSPA(equipmentType, person.getPrimaryRole(), clusterOnly) || + (TechConstants.isClan(equipmentType.getTechLevel(year)) != person.isClanPersonnel())) { return; } @@ -545,61 +536,58 @@ private static void addValidWeaponryToMap(final EquipmentType equipmentType, } // Determine the weight based on the tech level - final int weight = (weaponTechLevel < CampaignOptions.TECH_STANDARD) ? 50 - : (weaponTechLevel < CampaignOptions.TECH_ADVANCED) ? 25 - : (weaponTechLevel < CampaignOptions.TECH_EXPERIMENTAL) ? 5 - : 1; + final int weight = (weaponTechLevel < CampaignOptions.TECH_STANDARD) ? + 50 : + (weaponTechLevel < CampaignOptions.TECH_ADVANCED) ? + 25 : + (weaponTechLevel < CampaignOptions.TECH_EXPERIMENTAL) ? 5 : 1; weapons.add(weight, equipmentType); } /** - * Worker function that determines if a piece of equipment is eligible for being - * selected for an SPA. + * Worker function that determines if a piece of equipment is eligible for being selected for an SPA. * * @param et Equipment type to check - * @param role Person's primary role. This check is ignored if - * PersonnelRole.NONE is passed in. - * @param clusterOnly All weapon types or just ones that do rolls on the cluster - * table + * @param role Person's primary role. This check is ignored if PersonnelRole.NONE is passed in. + * @param clusterOnly All weapon types or just ones that do rolls on the cluster table */ public static boolean isWeaponEligibleForSPA(EquipmentType et, PersonnelRole role, boolean clusterOnly) { if (!(et instanceof WeaponType)) { return false; - } else if ((et instanceof InfantryWeapon) - || (et instanceof BayWeapon) - || (et instanceof InfantryAttack)) { + } else if ((et instanceof InfantryWeapon) || (et instanceof BayWeapon) || (et instanceof InfantryAttack)) { return false; } WeaponType wt = (WeaponType) et; - if (wt.isCapital() - || wt.isSubCapital() - || wt.hasFlag(WeaponType.F_INFANTRY) - || wt.hasFlag(WeaponType.F_ONESHOT) - || wt.hasFlag(WeaponType.F_PROTOTYPE)) { + if (wt.isCapital() || + wt.isSubCapital() || + wt.hasFlag(WeaponType.F_INFANTRY) || + wt.hasFlag(WeaponType.F_ONESHOT) || + wt.hasFlag(WeaponType.F_PROTOTYPE)) { return false; } - if (!role.isCivilian() - && !((wt.hasFlag(WeaponType.F_MEK_WEAPON) && !role.isMekWarrior()) - || (wt.hasFlag(WeaponType.F_AERO_WEAPON) && !role.isAerospacePilot()) - || (wt.hasFlag(WeaponType.F_TANK_WEAPON) && !role.isVehicleCrewMember()) - || (wt.hasFlag(WeaponType.F_BA_WEAPON) && !role.isBattleArmour()) - || (wt.hasFlag(WeaponType.F_PROTO_WEAPON) && !role.isProtoMekPilot()))) { + if (!role.isCivilian() && + !((wt.hasFlag(WeaponType.F_MEK_WEAPON) && !role.isMekWarrior()) || + (wt.hasFlag(WeaponType.F_AERO_WEAPON) && !role.isAerospacePilot()) || + (wt.hasFlag(WeaponType.F_TANK_WEAPON) && !role.isVehicleCrewMember()) || + (wt.hasFlag(WeaponType.F_BA_WEAPON) && !role.isBattleArmour()) || + (wt.hasFlag(WeaponType.F_PROTO_WEAPON) && !role.isProtoMekPilot()))) { return false; } // Should only apply to Large Ship-mounted weapons if (wt.getAtClass() == WeaponType.CLASS_NONE || - wt.getAtClass() == WeaponType.CLASS_POINT_DEFENSE || - (wt.getAtClass() >= WeaponType.CLASS_CAPITAL_LASER - && wt.getAtClass() <= WeaponType.CLASS_TELE_MISSILE)) { + wt.getAtClass() == WeaponType.CLASS_POINT_DEFENSE || + (wt.getAtClass() >= WeaponType.CLASS_CAPITAL_LASER && + wt.getAtClass() <= WeaponType.CLASS_TELE_MISSILE)) { return false; } - if (clusterOnly && !((wt.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) || - (wt instanceof ACWeapon) || - (wt instanceof UACWeapon) || - (wt instanceof LBXACWeapon))) { + if (clusterOnly && + !((wt.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) || + (wt instanceof ACWeapon) || + (wt instanceof UACWeapon) || + (wt instanceof LBXACWeapon))) { return false; } diff --git a/MekHQ/src/mekhq/campaign/personnel/autoAwards/SkillAwards.java b/MekHQ/src/mekhq/campaign/personnel/autoAwards/SkillAwards.java index 27dc6e7583a..01d9ab677ac 100644 --- a/MekHQ/src/mekhq/campaign/personnel/autoAwards/SkillAwards.java +++ b/MekHQ/src/mekhq/campaign/personnel/autoAwards/SkillAwards.java @@ -38,7 +38,7 @@ import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Award; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; public class SkillAwards { private static final MMLogger logger = MMLogger.create(SkillAwards.class); diff --git a/MekHQ/src/mekhq/campaign/personnel/education/Academy.java b/MekHQ/src/mekhq/campaign/personnel/education/Academy.java index c3b103597ce..2b15f360565 100644 --- a/MekHQ/src/mekhq/campaign/personnel/education/Academy.java +++ b/MekHQ/src/mekhq/campaign/personnel/education/Academy.java @@ -43,10 +43,10 @@ import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.education.AcademyType; import mekhq.campaign.personnel.enums.education.EducationLevel; import mekhq.campaign.personnel.enums.education.EducationLevel.Adapter; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.FactionHints; import mekhq.campaign.universe.Factions; diff --git a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java index 1b05c4c0008..51df1a18d91 100644 --- a/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java +++ b/MekHQ/src/mekhq/campaign/personnel/education/EducationController.java @@ -29,8 +29,8 @@ import static megamek.common.Compute.d6; import static megamek.common.Compute.randomInt; -import static mekhq.campaign.personnel.SkillType.EXP_REGULAR; -import static mekhq.campaign.personnel.SkillType.EXP_VETERAN; +import static mekhq.campaign.personnel.skills.SkillType.EXP_REGULAR; +import static mekhq.campaign.personnel.skills.SkillType.EXP_VETERAN; import static mekhq.campaign.randomEvents.personalities.PersonalityController.PERSONALITY_QUIRK_CHANCE; import static mekhq.campaign.randomEvents.personalities.PersonalityController.generateAndApplyPersonalityQuirk; import static mekhq.campaign.randomEvents.personalities.PersonalityController.writePersonalityDescription; diff --git a/MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java b/MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java index 64d8b6b36af..c3ed030ccd5 100644 --- a/MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java +++ b/MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java @@ -28,7 +28,7 @@ package mekhq.campaign.personnel.education; import static java.lang.Math.round; -import static mekhq.campaign.personnel.SkillType.EXP_GREEN; +import static mekhq.campaign.personnel.skills.SkillType.EXP_GREEN; import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; @@ -43,7 +43,7 @@ import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; +import mekhq.campaign.personnel.skills.Skill; import mekhq.campaign.unit.Unit; /** diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java index 590776582b0..a3b36fae351 100644 --- a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java +++ b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractPersonnelGenerator.java @@ -38,9 +38,9 @@ import mekhq.campaign.Campaign; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Phenotype; +import mekhq.campaign.personnel.skills.SkillType; /** * Represents a class which can generate new {@link Person} objects for a {@link Campaign}. diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSkillGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSkillGenerator.java index a82d591ce53..df2abf30160 100644 --- a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSkillGenerator.java +++ b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSkillGenerator.java @@ -33,9 +33,9 @@ import mekhq.campaign.Campaign; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; /** * Represents a class which can generate new {@link Skill} objects diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSpecialAbilityGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSpecialAbilityGenerator.java index c1b0c8317f3..70bad63c01a 100644 --- a/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSpecialAbilityGenerator.java +++ b/MekHQ/src/mekhq/campaign/personnel/generator/AbstractSpecialAbilityGenerator.java @@ -32,7 +32,7 @@ import mekhq.campaign.Campaign; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; /** * Represents a class which can generate new Special Abilities diff --git a/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSkillGenerator.java b/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSkillGenerator.java index 76d2dd8d7ad..17b80819b28 100644 --- a/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSkillGenerator.java +++ b/MekHQ/src/mekhq/campaign/personnel/generator/DefaultSkillGenerator.java @@ -27,9 +27,8 @@ */ package mekhq.campaign.personnel.generator; -import static mekhq.campaign.personnel.SkillDeprecationTool.DEPRECATED_SKILLS; +import static mekhq.campaign.personnel.skills.SkillDeprecationTool.DEPRECATED_SKILLS; -import java.util.Arrays; import java.util.ArrayList; import java.util.List; @@ -39,8 +38,8 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; public class DefaultSkillGenerator extends AbstractSkillGenerator { //region Constructors diff --git a/MekHQ/src/mekhq/campaign/personnel/Skill.java b/MekHQ/src/mekhq/campaign/personnel/skills/Skill.java similarity index 99% rename from MekHQ/src/mekhq/campaign/personnel/Skill.java rename to MekHQ/src/mekhq/campaign/personnel/skills/Skill.java index 98b5a0b7f4d..736e48bcf6b 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Skill.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/Skill.java @@ -26,7 +26,7 @@ * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. */ -package mekhq.campaign.personnel; +package mekhq.campaign.personnel.skills; import static java.lang.Math.max; import static java.lang.Math.min; @@ -36,6 +36,7 @@ import megamek.common.Compute; import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; +import mekhq.campaign.personnel.Person; import mekhq.campaign.randomEvents.personalities.enums.Intelligence; import mekhq.utilities.MHQXMLUtility; import org.w3c.dom.Node; diff --git a/MekHQ/src/mekhq/campaign/personnel/SkillDeprecationTool.java b/MekHQ/src/mekhq/campaign/personnel/skills/SkillDeprecationTool.java similarity index 99% rename from MekHQ/src/mekhq/campaign/personnel/SkillDeprecationTool.java rename to MekHQ/src/mekhq/campaign/personnel/skills/SkillDeprecationTool.java index e7fefa8032b..1d5f6adc4fa 100644 --- a/MekHQ/src/mekhq/campaign/personnel/SkillDeprecationTool.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/SkillDeprecationTool.java @@ -25,7 +25,7 @@ * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. */ -package mekhq.campaign.personnel; +package mekhq.campaign.personnel.skills; import static java.lang.Math.round; import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; @@ -34,6 +34,7 @@ import mekhq.campaign.Campaign; import mekhq.campaign.CampaignOptions; +import mekhq.campaign.personnel.Person; import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple; /** diff --git a/MekHQ/src/mekhq/campaign/personnel/SkillType.java b/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java similarity index 99% rename from MekHQ/src/mekhq/campaign/personnel/SkillType.java rename to MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java index 9a247170014..afdd97b6b0f 100644 --- a/MekHQ/src/mekhq/campaign/personnel/SkillType.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java @@ -26,9 +26,22 @@ * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. */ -package mekhq.campaign.personnel; +package mekhq.campaign.personnel.skills; -import megamek.common.*; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import megamek.common.Aero; +import megamek.common.BattleArmor; +import megamek.common.ConvFighter; +import megamek.common.Entity; +import megamek.common.Infantry; +import megamek.common.Jumpship; +import megamek.common.ProtoMek; +import megamek.common.SmallCraft; +import megamek.common.Tank; import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; import mekhq.MekHQ; @@ -38,11 +51,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - /** * Skill type will hold static information for each skill type like base target * number, diff --git a/MekHQ/src/mekhq/campaign/personnel/Skills.java b/MekHQ/src/mekhq/campaign/personnel/skills/Skills.java similarity index 97% rename from MekHQ/src/mekhq/campaign/personnel/Skills.java rename to MekHQ/src/mekhq/campaign/personnel/skills/Skills.java index ffd3ec7ccb4..1d2f4eb1f48 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Skills.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/Skills.java @@ -25,7 +25,7 @@ * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of * InMediaRes Productions, LLC. */ -package mekhq.campaign.personnel; +package mekhq.campaign.personnel.skills; import java.util.Collection; import java.util.HashMap; @@ -33,6 +33,7 @@ import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; +import mekhq.campaign.personnel.Person; /** * Tracks skills for a {@link Person}. diff --git a/MekHQ/src/mekhq/campaign/personnel/turnoverAndRetention/RetirementDefectionTracker.java b/MekHQ/src/mekhq/campaign/personnel/turnoverAndRetention/RetirementDefectionTracker.java index d9ede12d6ce..fa13792de5d 100644 --- a/MekHQ/src/mekhq/campaign/personnel/turnoverAndRetention/RetirementDefectionTracker.java +++ b/MekHQ/src/mekhq/campaign/personnel/turnoverAndRetention/RetirementDefectionTracker.java @@ -52,9 +52,9 @@ import mekhq.campaign.personnel.Injury; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Profession; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.FactionHints; import mekhq.utilities.MHQXMLUtility; diff --git a/MekHQ/src/mekhq/campaign/randomEvents/RoninOffer.java b/MekHQ/src/mekhq/campaign/randomEvents/RoninOffer.java index 1c604493f37..a863d29f3fb 100644 --- a/MekHQ/src/mekhq/campaign/randomEvents/RoninOffer.java +++ b/MekHQ/src/mekhq/campaign/randomEvents/RoninOffer.java @@ -60,8 +60,8 @@ import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.finances.Money; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.Skill; import mekhq.campaign.randomEvents.personalities.PersonalityController.PersonalityTraitType; import mekhq.campaign.randomEvents.personalities.enums.Aggression; import mekhq.campaign.randomEvents.personalities.enums.Ambition; diff --git a/MekHQ/src/mekhq/campaign/randomEvents/prisoners/EventEffectsManager.java b/MekHQ/src/mekhq/campaign/randomEvents/prisoners/EventEffectsManager.java index dcebec0cb8b..67075bbfa00 100644 --- a/MekHQ/src/mekhq/campaign/randomEvents/prisoners/EventEffectsManager.java +++ b/MekHQ/src/mekhq/campaign/randomEvents/prisoners/EventEffectsManager.java @@ -27,6 +27,28 @@ */ package mekhq.campaign.randomEvents.prisoners; +import static java.lang.Math.ceil; +import static java.lang.Math.max; +import static java.lang.Math.min; +import static megamek.codeUtilities.MathUtility.clamp; +import static megamek.codeUtilities.ObjectUtility.getRandomItem; +import static megamek.common.Compute.d6; +import static mekhq.campaign.force.ForceType.SECURITY; +import static mekhq.campaign.personnel.enums.PersonnelRole.DEPENDENT; +import static mekhq.campaign.personnel.enums.PersonnelRole.NONE; +import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; +import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; +import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + import megamek.common.annotations.Nullable; import megamek.common.enums.Gender; import megamek.logging.MMLogger; @@ -37,10 +59,10 @@ import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.enums.AtBMoraleLevel; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.PersonnelStatus; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.prisoners.enums.EventResultEffect; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus; @@ -53,22 +75,6 @@ import mekhq.campaign.universe.selectors.factionSelectors.DefaultFactionSelector; import mekhq.campaign.universe.selectors.planetSelectors.DefaultPlanetSelector; -import java.time.LocalDate; -import java.util.*; - -import static java.lang.Math.ceil; -import static java.lang.Math.max; -import static java.lang.Math.min; -import static megamek.codeUtilities.MathUtility.clamp; -import static megamek.codeUtilities.ObjectUtility.getRandomItem; -import static megamek.common.Compute.d6; -import static mekhq.campaign.force.ForceType.SECURITY; -import static mekhq.campaign.personnel.enums.PersonnelRole.DEPENDENT; -import static mekhq.campaign.personnel.enums.PersonnelRole.NONE; -import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; -import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; -import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; - /** * Manages the resolution and effects of prisoner events during a campaign. * diff --git a/MekHQ/src/mekhq/campaign/randomEvents/prisoners/PrisonEscapeScenario.java b/MekHQ/src/mekhq/campaign/randomEvents/prisoners/PrisonEscapeScenario.java index bc5623147b7..5fc3c94db88 100644 --- a/MekHQ/src/mekhq/campaign/randomEvents/prisoners/PrisonEscapeScenario.java +++ b/MekHQ/src/mekhq/campaign/randomEvents/prisoners/PrisonEscapeScenario.java @@ -31,8 +31,8 @@ import static megamek.common.Board.START_SW; import static megamek.common.Compute.randomInt; import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.AllGroundTerrain; -import static mekhq.campaign.personnel.SkillType.S_SMALL_ARMS; import static mekhq.campaign.personnel.enums.PersonnelRole.SOLDIER; +import static mekhq.campaign.personnel.skills.SkillType.S_SMALL_ARMS; import static mekhq.campaign.randomEvents.prisoners.enums.MobType.HUGE; import static mekhq.campaign.randomEvents.prisoners.enums.MobType.LARGE; import static mekhq.campaign.randomEvents.prisoners.enums.MobType.MEDIUM; diff --git a/MekHQ/src/mekhq/campaign/rating/AbstractUnitRating.java b/MekHQ/src/mekhq/campaign/rating/AbstractUnitRating.java index 55be0f087a7..c4397dfa760 100644 --- a/MekHQ/src/mekhq/campaign/rating/AbstractUnitRating.java +++ b/MekHQ/src/mekhq/campaign/rating/AbstractUnitRating.java @@ -41,7 +41,7 @@ import mekhq.campaign.Campaign; import mekhq.campaign.mission.Mission; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; +import mekhq.campaign.personnel.skills.Skill; import mekhq.campaign.unit.Unit; /** diff --git a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/AverageExperienceRating.java b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/AverageExperienceRating.java index 9696b9b0732..85593f99e21 100644 --- a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/AverageExperienceRating.java +++ b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/AverageExperienceRating.java @@ -27,17 +27,21 @@ */ package mekhq.campaign.rating.CamOpsReputation; +import static java.lang.Math.max; + import megamek.codeUtilities.MathUtility; -import megamek.common.*; +import megamek.common.Crew; +import megamek.common.Entity; +import megamek.common.Infantry; +import megamek.common.Jumpship; +import megamek.common.ProtoMek; import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; -import static java.lang.Math.max; - public class AverageExperienceRating { private static final MMLogger logger = MMLogger.create(AverageExperienceRating.class); diff --git a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java index 83c63708e8b..c0d3215b889 100644 --- a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java +++ b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java @@ -27,17 +27,17 @@ */ package mekhq.campaign.rating.CamOpsReputation; -import megamek.logging.MMLogger; -import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import static mekhq.campaign.randomEvents.personalities.PersonalityController.getPersonalityValue; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; -import static mekhq.campaign.randomEvents.personalities.PersonalityController.getPersonalityValue; +import megamek.logging.MMLogger; +import mekhq.campaign.Campaign; +import mekhq.campaign.CampaignOptions; +import mekhq.campaign.personnel.Person; +import mekhq.campaign.personnel.skills.SkillType; public class CommandRating { private static final MMLogger logger = MMLogger.create(CommandRating.class); diff --git a/MekHQ/src/mekhq/campaign/rating/FieldManualMercRevDragoonsRating.java b/MekHQ/src/mekhq/campaign/rating/FieldManualMercRevDragoonsRating.java index 9adf1e827e1..b715e8058b0 100644 --- a/MekHQ/src/mekhq/campaign/rating/FieldManualMercRevDragoonsRating.java +++ b/MekHQ/src/mekhq/campaign/rating/FieldManualMercRevDragoonsRating.java @@ -38,8 +38,8 @@ import megamek.logging.MMLogger; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; /** diff --git a/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java b/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java index f1a4140049d..6c63394f4f0 100644 --- a/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java +++ b/MekHQ/src/mekhq/campaign/storyarc/storypoint/CreateCharacterStoryPoint.java @@ -27,6 +27,13 @@ */ package mekhq.campaign.storyarc.storypoint; +import static mekhq.campaign.personnel.education.EducationController.setInitialEducationLevel; + +import java.io.PrintWriter; +import java.text.ParseException; +import java.util.Enumeration; +import java.util.UUID; + import megamek.Version; import megamek.common.options.IOption; import megamek.common.options.IOptionGroup; @@ -37,10 +44,10 @@ import mekhq.campaign.force.Force; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.backgrounds.BackgroundsController; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Phenotype; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.personalities.PersonalityController; import mekhq.campaign.storyarc.StoryPoint; import mekhq.campaign.unit.Unit; @@ -52,13 +59,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.io.PrintWriter; -import java.text.ParseException; -import java.util.Enumeration; -import java.util.UUID; - -import static mekhq.campaign.personnel.education.EducationController.setInitialEducationLevel; - /** * This StoryPoint opens a {@link CreateCharacterDialog CreateCharacterDialog} * which allows a player to create a new diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index ede88ca2dc2..2179caaeb29 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -48,9 +48,9 @@ import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.LowAtmosphere; import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.Space; import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.SpecificGroundTerrain; -import static mekhq.campaign.personnel.SkillType.S_ADMIN; -import static mekhq.campaign.personnel.SkillType.S_TACTICS; -import static mekhq.campaign.personnel.SkillType.getSkillHash; +import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; +import static mekhq.campaign.personnel.skills.SkillType.S_TACTICS; +import static mekhq.campaign.personnel.skills.SkillType.getSkillHash; import static mekhq.campaign.stratcon.StratconContractInitializer.getUnoccupiedCoords; import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementEligibilityType.AUXILIARY; import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementResultsType.DELAYED; @@ -105,8 +105,8 @@ import mekhq.campaign.mission.resupplyAndCaches.StarLeagueCache; import mekhq.campaign.mission.resupplyAndCaches.StarLeagueCache.CacheType; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.personnel.turnoverAndRetention.Fatigue; import mekhq.campaign.stratcon.StratconContractDefinition.StrategicObjectiveType; import mekhq.campaign.stratcon.StratconScenario.ScenarioState; diff --git a/MekHQ/src/mekhq/campaign/stratcon/SupportPointNegotiation.java b/MekHQ/src/mekhq/campaign/stratcon/SupportPointNegotiation.java index 5099c97dbed..488263a4e23 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/SupportPointNegotiation.java +++ b/MekHQ/src/mekhq/campaign/stratcon/SupportPointNegotiation.java @@ -27,19 +27,23 @@ */ package mekhq.campaign.stratcon; +import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; +import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; +import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + import megamek.common.Compute; import megamek.common.annotations.Nullable; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; - -import java.util.*; - -import static mekhq.campaign.personnel.SkillType.S_ADMIN; -import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; -import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; +import mekhq.campaign.personnel.skills.Skill; /** * This class handles Support Point negotiations for StratCon. diff --git a/MekHQ/src/mekhq/campaign/unit/Unit.java b/MekHQ/src/mekhq/campaign/unit/Unit.java index 1ff6b410868..ecad7c9d04d 100644 --- a/MekHQ/src/mekhq/campaign/unit/Unit.java +++ b/MekHQ/src/mekhq/campaign/unit/Unit.java @@ -86,8 +86,8 @@ import mekhq.campaign.parts.equipment.*; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.enums.CrewAssignmentState; import mekhq.campaign.unit.enums.TransporterType; import mekhq.campaign.work.IAcquisitionWork; diff --git a/MekHQ/src/mekhq/campaign/unit/actions/HirePersonnelUnitAction.java b/MekHQ/src/mekhq/campaign/unit/actions/HirePersonnelUnitAction.java index b83036d1e0f..d85168106ff 100644 --- a/MekHQ/src/mekhq/campaign/unit/actions/HirePersonnelUnitAction.java +++ b/MekHQ/src/mekhq/campaign/unit/actions/HirePersonnelUnitAction.java @@ -27,17 +27,17 @@ */ package mekhq.campaign.unit.actions; +import java.util.Set; + import megamek.codeUtilities.ObjectUtility; import megamek.common.*; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.generator.DefaultSkillGenerator; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; -import java.util.Set; - /** * Hires a full complement of personnel for a unit. */ diff --git a/MekHQ/src/mekhq/campaign/universe/generators/companyGenerators/AbstractCompanyGenerator.java b/MekHQ/src/mekhq/campaign/universe/generators/companyGenerators/AbstractCompanyGenerator.java index 4db298639ef..d04ab88b204 100644 --- a/MekHQ/src/mekhq/campaign/universe/generators/companyGenerators/AbstractCompanyGenerator.java +++ b/MekHQ/src/mekhq/campaign/universe/generators/companyGenerators/AbstractCompanyGenerator.java @@ -27,8 +27,28 @@ */ package mekhq.campaign.universe.generators.companyGenerators; +import static mekhq.campaign.personnel.education.EducationController.setInitialEducationLevel; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.ResourceBundle; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + import megamek.client.generator.RandomCallsignGenerator; -import megamek.common.*; +import megamek.common.AmmoType; +import megamek.common.Entity; +import megamek.common.EntityWeightClass; +import megamek.common.MekFileParser; +import megamek.common.MekSummary; +import megamek.common.UnitType; import megamek.common.annotations.Nullable; import megamek.common.options.OptionsConstants; import megamek.logging.MMLogger; @@ -52,11 +72,11 @@ import mekhq.campaign.parts.enums.PartQuality; import mekhq.campaign.parts.equipment.AmmoBin; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.generator.AbstractPersonnelGenerator; import mekhq.campaign.personnel.ranks.Rank; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.companyGeneration.AtBRandomMekParameters; @@ -75,16 +95,6 @@ import mekhq.campaign.universe.selectors.planetSelectors.RangedPlanetSelector; import mekhq.campaign.work.WorkTime; -import java.time.LocalDate; -import java.util.*; -import java.util.Map.Entry; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - -import static mekhq.campaign.personnel.education.EducationController.setInitialEducationLevel; - /** * Startup: * Second Panel: Presets, Date, Starting Faction, Starting Planet, AtB diff --git a/MekHQ/src/mekhq/gui/BriefingTab.java b/MekHQ/src/mekhq/gui/BriefingTab.java index 5e43a99e4b5..5ce3197100f 100644 --- a/MekHQ/src/mekhq/gui/BriefingTab.java +++ b/MekHQ/src/mekhq/gui/BriefingTab.java @@ -84,9 +84,9 @@ import mekhq.campaign.mission.atb.AtBScenarioFactory; import mekhq.campaign.mission.enums.MissionStatus; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.autoAwards.AutoAwardsController; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.prisoners.PrisonerMissionEndEvent; import mekhq.campaign.stratcon.StratconScenario; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index b64e92d432d..776dc261e78 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -92,7 +92,6 @@ import mekhq.campaign.parts.Refit; import mekhq.campaign.parts.enums.PartQuality; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.autoAwards.AutoAwardsController; import mekhq.campaign.personnel.divorce.RandomDivorce; import mekhq.campaign.personnel.enums.PersonnelRole; @@ -104,6 +103,7 @@ import mekhq.campaign.personnel.procreation.RandomProcreation; import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.report.CargoReport; import mekhq.campaign.report.HangarReport; import mekhq.campaign.report.PersonnelReport; diff --git a/MekHQ/src/mekhq/gui/CommandCenterTab.java b/MekHQ/src/mekhq/gui/CommandCenterTab.java index ef6f2a80503..f4d5892bbec 100644 --- a/MekHQ/src/mekhq/gui/CommandCenterTab.java +++ b/MekHQ/src/mekhq/gui/CommandCenterTab.java @@ -27,6 +27,25 @@ */ package mekhq.gui; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.ResourceBundle; +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; + import megamek.client.ui.swing.UnitLoadingDialog; import megamek.client.ui.swing.dialog.AbstractUnitSelectorDialog; import megamek.common.MekSummaryCache; @@ -40,6 +59,7 @@ import mekhq.campaign.finances.FinancialReport; import mekhq.campaign.mission.Mission; import mekhq.campaign.mission.Scenario; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.rating.UnitRatingMethod; import mekhq.campaign.report.CargoReport; @@ -48,8 +68,18 @@ import mekhq.campaign.report.TransportReport; import mekhq.campaign.work.IAcquisitionWork; import mekhq.gui.adapter.ProcurementTableMouseAdapter; -import mekhq.gui.dialog.*; -import mekhq.gui.dialog.reportDialogs.*; +import mekhq.gui.dialog.AcquisitionsDialog; +import mekhq.gui.dialog.MRMSDialog; +import mekhq.gui.dialog.MekHQUnitSelectorDialog; +import mekhq.gui.dialog.PartsReportDialog; +import mekhq.gui.dialog.PartsStoreDialog; +import mekhq.gui.dialog.UnitMarketDialog; +import mekhq.gui.dialog.reportDialogs.CargoReportDialog; +import mekhq.gui.dialog.reportDialogs.HangarReportDialog; +import mekhq.gui.dialog.reportDialogs.PersonnelReportDialog; +import mekhq.gui.dialog.reportDialogs.ReputationReportDialog; +import mekhq.gui.dialog.reportDialogs.TransportReportDialog; +import mekhq.gui.dialog.reportDialogs.UnitRatingReportDialog; import mekhq.gui.enums.MHQTabType; import mekhq.gui.model.ProcurementTableModel; import mekhq.gui.sorter.FormattedNumberSorter; @@ -58,17 +88,6 @@ import mekhq.service.enums.MRMSMode; import mekhq.service.mrms.MRMSService; -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.table.TableColumn; -import javax.swing.table.TableRowSorter; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.*; - /** * Collates important information about the campaign and displays it, along with some actionable buttons */ @@ -117,10 +136,10 @@ public final class CommandCenterTab extends CampaignGuiTab { private JLabel lblIcon; private static final ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.CampaignGUI", - MekHQ.getMHQOptions().getLocale()); + MekHQ.getMHQOptions().getLocale()); /** - * @param gui a {@link CampaignGUI} object that this tab is a component of + * @param gui a {@link CampaignGUI} object that this tab is a component of * @param name a String giving the name of this tab */ public CommandCenterTab(CampaignGUI gui, String name) { @@ -242,8 +261,8 @@ private void initInfoPanel() { // This seems to be overwritten completely and immediately by refresh StringBuilder experienceString = new StringBuilder(64); experienceString.append("") - .append(mekhq.campaign.personnel.SkillType.getColoredExperienceLevelName(getCampaign().getReputation().getAverageSkillLevel())) - .append(""); + .append(SkillType.getColoredExperienceLevelName(getCampaign().getReputation().getAverageSkillLevel())) + .append(""); lblExperience.setText(experienceString.toString()); } @@ -280,7 +299,8 @@ private void initInfoPanel() { gridBagConstraints.weightx = 1.0; panInfo.add(lblPersonnel, gridBagConstraints); - if ((getCampaign().getCampaignOptions().isUseRandomRetirement()) && (getCampaign().getCampaignOptions().isUseAdministrativeStrain())) { + if ((getCampaign().getCampaignOptions().isUseRandomRetirement()) && + (getCampaign().getCampaignOptions().isUseAdministrativeStrain())) { JLabel lblAdministrativeCapacityHead = new JLabel(resourceMap.getString("lblAdministrativeCapacity.text")); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; @@ -289,7 +309,8 @@ private void initInfoPanel() { gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new Insets(1, 5, 1, 5); panInfo.add(lblAdministrativeCapacityHead, gridBagConstraints); - lblAdminstrativeCapacity = new JLabel(getCampaign().getCampaignSummary().getAdministrativeCapacityReport(getCampaign())); + lblAdminstrativeCapacity = new JLabel(getCampaign().getCampaignSummary() + .getAdministrativeCapacityReport(getCampaign())); lblAdministrativeCapacityHead.setLabelFor(lblAdminstrativeCapacity); gridBagConstraints.gridx = 1; gridBagConstraints.weightx = 1.0; @@ -372,8 +393,8 @@ private void initInfoPanel() { } /** - * Initialize the panel for showing any objectives that might exist. Objectives might come from - * different play modes. + * Initialize the panel for showing any objectives that might exist. Objectives might come from different play + * modes. */ private void initObjectivesPanel() { panObjectives = new JPanel(new BorderLayout()); @@ -417,22 +438,23 @@ private void initProcurementPanel() { btnNeededParts = new JButton(resourceMap.getString("btnNeededParts.text")); btnNeededParts.setToolTipText(resourceMap.getString("btnNeededParts.toolTipText")); - btnNeededParts.addActionListener(evt -> - new AcquisitionsDialog(getFrame(), true, getCampaignGui()).setVisible(true)); + btnNeededParts.addActionListener(evt -> new AcquisitionsDialog(getFrame(), true, getCampaignGui()).setVisible( + true)); panProcurementButtons.add(btnNeededParts); btnPartsReport = new JButton(resourceMap.getString("btnPartsReport.text")); btnPartsReport.setToolTipText(resourceMap.getString("btnPartsReport.toolTipText")); - btnPartsReport.addActionListener(evt -> - new PartsReportDialog(getCampaignGui(), true).setVisible(true)); + btnPartsReport.addActionListener(evt -> new PartsReportDialog(getCampaignGui(), true).setVisible(true)); panProcurementButtons.add(btnPartsReport); btnMRMSDialog = new JButton(resourceMap.getString("btnMRMSDialog.text")); btnMRMSDialog.setToolTipText(resourceMap.getString("btnMRMSDialog.toolTipText")); btnMRMSDialog.setName("btnMRMSDialog"); - btnMRMSDialog.addActionListener(evt -> - new MRMSDialog(getFrame(), true, getCampaignGui(), null, MRMSMode.UNITS) - .setVisible(true)); + btnMRMSDialog.addActionListener(evt -> new MRMSDialog(getFrame(), + true, + getCampaignGui(), + null, + MRMSMode.UNITS).setVisible(true)); btnMRMSDialog.setVisible(MekHQ.getMHQOptions().getCommandCenterMRMS()); panProcurementButtons.add(btnMRMSDialog); @@ -441,8 +463,10 @@ private void initProcurementPanel() { btnMRMSInstant.setName("btnMRMSInstant"); btnMRMSInstant.addActionListener(evt -> { MRMSService.mrmsAllUnits(getCampaign()); - JOptionPane.showMessageDialog(getCampaignGui().getFrame(), "Mass Repair/Salvage complete.", - "Complete", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(getCampaignGui().getFrame(), + "Mass Repair/Salvage complete.", + "Complete", + JOptionPane.INFORMATION_MESSAGE); }); btnMRMSInstant.setVisible(MekHQ.getMHQOptions().getCommandCenterMRMS()); panProcurementButtons.add(btnMRMSInstant); @@ -468,8 +492,10 @@ private void initProcurementPanel() { procurementTable.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "ADD"); procurementTable.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, 0), "ADD"); - procurementTable.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "REMOVE"); - procurementTable.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), "REMOVE"); + procurementTable.getInputMap(JComponent.WHEN_FOCUSED) + .put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "REMOVE"); + procurementTable.getInputMap(JComponent.WHEN_FOCUSED) + .put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), "REMOVE"); procurementTable.getActionMap().put("ADD", new AbstractAction() { @Override @@ -490,8 +516,7 @@ public void actionPerformed(ActionEvent e) { continue; } final int row = procurementTable.convertRowIndexToModel(rowIndex); - if (procurementModel.getAcquisition(row).map(IAcquisitionWork::getQuantity) - .orElse(0) > 0) { + if (procurementModel.getAcquisition(row).map(IAcquisitionWork::getQuantity).orElse(0) > 0) { procurementModel.decrementItem(row); } } @@ -527,31 +552,33 @@ private void initReportsPanel() { JButton btnTransportReport = new JButton(resourceMap.getString("btnTransportReport.text")); btnTransportReport.addActionListener(ev -> new TransportReportDialog(getCampaignGui().getFrame(), - new TransportReport(getCampaign())).setVisible(true)); + new TransportReport(getCampaign())).setVisible(true)); panReports.add(btnTransportReport); JButton btnHangarOverview = new JButton(resourceMap.getString("btnHangarOverview.text")); btnHangarOverview.addActionListener(evt -> new HangarReportDialog(getCampaignGui().getFrame(), - new HangarReport(getCampaign())).setVisible(true)); + new HangarReport(getCampaign())).setVisible(true)); panReports.add(btnHangarOverview); JButton btnPersonnelOverview = new JButton(resourceMap.getString("btnPersonnelOverview.text")); btnPersonnelOverview.addActionListener(evt -> new PersonnelReportDialog(getCampaignGui().getFrame(), - new PersonnelReport(getCampaign())).setVisible(true)); + new PersonnelReport(getCampaign())).setVisible(true)); panReports.add(btnPersonnelOverview); JButton btnCargoCapacity = new JButton(resourceMap.getString("btnCargoCapacity.text")); btnCargoCapacity.addActionListener(evt -> new CargoReportDialog(getCampaignGui().getFrame(), - new CargoReport(getCampaign())).setVisible(true)); + new CargoReport(getCampaign())).setVisible(true)); panReports.add(btnCargoCapacity); btnUnitRating = new JButton(resourceMap.getString("btnUnitRating.text")); btnUnitRating.setVisible(getCampaign().getCampaignOptions().getUnitRatingMethod().isEnabled()); if (getCampaign().getCampaignOptions().getUnitRatingMethod().isFMMR()) { - btnUnitRating.addActionListener(evt -> new UnitRatingReportDialog(getCampaignGui().getFrame(), getCampaign()).setVisible(true)); + btnUnitRating.addActionListener(evt -> new UnitRatingReportDialog(getCampaignGui().getFrame(), + getCampaign()).setVisible(true)); } else { - btnUnitRating.addActionListener(evt -> new ReputationReportDialog(getCampaignGui().getFrame(), getCampaign()).setVisible(true)); + btnUnitRating.addActionListener(evt -> new ReputationReportDialog(getCampaignGui().getFrame(), + getCampaign()).setVisible(true)); } panReports.add(btnUnitRating); @@ -600,8 +627,8 @@ private void refreshBasicInfo() { StringBuilder experienceString = new StringBuilder(64); experienceString.append("") - .append(mekhq.campaign.personnel.SkillType.getColoredExperienceLevelName(campaign.getReputation().getAverageSkillLevel())) - .append(""); + .append(SkillType.getColoredExperienceLevelName(campaign.getReputation().getAverageSkillLevel())) + .append(""); lblExperience.setText(experienceString.toString()); } @@ -617,13 +644,15 @@ private void refreshBasicInfo() { if (campaignOptions.isUseAdministrativeStrain()) { try { lblAdminstrativeCapacity.setText(campaignSummary.getAdministrativeCapacityReport(campaign)); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } if (campaignOptions.isUseFatigue()) { try { lblFacilityCapacities.setText(campaignSummary.getFacilityReport()); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } } @@ -644,7 +673,8 @@ private void refreshObjectives() { for (Mission mission : getCampaign().getActiveMissions(false)) { List scenarios = mission.getScenarios(); - scenarios.sort(Comparator.comparing(Scenario::getDate, Comparator.nullsFirst(Comparator.naturalOrder()))); + scenarios.sort(Comparator.comparing(Scenario::getDate, + Comparator.nullsFirst(Comparator.naturalOrder()))); Collections.reverse(scenarios); if (!scenarios.isEmpty()) { @@ -654,9 +684,15 @@ private void refreshObjectives() { if (scenario.getStatus().isCurrent()) { // StratCon facility contacts that haven't yet been discovered are stored as scenarios with null start dates if (scenario.getDate() != null) { - model.addElement(String.format("" + scenario.getName() + ": " - + "" - + ChronoUnit.DAYS.between(getCampaign().getLocalDate(), scenario.getDate())) + " days"); + model.addElement(String.format("" + + scenario.getName() + + ": " + + "" + + ChronoUnit.DAYS.between(getCampaign().getLocalDate(), + scenario.getDate())) + " days"); } } } @@ -679,13 +715,16 @@ public List getAbridgedFinancialReport() { String formatted = "%ss"; - reportString.add("Net Worth: " - + String.format(formatted, report.getNetWorth().toAmountAndSymbolString()) - + ""); + reportString.add("Net Worth: " + + String.format(formatted, report.getNetWorth().toAmountAndSymbolString()) + + ""); - reportString.add("Monthly Profit: " - + String.format(formatted, report.getMonthlyIncome().minus(report.getMonthlyExpenses()).toAmountAndSymbolString()) - + ""); + reportString.add("Monthly Profit: " + + String.format(formatted, + report.getMonthlyIncome() + .minus(report.getMonthlyExpenses()) + .toAmountAndSymbolString()) + + ""); reportString.add("
"); @@ -716,20 +755,22 @@ synchronized private void refreshLog() { } /** - * brings up the {@link AbstractUnitSelectorDialog} or {@link UnitMarketDialog}, depending on - * the currently selected options + * brings up the {@link AbstractUnitSelectorDialog} or {@link UnitMarketDialog}, depending on the currently selected + * options */ private void getUnit() { - if (MekHQ.getMHQOptions().getCommandCenterUseUnitMarket() - && !getCampaign().getUnitMarket().getMethod().isNone()) { + if (MekHQ.getMHQOptions().getCommandCenterUseUnitMarket() && + !getCampaign().getUnitMarket().getMethod().isNone()) { new UnitMarketDialog(getFrame(), getCampaign()).showDialog(); } else { UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(getFrame()); if (!MekSummaryCache.getInstance().isInitialized()) { unitLoadingDialog.setVisible(true); } - AbstractUnitSelectorDialog usd = new MekHQUnitSelectorDialog(getFrame(), unitLoadingDialog, - getCampaign(), true); + AbstractUnitSelectorDialog usd = new MekHQUnitSelectorDialog(getFrame(), + unitLoadingDialog, + getCampaign(), + true); usd.setVisible(true); } } diff --git a/MekHQ/src/mekhq/gui/RepairTab.java b/MekHQ/src/mekhq/gui/RepairTab.java index e9343277192..fe9c79f82a0 100644 --- a/MekHQ/src/mekhq/gui/RepairTab.java +++ b/MekHQ/src/mekhq/gui/RepairTab.java @@ -64,8 +64,8 @@ import mekhq.campaign.parts.Part; import mekhq.campaign.parts.PodSpace; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IPartWork; import mekhq.gui.adapter.ServicedUnitsTableMouseAdapter; diff --git a/MekHQ/src/mekhq/gui/WarehouseTab.java b/MekHQ/src/mekhq/gui/WarehouseTab.java index 9efc90b3074..07cfa75968c 100644 --- a/MekHQ/src/mekhq/gui/WarehouseTab.java +++ b/MekHQ/src/mekhq/gui/WarehouseTab.java @@ -53,8 +53,8 @@ import mekhq.campaign.parts.*; import mekhq.campaign.parts.equipment.EquipmentPart; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.gui.adapter.PartsTableMouseAdapter; import mekhq.gui.enums.MHQTabType; diff --git a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java index b05b42b06c6..730436342a3 100644 --- a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java @@ -38,11 +38,11 @@ import static mekhq.campaign.mod.am.InjuryTypes.REPLACEMENT_LIMB_COST_LEG_TYPE_5; import static mekhq.campaign.mod.am.InjuryTypes.REPLACEMENT_LIMB_MINIMUM_SKILL_REQUIRED_TYPES_3_4_5; import static mekhq.campaign.mod.am.InjuryTypes.REPLACEMENT_LIMB_RECOVERY; -import static mekhq.campaign.personnel.SkillType.S_DOCTOR; import static mekhq.campaign.personnel.education.Academy.skillParser; import static mekhq.campaign.personnel.education.EducationController.getAcademy; import static mekhq.campaign.personnel.education.EducationController.makeEnrollmentCheck; import static mekhq.campaign.personnel.enums.education.EducationLevel.DOCTORATE; +import static mekhq.campaign.personnel.skills.SkillType.S_DOCTOR; import static mekhq.campaign.randomEvents.personalities.PersonalityController.writePersonalityDescription; import static mekhq.campaign.randomEvents.prisoners.PrisonerEventManager.processAdHocExecution; @@ -86,7 +86,14 @@ import mekhq.campaign.log.LogEntry; import mekhq.campaign.log.PersonalLogger; import mekhq.campaign.mod.am.InjuryUtil; -import mekhq.campaign.personnel.*; +import mekhq.campaign.personnel.Award; +import mekhq.campaign.personnel.AwardsFactory; +import mekhq.campaign.personnel.BodyLocation; +import mekhq.campaign.personnel.Injury; +import mekhq.campaign.personnel.InjuryType; +import mekhq.campaign.personnel.Person; +import mekhq.campaign.personnel.PersonnelOptions; +import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.autoAwards.AutoAwardsController; import mekhq.campaign.personnel.education.Academy; import mekhq.campaign.personnel.education.AcademyFactory; @@ -107,6 +114,8 @@ import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.RankValidator; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.personalities.PersonalityController; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus; import mekhq.campaign.unit.Unit; diff --git a/MekHQ/src/mekhq/gui/adapter/TaskTableMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/TaskTableMouseAdapter.java index 06543e26547..41b3da55e55 100644 --- a/MekHQ/src/mekhq/gui/adapter/TaskTableMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/TaskTableMouseAdapter.java @@ -27,23 +27,28 @@ */ package mekhq.gui.adapter; +import java.awt.event.ActionEvent; +import java.util.Optional; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.JTable; + import megamek.common.TargetRoll; import mekhq.MekHQ; import mekhq.campaign.event.PartChangedEvent; import mekhq.campaign.event.PartModeChangedEvent; import mekhq.campaign.event.UnitChangedEvent; import mekhq.campaign.parts.Part; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IPartWork; import mekhq.campaign.work.WorkTime; import mekhq.gui.CampaignGUI; import mekhq.gui.model.TaskTableModel; -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.util.Optional; - public class TaskTableMouseAdapter extends JPopupMenuAdapter { //region Variable Declarations private CampaignGUI gui; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java index 5d490375141..bb32c1cc2b6 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java @@ -48,7 +48,7 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.event.OptionsChangedEvent; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.gui.baseComponents.AbstractMHQTabbedPane; import mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/CreateCampaignPreset.java b/MekHQ/src/mekhq/gui/campaignOptions/CreateCampaignPreset.java index 0b8bead4401..a209e36c18d 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/CreateCampaignPreset.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/CreateCampaignPreset.java @@ -27,6 +27,20 @@ */ package mekhq.gui.campaignOptions; +import java.awt.Component; +import java.awt.Container; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.time.LocalDate; +import java.util.Comparator; +import java.util.Map; +import java.util.stream.Collectors; +import javax.swing.*; +import javax.swing.GroupLayout.Alignment; +import javax.swing.border.TitledBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + import megamek.client.ui.baseComponents.MMButton; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.enums.ValidationState; @@ -42,10 +56,10 @@ import mekhq.campaign.Campaign; import mekhq.campaign.CampaignOptions; import mekhq.campaign.RandomSkillPreferences; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.ranks.RankSystem; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.Factions; import mekhq.campaign.universe.Planet; @@ -57,17 +71,6 @@ import mekhq.gui.dialog.DateChooser; import mekhq.gui.displayWrappers.FactionDisplay; -import javax.swing.*; -import javax.swing.GroupLayout.Alignment; -import javax.swing.border.TitledBorder; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import java.awt.*; -import java.time.LocalDate; -import java.util.Comparator; -import java.util.Map; -import java.util.stream.Collectors; - /** * @author Justin "Windchild" Bowen */ diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java index 5de096137d7..5a7e080b3fc 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java @@ -27,6 +27,31 @@ */ package mekhq.gui.campaignOptions.contents; +import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY; +import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.MANEUVERING_ABILITY; +import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.UTILITY_ABILITY; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.ResourceBundle; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + import megamek.client.ui.swing.util.UIUtil; import megamek.common.annotations.Nullable; import megamek.common.options.IOption; @@ -43,24 +68,10 @@ import mekhq.gui.campaignOptions.components.CampaignOptionsStandardPanel; import mekhq.gui.dialog.EditSpecialAbilityDialog; -import javax.swing.*; -import java.awt.*; -import java.util.*; -import java.util.Map.Entry; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY; -import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.MANEUVERING_ABILITY; -import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.UTILITY_ABILITY; -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; - /** - * The {@code AbilitiesTab} class represents a GUI tab for configuring and managing - * special abilities in a campaign. This class handles the initialization, categorization, - * and display of abilities, providing functionality for enabling, disabling, and customizing - * abilities within the combat, maneuvering, and utility categories. + * The {@code AbilitiesTab} class represents a GUI tab for configuring and managing special abilities in a campaign. + * This class handles the initialization, categorization, and display of abilities, providing functionality for + * enabling, disabling, and customizing abilities within the combat, maneuvering, and utility categories. *

* This tab is used as part of the MekHQ campaign options UI for managing personnel-related abilities. */ @@ -75,18 +86,17 @@ public class AbilitiesTab { private JPanel utilityTab; /** - * Constructor for the {@code AbilitiesTab} class. - * Initializes the tab by creating containers for ability categories and populating - * them with related ability information. + * Constructor for the {@code AbilitiesTab} class. Initializes the tab by creating containers for ability categories + * and populating them with related ability information. */ public AbilitiesTab() { initialize(); } /** - * Initializes the internal data structures and UI components for managing abilities. - * Prepares the containers for each ability category (combat, maneuvering, utility) - * and populates the {@code allAbilityInfo} map by processing an initial set of abilities. + * Initializes the internal data structures and UI components for managing abilities. Prepares the containers for + * each ability category (combat, maneuvering, utility) and populates the {@code allAbilityInfo} map by processing + * an initial set of abilities. */ private void initialize() { allAbilityInfo = new HashMap<>(); @@ -98,9 +108,8 @@ private void initialize() { } /** - * Builds and initializes the {@code allAbilityInfo} map, which holds information about - * abilities categorized into combat, maneuvering, and utility abilities. Ensures missing - * abilities are also included and updates the display. + * Builds and initializes the {@code allAbilityInfo} map, which holds information about abilities categorized into + * combat, maneuvering, and utility abilities. Ensures missing abilities are also included and updates the display. * * @param abilities A map of active special abilities keyed by name. */ @@ -111,14 +120,14 @@ public void buildAllAbilityInfo(Map abilities) { // Build list of Level 3 abilities PersonnelOptions personnelOptions = new PersonnelOptions(); - for (final Enumeration i = personnelOptions.getGroups(); i.hasMoreElements();) { + for (final Enumeration i = personnelOptions.getGroups(); i.hasMoreElements(); ) { IOptionGroup group = i.nextElement(); if (!group.getKey().equalsIgnoreCase(PersonnelOptions.LVL3_ADVANTAGES)) { continue; } - for (final Enumeration j = group.getOptions(); j.hasMoreElements();) { + for (final Enumeration j = group.getOptions(); j.hasMoreElements(); ) { IOption option = j.nextElement(); level3Abilities.add(option.getName()); } @@ -145,8 +154,7 @@ public void buildAllAbilityInfo(Map abilities) { } /** - * Refreshes and updates all tabs related to abilities by clearing their contents - * and reloading the data. + * Refreshes and updates all tabs related to abilities by clearing their contents and reloading the data. */ private void refreshAll() { refreshTabContents(combatTab, AbilityCategory.COMBAT_ABILITY); @@ -155,8 +163,8 @@ private void refreshAll() { } /** - * Updates the contents of a specific ability category tab by rebuilding its layout - * and content based on the category. + * Updates the contents of a specific ability category tab by rebuilding its layout and content based on the + * category. * * @param tab The {@code JPanel} representing the tab to be refreshed. * @param category The ability category associated with the tab. @@ -174,12 +182,11 @@ private void refreshTabContents(JPanel tab, AbilityCategory category) { } /** - * Populates the {@code allAbilityInfo} map with special ability information and - * categorizes abilities based on their type (combat, maneuvering, utility). + * Populates the {@code allAbilityInfo} map with special ability information and categorizes abilities based on + * their type (combat, maneuvering, utility). * * @param abilities A map of abilities to be processed. - * @param isEnabled {@code true} if these abilities should start as enabled; - * otherwise, {@code false}. + * @param isEnabled {@code true} if these abilities should start as enabled; otherwise, {@code false}. */ private void buildAbilityInfo(Map abilities, boolean isEnabled) { for (Entry entry : abilities.entrySet()) { @@ -192,25 +199,26 @@ private void buildAbilityInfo(Map abilities, boolean isE } // Mark the ability as active - allAbilityInfo.put(abilityName, new CampaignOptionsAbilityInfo(abilityName, - clonedAbility, isEnabled, category)); + allAbilityInfo.put(abilityName, + new CampaignOptionsAbilityInfo(abilityName, clonedAbility, isEnabled, category)); } } /** - * Determines the {@code AbilityCategory} for the given special ability based on - * skill prerequisites such as "Gunnery", "Piloting", etc. + * Determines the {@code AbilityCategory} for the given special ability based on skill prerequisites such as + * "Gunnery", "Piloting", etc. * * @param ability The {@code SpecialAbility} for which the category will be identified. + * * @return The {@code AbilityCategory} for the specified ability. */ private AbilityCategory getCategory(SpecialAbility ability) { for (SkillPerquisite skillPerquisite : ability.getPrereqSkills()) { // Is the ability classified as a Combat Ability? boolean isCombatAbility = Stream.of("Gunnery", "Artillery", "Small Arms") - .anyMatch(word -> Pattern.compile("\\b" + word) - .matcher(skillPerquisite.toString()) - .find()); + .anyMatch(word -> Pattern.compile("\\b" + word) + .matcher(skillPerquisite.toString()) + .find()); if (isCombatAbility) { return COMBAT_ABILITY; @@ -218,9 +226,9 @@ private AbilityCategory getCategory(SpecialAbility ability) { // Is the ability classified as a Maneuvering Ability? boolean isManeuveringAbility = Stream.of("Piloting", "Anti-Mek") - .anyMatch(word -> Pattern.compile("\\b" + word) - .matcher(skillPerquisite.toString()) - .find()); + .anyMatch(word -> Pattern.compile("\\b" + word) + .matcher(skillPerquisite.toString()) + .find()); if (isManeuveringAbility) { return MANEUVERING_ABILITY; @@ -232,24 +240,22 @@ private AbilityCategory getCategory(SpecialAbility ability) { } /** - * Creates a new abilities configuration tab for a specific category. - * This includes adding controls, headers, and listed abilities. + * Creates a new abilities configuration tab for a specific category. This includes adding controls, headers, and + * listed abilities. * * @param abilityCategory The {@code AbilityCategory} to generate a tab for. + * * @return A {@code JPanel} representing the generated abilities tab. */ public JPanel createAbilitiesTab(AbilityCategory abilityCategory) { // Header JPanel headerPanel = switch (abilityCategory) { - case COMBAT_ABILITY -> - new CampaignOptionsHeaderPanel("CombatAbilitiesTab", - getImageDirectory() + "logo_aurigan_coalition.png"); - case MANEUVERING_ABILITY -> - new CampaignOptionsHeaderPanel("ManeuveringAbilitiesTab", - getImageDirectory() + "logo_clan_hells_horses.png"); - case UTILITY_ABILITY -> - new CampaignOptionsHeaderPanel("UtilityAbilitiesTab", - getImageDirectory() + "logo_circinus_federation.png"); + case COMBAT_ABILITY -> new CampaignOptionsHeaderPanel("CombatAbilitiesTab", + getImageDirectory() + "logo_aurigan_coalition.png"); + case MANEUVERING_ABILITY -> new CampaignOptionsHeaderPanel("ManeuveringAbilitiesTab", + getImageDirectory() + "logo_clan_hells_horses.png"); + case UTILITY_ABILITY -> new CampaignOptionsHeaderPanel("UtilityAbilitiesTab", + getImageDirectory() + "logo_circinus_federation.png"); }; // Contents @@ -328,11 +334,11 @@ public JPanel createAbilitiesTab(AbilityCategory abilityCategory) { } /** - * Creates a panel for rendering a single ability within the tab, enabling users - * to customize or enable/disable the ability. + * Creates a panel for rendering a single ability within the tab, enabling users to customize or enable/disable the + * ability. + * + * @param abilityInfo The {@code CampaignOptionsAbilityInfo} containing details about a specific ability. * - * @param abilityInfo The {@code CampaignOptionsAbilityInfo} containing details - * about a specific ability. * @return A {@code JPanel} containing the UI elements related to the ability. */ private JPanel createSPAPanel(CampaignOptionsAbilityInfo abilityInfo) { @@ -341,19 +347,20 @@ private JPanel createSPAPanel(CampaignOptionsAbilityInfo abilityInfo) { // Initialization final JPanel panel = new AbilitiesTabStandardPanel(ability); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel, - GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL); + GridBagConstraints.NORTHWEST, + GridBagConstraints.HORIZONTAL); // Contents JCheckBox chkAbility = new JCheckBox(resources.getString("abilityEnable.text")); chkAbility.setSelected(abilityInfo.isEnabled()); chkAbility.addActionListener(e -> abilityInfo.setEnabled(chkAbility.isSelected())); - JLabel lblCost = new JLabel(String.format(resources.getString("abilityCost.text"), - ability.getCost())); + JLabel lblCost = new JLabel(String.format(resources.getString("abilityCost.text"), ability.getCost())); JLabel lblDescription = new JLabel(); lblDescription.setText(String.format("

%s
", - UIUtil.scaleForGUI(400), ability.getDescription())); + UIUtil.scaleForGUI(400), + ability.getDescription())); JLabel lblPrerequisites = createAbilityLabel("prerequisites.text", ability.getAllPrereqDesc()); JLabel lblIncompatible = createAbilityLabel("incompatible.text", ability.getInvalidDesc()); @@ -365,19 +372,17 @@ private JPanel createSPAPanel(CampaignOptionsAbilityInfo abilityInfo) { // This will run on the SWT thread SwingUtilities.invokeLater(() -> { // Update components with new values - lblCost.setText(String.format(resources.getString("abilityCost.text"), - ability.getCost())); + lblCost.setText(String.format(resources.getString("abilityCost.text"), ability.getCost())); - String prerequisitesDescription = resources.getString("prerequisites.text") - + ability.getAllPrereqDesc(); + String prerequisitesDescription = resources.getString("prerequisites.text") + + ability.getAllPrereqDesc(); lblPrerequisites.setText(buildAbilityDescription(prerequisitesDescription)); - String incompatibleDescription = resources.getString("incompatible.text") - + ability.getInvalidDesc(); + String incompatibleDescription = resources.getString("incompatible.text") + + ability.getInvalidDesc(); lblIncompatible.setText(buildAbilityDescription(incompatibleDescription)); - String removesDescription = resources.getString("removes.text") - + ability.getRemovedDesc(); + String removesDescription = resources.getString("removes.text") + ability.getRemovedDesc(); lblRemoves.setText(buildAbilityDescription(removesDescription)); }); } @@ -417,8 +422,8 @@ private JPanel createSPAPanel(CampaignOptionsAbilityInfo abilityInfo) { * Opens a dialog to edit the details of the specified special ability. * * @param ability The {@code SpecialAbility} instance to be edited. - * @return {@code true} if the user confirmed the changes; {@code false} if the operation - * was canceled. + * + * @return {@code true} if the user confirmed the changes; {@code false} if the operation was canceled. */ private boolean editSPA(SpecialAbility ability) { Map temporaryMap = new HashMap<>(); @@ -427,22 +432,20 @@ private boolean editSPA(SpecialAbility ability) { temporaryMap.put(info.getKey(), info.getValue().getAbility()); } - EditSpecialAbilityDialog dialog = new EditSpecialAbilityDialog(null, ability, - temporaryMap); + EditSpecialAbilityDialog dialog = new EditSpecialAbilityDialog(null, ability, temporaryMap); dialog.setVisible(true); return !dialog.wasCancelled(); } /** - * A custom {@code JPanel} implementation for displaying abilities configured in the tab. - * Displays the ability's name in a bordered, titled panel and scales the panel size appropriately - * for the UI. + * A custom {@code JPanel} implementation for displaying abilities configured in the tab. Displays the ability's + * name in a bordered, titled panel and scales the panel size appropriately for the UI. */ static class AbilitiesTabStandardPanel extends JPanel { /** - * Constructs a panel representing an individual ability with a styled header based - * on the name of the given {@code SpecialAbility}. + * Constructs a panel representing an individual ability with a styled header based on the name of the given + * {@code SpecialAbility}. * * @param ability The {@code SpecialAbility} used to configure the layout and title of this panel. */ @@ -458,17 +461,18 @@ public Dimension getPreferredSize() { }; setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), - String.format("%s", name))); + String.format("%s", name))); setName("pnl" + name); } } /** - * Creates a label with a description for a specific attribute of the ability. For example, - * prerequisites, incompatible abilities, or removed abilities. + * Creates a label with a description for a specific attribute of the ability. For example, prerequisites, + * incompatible abilities, or removed abilities. * * @param resourceKey The key used to retrieve the label text from resources. * @param descriptionFromAbility The description related to the ability attribute. + * * @return A {@code JLabel} with the generated description. */ private JLabel createAbilityLabel(String resourceKey, String descriptionFromAbility) { @@ -480,20 +484,19 @@ private JLabel createAbilityLabel(String resourceKey, String descriptionFromAbil * Builds the HTML-formatted description for a specific ability or attribute for display in the UI. * * @param description The plain text description to be formatted. + * * @return A string containing the HTML-formatted description. */ private static String buildAbilityDescription(String description) { - return ("" + description + "") - .replaceAll("\\{", "") - .replaceAll("}", ""); + return ("" + description + "").replaceAll("\\{", "").replaceAll("}", ""); } /** - * Applies the current campaign options to a specified {@code CampaignPreset}. - * Enabled abilities are added to the preset or globally updated within the campaign. + * Applies the current campaign options to a specified {@code CampaignPreset}. Enabled abilities are added to the + * preset or globally updated within the campaign. * - * @param preset The {@code CampaignPreset} to apply abilities to, or {@code null} - * for directly setting them in the campaign. + * @param preset The {@code CampaignPreset} to apply abilities to, or {@code null} for directly setting them in the + * campaign. */ public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset) { Map enabledAbilities = new HashMap<>(); diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/AdvancementTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/AdvancementTab.java index 57a7ba92a1a..51014869017 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/AdvancementTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/AdvancementTab.java @@ -43,9 +43,9 @@ import mekhq.campaign.Campaign; import mekhq.campaign.CampaignOptions; import mekhq.campaign.RandomSkillPreferences; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.Phenotype; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.campaignOptions.components.CampaignOptionsCheckBox; import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/EquipmentAndSuppliesTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/EquipmentAndSuppliesTab.java index 9414fbe2936..d56383dc682 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/EquipmentAndSuppliesTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/EquipmentAndSuppliesTab.java @@ -48,7 +48,7 @@ import mekhq.MekHQ; import mekhq.campaign.CampaignOptions; import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.campaignOptions.components.CampaignOptionsCheckBox; import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/MarketsTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/MarketsTab.java index ab403c931e9..8a3b9f0914f 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/MarketsTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/MarketsTab.java @@ -54,7 +54,7 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.market.enums.ContractMarketMethod; import mekhq.campaign.market.enums.UnitMarketMethod; -import mekhq.campaign.personnel.Skills; +import mekhq.campaign.personnel.skills.Skills; import mekhq.gui.campaignOptions.components.CampaignOptionsCheckBox; import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java index 6fe34091ab4..e425e383d14 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java @@ -50,10 +50,10 @@ import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; import mekhq.campaign.CampaignOptions; -import mekhq.campaign.personnel.Skills; import mekhq.campaign.personnel.enums.AwardBonus; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.TimeInDisplayFormat; +import mekhq.campaign.personnel.skills.Skills; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerCaptureStyle; import mekhq.campaign.randomEvents.prisoners.enums.PrisonerStatus; import mekhq.gui.campaignOptions.components.CampaignOptionsCheckBox; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/RulesetsTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/RulesetsTab.java index 3a75fb14bc0..f6391324b00 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/RulesetsTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/RulesetsTab.java @@ -27,6 +27,21 @@ */ package mekhq.gui.campaignOptions.contents; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; + +import java.awt.GridBagConstraints; +import java.util.ResourceBundle; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + import megamek.client.ui.baseComponents.FileNameComboBoxModel; import megamek.client.ui.baseComponents.MMComboBox; import megamek.client.ui.swing.GUIPreferences; @@ -36,17 +51,14 @@ import mekhq.campaign.autoresolve.AutoResolveMethod; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.enums.CombatRole; -import mekhq.campaign.personnel.Skills; -import mekhq.gui.campaignOptions.components.*; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.util.ResourceBundle; - -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; +import mekhq.campaign.personnel.skills.Skills; +import mekhq.gui.campaignOptions.components.CampaignOptionsButton; +import mekhq.gui.campaignOptions.components.CampaignOptionsCheckBox; +import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; +import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; +import mekhq.gui.campaignOptions.components.CampaignOptionsLabel; +import mekhq.gui.campaignOptions.components.CampaignOptionsSpinner; +import mekhq.gui.campaignOptions.components.CampaignOptionsStandardPanel; /** * Represents a tab in the campaign options UI for managing ruleset configurations in campaigns. diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java index 94b135896b3..13b6f12cb23 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java @@ -27,22 +27,40 @@ */ package mekhq.gui.campaignOptions.contents; +import static megamek.common.enums.SkillLevel.ELITE; +import static megamek.common.enums.SkillLevel.GREEN; +import static megamek.common.enums.SkillLevel.NONE; +import static megamek.common.enums.SkillLevel.REGULAR; +import static megamek.common.enums.SkillLevel.ULTRA_GREEN; +import static megamek.common.enums.SkillLevel.VETERAN; +import static megamek.common.enums.SkillLevel.parseFromInteger; +import static mekhq.campaign.personnel.skills.SkillType.isCombatSkill; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; +import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; + +import java.awt.GridBagConstraints; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSpinner; + import megamek.common.annotations.Nullable; import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; import mekhq.campaign.CampaignOptions; -import mekhq.campaign.personnel.SkillType; -import mekhq.gui.campaignOptions.components.*; - -import javax.swing.*; -import java.awt.*; -import java.util.*; -import java.util.List; - -import static megamek.common.enums.SkillLevel.*; -import static mekhq.campaign.personnel.SkillType.isCombatSkill; -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; -import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; +import mekhq.campaign.personnel.skills.SkillType; +import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; +import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; +import mekhq.gui.campaignOptions.components.CampaignOptionsLabel; +import mekhq.gui.campaignOptions.components.CampaignOptionsSpinner; +import mekhq.gui.campaignOptions.components.CampaignOptionsStandardPanel; /** * SkillsTab is a component of the campaign options user interface that allows players diff --git a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java index eaabe24efd9..b6ffe72b34d 100644 --- a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java @@ -51,10 +51,10 @@ import mekhq.campaign.CampaignOptions; import mekhq.campaign.log.PersonalLogger; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.ranks.Rank; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.enums.PersonnelTableModelColumn; import mekhq.gui.model.PersonnelTableModel; import mekhq.gui.utilities.JScrollPaneWithSpeed; diff --git a/MekHQ/src/mekhq/gui/dialog/CampaignExportWizard.java b/MekHQ/src/mekhq/gui/dialog/CampaignExportWizard.java index 129ecf6458d..65d6a31db40 100644 --- a/MekHQ/src/mekhq/gui/dialog/CampaignExportWizard.java +++ b/MekHQ/src/mekhq/gui/dialog/CampaignExportWizard.java @@ -64,8 +64,8 @@ import mekhq.campaign.parts.Armor; import mekhq.campaign.parts.Part; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.gui.CampaignGUI; import mekhq.gui.FileDialogs; diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java index 53248f94d0c..179b6201638 100644 --- a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java @@ -30,8 +30,8 @@ import static java.lang.Math.max; import static java.lang.Math.min; import static megamek.codeUtilities.MathUtility.clamp; -import static mekhq.campaign.personnel.Skill.getCountDownMaxValue; -import static mekhq.campaign.personnel.Skill.getCountUpMaxValue; +import static mekhq.campaign.personnel.skills.Skill.getCountDownMaxValue; +import static mekhq.campaign.personnel.skills.Skill.getCountUpMaxValue; import static mekhq.campaign.randomEvents.personalities.enums.PersonalityQuirk.personalityQuirksSortedAlphabetically; import java.awt.BorderLayout; @@ -76,11 +76,11 @@ import mekhq.campaign.personnel.Bloodname; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.enums.Phenotype; import mekhq.campaign.personnel.enums.education.EducationLevel; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.personalities.PersonalityController; import mekhq.campaign.randomEvents.personalities.enums.Aggression; import mekhq.campaign.randomEvents.personalities.enums.Ambition; diff --git a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java index 0d254d024cf..d619ce188a6 100644 --- a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java @@ -30,8 +30,8 @@ import static java.lang.Math.max; import static java.lang.Math.min; import static megamek.codeUtilities.MathUtility.clamp; -import static mekhq.campaign.personnel.Skill.getCountDownMaxValue; -import static mekhq.campaign.personnel.Skill.getCountUpMaxValue; +import static mekhq.campaign.personnel.skills.Skill.getCountDownMaxValue; +import static mekhq.campaign.personnel.skills.Skill.getCountUpMaxValue; import static mekhq.campaign.randomEvents.personalities.enums.PersonalityQuirk.personalityQuirksSortedAlphabetically; import java.awt.Component; @@ -74,11 +74,11 @@ import mekhq.campaign.personnel.Bloodname; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.enums.Phenotype; import mekhq.campaign.personnel.enums.education.EducationLevel; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.personalities.PersonalityController; import mekhq.campaign.randomEvents.personalities.enums.Aggression; import mekhq.campaign.randomEvents.personalities.enums.Ambition; diff --git a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java index bf89d4d627e..fdf2b6cf786 100644 --- a/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/DataLoadingDialog.java @@ -27,6 +27,30 @@ */ package mekhq.gui.dialog; +import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP; +import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP_ABRIDGED; +import static mekhq.gui.campaignOptions.SelectPresetDialog.PRESET_SELECTION_CANCELLED; +import static mekhq.gui.campaignOptions.SelectPresetDialog.PRESET_SELECTION_CUSTOMIZE; +import static mekhq.gui.campaignOptions.SelectPresetDialog.PRESET_SELECTION_SELECT; +import static mekhq.utilities.EntityUtilities.isUnsupportedEntity; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.FileInputStream; +import java.time.LocalDate; +import java.util.Collection; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JProgressBar; +import javax.swing.SwingWorker; + import megamek.client.generator.RandomCallsignGenerator; import megamek.client.generator.RandomNameGenerator; import megamek.client.ui.swing.util.UIUtil; @@ -47,10 +71,10 @@ import mekhq.campaign.market.enums.ContractMarketMethod; import mekhq.campaign.mod.am.InjuryTypes; import mekhq.campaign.personnel.Bloodname; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.SpecialAbility; import mekhq.campaign.personnel.backgrounds.RandomCompanyNameGenerator; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.storyarc.StoryArc; import mekhq.campaign.storyarc.StoryArcStub; @@ -64,22 +88,6 @@ import mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode; import mekhq.gui.campaignOptions.SelectPresetDialog; -import javax.swing.*; -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.File; -import java.io.FileInputStream; -import java.time.LocalDate; -import java.util.Collection; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; - -import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP; -import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP_ABRIDGED; -import static mekhq.gui.campaignOptions.SelectPresetDialog.*; -import static mekhq.utilities.EntityUtilities.isUnsupportedEntity; - public class DataLoadingDialog extends AbstractMHQDialogBasic implements PropertyChangeListener { private static final MMLogger logger = MMLogger.create(DataLoadingDialog.class); diff --git a/MekHQ/src/mekhq/gui/dialog/EditSkillPerquisiteDialog.java b/MekHQ/src/mekhq/gui/dialog/EditSkillPerquisiteDialog.java index 9b843ad74c9..ff17a0ecae4 100644 --- a/MekHQ/src/mekhq/gui/dialog/EditSkillPerquisiteDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/EditSkillPerquisiteDialog.java @@ -47,7 +47,7 @@ import megamek.logging.MMLogger; import mekhq.MekHQ; import mekhq.campaign.personnel.SkillPerquisite; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.utilities.JScrollPaneWithSpeed; /** @@ -63,26 +63,26 @@ public class EditSkillPerquisiteDialog extends JDialog { private boolean cancelled; private Hashtable> skillLevels = new Hashtable<>(); - private Hashtable skillChks = new Hashtable<>(); + private Hashtable skillChks = new Hashtable<>(); public EditSkillPerquisiteDialog(final JFrame frame, final SkillPerquisite pre) { super(frame, true); cancelled = false; - prereq = pre; + prereq = pre; initComponents(); setLocationRelativeTo(frame); setUserPreferences(); } private void initComponents() { - btnOK = new JButton(); + btnOK = new JButton(); btnClose = new JButton(); JPanel panMain = new JPanel(new GridLayout(SkillType.skillList.length, 2)); for (int i = 0; i < SkillType.getSkillList().length; i++) { - final String type = SkillType.getSkillList()[i]; - JCheckBox chkSkill = new JCheckBox(type); + final String type = SkillType.getSkillList()[i]; + JCheckBox chkSkill = new JCheckBox(type); chkSkill.setSelected(prereq.getSkillLevel(type) > -1); chkSkill.addItemListener(evt -> changeLevelEnabled(type)); skillChks.put(type, chkSkill); diff --git a/MekHQ/src/mekhq/gui/dialog/EditSpecialAbilityDialog.java b/MekHQ/src/mekhq/gui/dialog/EditSpecialAbilityDialog.java index 1d59d2771e8..e94771e5ad8 100644 --- a/MekHQ/src/mekhq/gui/dialog/EditSpecialAbilityDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/EditSpecialAbilityDialog.java @@ -63,8 +63,8 @@ public class EditSpecialAbilityDialog extends JDialog { private SpecialAbility ability; - private JButton btnClose; - private JButton btnOK; + private JButton btnClose; + private JButton btnOK; private JSpinner spnXP; private JButton btnEditPreparerAbility; @@ -73,10 +73,10 @@ public class EditSpecialAbilityDialog extends JDialog { private JButton btnClearPrerequisiteSkills; private JButton btnAddSkillPerquisite; - private Vector prerequisiteAbilities; + private Vector prerequisiteAbilities; private Vector prerequisiteSkills; - private Vector invalidAbilities; - private Vector removeAbilities; + private Vector invalidAbilities; + private Vector removeAbilities; private Map allSPAs; @@ -85,7 +85,7 @@ public class EditSpecialAbilityDialog extends JDialog { private JLabel lblRemoveAbility; private boolean cancelled; - private int currentXP; + private int currentXP; // region Constructors @SuppressWarnings("unchecked") @@ -97,11 +97,11 @@ public EditSpecialAbilityDialog(JFrame parent, SpecialAbility spa, Map // .clone() returns an Object instead of a new Vector - DOH! prerequisiteAbilities = (Vector) ability.getPrereqAbilities().clone(); - invalidAbilities = (Vector) ability.getInvalidAbilities().clone(); - removeAbilities = (Vector) ability.getRemovedAbilities().clone(); - prerequisiteSkills = (Vector) ability.getPrereqSkills().clone(); - cancelled = false; - currentXP = ability.getCost(); + invalidAbilities = (Vector) ability.getInvalidAbilities().clone(); + removeAbilities = (Vector) ability.getRemovedAbilities().clone(); + prerequisiteSkills = (Vector) ability.getPrereqSkills().clone(); + cancelled = false; + currentXP = ability.getCost(); initComponents(); setLocationRelativeTo(parent); setUserPreferences(); @@ -110,35 +110,35 @@ public EditSpecialAbilityDialog(JFrame parent, SpecialAbility spa, MapPrerequisite Abilities"), gridBagConstraints); btnEditPreparerAbility = new JButton("Edit Prerequisite Abilities"); btnEditPreparerAbility.addActionListener(evt -> { @@ -150,27 +150,27 @@ private void initComponents() { refreshGUI(); } }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panAbility.add(btnEditPreparerAbility, gridBagConstraints); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(1, 10, 1, 1); - lblPrerequisiteAbility = new JLabel("" + getPrerequisiteAbilityDesc() + ""); + gridBagConstraints.weighty = 0.0; + gridBagConstraints.insets = new Insets(1, 10, 1, 1); + lblPrerequisiteAbility = new JLabel("" + getPrerequisiteAbilityDesc() + ""); panAbility.add(lblPrerequisiteAbility, gridBagConstraints); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 2; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panAbility.add(new JLabel("Invalid Abilities"), gridBagConstraints); btnEditInvalid = new JButton("Edit Invalid Abilities"); btnEditInvalid.addActionListener(evt -> { @@ -182,27 +182,27 @@ private void initComponents() { refreshGUI(); } }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 2; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panAbility.add(btnEditInvalid, gridBagConstraints); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 3; + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 2; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(1, 10, 1, 1); - lblInvalidAbility = new JLabel("" + getInvalidDesc() + ""); + gridBagConstraints.weighty = 0.0; + gridBagConstraints.insets = new Insets(1, 10, 1, 1); + lblInvalidAbility = new JLabel("" + getInvalidDesc() + ""); panAbility.add(lblInvalidAbility, gridBagConstraints); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 4; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panAbility.add(new JLabel("Removed Abilities"), gridBagConstraints); btnEditRemove = new JButton("Edit Removed Abilities"); btnEditRemove.addActionListener(evt -> { @@ -214,49 +214,49 @@ private void initComponents() { refreshGUI(); } }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 4; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 4; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panAbility.add(btnEditRemove, gridBagConstraints); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 5; + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = 2; - gridBagConstraints.weighty = 1.0; - gridBagConstraints.insets = new Insets(1, 10, 1, 1); - lblRemoveAbility = new JLabel("" + getRemovedDesc() + ""); + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new Insets(1, 10, 1, 1); + lblRemoveAbility = new JLabel("" + getRemovedDesc() + ""); panAbility.add(lblRemoveAbility, gridBagConstraints); JPanel panMain = new JPanel(new GridBagLayout()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 0.0; gridBagConstraints.weighty = 0.0; - gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); + gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); panMain.add(panXP, gridBagConstraints); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; gridBagConstraints.weightx = 0.0; gridBagConstraints.weighty = 1.0; - gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); + gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); panMain.add(panAbility, gridBagConstraints); JPanel panSkill = createSkillPanel(); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 0; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 1.0; - gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); panMain.add(panSkill, gridBagConstraints); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); @@ -270,23 +270,23 @@ private void initComponents() { btnOK.setText("OK"); btnOK.setName("btnOK"); btnOK.addActionListener(evt -> edit()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 6; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 1; - gridBagConstraints.anchor = GridBagConstraints.EAST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); + gridBagConstraints.anchor = GridBagConstraints.EAST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); panButton.add(btnOK, gridBagConstraints); btnClose.setText("Cancel"); btnClose.setName("btnClose"); btnClose.addActionListener(evt -> cancel()); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 6; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 1; - gridBagConstraints.anchor = GridBagConstraints.WEST; - gridBagConstraints.insets = new Insets(5, 5, 5, 5); + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 5, 5); panButton.add(btnClose, gridBagConstraints); getContentPane().add(panButton, BorderLayout.SOUTH); @@ -298,12 +298,12 @@ private JPanel createSkillPanel() { JPanel panSkill = new JPanel(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; panSkill.add(new JLabel("Prerequisite Skill Sets"), gridBagConstraints); btnAddSkillPerquisite = new JButton("Add Skill Prerequisite"); @@ -316,13 +316,13 @@ private JPanel createSkillPanel() { refreshGUI(); } }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; gridBagConstraints.weightx = 0.0; gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.NONE; panSkill.add(btnAddSkillPerquisite, gridBagConstraints); btnClearPrerequisiteSkills = new JButton("Clear Skill Prerequisites"); @@ -330,25 +330,25 @@ private JPanel createSkillPanel() { prerequisiteSkills = new Vector<>(); refreshGUI(); }); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 1; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.NONE; panSkill.add(btnClearPrerequisiteSkills, gridBagConstraints); - gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 2; + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.insets = new Insets(2, 2, 2, 2); - gridBagConstraints.fill = GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 0.0; + gridBagConstraints.insets = new Insets(2, 2, 2, 2); + gridBagConstraints.fill = GridBagConstraints.BOTH; - JPanel panSkPre; + JPanel panSkPre; JButton btnRemoveSkill; JButton btnEditSkill; for (int i = 0; i < prerequisiteSkills.size(); i++) { @@ -356,36 +356,36 @@ private JPanel createSkillPanel() { panSkPre = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); - c.gridx = 0; - c.gridy = 0; + c.gridx = 0; + c.gridy = 0; c.gridheight = 2; - c.weightx = 0.0; - c.weighty = 1.0; - c.anchor = GridBagConstraints.NORTHWEST; - c.insets = new Insets(2, 2, 2, 2); - c.fill = GridBagConstraints.BOTH; + c.weightx = 0.0; + c.weighty = 1.0; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(2, 2, 2, 2); + c.fill = GridBagConstraints.BOTH; panSkPre.add(new JLabel("" + skillPerquisite.toString() + ""), c); - c.gridx = 1; - c.gridy = 0; + c.gridx = 1; + c.gridy = 0; c.gridheight = 1; - c.weightx = 1.0; - c.weighty = 0.0; - c.insets = new Insets(2, 2, 2, 2); - c.anchor = GridBagConstraints.NORTHWEST; - c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1.0; + c.weighty = 0.0; + c.insets = new Insets(2, 2, 2, 2); + c.anchor = GridBagConstraints.NORTHWEST; + c.fill = GridBagConstraints.HORIZONTAL; btnEditSkill = new JButton("Edit"); btnEditSkill.setActionCommand(Integer.toString(i)); btnEditSkill.addActionListener(new EditSkillListener()); panSkPre.add(btnEditSkill, c); - c.gridx = 1; - c.gridy = 1; - c.weightx = 1.0; - c.weighty = 1.0; - c.anchor = GridBagConstraints.NORTHWEST; - c.insets = new Insets(2, 2, 2, 2); - c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = 1; + c.weightx = 1.0; + c.weighty = 1.0; + c.anchor = GridBagConstraints.NORTHWEST; + c.insets = new Insets(2, 2, 2, 2); + c.fill = GridBagConstraints.HORIZONTAL; btnRemoveSkill = new JButton("Remove"); btnRemoveSkill.setActionCommand(Integer.toString(i)); btnRemoveSkill.addActionListener(new RemoveSkillListener()); diff --git a/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java b/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java index d2d0738dd6f..b7b5d6c70e3 100644 --- a/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/MRMSDialog.java @@ -59,7 +59,7 @@ import mekhq.campaign.parts.Part; import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.AmmoBin; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IPartWork; import mekhq.gui.CampaignGUI; diff --git a/MekHQ/src/mekhq/gui/dialog/NewContractDialog.java b/MekHQ/src/mekhq/gui/dialog/NewContractDialog.java index 4d36df73b71..90e99fb398d 100644 --- a/MekHQ/src/mekhq/gui/dialog/NewContractDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/NewContractDialog.java @@ -53,7 +53,7 @@ import mekhq.campaign.mission.Mission; import mekhq.campaign.mission.enums.ContractCommandRights; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.PlanetarySystem; import mekhq.campaign.universe.Systems; import mekhq.gui.utilities.JScrollPaneWithSpeed; diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java index 3cf4c5a26fc..5714682911e 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java @@ -50,8 +50,8 @@ import mekhq.campaign.market.PersonnelMarket; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.GenderDescriptors; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.personalities.enums.Aggression; import mekhq.campaign.randomEvents.personalities.enums.Ambition; import mekhq.campaign.randomEvents.personalities.enums.Greed; diff --git a/MekHQ/src/mekhq/gui/model/CrewListModel.java b/MekHQ/src/mekhq/gui/model/CrewListModel.java index 127b326ee14..2ba8883fdf2 100644 --- a/MekHQ/src/mekhq/gui/model/CrewListModel.java +++ b/MekHQ/src/mekhq/gui/model/CrewListModel.java @@ -27,20 +27,22 @@ */ package mekhq.gui.model; +import java.awt.Component; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import javax.swing.AbstractListModel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + import megamek.common.Aero; import megamek.common.Tank; import megamek.common.VTOL; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.gui.BasicInfo; -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - /** * Model for a list that displays a unit's crew with their role. * diff --git a/MekHQ/src/mekhq/gui/model/DocTableModel.java b/MekHQ/src/mekhq/gui/model/DocTableModel.java index 11506be3c96..39cb653fb8b 100644 --- a/MekHQ/src/mekhq/gui/model/DocTableModel.java +++ b/MekHQ/src/mekhq/gui/model/DocTableModel.java @@ -29,15 +29,14 @@ import java.awt.Component; import java.util.ArrayList; - import javax.swing.JTable; import javax.swing.table.TableCellRenderer; import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.BasicInfo; /** diff --git a/MekHQ/src/mekhq/gui/model/TaskTableModel.java b/MekHQ/src/mekhq/gui/model/TaskTableModel.java index 39fdf4b85af..98062539eb8 100644 --- a/MekHQ/src/mekhq/gui/model/TaskTableModel.java +++ b/MekHQ/src/mekhq/gui/model/TaskTableModel.java @@ -27,6 +27,17 @@ */ package mekhq.gui.model; +import java.awt.Component; +import java.awt.Image; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; + import megamek.common.TargetRoll; import mekhq.IconPackage; import mekhq.campaign.parts.MissingPart; @@ -34,22 +45,12 @@ import mekhq.campaign.parts.PartInventory; import mekhq.campaign.parts.PodSpace; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; +import mekhq.campaign.personnel.skills.Skill; import mekhq.campaign.work.IPartWork; import mekhq.gui.CampaignGUI; import mekhq.gui.ITechWorkPanel; import mekhq.gui.RepairTaskInfo; -import javax.swing.*; -import javax.swing.table.TableCellRenderer; -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * A table model for displaying work items */ diff --git a/MekHQ/src/mekhq/gui/model/TechTableModel.java b/MekHQ/src/mekhq/gui/model/TechTableModel.java index ad158b90bfd..55898487d16 100644 --- a/MekHQ/src/mekhq/gui/model/TechTableModel.java +++ b/MekHQ/src/mekhq/gui/model/TechTableModel.java @@ -36,8 +36,8 @@ import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.work.IPartWork; import mekhq.gui.BasicInfo; import mekhq.gui.CampaignGUI; diff --git a/MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java b/MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java index 226d0b6cff5..a6d13961d5e 100644 --- a/MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java +++ b/MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java @@ -29,7 +29,7 @@ import static mekhq.campaign.mission.AtBDynamicScenarioFactory.scaleObjectiveTimeLimits; import static mekhq.campaign.mission.AtBDynamicScenarioFactory.translateTemplateObjectives; -import static mekhq.campaign.personnel.SkillType.S_LEADER; +import static mekhq.campaign.personnel.skills.SkillType.S_LEADER; import static mekhq.campaign.stratcon.StratconRulesManager.BASE_LEADERSHIP_BUDGET; import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementEligibilityType; import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementResultsType; diff --git a/MekHQ/src/mekhq/gui/view/ContractSummaryPanel.java b/MekHQ/src/mekhq/gui/view/ContractSummaryPanel.java index 3d66ebf5869..07a4fc3316c 100644 --- a/MekHQ/src/mekhq/gui/view/ContractSummaryPanel.java +++ b/MekHQ/src/mekhq/gui/view/ContractSummaryPanel.java @@ -28,6 +28,21 @@ */ package mekhq.gui.view; +import static megamek.client.ui.WrapLayout.wordWrap; + +import java.awt.Cursor; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ResourceBundle; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.JumpPath; @@ -36,19 +51,11 @@ import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.Contract; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Systems; import mekhq.gui.enums.MHQTabType; -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ResourceBundle; - -import static megamek.client.ui.WrapLayout.wordWrap; - /** * Contract summary view for ContractMarketDialog * diff --git a/MekHQ/src/mekhq/gui/view/ForceViewPanel.java b/MekHQ/src/mekhq/gui/view/ForceViewPanel.java index 545ae0d6388..9f4619ee56b 100644 --- a/MekHQ/src/mekhq/gui/view/ForceViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/ForceViewPanel.java @@ -52,7 +52,7 @@ import mekhq.campaign.force.Force; import mekhq.campaign.force.ForceType; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.gui.baseComponents.JScrollablePanel; import mekhq.gui.utilities.MarkdownRenderer; diff --git a/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java b/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java index c53e111e8dc..b57511607cd 100644 --- a/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java +++ b/MekHQ/src/mekhq/gui/view/LanceAssignmentView.java @@ -54,7 +54,7 @@ import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.mission.enums.CombatRole; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.gui.model.DataTableModel; import mekhq.gui.utilities.MekHqTableCellRenderer; diff --git a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java index bb00531ccc8..646d5b933c9 100644 --- a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java @@ -76,13 +76,13 @@ import mekhq.campaign.personnel.Injury; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.education.Academy; import mekhq.campaign.personnel.education.EducationController; import mekhq.campaign.personnel.enums.GenderDescriptors; import mekhq.campaign.personnel.enums.PersonnelStatus; import mekhq.campaign.personnel.enums.education.EducationStage; import mekhq.campaign.personnel.familyTree.FormerSpouse; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.PlanetarySystem; import mekhq.gui.CampaignGUI; import mekhq.gui.baseComponents.JScrollablePanel; @@ -93,22 +93,6 @@ import mekhq.gui.utilities.MarkdownRenderer; import mekhq.gui.utilities.WrapLayout; -import javax.accessibility.AccessibleRelation; -import javax.swing.*; -import javax.swing.table.TableColumn; -import java.awt.*; -import java.awt.Dialog.ModalityType; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.*; -import java.util.List; -import java.util.stream.Collectors; - -import static megamek.client.ui.WrapLayout.wordWrap; -import static megamek.common.EntityWeightClass.WEIGHT_ULTRA_LIGHT; -import static mekhq.campaign.personnel.Person.getLoyaltyName; - /** * A custom panel that gets filled in with goodies from a Person record * diff --git a/MekHQ/src/mekhq/module/atb/AtBEventProcessor.java b/MekHQ/src/mekhq/module/atb/AtBEventProcessor.java index c0f162b4e98..d91a94c9156 100644 --- a/MekHQ/src/mekhq/module/atb/AtBEventProcessor.java +++ b/MekHQ/src/mekhq/module/atb/AtBEventProcessor.java @@ -51,8 +51,8 @@ import mekhq.campaign.finances.Money; import mekhq.campaign.finances.enums.TransactionType; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.IUnitRating; import mekhq.campaign.universe.Factions; import mekhq.campaign.universe.IUnitGenerator; diff --git a/MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java b/MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java index 56fa0f69b25..6188c308c9f 100644 --- a/MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java +++ b/MekHQ/src/mekhq/module/atb/PersonnelMarketAtB.java @@ -34,8 +34,8 @@ import megamek.common.Compute; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.module.api.PersonnelMarketMethod; /** diff --git a/MekHQ/src/mekhq/service/mrms/MRMSOption.java b/MekHQ/src/mekhq/service/mrms/MRMSOption.java index 1c94e09372c..500b7193c1c 100644 --- a/MekHQ/src/mekhq/service/mrms/MRMSOption.java +++ b/MekHQ/src/mekhq/service/mrms/MRMSOption.java @@ -31,14 +31,13 @@ import java.util.ArrayList; import java.util.List; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import megamek.Version; import megamek.logging.MMLogger; import mekhq.campaign.parts.enums.PartRepairType; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.utilities.MHQXMLUtility; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; public class MRMSOption { private static final MMLogger logger = MMLogger.create(MRMSOption.class); diff --git a/MekHQ/src/mekhq/service/mrms/MRMSService.java b/MekHQ/src/mekhq/service/mrms/MRMSService.java index dda96260c09..42576303b3a 100644 --- a/MekHQ/src/mekhq/service/mrms/MRMSService.java +++ b/MekHQ/src/mekhq/service/mrms/MRMSService.java @@ -53,8 +53,8 @@ import mekhq.campaign.parts.enums.PartRepairType; import mekhq.campaign.parts.equipment.AmmoBin; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.IPartWork; import mekhq.campaign.work.WorkTime; diff --git a/MekHQ/unittests/mekhq/campaign/autoresolve/ResolverTest.java b/MekHQ/unittests/mekhq/campaign/autoresolve/ResolverTest.java index 1bd2eccc6a5..d9dd0f7a90e 100644 --- a/MekHQ/unittests/mekhq/campaign/autoresolve/ResolverTest.java +++ b/MekHQ/unittests/mekhq/campaign/autoresolve/ResolverTest.java @@ -28,8 +28,26 @@ package mekhq.campaign.autoresolve; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; + import megamek.client.ui.swing.util.PlayerColour; -import megamek.common.*; +import megamek.common.Board; +import megamek.common.Crew; +import megamek.common.CrewType; +import megamek.common.Entity; +import megamek.common.EquipmentType; +import megamek.common.MekSummary; import megamek.common.autoresolve.Resolver; import megamek.common.autoresolve.acar.SimulationOptions; import megamek.common.autoresolve.converter.FlattenForces; @@ -37,7 +55,13 @@ import megamek.common.enums.Gender; import megamek.common.enums.SkillLevel; import megamek.common.icons.Camouflage; -import megamek.common.planetaryconditions.*; +import megamek.common.planetaryconditions.Atmosphere; +import megamek.common.planetaryconditions.BlowingSand; +import megamek.common.planetaryconditions.EMI; +import megamek.common.planetaryconditions.Fog; +import megamek.common.planetaryconditions.Light; +import megamek.common.planetaryconditions.Weather; +import megamek.common.planetaryconditions.Wind; import mekhq.campaign.Campaign; import mekhq.campaign.RandomSkillPreferences; import mekhq.campaign.force.Force; @@ -47,31 +71,25 @@ import mekhq.campaign.mission.BotForce; import mekhq.campaign.mission.enums.CombatRole; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.generator.AbstractSkillGenerator; import mekhq.campaign.personnel.generator.DefaultSkillGenerator; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.rating.CamOpsReputation.ReputationController; import mekhq.campaign.unit.Unit; import mekhq.campaign.universe.Systems; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.RepeatedTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.function.Consumer; - -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; - /** * @author Luana Coppio diff --git a/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java b/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java index c2826498553..fa4e7c663f2 100644 --- a/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java +++ b/MekHQ/unittests/mekhq/campaign/parts/MekLocationTest.java @@ -52,16 +52,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.function.Predicate; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - import megamek.Version; import megamek.common.CriticalSlot; import megamek.common.Entity; @@ -79,10 +72,15 @@ import mekhq.campaign.parts.equipment.EquipmentPart; import mekhq.campaign.personnel.Person; import mekhq.campaign.personnel.PersonnelOptions; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; import mekhq.campaign.work.WorkTime; import mekhq.utilities.MHQXMLUtility; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; class MekLocationTest { @Test diff --git a/MekHQ/unittests/mekhq/campaign/personnel/education/AcademyTests.java b/MekHQ/unittests/mekhq/campaign/personnel/education/AcademyTests.java index 585f7f6236b..ffe86019783 100644 --- a/MekHQ/unittests/mekhq/campaign/personnel/education/AcademyTests.java +++ b/MekHQ/unittests/mekhq/campaign/personnel/education/AcademyTests.java @@ -27,25 +27,25 @@ */ package mekhq.campaign.personnel.education; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.List; + import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.education.AcademyType; import mekhq.campaign.personnel.enums.education.EducationLevel; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Faction; import mekhq.campaign.universe.PlanetarySystem; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.util.Arrays; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.when; - class AcademyTests { @Test void testSetName() { diff --git a/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/EventEffectsManagerTest.java b/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/EventEffectsManagerTest.java index edec467252f..3aa4befd7fe 100644 --- a/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/EventEffectsManagerTest.java +++ b/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/EventEffectsManagerTest.java @@ -27,11 +27,38 @@ */ package mekhq.campaign.randomEvents.prisoners; +import static mekhq.campaign.mission.enums.AtBMoraleLevel.STALEMATE; +import static mekhq.campaign.personnel.enums.PersonnelRole.ADMINISTRATOR_LOGISTICS; +import static mekhq.campaign.personnel.enums.PersonnelRole.DEPENDENT; +import static mekhq.campaign.personnel.enums.PersonnelRole.NONE; +import static mekhq.campaign.personnel.enums.PersonnelRole.SOLDIER; +import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; +import static mekhq.campaign.personnel.skills.SkillType.S_DOCTOR; +import static mekhq.campaign.personnel.skills.SkillType.S_SMALL_ARMS; +import static mekhq.campaign.randomEvents.prisoners.enums.EventResultEffect.*; +import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.BARTERING; +import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.BREAKOUT; +import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.MISTAKE; +import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.POISON; +import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.UNDERCOVER; +import static mekhq.campaign.randomEvents.prisoners.enums.ResponseQuality.RESPONSE_NEUTRAL; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + import mekhq.campaign.Campaign; import mekhq.campaign.CampaignOptions; import mekhq.campaign.mission.AtBContract; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.randomEvents.prisoners.records.EventResult; import mekhq.campaign.randomEvents.prisoners.records.PrisonerEventData; import mekhq.campaign.randomEvents.prisoners.records.PrisonerResponseEntry; @@ -39,25 +66,6 @@ import mekhq.campaign.universe.Faction; import org.junit.jupiter.api.Test; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -import static mekhq.campaign.mission.enums.AtBMoraleLevel.STALEMATE; -import static mekhq.campaign.personnel.SkillType.S_ADMIN; -import static mekhq.campaign.personnel.SkillType.S_DOCTOR; -import static mekhq.campaign.personnel.SkillType.S_SMALL_ARMS; -import static mekhq.campaign.personnel.enums.PersonnelRole.ADMINISTRATOR_LOGISTICS; -import static mekhq.campaign.personnel.enums.PersonnelRole.DEPENDENT; -import static mekhq.campaign.personnel.enums.PersonnelRole.NONE; -import static mekhq.campaign.personnel.enums.PersonnelRole.SOLDIER; -import static mekhq.campaign.randomEvents.prisoners.enums.EventResultEffect.*; -import static mekhq.campaign.randomEvents.prisoners.enums.PrisonerEvent.*; -import static mekhq.campaign.randomEvents.prisoners.enums.ResponseQuality.RESPONSE_NEUTRAL; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - /** * Unit test class for the {@link EventEffectsManager}. * diff --git a/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/PrisonerMissionEndEventTest.java b/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/PrisonerMissionEndEventTest.java index e68e52abdcf..60bd0f46583 100644 --- a/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/PrisonerMissionEndEventTest.java +++ b/MekHQ/unittests/mekhq/campaign/randomEvents/prisoners/PrisonerMissionEndEventTest.java @@ -27,29 +27,29 @@ */ package mekhq.campaign.randomEvents.prisoners; -import mekhq.campaign.Campaign; -import mekhq.campaign.CampaignOptions; -import mekhq.campaign.finances.Money; -import mekhq.campaign.mission.AtBContract; -import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; -import java.util.List; - import static mekhq.campaign.personnel.Person.MEKWARRIOR_AERO_RANSOM_VALUES; import static mekhq.campaign.personnel.Person.OTHER_RANSOM_VALUES; -import static mekhq.campaign.personnel.SkillType.S_GUN_MEK; -import static mekhq.campaign.personnel.SkillType.S_PILOT_MEK; -import static mekhq.campaign.personnel.SkillType.S_SMALL_ARMS; import static mekhq.campaign.personnel.enums.PersonnelRole.MEKWARRIOR; import static mekhq.campaign.personnel.enums.PersonnelRole.SOLDIER; +import static mekhq.campaign.personnel.skills.SkillType.S_GUN_MEK; +import static mekhq.campaign.personnel.skills.SkillType.S_PILOT_MEK; +import static mekhq.campaign.personnel.skills.SkillType.S_SMALL_ARMS; import static mekhq.campaign.randomEvents.prisoners.PrisonerMissionEndEvent.GOOD_EVENT_CHANCE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.time.LocalDate; +import java.util.List; + +import mekhq.campaign.Campaign; +import mekhq.campaign.CampaignOptions; +import mekhq.campaign.finances.Money; +import mekhq.campaign.mission.AtBContract; +import mekhq.campaign.personnel.Person; +import mekhq.campaign.personnel.skills.SkillType; +import org.junit.jupiter.api.Test; + /** * This class contains unit tests for the {@link PrisonerMissionEndEvent} class, focusing on the * functionality and correctness of methods such as {@code determineGoodEventChance} and {@code getRansom}. diff --git a/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java b/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java index 6ce4fb4698b..1e8315ea3ec 100644 --- a/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java +++ b/MekHQ/unittests/mekhq/campaign/rating/FieldManualMercRevDragoonsRatingTest.java @@ -44,19 +44,18 @@ import java.util.List; import java.util.Vector; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import megamek.common.*; import mekhq.campaign.Campaign; import mekhq.campaign.CampaignOptions; import mekhq.campaign.Hangar; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.Skill; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.enums.PersonnelRole; import mekhq.campaign.personnel.enums.PersonnelStatus; +import mekhq.campaign.personnel.skills.Skill; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Deric Page (deric (dot) page (at) usa.net) diff --git a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UntreatedPersonnelNagLogicTest.java b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UntreatedPersonnelNagLogicTest.java index 6a02476d51e..3a3c6b08a79 100644 --- a/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UntreatedPersonnelNagLogicTest.java +++ b/MekHQ/unittests/mekhq/gui/dialog/nagDialogs/nagLogic/UntreatedPersonnelNagLogicTest.java @@ -27,8 +27,8 @@ */ package mekhq.gui.dialog.nagDialogs.nagLogic; -import static mekhq.campaign.personnel.SkillType.S_DOCTOR; import static mekhq.campaign.personnel.enums.PersonnelRole.DOCTOR; +import static mekhq.campaign.personnel.skills.SkillType.S_DOCTOR; import static mekhq.gui.dialog.nagDialogs.nagLogic.UntreatedPersonnelNagLogic.campaignHasUntreatedInjuries; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -41,8 +41,8 @@ import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.SkillType; import mekhq.campaign.personnel.ranks.Ranks; +import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.universe.Systems; import mekhq.gui.dialog.nagDialogs.UntreatedPersonnelNagDialog; import org.junit.jupiter.api.BeforeAll; From 5b4bcfc606fdcedb85ba1ac01fd0a6f4344531eb Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 2 Apr 2025 14:06:31 -0500 Subject: [PATCH 2/3] Added ATOW Attributes to Skills; Improved Combat vs. Non-Combat Skill Handling - Introduced `SkillAttribute` enum to represent attributes associated with skills. - Includes attributes such as REFLEXES, DEXTERITY, CHARISMA, etc. - Provides a utility method `fromString` for parsing input strings or integers. - Updated `SkillType` class: - Added references to `SkillAttribute` and `SkillSubType`. - Integrated new attributes `firstAttribute`, `secondAttribute`, and `subType`. - Deprecated methods `isCombatSkill`, `isPiloting`, and `isGunnery` in favor of `isSubTypeOf` methods. - Enhanced XML deserialization to handle new attributes and ensure backward compatibility. - Implemented a robust compatibility handler for legacy `SkillType` definitions. - Ensures compliance with new standards by updating subtype and attributes where missing. --- .../CampaignOptionsDialog.properties | 52 +- .../campaign/personnel/skills/SkillType.java | 456 ++++++++++++++---- .../skills/enums/SkillAttribute.java | 116 +++++ .../personnel/skills/enums/SkillSubType.java | 104 ++++ .../campaignOptions/CampaignOptionsPane.java | 16 +- .../campaignOptions/contents/SkillsTab.java | 240 ++++----- 6 files changed, 726 insertions(+), 258 deletions(-) create mode 100644 MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillAttribute.java create mode 100644 MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillSubType.java diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties index a4daa7d8d9a..6d73e4bd2c4 100644 --- a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties @@ -1904,16 +1904,24 @@ lblRecruitmentBonusesCombatPanel.text=Combat Roles lblRecruitmentBonusesSupportPanel.text=Support Roles ## Advancement Tab skillsContentTabs.title=Skills -combatSkillsTab.title=Combat Skills -combatSkillsTab.border="Every skill you master is another weapon in your arsenal. Out here, the\ +0gunnerySkillsTab.title=Gunnery Skills +0gunnerySkillsTab.border="Every skill you master is another weapon in your arsenal. Out here, the\ \ better you fight, the longer you live."\
Sergeant Mick "Crash" Lannister\
The Enforcers
-supportSkillsTab.title=Support Skills -supportSkillsTab.border="Support staff are like the coolant system in a 'Mek \u2014 nobody notices them\ +1pilotingSkillsTab.title=Piloting Skills +1pilotingSkillsTab.border="Victory or debt!"\ +
The Mercenary's Battle Cry +2supportSkillsTab.title=Support Skills +2supportSkillsTab.border="Support staff are like the coolant system in a 'Mek \u2014 nobody notices them\ \ until they're gone, and then everyone's screaming."\
Sergeant Leo "Gears" Malone\
The Panther Corsairs
+3roleplaySkillsTab.title=Roleplay Skills +3roleplaySkillsTab.border="War doesn't just change planets and politics \u2014 it changes us. The person you\ + \ are doesn't survive who you become."\ +
Colonel Erik "Warhound" Voss\ +
The Scion Saviors
btnToggle.text=Toggle Advanced Options btnHideAll.text=Hide All Advanced Options btnDisplayAll.text=Display All Advanced Options @@ -1934,40 +1942,10 @@ lblSkillLevel8.text=8 lblSkillLevel9.text=9 lblSkillLevel10.text=10 # Combat Skills Tab -lblCombatSkillsTab.text=Combat Skill Options -lblSkillPanelPiloting/Mek.text=Piloting/Mek -lblSkillPanelPiloting/Aerospace.text=Piloting/Aerospace -lblSkillPanelPiloting/Aircraft.text=Piloting/Aircraft -lblSkillPanelPiloting/GroundVehicle.text=Piloting/Ground Vehicle -lblSkillPanelPiloting/VTOL.text=Piloting/VTOL -lblSkillPanelPiloting/Naval.text=Piloting/Naval -lblSkillPanelPiloting/Spacecraft.text=Piloting/Spacecraft -lblSkillPanelGunnery/Mek.text=Gunnery/Mek -lblSkillPanelGunnery/Aerospace.text=Gunnery/Aerospace -lblSkillPanelGunnery/Aircraft.text=Gunnery/Aircraft -lblSkillPanelGunnery/Vehicle.text=Gunnery/Vehicle -lblSkillPanelGunnery/Spacecraft.text=Gunnery/Spacecraft -lblSkillPanelGunnery/BattleArmor.text=Gunnery/BattleArmor -lblSkillPanelGunnery/ProtoMek.text=Gunnery/ProtoMek -lblSkillPanelArtillery.text=Artillery -lblSkillPanelSmallArms.text=Small Arms -lblSkillPanelAnti-Mek.text=Anti-Mek +lblGunnerySkillsTab.text=Gunnery Skill Options +lblPilotingSkillsTab.text=Piloting Skill Options lblSupportSkillsTab.text=Support Skill Options -lblSkillPanelTech/Mek.text=Tech/Mek -lblSkillPanelTech/Mechanic.text=Tech/Mechanic -lblSkillPanelTech/Aero.text=Tech/Aero -lblSkillPanelTech/BattleArmor.text=Tech/BattleArmor -lblSkillPanelTech/Vessel.text=Tech/Vessel -lblSkillPanelAstech.text=Astech -lblSkillPanelDoctor.text=Doctor -lblSkillPanelMedTech.text=MedTech -lblSkillPanelHyperspaceNavigation.text=Hyperspace Navigation -lblSkillPanelAdministration.text=Administration -lblSkillPanelNegotiation.text=Negotiation -lblSkillPanelLeadership.text=Leadership -lblSkillPanelScrounge.text=Scrounge (Deprecated) -lblSkillPanelStrategy.text=Strategy -lblSkillPanelTactics.text=Tactics +lblRoleplaySkillsTab.text=Roleplay Skill Options ## Advancement Tab abilityContentTabs.title=Abilities combatAbilitiesTab.title=Combat Abilities diff --git a/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java b/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java index afdd97b6b0f..9926d2a42c9 100644 --- a/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/SkillType.java @@ -28,9 +28,19 @@ */ package mekhq.campaign.personnel.skills; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.CHARISMA; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.DEXTERITY; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.INTELLIGENCE; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.NONE; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.REFLEXES; +import static mekhq.campaign.personnel.skills.enums.SkillAttribute.WILLPOWER; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_PILOTING; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT; +import static mekhq.utilities.ReportingUtilities.messageSurroundedBySpanWithColor; + import java.io.PrintWriter; import java.util.Hashtable; -import java.util.List; import java.util.Map; import megamek.common.Aero; @@ -45,16 +55,16 @@ import megamek.common.enums.SkillLevel; import megamek.logging.MMLogger; import mekhq.MekHQ; +import mekhq.campaign.personnel.skills.enums.SkillAttribute; +import mekhq.campaign.personnel.skills.enums.SkillSubType; import mekhq.utilities.MHQXMLUtility; -import mekhq.utilities.ReportingUtilities; import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * Skill type will hold static information for each skill type like base target - * number, - * whether to count up, and XP costs for advancement. + * Skill type will hold static information for each skill type like base target number, whether to count up, and XP + * costs for advancement. * * @author Jay Lawson (jaylawson39 at yahoo.com) */ @@ -99,40 +109,12 @@ public class SkillType { public static final int NUM_LEVELS = 11; - public static final String[] skillList = { - S_PILOT_MEK, - S_GUN_MEK, - S_PILOT_AERO, - S_GUN_AERO, - S_PILOT_GVEE, - S_PILOT_VTOL, - S_PILOT_NVEE, - S_GUN_VEE, - S_PILOT_JET, - S_GUN_JET, - S_PILOT_SPACE, - S_GUN_SPACE, - S_ARTILLERY, - S_GUN_BA, - S_GUN_PROTO, - S_SMALL_ARMS, - S_ANTI_MEK, - S_TECH_MEK, - S_TECH_MECHANIC, - S_TECH_AERO, - S_TECH_BA, - S_TECH_VESSEL, - S_ASTECH, - S_DOCTOR, - S_MEDTECH, - S_NAV, - S_ADMIN, - S_TACTICS, - S_STRATEGY, - S_NEG, - S_LEADER, - S_SCROUNGE - }; + public static final String[] skillList = { S_PILOT_MEK, S_GUN_MEK, S_PILOT_AERO, S_GUN_AERO, S_PILOT_GVEE, + S_PILOT_VTOL, S_PILOT_NVEE, S_GUN_VEE, S_PILOT_JET, S_GUN_JET, + S_PILOT_SPACE, S_GUN_SPACE, S_ARTILLERY, S_GUN_BA, S_GUN_PROTO, + S_SMALL_ARMS, S_ANTI_MEK, S_TECH_MEK, S_TECH_MECHANIC, S_TECH_AERO, + S_TECH_BA, S_TECH_VESSEL, S_ASTECH, S_DOCTOR, S_MEDTECH, S_NAV, S_ADMIN, + S_TACTICS, S_STRATEGY, S_NEG, S_LEADER, S_SCROUNGE }; public static Map lookupHash; @@ -148,14 +130,18 @@ public class SkillType { private String name; private int target; private boolean countUp; + private SkillSubType subType; + private SkillAttribute firstAttribute; + private SkillAttribute secondAttribute; private int greenLvl; private int regLvl; private int vetLvl; private int eliteLvl; private Integer[] costs; - /** + /** * @param level skill level integer to get name for + * * @return String skill name */ public static String getExperienceLevelName(int level) { @@ -172,6 +158,7 @@ public static String getExperienceLevelName(int level) { /** * @param level skill level integer to get color for + * * @return String hex code for a font tag */ public static String getExperienceLevelColor(int level) { @@ -181,17 +168,17 @@ public static String getExperienceLevelColor(int level) { case EXP_REGULAR -> MekHQ.getMHQOptions().getFontColorSkillRegularHexColor(); case EXP_VETERAN -> MekHQ.getMHQOptions().getFontColorSkillVeteranHexColor(); case EXP_ELITE -> MekHQ.getMHQOptions().getFontColorSkillEliteHexColor(); - case -1 -> ""; default -> ""; }; } - /** + /** * @param level SkillLevel enum to get color for + * * @return String hex code for a font tag */ public static String getExperienceLevelColor(SkillLevel level) { - return switch(level) { + return switch (level) { case ULTRA_GREEN -> MekHQ.getMHQOptions().getFontColorSkillUltraGreenHexColor(); case GREEN -> MekHQ.getMHQOptions().getFontColorSkillGreenHexColor(); case REGULAR -> MekHQ.getMHQOptions().getFontColorSkillRegularHexColor(); @@ -204,21 +191,18 @@ public static String getExperienceLevelColor(SkillLevel level) { } /** - * Checks if a given skill is a combat skill. + * @deprecated was previously used by Campaign Options, now unused. * - * @param skill The skill to check if it is a combat skill. - * @return {@code true} if the skill is a combat skill, {@code false} otherwise. + *

Use {@link #isSubTypeOf(SkillSubType)} instead.

*/ + @Deprecated(since = "0.50.05", forRemoval = true) public static boolean isCombatSkill(SkillType skill) { - List combatSkills = List.of(S_PILOT_MEK, S_PILOT_AERO, S_PILOT_JET, S_PILOT_GVEE, S_PILOT_VTOL, - S_PILOT_NVEE, S_PILOT_SPACE, S_GUN_MEK, S_GUN_AERO, S_GUN_JET, S_GUN_VEE, S_GUN_SPACE, - S_GUN_BA, S_GUN_PROTO, S_ARTILLERY, S_SMALL_ARMS, S_ANTI_MEK); - - return combatSkills.contains(skill.getName()); + return skill.isSubTypeOf(COMBAT_GUNNERY) || skill.isSubTypeOf(COMBAT_PILOTING); } /** * @param level - skill level integer to get tagged name for + * * @return "Skillname" wrapped by coloring span or bare if no color exists */ public static String getColoredExperienceLevelName(int level) { @@ -226,12 +210,12 @@ public static String getColoredExperienceLevelName(int level) { return getExperienceLevelName(level); } - return ReportingUtilities.messageSurroundedBySpanWithColor( - getExperienceLevelColor(level), getExperienceLevelName(level)); + return messageSurroundedBySpanWithColor(getExperienceLevelColor(level), getExperienceLevelName(level)); } /** * @param level - SkillLevel enum to get tagged name for + * * @return "Skillname" wrapped by coloring span or bare if no color exists */ public static String getColoredExperienceLevelName(SkillLevel level) { @@ -239,15 +223,13 @@ public static String getColoredExperienceLevelName(SkillLevel level) { return level.toString(); } - return ReportingUtilities.messageSurroundedBySpanWithColor( - getExperienceLevelColor(level), level.toString()); + return messageSurroundedBySpanWithColor(getExperienceLevelColor(level), level.toString()); } public static void setSkillTypes(Map skills) { // we are going to cycle through all skills in case ones have been added since - // this hash - // was created + // this hash was created for (String name : skillList) { if (null != skills.get(name)) { lookupHash.put(name, skills.get(name)); @@ -292,21 +274,33 @@ public boolean countUp() { return countUp; } + public SkillSubType getSubType() { + return subType; + } + + public boolean isSubTypeOf(SkillSubType subType) { + return this.subType == subType; + } + + public SkillAttribute getFirstAttribute() { + return firstAttribute; + } + + public SkillAttribute getSecondAttribute() { + return secondAttribute; + } + public int getLevelFromExperience(int expLvl) { - switch (expLvl) { - case EXP_REGULAR: - return regLvl; - case EXP_VETERAN: - return vetLvl; - case EXP_ELITE: - return eliteLvl; - case EXP_GREEN: - return greenLvl; - default: + return switch (expLvl) { + case EXP_REGULAR -> regLvl; + case EXP_VETERAN -> vetLvl; + case EXP_ELITE -> eliteLvl; + case EXP_GREEN -> greenLvl; + default -> // for ultra-green we take the midpoint between green and 0, rounding down. // If the user has set green as zero, then this will be the same - return (int) Math.floor(greenLvl / 2.0); - } + (int) Math.floor(greenLvl / 2.0); + }; } public int getGreenLevel() { @@ -368,8 +362,7 @@ public int getTotalCost(int lvl) { } /** - * @return the maximum level of that skill (the last one not set to cost = -1, - * or 10) + * @return the maximum level of that skill (the last one not set to cost = -1, or 10) */ public int getMaxLevel() { for (int lvl = 0; lvl < costs.length; ++lvl) { @@ -388,19 +381,34 @@ public static void setCost(String name, int cost, int lvl) { } } + /** + * @deprecated use {@link #isSubTypeOf(SkillSubType)} instead. + */ + @Deprecated(since = "0.50.05", forRemoval = true) public boolean isPiloting() { - return name.equals(S_PILOT_MEK) || name.equals(S_PILOT_AERO) - || name.equals(S_PILOT_GVEE) || name.equals(S_PILOT_VTOL) - || name.equals(S_PILOT_NVEE) || name.equals(S_PILOT_JET) - || name.equals(S_PILOT_SPACE); + return name.equals(S_PILOT_MEK) || + name.equals(S_PILOT_AERO) || + name.equals(S_PILOT_GVEE) || + name.equals(S_PILOT_VTOL) || + name.equals(S_PILOT_NVEE) || + name.equals(S_PILOT_JET) || + name.equals(S_PILOT_SPACE); } + /** + * @deprecated use {@link #isSubTypeOf(SkillSubType)} instead. + */ + @Deprecated(since = "0.50.05", forRemoval = true) public boolean isGunnery() { - return name.equals(S_GUN_MEK) || name.equals(S_GUN_AERO) - || name.equals(S_GUN_VEE) || name.equals(S_GUN_BA) - || name.equals(S_SMALL_ARMS) || name.equals(S_GUN_JET) - || name.equals(S_GUN_SPACE) || name.equals(S_GUN_PROTO) - || name.equals(S_ARTILLERY); + return name.equals(S_GUN_MEK) || + name.equals(S_GUN_AERO) || + name.equals(S_GUN_VEE) || + name.equals(S_GUN_BA) || + name.equals(S_SMALL_ARMS) || + name.equals(S_GUN_JET) || + name.equals(S_GUN_SPACE) || + name.equals(S_GUN_PROTO) || + name.equals(S_ARTILLERY); } public int getExperienceLevel(int lvl) { @@ -522,6 +530,9 @@ public void writeToXML(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "name", name); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "target", target); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "countUp", countUp); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "subType", subType.toString()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "firstAttribute", firstAttribute.toString()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "secondAttribute", secondAttribute.toString()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "greenLvl", greenLvl); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "regLvl", regLvl); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "vetLvl", vetLvl); @@ -537,17 +548,17 @@ public void writeToXML(final PrintWriter pw, int indent) { */ public static void generateInstanceFromXML(Node workingNode) { try { - SkillType relativeValue = new SkillType(); + SkillType skillType = new SkillType(); NodeList nodeList = workingNode.getChildNodes(); for (int x = 0; x < nodeList.getLength(); x++) { Node wn2 = nodeList.item(x); if (wn2.getNodeName().equalsIgnoreCase("name")) { - // relativeValue.name = wn2.getTextContent(); + // skillType.name = wn2.getTextContent(); //Start <50.01 compatibility handler. // The above code can be uncommented once these handlers have been removed - relativeValue.name = switch (wn2.getTextContent().toLowerCase()) { + skillType.name = switch (wn2.getTextContent().toLowerCase()) { case "piloting/mech" -> "Piloting/Mek"; case "gunnery/mech" -> "Gunnery/Mek"; case "gunnery/battlesuit" -> "Gunnery/BattleArmor"; @@ -560,77 +571,209 @@ public static void generateInstanceFromXML(Node workingNode) { }; //End <50.01 compatibility handler } else if (wn2.getNodeName().equalsIgnoreCase("target")) { - relativeValue.target = Integer.parseInt(wn2.getTextContent()); + skillType.target = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("greenLvl")) { - relativeValue.greenLvl = Integer.parseInt(wn2.getTextContent()); + skillType.greenLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("regLvl")) { - relativeValue.regLvl = Integer.parseInt(wn2.getTextContent()); + skillType.regLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("vetLvl")) { - relativeValue.vetLvl = Integer.parseInt(wn2.getTextContent()); + skillType.vetLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("eliteLvl")) { - relativeValue.eliteLvl = Integer.parseInt(wn2.getTextContent()); + skillType.eliteLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("countUp")) { - relativeValue.countUp = Boolean.parseBoolean(wn2.getTextContent().trim()); + skillType.countUp = Boolean.parseBoolean(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("subType")) { + skillType.subType = SkillSubType.fromString(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("firstAttribute")) { + skillType.firstAttribute = SkillAttribute.fromString(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("secondAttribute")) { + skillType.secondAttribute = SkillAttribute.fromString(wn2.getTextContent().trim()); } else if (wn2.getNodeName().equalsIgnoreCase("costs")) { String[] values = wn2.getTextContent().split(","); for (int i = 0; i < values.length; i++) { - relativeValue.costs[i] = Integer.parseInt(values[i]); + skillType.costs[i] = Integer.parseInt(values[i]); } } } - lookupHash.put(relativeValue.name, relativeValue); + // <50.05 compatibility handler + if (skillType.getSubType() == null || + skillType.getFirstAttribute() == null || + skillType.getSecondAttribute() == null) { + compatibilityHandler(skillType); + } + + lookupHash.put(skillType.name, skillType); } catch (Exception ex) { logger.error("", ex); } } - public static void generateSeparateInstanceFromXML(final Node wn, - final Map hash) { + public static void generateSeparateInstanceFromXML(final Node wn, final Map hash) { try { - SkillType retVal = new SkillType(); + SkillType skillType = new SkillType(); NodeList nl = wn.getChildNodes(); for (int x = 0; x < nl.getLength(); x++) { Node wn2 = nl.item(x); if (wn2.getNodeName().equalsIgnoreCase("name")) { - retVal.name = wn2.getTextContent(); + skillType.name = wn2.getTextContent(); } else if (wn2.getNodeName().equalsIgnoreCase("target")) { - retVal.target = Integer.parseInt(wn2.getTextContent()); + skillType.target = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("greenLvl")) { - retVal.greenLvl = Integer.parseInt(wn2.getTextContent()); + skillType.greenLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("regLvl")) { - retVal.regLvl = Integer.parseInt(wn2.getTextContent()); + skillType.regLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("vetLvl")) { - retVal.vetLvl = Integer.parseInt(wn2.getTextContent()); + skillType.vetLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("eliteLvl")) { - retVal.eliteLvl = Integer.parseInt(wn2.getTextContent()); + skillType.eliteLvl = Integer.parseInt(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("countUp")) { - retVal.countUp = Boolean.parseBoolean(wn2.getTextContent().trim()); + skillType.countUp = Boolean.parseBoolean(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("subType")) { + skillType.subType = SkillSubType.fromString(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("firstAttribute")) { + skillType.firstAttribute = SkillAttribute.fromString(wn2.getTextContent().trim()); + } else if (wn2.getNodeName().equalsIgnoreCase("secondAttribute")) { + skillType.secondAttribute = SkillAttribute.fromString(wn2.getTextContent().trim()); } else if (wn2.getNodeName().equalsIgnoreCase("costs")) { String[] values = wn2.getTextContent().split(","); for (int i = 0; i < values.length; i++) { - retVal.costs[i] = Integer.parseInt(values[i]); + skillType.costs[i] = Integer.parseInt(values[i]); } } } - if ("Gunnery/Protomek".equals(retVal.getName())) { // Renamed in 0.49.12 - retVal.name = "Gunnery/ProtoMek"; + if ("Gunnery/Protomek".equals(skillType.getName())) { // Renamed in 0.49.12 + skillType.name = "Gunnery/ProtoMek"; + } + + // <50.05 compatibility handler + if (skillType.getSubType() == null || + skillType.getFirstAttribute() == null || + skillType.getSecondAttribute() == null) { + compatibilityHandler(skillType); } - hash.put(retVal.name, retVal); + hash.put(skillType.name, skillType); } catch (Exception ex) { logger.error("", ex); } } + /** + * Handles compatibility upgrades for outdated or incomplete {@link SkillType} definitions. + * + *

This method ensures that instances of {@link SkillType} are updated to meet current standards by: + * assigning suitable subtypes and attributes based on predefined mappings. If the skill type is recognized as + * outdated or missing attributes, the method creates a temporary reference skill and updates the original skill + * instance. All changes are logged, and unrecognized skill types are flagged with an error log.

+ * + *

Behavior:

+ *
    + *
  • Checks if the {@code skillType} is {@code null} and logs a message. If {@code null}, no processing is + * performed.
  • + *
  • Matches the name of the {@link SkillType} against predefined mappings to check for compatibility issues.
  • + *
  • Uses a factory method to create a temporary {@link SkillType} instance designed for the corresponding skill + * (e.g., {@code createPilotingMek()}, {@code createGunneryAero()}).
  • + *
  • Updates incomplete attributes (subtype, first attribute, or second attribute) on the original + * {@link SkillType} to match the temporary reference. Logs the updates for traceability.
  • + *
  • If the skill type name is not recognized, logs an error and halts further processing.
  • + *
+ * + *

Error Handling:

+ *
    + *
  • If the skill type is {@code null}, logs a warning and skips the update process.
  • + *
  • If the skill type name is invalid or unmapped, logs an error with the message + * "Unexpected value in compatibilityHandler".
  • + *
+ * + * @param skillType the {@link SkillType} instance to be checked and updated for compatibility. If the + * {@code skillType} is {@code null}, no action is performed. + */ + private static void compatibilityHandler(SkillType skillType) { + if (skillType == null) { + logger.info("SkillType is null, unable to update compatibility. " + + "This suggests a deeper issue and should be reported."); + return; + } + + SkillType temporarySkillType = switch (skillType.getName()) { + case S_PILOT_MEK, "Piloting/Mech" -> createPilotingMek(); + case S_GUN_MEK, "Gunnery/Mech" -> createGunneryMek(); + case S_PILOT_AERO -> createPilotingAero(); + case S_GUN_AERO -> createGunneryAero(); + case S_PILOT_JET -> createPilotingJet(); + case S_GUN_JET -> createGunneryJet(); + case S_PILOT_SPACE -> createPilotingSpace(); + case S_GUN_SPACE -> createGunnerySpace(); + case S_PILOT_GVEE -> createPilotingGroundVee(); + case S_PILOT_NVEE -> createPilotingNavalVee(); + case S_PILOT_VTOL -> createPilotingVTOL(); + case S_GUN_VEE -> createGunneryVehicle(); + case S_ARTILLERY -> createArtillery(); + case S_GUN_BA, "Gunnery/Battlesuit" -> createGunneryBA(); + case S_GUN_PROTO, "Gunnery/ProtoMech" -> createGunneryProto(); + case S_SMALL_ARMS -> createSmallArms(); + case S_ANTI_MEK, "Anti-Mech" -> createAntiMek(); + case S_TECH_MEK, "Tech/Mech" -> createTechMek(); + case S_TECH_MECHANIC -> createTechMechanic(); + case S_TECH_AERO -> createTechAero(); + case S_TECH_BA, "Tech/BA" -> createTechBA(); + case S_TECH_VESSEL -> createTechVessel(); + case S_ASTECH -> createAstech(); + case S_DOCTOR -> createDoctor(); + case S_MEDTECH, "Medtech" -> createMedTech(); + case S_NAV -> createNav(); + case S_ADMIN -> createAdmin(); + case S_NEG -> createNegotiation(); + case S_LEADER -> createLeadership(); + case S_SCROUNGE -> createScrounge(); + case S_STRATEGY -> createStrategy(); + case S_TACTICS -> createTactics(); + default -> { + logger.errorDialog("REPORT TO MEGAMEK TEAM", + "Unexpected value in compatibilityHandler: {}", + skillType.getName()); + yield null; + } + }; + + if (temporarySkillType == null) { + return; + } + + if (skillType.getSubType() == null) { + skillType.subType = temporarySkillType.getSubType(); + logger.info("SkillType {} has been updated to sub type {}", + skillType.getName(), + temporarySkillType.getSubType()); + } + + if (skillType.getFirstAttribute() == null) { + skillType.firstAttribute = temporarySkillType.getFirstAttribute(); + logger.info("SkillType {} has been updated to first attribute {}", + skillType.getName(), + temporarySkillType.getFirstAttribute()); + } + + if (skillType.getSecondAttribute() == null) { + skillType.secondAttribute = temporarySkillType.getSecondAttribute(); + logger.info("SkillType {} has been updated to second attribute {}", + skillType.getName(), + temporarySkillType.getSecondAttribute()); + } + } + public static SkillType createPilotingMek() { SkillType skill = new SkillType(); skill.name = S_PILOT_MEK; skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -642,6 +785,9 @@ public static SkillType createGunneryMek() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -653,6 +799,9 @@ public static SkillType createPilotingAero() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -664,6 +813,9 @@ public static SkillType createGunneryAero() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -675,6 +827,9 @@ public static SkillType createPilotingJet() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -686,6 +841,9 @@ public static SkillType createGunneryJet() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -697,6 +855,9 @@ public static SkillType createPilotingSpace() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -708,6 +869,9 @@ public static SkillType createGunnerySpace() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -719,6 +883,9 @@ public static SkillType createPilotingGroundVee() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -730,6 +897,9 @@ public static SkillType createPilotingNavalVee() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -741,6 +911,9 @@ public static SkillType createPilotingVTOL() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_PILOTING; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -752,6 +925,9 @@ public static SkillType createGunneryVehicle() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -763,6 +939,9 @@ public static SkillType createArtillery() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = WILLPOWER; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -774,6 +953,9 @@ public static SkillType createGunneryBA() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -785,6 +967,9 @@ public static SkillType createGunneryProto() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = REFLEXES; + skill.secondAttribute = DEXTERITY; skill.costs = new Integer[] { 16, 8, 8, 8, 8, 8, 8, 8, -1, -1, -1 }; return skill; @@ -796,6 +981,9 @@ public static SkillType createSmallArms() { skill.target = 7; skill.greenLvl = 2; skill.countUp = false; + skill.subType = COMBAT_GUNNERY; + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -807,6 +995,11 @@ public static SkillType createAntiMek() { skill.target = 8; skill.greenLvl = 2; skill.countUp = false; + // Anti-Mek is the 'piloting' skill of Conventional Infantry + skill.subType = COMBAT_PILOTING; + // Anti-Mek doesn't exist in ATOW so we use the linked attributes Demolitions + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 6, 6, 6, 6, 6, 6, 6, -1, -1 }; return skill; @@ -817,6 +1010,10 @@ public static SkillType createTechMek() { skill.name = S_TECH_MEK; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Technician' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 0, 6, 6, 6, -1, -1, -1, -1, -1 }; return skill; @@ -827,6 +1024,10 @@ public static SkillType createTechMechanic() { skill.name = S_TECH_MECHANIC; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Technician' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 0, 6, 6, 6, -1, -1, -1, -1, -1 }; return skill; @@ -837,6 +1038,10 @@ public static SkillType createTechAero() { skill.name = S_TECH_AERO; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Technician' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 0, 6, 6, 6, -1, -1, -1, -1, -1 }; return skill; @@ -847,6 +1052,10 @@ public static SkillType createTechBA() { skill.name = S_TECH_BA; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Technician' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 0, 6, 6, 6, -1, -1, -1, -1, -1 }; return skill; @@ -857,6 +1066,10 @@ public static SkillType createTechVessel() { skill.name = S_TECH_VESSEL; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Technician' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 12, 6, 0, 6, 6, 6, -1, -1, -1, -1, -1 }; return skill; @@ -867,6 +1080,10 @@ public static SkillType createAstech() { skill.name = S_ASTECH; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This doesn't correspond to an ATOW skill, so we went with INTELLIGENCE as the tech equivalent of MedTech + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; return skill; @@ -877,6 +1094,10 @@ public static SkillType createDoctor() { skill.name = S_DOCTOR; skill.target = 11; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Surgery' + skill.firstAttribute = DEXTERITY; + skill.secondAttribute = INTELLIGENCE; skill.costs = new Integer[] { 16, 8, 0, 8, 8, 8, -1, -1, -1, -1, -1 }; return skill; @@ -887,6 +1108,9 @@ public static SkillType createMedTech() { skill.name = S_MEDTECH; skill.target = 11; skill.countUp = false; + skill.subType = SUPPORT; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; return skill; @@ -897,6 +1121,9 @@ public static SkillType createNav() { skill.name = S_NAV; skill.target = 8; skill.countUp = false; + skill.subType = SUPPORT; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, -1, -1 }; return skill; @@ -907,6 +1134,9 @@ public static SkillType createTactics() { skill.name = S_TACTICS; skill.target = 0; skill.countUp = true; + skill.subType = SUPPORT; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = WILLPOWER; skill.costs = new Integer[] { 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }; return skill; @@ -917,6 +1147,9 @@ public static SkillType createStrategy() { skill.name = S_STRATEGY; skill.target = 0; skill.countUp = true; + skill.subType = SUPPORT; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = WILLPOWER; skill.costs = new Integer[] { 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }; return skill; @@ -927,6 +1160,9 @@ public static SkillType createAdmin() { skill.name = S_ADMIN; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + skill.firstAttribute = INTELLIGENCE; + skill.secondAttribute = WILLPOWER; skill.costs = new Integer[] { 8, 4, 0, 4, 4, 4, -1, -1, -1, -1, -1 }; return skill; @@ -937,6 +1173,9 @@ public static SkillType createLeadership() { skill.name = S_LEADER; skill.target = 0; skill.countUp = true; + skill.subType = SUPPORT; + skill.firstAttribute = WILLPOWER; + skill.secondAttribute = CHARISMA; skill.costs = new Integer[] { 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }; return skill; @@ -947,6 +1186,9 @@ public static SkillType createNegotiation() { skill.name = S_NEG; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + skill.firstAttribute = CHARISMA; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; return skill; @@ -957,6 +1199,10 @@ public static SkillType createScrounge() { skill.name = S_SCROUNGE; skill.target = 10; skill.countUp = false; + skill.subType = SUPPORT; + // This corresponds to the ATOW skill 'Negotiation' + skill.firstAttribute = CHARISMA; + skill.secondAttribute = NONE; skill.costs = new Integer[] { 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; return skill; diff --git a/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillAttribute.java b/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillAttribute.java new file mode 100644 index 00000000000..aea128407ca --- /dev/null +++ b/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillAttribute.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2025 The MegaMek Team. All Rights Reserved. + * + * This file is part of MekHQ. + * + * MekHQ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License (GPL), + * version 3 or (at your option) any later version, + * as published by the Free Software Foundation. + * + * MekHQ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * A copy of the GPL should have been included with this project; + * if not, see . + * + * NOTICE: The MegaMek organization is a non-profit group of volunteers + * creating free software for the BattleTech community. + * + * MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks + * of The Topps Company, Inc. All Rights Reserved. + * + * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of + * InMediaRes Productions, LLC. + */ +package mekhq.campaign.personnel.skills.enums; + +import megamek.logging.MMLogger; + +/** + * Enum representing the primary attributes associated with skills in MekHQ. These attributes correspond to their ATOW + * equivalents. + * + *

This enum also provides a utility method to parse values from strings or integers.

+ */ +public enum SkillAttribute { + /** + * Represents no specific attribute. + */ + NONE, + + /** + * Represents physical strength or power. + */ + STRENGTH, + + /** + * Represents overall physical condition and health. + */ + BODY, + + /** + * Represents coordination and fine motor skills. + */ + DEXTERITY, + + /** + * Represents reflexes or reaction time. + */ + REFLEXES, + + /** + * Represents cognitive ability and problem-solving skills. + */ + INTELLIGENCE, + + /** + * Represents mental willpower and determination. + */ + WILLPOWER, + + /** + * Represents social skills and personal magnetism. + */ + CHARISMA; + + /** + * Converts a string or integer input to its corresponding {@link SkillAttribute}. + * + *

This method attempts the following:

+ * + *
    + *
  • Parses the input string to match a {@link SkillAttribute} value. The input is case-insensitive, and + * spaces are replaced with underscores ("_").
  • + *
  • If the above fails, converts the input string to an integer and matches it to an ordinal value + * of {@link SkillAttribute}.
  • + *
  • If both attempts fail, logs an error and returns {@link #NONE} as the default value.
  • + *
+ * + * @param text The input string or integer representing the skill attribute. + * + * @return The corresponding {@link SkillAttribute} value if the input is valid, or {@link #NONE} as the default if + * fault if it is not. + */ + public static SkillAttribute fromString(String text) { + try { + // Attempt to parse as string with case/space adjustments. + return SkillAttribute.valueOf(text.toUpperCase().replace(" ", "_")); + } catch (Exception ignored) { + } + + try { + // Attempt to parse as an integer and use as ordinal. + return SkillAttribute.values()[Integer.parseInt(text)]; + } catch (Exception ignored) { + } + + // Log error if parsing fails and return default value. + MMLogger logger = MMLogger.create(SkillAttribute.class); + logger.error("Unknown SkillAttribute ordinal: {} - returning {}.", text, NONE); + + return NONE; + } +} diff --git a/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillSubType.java b/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillSubType.java new file mode 100644 index 00000000000..a1ae2bf4fb7 --- /dev/null +++ b/MekHQ/src/mekhq/campaign/personnel/skills/enums/SkillSubType.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2025 The MegaMek Team. All Rights Reserved. + * + * This file is part of MekHQ. + * + * MekHQ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License (GPL), + * version 3 or (at your option) any later version, + * as published by the Free Software Foundation. + * + * MekHQ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * A copy of the GPL should have been included with this project; + * if not, see . + * + * NOTICE: The MegaMek organization is a non-profit group of volunteers + * creating free software for the BattleTech community. + * + * MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks + * of The Topps Company, Inc. All Rights Reserved. + * + * Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of + * InMediaRes Productions, LLC. + */ +package mekhq.campaign.personnel.skills.enums; + +import megamek.logging.MMLogger; + +/** + * Enum representing the sub-types of skills used in MekHQ. + * + *

The available skill sub-types are:

+ * + *
    + *
  • {@link #COMBAT_GUNNERY}: Representing gunnery-related combat skills.
  • + *
  • {@link #COMBAT_PILOTING}: Representing piloting-related combat skills.
  • + *
  • {@link #SUPPORT}: Representing non-combat, support-related skills.
  • + *
  • {@link #ROLEPLAY}: Representing skills for roleplay or narrative elements.
  • + *
+ *

+ * This enum also includes a utility method for parsing {@link SkillSubType} values from strings + * or integers. + */ +public enum SkillSubType { + /** + * Represents gunnery-related combat skills. + */ + COMBAT_GUNNERY, + + /** + * Represents piloting-related combat skills. + */ + COMBAT_PILOTING, + + /** + * Represents support (non-combat) skills. + */ + SUPPORT, + + /** + * Represents roleplay or narrative-based skills. + */ + ROLEPLAY; + + /** + * Converts a string or integer input to its corresponding {@link SkillSubType}. + * + *

This method attempts the following:

+ *
    + *
  • Parses the input string as a {@link SkillSubType} value. The input is case-insensitive and can contain spaces, + * which will be replaced by underscores ("_").
  • + *
  • If the above fails, converts the input string to an integer and attempts to match it to an ordinal value + * of {@link SkillSubType}.
  • + *
  • If both attempts fail, logs an error and returns {@link #COMBAT_GUNNERY} as the default value.
  • + *
+ * + * @param text The input string or integer representing the skill subtype. + * + * @return The corresponding {@link SkillSubType} value if the input is valid, or {@link #COMBAT_GUNNERY} as the + * default if it is not. + */ + public static SkillSubType fromString(String text) { + try { + // Attempt to parse as string with case/space adjustments. + return SkillSubType.valueOf(text.toUpperCase().replace(" ", "_")); + } catch (Exception ignored) { + } + + try { + // Attempt to parse as an integer and use as ordinal. + return SkillSubType.values()[Integer.parseInt(text)]; + } catch (Exception ignored) { + } + + // Log error if parsing fails and return default value. + MMLogger logger = MMLogger.create(SkillSubType.class); + logger.error("Unknown SkillSubType ordinal: {} - returning {}.", text, COMBAT_GUNNERY); + + return COMBAT_GUNNERY; + } +} diff --git a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java index bb32c1cc2b6..42af608c091 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java @@ -29,6 +29,9 @@ import static java.lang.Math.round; import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_PILOTING; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT; import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.ABRIDGED; import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP_ABRIDGED; import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createSubTabs; @@ -299,10 +302,12 @@ private JTabbedPane createAdvancementParentTab() { // Skills skillsTab = new SkillsTab(campaignOptions); - JTabbedPane skillsContentTabs = createSubTabs(Map.of("combatSkillsTab", - skillsTab.createSkillsTab(true), - "supportSkillsTab", - skillsTab.createSkillsTab(false))); + JTabbedPane skillsContentTabs = createSubTabs(Map.of("0gunnerySkillsTab", + skillsTab.createSkillsTab(COMBAT_GUNNERY), + "1pilotingSkillsTab", + skillsTab.createSkillsTab(COMBAT_PILOTING), + "2supportSkillsTab", + skillsTab.createSkillsTab(SUPPORT))); skillsTab.loadValuesFromCampaignOptions(); // SPAs @@ -445,7 +450,8 @@ private JTabbedPane createStrategicOperationsParentTab() { * @param isStartUp specifies whether this is run as part of a startup initialization * @param isSaveAction determines if this action is saving options to a preset */ - public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset, boolean isStartUp, boolean isSaveAction) { + public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset, boolean isStartUp, + boolean isSaveAction) { CampaignOptions options = this.campaignOptions; RandomSkillPreferences presetRandomSkillPreferences = null; Map presetSkills = null; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java index 13b6f12cb23..1302cb10e45 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/SkillsTab.java @@ -34,7 +34,8 @@ import static megamek.common.enums.SkillLevel.ULTRA_GREEN; import static megamek.common.enums.SkillLevel.VETERAN; import static megamek.common.enums.SkillLevel.parseFromInteger; -import static mekhq.campaign.personnel.skills.SkillType.isCombatSkill; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT; import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel; import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory; @@ -44,6 +45,7 @@ import java.util.List; import java.util.Map; import java.util.ResourceBundle; +import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -56,6 +58,7 @@ import megamek.logging.MMLogger; import mekhq.campaign.CampaignOptions; import mekhq.campaign.personnel.skills.SkillType; +import mekhq.campaign.personnel.skills.enums.SkillSubType; import mekhq.gui.campaignOptions.components.CampaignOptionsGridBagConstraints; import mekhq.gui.campaignOptions.components.CampaignOptionsHeaderPanel; import mekhq.gui.campaignOptions.components.CampaignOptionsLabel; @@ -63,8 +66,8 @@ import mekhq.gui.campaignOptions.components.CampaignOptionsStandardPanel; /** - * SkillsTab is a component of the campaign options user interface that allows players - * to configure the rules and costs associated with skills in their campaign. + * SkillsTab is a component of the campaign options user interface that allows players to configure the rules and costs + * associated with skills in their campaign. *

* This tab can be configured for either combat or support skills. It allows users to: *

@@ -100,11 +103,11 @@ public class SkillsTab { private static final MMLogger logger = MMLogger.create(SkillsTab.class); /** - * Constructs a new `SkillsTab` instance and initializes the necessary data - * structures for managing skill configurations. + * Constructs a new `SkillsTab` instance and initializes the necessary data structures for managing skill + * configurations. * - * @param campaignOptions the {@code CampaignOptions} instance that holds the settings - * to be modified or displayed in this tab. + * @param campaignOptions the {@code CampaignOptions} instance that holds the settings to be modified or displayed + * in this tab. */ public SkillsTab(CampaignOptions campaignOptions) { this.campaignOptions = campaignOptions; @@ -112,17 +115,16 @@ public SkillsTab(CampaignOptions campaignOptions) { } /** - * Initializes the SkillsTab by setting up the necessary data structures and - * default values for skill configuration. + * Initializes the SkillsTab by setting up the necessary data structures and default values for skill + * configuration. */ private void initialize() { initializeGeneral(); } /** - * Sets up the general data structures needed for skill configuration in the - * SkillsTab. This includes collections for tracking target numbers, costs, - * and milestones for every skill. + * Sets up the general data structures needed for skill configuration in the SkillsTab. This includes collections + * for tracking target numbers, costs, and milestones for every skill. */ private void initializeGeneral() { allTargetNumbers = new HashMap<>(); @@ -138,37 +140,62 @@ private void initializeGeneral() { spnEdgeCost = new JSpinner(); } + @Deprecated(since = "0.50.05", forRemoval = true) + public JPanel createSkillsTab(boolean isCombatTab) { + return createSkillsTab(isCombatTab ? COMBAT_GUNNERY : SUPPORT); + } + /** - * Creates the main panel for the SkillsTab UI. - *

- * Depending on the `isCombatTab` argument, it creates a tab for either combat - * or support skills. The tab displays skill panels associated with the selected - * category, allowing users to configure their target numbers, costs, and milestones. - *

+ * Creates the main panel for the SkillsTab UI based on the provided {@link SkillSubType} category. + * + *

This method dynamically generates a tab for either combat, support, or roleplay skills. The tab displays + * skill + * panels associated with the specified category, allowing users to configure target numbers, costs, and milestones. + * It also includes buttons to toggle visibility of skill panels and manages layout to organize various UI + * components.

* - * @param isCombatTab a boolean indicating whether this is a combat tab - * (true for combat skills, false for support skills). - * @return a {@link JPanel} containing the dynamically generated skill options - * for the selected tab. + * @param category the {@link SkillSubType} representing the skill category. This determines which set of skills + * will be displayed (e.g., {@code COMBAT_GUNNERY}, {@code COMBAT_PILOTING}, {@code SUPPORT}, or + * {@code ROLEPLAY}). + * + * @return a {@link JPanel} containing the dynamically generated skill options and UI components for the selected + * category. */ - public JPanel createSkillsTab(boolean isCombatTab) { + public JPanel createSkillsTab(SkillSubType category) { // Header - JPanel headerPanel; - if (isCombatTab) { - headerPanel = new CampaignOptionsHeaderPanel("CombatSkillsTab", - getImageDirectory() + "logo_clan_diamond_sharks.png"); - } else { - headerPanel = new CampaignOptionsHeaderPanel("SupportSkillsTab", - getImageDirectory() + "logo_free_worlds_league.png"); + JPanel headerPanel = new JPanel(); + String panelName = ""; + switch (category) { + case COMBAT_GUNNERY -> { + headerPanel = new CampaignOptionsHeaderPanel("GunnerySkillsTab", + getImageDirectory() + "logo_clan_diamond_sharks.png"); + panelName = "GunnerySkillsTab"; + } + case COMBAT_PILOTING -> { + headerPanel = new CampaignOptionsHeaderPanel("PilotingSkillsTab", + getImageDirectory() + "logo_capellan_confederation.png"); + panelName = "PilotingSkillsTab"; + } + case SUPPORT -> { + headerPanel = new CampaignOptionsHeaderPanel("SupportSkillsTab", + getImageDirectory() + "logo_clan_goliath_scorpion.png"); + panelName = "SupportSkillsTab"; + } + case ROLEPLAY -> { + headerPanel = new CampaignOptionsHeaderPanel("RoleplaySkillsTab", + getImageDirectory() + "logo_clan_jade_falcon.png", + true); + panelName = "RoleplaySkillsTab"; + } } // Contents List relevantSkills = new ArrayList<>(); for (String skillName : SkillType.getSkillList()) { SkillType skill = SkillType.getType(skillName); - boolean isCombatSkill = isCombatSkill(skill); + SkillSubType subType = skill.getSubType(); - if (isCombatSkill == isCombatTab) { + if (subType == category || (subType == null && category == COMBAT_GUNNERY)) { relevantSkills.add(skill); } } @@ -182,11 +209,10 @@ public JPanel createSkillsTab(boolean isCombatTab) { // Content pnlEdgeCost = createEdgeCostPanel(); - pnlEdgeCost.setVisible(!isCombatTab); + pnlEdgeCost.setVisible(category == COMBAT_GUNNERY); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel(isCombatTab ? - "CombatSkillsTab" : "SupportSkillsTab", true); + final JPanel panel = new CampaignOptionsStandardPanel(panelName, true); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); // Create a button to toggle the table @@ -249,12 +275,10 @@ public JPanel createSkillsTab(boolean isCombatTab) { */ private JPanel createEdgeCostPanel() { lblEdgeCost = new CampaignOptionsLabel("EdgeCost"); - spnEdgeCost = new CampaignOptionsSpinner("EdgeCost", - 100, 0, 500, 1); + spnEdgeCost = new CampaignOptionsSpinner("EdgeCost", 100, 0, 500, 1); // Layout the Panel - final JPanel panel = new CampaignOptionsStandardPanel("EdgeCostPanel", - true, "EdgeCostPanel"); + final JPanel panel = new CampaignOptionsStandardPanel("EdgeCostPanel", true, "EdgeCostPanel"); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); layout.gridwidth = 1; @@ -270,8 +294,8 @@ private JPanel createEdgeCostPanel() { /** * Toggles the visibility of all components related to skills in the SkillsTab UI. *

- * This can be used to either hide or display all components for easier navigation - * or cleaner representation of the tab. + * This can be used to either hide or display all components for easier navigation or cleaner representation of the + * tab. *

* * @param visible a boolean indicating whether to show or hide all components. @@ -285,17 +309,16 @@ private void setVisibleForAll(boolean visible) { /** * Toggles the visibility of a specific category of components in the SkillsTab UI. *

- * This method allows visibility control over target numbers, costs, and skill - * level milestones based on the provided component map. + * This method allows visibility control over target numbers, costs, and skill level milestones based on the + * provided component map. *

* * @param componentsMap a map containing the components to show or hide. - * @param visible a boolean indicating whether to show or hide the components. - * @param the type of the component to toggle visibility for - * (e.g., {@link JSpinner}, {@link JComboBox}). + * @param visible a boolean indicating whether to show or hide the components. + * @param the type of the component to toggle visibility for (e.g., {@link JSpinner}, + * {@link JComboBox}). */ - private void setVisibleForAll(Map> componentsMap, - boolean visible) { + private void setVisibleForAll(Map> componentsMap, boolean visible) { for (String SkillName : componentsMap.keySet()) { List components = componentsMap.get(SkillName); if (components != null) { @@ -311,14 +334,15 @@ private void setVisibleForAll(Map> compon *

* Each skill panel includes controls for: *

- *

  • Setting the target number for the skill.
  • - *
  • Configuring costs of the skill at different levels.
  • - *
  • Defining milestones for skill progression (e.g., from Green to Veteran).
  • + *
  • Setting the target number for the skill.
  • + *
  • Configuring costs of the skill at different levels.
  • + *
  • Defining milestones for skill progression (e.g., from Green to Veteran).
  • *

    * Copy and paste buttons are available for transferring configurations between skills. *

    * * @param skill the {@link SkillType} object representing the skill to be configured. + * * @return a {@link JPanel} containing the UI components for the given skill. */ private JPanel createSkillPanel(SkillType skill) { @@ -326,8 +350,7 @@ private JPanel createSkillPanel(SkillType skill) { // Create the target number spinner JLabel lblTargetNumber = new CampaignOptionsLabel("SkillPanelTargetNumber"); - JSpinner spnTargetNumber = new CampaignOptionsSpinner("SkillPanelTargetNumber", - 0, 0, 12, 1); + JSpinner spnTargetNumber = new CampaignOptionsSpinner("SkillPanelTargetNumber", 0, 0, 12, 1); allTargetNumbers.put(skill.getName(), spnTargetNumber); List labels = new ArrayList<>(); @@ -343,8 +366,7 @@ private JPanel createSkillPanel(SkillType skill) { labels.add(label); skillLevels.add(label); - JSpinner spinner = new CampaignOptionsSpinner("SkillLevel" + i, - null, 0, -1, 9999, 1, true); + JSpinner spinner = new CampaignOptionsSpinner("SkillLevel" + i, null, 0, -1, 9999, 1, true); spinner.setVisible(false); spinners.add(spinner); skillCosts.add(spinner); @@ -388,7 +410,9 @@ private JPanel createSkillPanel(SkillType skill) { } }); - final JPanel panel = new CampaignOptionsStandardPanel(panelName, true, panelName); + final JPanel panel = new CampaignOptionsStandardPanel(panelName); + panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), + String.format(skill.getName()))); final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel); // Create a button to toggle the table @@ -443,15 +467,16 @@ private JPanel createSkillPanel(SkillType skill) { /** * Action listener for milestone combo boxes to synchronize their values sequentially. *

    - * When the user changes the value of a milestone, subsequent milestones are - * automatically adjusted to ensure logical skill progression (e.g., later - * milestones cannot precede earlier ones). This method enforces such constraints. + * When the user changes the value of a milestone, subsequent milestones are automatically adjusted to ensure + * logical skill progression (e.g., later milestones cannot precede earlier ones). This method enforces such + * constraints. *

    * * @param comboBoxes the list of combo boxes representing milestones for a single skill. * @param comboBox the combo box that triggered the action. */ - private static void milestoneActionListener(List> comboBoxes, JComboBox comboBox) { + private static void milestoneActionListener(List> comboBoxes, + JComboBox comboBox) { int originIndex = comboBoxes.indexOf(comboBox); SkillLevel currentSelection = (SkillLevel) comboBox.getSelectedItem(); @@ -487,8 +512,7 @@ private static void milestoneActionListener(List> comboBox /** * Loads skill values from the default campaign options. *

    - * A version of this method without parameters that uses default skill values - * defined in the campaign. + * A version of this method without parameters that uses default skill values defined in the campaign. *

    */ public void loadValuesFromCampaignOptions() { @@ -498,13 +522,12 @@ public void loadValuesFromCampaignOptions() { /** * Loads skill values into the UI components from the campaign options. *

    - * The method populates the spinners, labels, and comboboxes for all skills - * with their corresponding properties (e.g., target numbers, costs, and milestones) - * retrieved from the campaign's configuration. + * The method populates the spinners, labels, and comboboxes for all skills with their corresponding properties + * (e.g., target numbers, costs, and milestones) retrieved from the campaign's configuration. *

    * - * @param presetSkillValues an optional map of preset skill values. If null - * or empty, default skill values are used instead. + * @param presetSkillValues an optional map of preset skill values. If null or empty, default skill values are used + * instead. */ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampaignOptions, Map presetSkillValues) { @@ -521,7 +544,7 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai // Skip outdated or missing skills if (allTargetNumbers.get(skillName) == null) { - logger.info(String.format("Skipping outdated or missing skill: %s", skillName)); + logger.info("(loadValuesFromCampaignOptions) Skipping outdated or missing skill: {}", skillName); continue; } @@ -547,8 +570,11 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai int eliteIndex = skill.getEliteLevel(); for (int i = 0; i < milestones.size(); i++) { - SkillLevel levelToSet = determineMilestoneLevel(i, greenIndex, regularIndex, - veteranIndex, eliteIndex); + SkillLevel levelToSet = determineMilestoneLevel(i, + greenIndex, + regularIndex, + veteranIndex, + eliteIndex); milestones.get(i).setSelectedItem(levelToSet); } } @@ -561,8 +587,8 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai /** * Determines the skill level milestone based on progress indices. *

    - * It evaluates whether the milestone falls under Green, Regular, Veteran, or Elite - * levels, ensuring proper assignments for milestone thresholds. + * It evaluates whether the milestone falls under Green, Regular, Veteran, or Elite levels, ensuring proper + * assignments for milestone thresholds. *

    * * @param index the position in the milestone sequence. @@ -570,10 +596,11 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai * @param regularIndex the index where Regular begins. * @param veteranIndex the index where Veteran begins. * @param eliteIndex the index where Elite begins. + * * @return the corresponding {@link SkillLevel} for the given milestone. */ - private SkillLevel determineMilestoneLevel(int index, int greenIndex, int regularIndex, - int veteranIndex, int eliteIndex) { + private SkillLevel determineMilestoneLevel(int index, int greenIndex, int regularIndex, int veteranIndex, + int eliteIndex) { if (index < greenIndex) { return ULTRA_GREEN; } @@ -590,18 +617,16 @@ private SkillLevel determineMilestoneLevel(int index, int greenIndex, int regula } /** - * Transfers the configured skill values from the SkillsTab UI into the campaign's - * underlying data model. + * Transfers the configured skill values from the SkillsTab UI into the campaign's underlying data model. *

    - * The method iterates through all configurable skills, updating the campaign - * with the configured target numbers, costs, and milestones for each skill. + * The method iterates through all configurable skills, updating the campaign with the configured target numbers, + * costs, and milestones for each skill. *

    * - * @param presetCampaignOptions the {@link CampaignOptions} instance to save settings to, - * or {@code null} to update the current campaign options. - * @param presetSkills an optional map of preset skill values. Overrides default - * values if provided. Null values will use the campaign's - * default values. + * @param presetCampaignOptions the {@link CampaignOptions} instance to save settings to, or {@code null} to update + * the current campaign options. + * @param presetSkills an optional map of preset skill values. Overrides default values if provided. Null + * values will use the campaign's default values. */ public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampaignOptions, @Nullable Map presetSkills) { @@ -617,7 +642,7 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampa } if (type == null) { - logger.info(String.format("Skipping outdated or missing skill: %s", skillName)); + logger.info("(applyCampaignOptionsToCampaign) Skipping outdated or missing skill: {}", skillName); continue; } @@ -636,16 +661,14 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampa } /** - * Updates the target number for a given skill in the campaign based on the - * corresponding user input from the SkillsTab UI. + * Updates the target number for a given skill in the campaign based on the corresponding user input from the + * SkillsTab UI. *

    - * The target number determines the difficulty level for the specified skill - * in the campaign. This value is fetched from the associated spinner component - * in the UI and is applied to the given {@link SkillType}. + * The target number determines the difficulty level for the specified skill in the campaign. This value is fetched + * from the associated spinner component in the UI and is applied to the given {@link SkillType}. *

    * - * @param type the {@link SkillType} object representing the skill whose target - * number needs to be updated. + * @param type the {@link SkillType} object representing the skill whose target number needs to be updated. */ private void updateTargetNumber(SkillType type) { int targetNumber = (int) allTargetNumbers.get(type.getName()).getValue(); @@ -653,12 +676,10 @@ private void updateTargetNumber(SkillType type) { } /** - * Updates the costs associated with a given skill based on the user input - * from the SkillsTab UI. + * Updates the costs associated with a given skill based on the user input from the SkillsTab UI. *

    - * For each level of the specified skill, the cost values are retrieved from - * the corresponding spinner components in the UI and stored in the campaign's - * configuration. The costs represent the resource requirements for acquiring + * For each level of the specified skill, the cost values are retrieved from the corresponding spinner components in + * the UI and stored in the campaign's configuration. The costs represent the resource requirements for acquiring * the skill at various levels. *

    * @@ -674,29 +695,25 @@ private void updateSkillCosts(String skillName) { } /** - * Updates the skill milestones for a given skill in the campaign - * based on user input from the SkillsTab UI. + * Updates the skill milestones for a given skill in the campaign based on user input from the SkillsTab UI. *

    - * Milestones represent the thresholds required to reach - * certain skill levels (e.g., Green, Regular, Veteran, Elite). - * The method processes these values from the associated combo boxes - * in the UI and applies them to the provided {@link SkillType}. + * Milestones represent the thresholds required to reach certain skill levels (e.g., Green, Regular, Veteran, + * Elite). The method processes these values from the associated combo boxes in the UI and applies them to the + * provided {@link SkillType}. *

    - * The method ensures logical milestone progression and assigns - * default values if necessary. + * The method ensures logical milestone progression and assigns default values if necessary. *

    * - * @param type the {@link SkillType} object representing the skill whose - * milestones are to be updated. + * @param type the {@link SkillType} object representing the skill whose milestones are to be updated. */ private void updateSkillMilestones(SkillType type) { List> skillMilestones = allSkillMilestones.get(type.getName()); // These allow us to ensure the full array of milestones has been assigned - type.setGreenLevel(skillMilestones.size() -4); - type.setRegularLevel(skillMilestones.size() -3); - type.setVeteranLevel(skillMilestones.size() -2); - type.setEliteLevel(skillMilestones.size() -1); + type.setGreenLevel(skillMilestones.size() - 4); + type.setRegularLevel(skillMilestones.size() - 3); + type.setVeteranLevel(skillMilestones.size() - 2); + type.setEliteLevel(skillMilestones.size() - 1); // Then we overwrite those insurance values with the actual values SkillLevel lastAssignment = ULTRA_GREEN; @@ -714,7 +731,8 @@ private void updateSkillMilestones(SkillType type) { case REGULAR -> type.setRegularLevel(i); case VETERAN -> type.setVeteranLevel(i); case ELITE -> type.setEliteLevel(i); - default -> {} + default -> { + } } } } From e1247a7422525fd5a3b220fd98fd457d03a52516 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 4 Apr 2025 14:26:57 -0500 Subject: [PATCH 3/3] Fixed conflicts --- MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java | 4 ++-- MekHQ/src/mekhq/gui/CommandCenterTab.java | 6 ++---- .../src/mekhq/gui/campaignOptions/CampaignOptionsPane.java | 5 ++++- .../mekhq/gui/campaignOptions/contents/AbilitiesTab.java | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java index e0fa4e45cef..ba5c7798909 100644 --- a/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java +++ b/MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java @@ -29,8 +29,8 @@ import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; import static mekhq.campaign.force.Force.FORCE_NONE; -import static mekhq.campaign.personnel.SkillDeprecationTool.DEPRECATED_SKILLS; import static mekhq.campaign.personnel.enums.PersonnelStatus.statusValidator; +import static mekhq.campaign.personnel.skills.SkillDeprecationTool.DEPRECATED_SKILLS; import static org.apache.commons.lang3.ObjectUtils.firstNonNull; import java.io.File; @@ -1709,7 +1709,7 @@ private static void processPartsInUseRequestedStockMap(Campaign retVal, Node wn) } private static void processPartsInUseRequestedStockMapVal(Campaign retVal, Node wn, - Map partsInUseRequestedStockMap) { + Map partsInUseRequestedStockMap) { NodeList wList = wn.getChildNodes(); String key = null; diff --git a/MekHQ/src/mekhq/gui/CommandCenterTab.java b/MekHQ/src/mekhq/gui/CommandCenterTab.java index 77e14da7dd7..8b8fe50b5d4 100644 --- a/MekHQ/src/mekhq/gui/CommandCenterTab.java +++ b/MekHQ/src/mekhq/gui/CommandCenterTab.java @@ -261,8 +261,7 @@ private void initInfoPanel() { // This seems to be overwritten completely and immediately by refresh StringBuilder experienceString = new StringBuilder(64); experienceString.append("") - .append(mekhq.campaign.personnel.SkillType.getColoredExperienceLevelName(getCampaign().getReputation() - .getAverageSkillLevel())) + .append(SkillType.getColoredExperienceLevelName(getCampaign().getReputation().getAverageSkillLevel())) .append(""); lblExperience.setText(experienceString.toString()); } @@ -628,8 +627,7 @@ private void refreshBasicInfo() { StringBuilder experienceString = new StringBuilder(64); experienceString.append("") - .append(mekhq.campaign.personnel.SkillType.getColoredExperienceLevelName(campaign.getReputation() - .getAverageSkillLevel())) + .append(SkillType.getColoredExperienceLevelName(campaign.getReputation().getAverageSkillLevel())) .append(""); lblExperience.setText(experienceString.toString()); } diff --git a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java index 4d474c896da..61e60891be9 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java @@ -29,6 +29,9 @@ import static java.lang.Math.round; import static mekhq.campaign.force.CombatTeam.recalculateCombatTeams; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_PILOTING; +import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.CHARACTER_CREATION_ONLY; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.CHARACTER_FLAW; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY; @@ -456,7 +459,7 @@ private JTabbedPane createStrategicOperationsParentTab() { * @param isSaveAction determines if this action is saving options to a preset */ public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset, boolean isStartUp, - boolean isSaveAction) { + boolean isSaveAction) { CampaignOptions options = this.campaignOptions; RandomSkillPreferences presetRandomSkillPreferences = null; Map presetSkills = null; diff --git a/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java b/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java index 54fcc68285f..0d25250fb95 100644 --- a/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java +++ b/MekHQ/src/mekhq/gui/campaignOptions/contents/AbilitiesTab.java @@ -27,6 +27,8 @@ */ package mekhq.gui.campaignOptions.contents; +import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.CHARACTER_CREATION_ONLY; +import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.CHARACTER_FLAW; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.MANEUVERING_ABILITY; import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.UTILITY_ABILITY; @@ -44,7 +46,6 @@ import java.util.Map.Entry; import java.util.ResourceBundle; import java.util.regex.Pattern; -import java.util.stream.Stream; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox;