diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index b258f6018f..77d0ceff7d 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -54,6 +54,7 @@ import static mekhq.campaign.personnel.lifeEvents.FreedomDayAnnouncement.isFreedomDay; import static mekhq.campaign.personnel.lifeEvents.NewYearsDayAnnouncement.isNewYear; import static mekhq.campaign.personnel.lifeEvents.WinterHolidayAnnouncement.isWinterHolidayMajorDay; +import static mekhq.campaign.personnel.skills.Aging.applyAgingSPA; import static mekhq.campaign.personnel.skills.Aging.updateAllSkillAgeModifiers; import static mekhq.campaign.personnel.turnoverAndRetention.Fatigue.areFieldKitchensWithinCapacity; import static mekhq.campaign.personnel.turnoverAndRetention.Fatigue.checkFieldKitchenCapacity; @@ -5096,6 +5097,7 @@ private void processWeeklyRelationshipEvents(Person person) { private void processAnniversaries(Person person) { LocalDate birthday = person.getBirthday(getGameYear()); boolean isBirthday = birthday != null && birthday.equals(currentDay); + int age = person.getAge(currentDay); if ((person.getRank().isOfficer()) || (!campaignOptions.isAnnounceOfficersOnly())) { if (isBirthday && campaignOptions.isAnnounceBirthdays()) { @@ -5132,7 +5134,7 @@ private void processAnniversaries(Person person) { } if (campaignOptions.isShowLifeEventDialogComingOfAge()) { - if ((person.getAge(currentDay) == 16) && (isBirthday)) { + if ((age == 16) && (isBirthday)) { new ComingOfAgeAnnouncement(this, person); } } @@ -5140,6 +5142,7 @@ private void processAnniversaries(Person person) { if (campaignOptions.isUseAgeEffects() && isBirthday) { // This is where we update all the aging modifiers for the character. updateAllSkillAgeModifiers(currentDay, person); + applyAgingSPA(age, person); } if (campaignOptions.isRewardComingOfAgeAbilities() && isBirthday && (person.getAge(currentDay) == 16)) { @@ -6114,6 +6117,21 @@ public Faction getFaction() { return faction; } + /** + * Determines whether the current campaign is a clan campaign. + * + *

This method checks if the faction associated with the campaign is a clan, returning {@code true} + * if it is, and {@code false} otherwise.

+ * + * @return {@code true} if the campaign belongs to a clan faction, {@code false} otherwise. + * + * @author Illiani + * @since 0.50.05 + */ + public boolean isClanCampaign() { + return faction.isClan(); + } + public void setFaction(final Faction faction) { setFactionDirect(faction); updateTechFactionCode(); diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index 69c1c144b9..13d7978e2b 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -778,7 +778,11 @@ private void calculateNegotiationSkill() { Skill skill = negotiator.getSkill(SkillType.S_NEG); if (skill != null) { - int skillLevel = skill.getFinalSkillValue(negotiator.getOptions(), negotiator.getReputation()); + int reputation = negotiator.getAdjustedReputation(campaign.getCampaignOptions().isUseAgeEffects(), + campaign.isClanCampaign(), + campaign.getLocalDate(), + negotiator.getRankLevel()); + int skillLevel = skill.getFinalSkillValue(negotiator.getOptions(), reputation); negotiatorSkill = skill.getType().getExperienceLevel(skillLevel); } } diff --git a/MekHQ/src/mekhq/campaign/personnel/Person.java b/MekHQ/src/mekhq/campaign/personnel/Person.java index dfe75c7f88..bdbc636271 100644 --- a/MekHQ/src/mekhq/campaign/personnel/Person.java +++ b/MekHQ/src/mekhq/campaign/personnel/Person.java @@ -39,6 +39,7 @@ import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup; import static mekhq.campaign.personnel.skills.Attributes.MAXIMUM_ATTRIBUTE_SCORE; import static mekhq.campaign.personnel.skills.Attributes.MINIMUM_ATTRIBUTE_SCORE; +import static mekhq.campaign.personnel.skills.Aging.getReputationAgeModifier; import static mekhq.campaign.personnel.skills.SkillType.S_ADMIN; import java.io.PrintWriter; @@ -5147,10 +5148,48 @@ public void setHasPerformedExtremeExpenditure(final boolean hasPerformedExtremeE this.hasPerformedExtremeExpenditure = hasPerformedExtremeExpenditure; } + /** + * Retrieves the raw reputation value of the character. + * + *

This method returns the unadjusted reputation value associated with the character.

+ * + *

Usage: If aging effects are enabled, you likely want to use + * {@link #getAdjustedReputation(boolean, boolean, LocalDate, int)} instead.

+ * + * @return The raw reputation value. + */ public int getReputation() { return reputation; } + /** + * Calculates the adjusted reputation value for the character based on aging effects, the current campaign type, + * date, and rank. + * + *

This method computes the character's reputation by applying age-based modifiers, which depend on factors such + * as whether aging effects are enabled, whether the campaign is clan-specific, the character's bloodname status, + * and their rank in the clan hierarchy. If aging effects are disabled, the reputation remains unchanged.

+ * + *

Usage: If aging effects are disabled, the result will be equivalent to the base reputation value + * provided by {@link #getReputation()}.

+ * + * @param isUseAgingEffects Indicates whether aging effects should be applied to the reputation calculation. + * @param isClanCampaign Indicates whether the current campaign is specific to a clan. + * @param today The current date used to calculate the character's age. + * @param rankIndex The rank index of the character, which can adjust the reputation modifier in clan-based + * campaigns. + * + * @return The adjusted reputation value, accounting for factors like age, clan campaign status, bloodname + * possession, and rank. If aging effects are disabled, the base reputation value is returned. + */ + public int getAdjustedReputation(boolean isUseAgingEffects, boolean isClanCampaign, LocalDate today, + int rankIndex) { + return reputation + + (isUseAgingEffects ? + getReputationAgeModifier(getAge(today), isClanCampaign, !bloodname.isBlank(), rankIndex) : + 0); + } + public void setReputation(final int reputation) { this.reputation = clamp(reputation, MINIMUM_REPUTATION, MAXIMUM_REPUTATION); } diff --git a/MekHQ/src/mekhq/campaign/personnel/skills/Aging.java b/MekHQ/src/mekhq/campaign/personnel/skills/Aging.java index afb4b5426f..0275ef5e5d 100644 --- a/MekHQ/src/mekhq/campaign/personnel/skills/Aging.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/Aging.java @@ -27,13 +27,23 @@ */ package mekhq.campaign.personnel.skills; +import static megamek.common.options.PilotOptions.LVL3_ADVANTAGES; +import static mekhq.campaign.personnel.PersonnelOptions.ATOW_FAST_LEARNER; +import static mekhq.campaign.personnel.PersonnelOptions.ATOW_TOUGHNESS; +import static mekhq.campaign.personnel.PersonnelOptions.FLAW_GLASS_JAW; +import static mekhq.campaign.personnel.PersonnelOptions.FLAW_SLOW_LEARNER; +import static mekhq.campaign.personnel.skills.enums.AgingMilestone.CLAN_REPUTATION_MULTIPLIER; import static mekhq.campaign.personnel.skills.enums.AgingMilestone.NONE; +import static mekhq.campaign.personnel.skills.enums.AgingMilestone.STAR_CAPTAIN_RANK_INDEX; +import static mekhq.campaign.personnel.skills.enums.AgingMilestone.STAR_CAPTAIN_REPUTATION_MULTIPLIER; +import static mekhq.campaign.personnel.skills.enums.AgingMilestone.STAR_COLONEL_REPUTATION_MULTIPLIER; import static mekhq.campaign.personnel.skills.enums.AgingMilestone.TWENTY_FIVE; import static mekhq.campaign.personnel.skills.enums.SkillAttribute.NO_SKILL_ATTRIBUTE; import java.time.LocalDate; import mekhq.campaign.personnel.Person; +import mekhq.campaign.personnel.PersonnelOptions; import mekhq.campaign.personnel.skills.enums.AgingMilestone; import mekhq.campaign.personnel.skills.enums.SkillAttribute; @@ -89,6 +99,17 @@ public static void updateAllSkillAgeModifiers(LocalDate today, Person person) { } } + /** + * Resets all age-related modifiers for the skills of a given person to zero. + * + *

This method iterates through all skills in the {@code SkillType.skillList} and, for each skill that + * the person possesses, sets its aging modifier to zero. Skills that the person does not have are ignored.

+ * + * @param person The person whose skill age modifiers will be cleared. + * + * @author Illiani + * @since 0.50.05 + */ public static void clearAllAgeModifiers(Person person) { for (String skillName : SkillType.skillList) { boolean hasSkill = person.hasSkill(skillName); @@ -156,7 +177,7 @@ public static int getAgeModifier(int characterAge, SkillAttribute firstAttribute * 0} if no valid combination or milestone exists */ public static int getAgeModifier(AgingMilestone milestone, SkillAttribute firstAttribute, - SkillAttribute secondAttribute) { + SkillAttribute secondAttribute) { // If no milestone applies, return no modifier if (milestone == NONE) { return 0; @@ -180,6 +201,98 @@ public static int getAgeModifier(AgingMilestone milestone, SkillAttribute firstA return applyAgingModifier((firstModifier + secondModifier) / 2); } + /** + * Calculates the reputation age modifier for a character based on their age, clan affiliation, bloodname status, + * and military rank. + * + *

This method determines a character's reputation age modifier by evaluating their age against a predefined + * aging milestone, their clan affiliation, their possession of a bloodname, and their rank in the clan hierarchy. + * If the character meets specific conditions, such as holding a high enough rank or possessing a bloodname, the + * reputation multiplier is adjusted. The final result is scaled by a clan-specific reputation multiplier.

+ * + * @param characterAge The age of the character for which the reputation modifier is being calculated. + * @param isClan Indicates whether the character is part of a clan. If {@code false}, the method returns 0. + * @param hasBloodname Indicates whether the character possesses a bloodname, which can decrease the reputation + * multiplier under certain conditions. + * @param rankIndex The rank index of the character, used to determine if they meet rank-specific milestone + * conditions for reputation adjustment. + * + * @return The calculated reputation age modifier. Returns 0 if the character is not a clan member. + * + * @author Illiani + * @since 0.50.05 + */ + public static int getReputationAgeModifier(int characterAge, boolean isClan, boolean hasBloodname, int rankIndex) { + if (!isClan) { + return 0; + } + + AgingMilestone milestone = getMilestone(characterAge); + + int reputationMultiplier = milestone.getReputation(); + boolean hasHitRankTarget = false; + + if (reputationMultiplier == STAR_CAPTAIN_REPUTATION_MULTIPLIER && rankIndex >= STAR_CAPTAIN_RANK_INDEX) { + hasHitRankTarget = true; + } + + if (reputationMultiplier == STAR_COLONEL_REPUTATION_MULTIPLIER && rankIndex >= STAR_CAPTAIN_RANK_INDEX) { + hasHitRankTarget = true; + } + + if (hasHitRankTarget || hasBloodname) { + reputationMultiplier--; + } + + return reputationMultiplier * CLAN_REPUTATION_MULTIPLIER; + } + + /** + * Applies age-related special abilities or flaws to a given person based on their age. + * + *

This method evaluates the character's age against predefined aging milestones, and if the age matches + * a milestone, specific effects such as applying flaws or adjusting abilities are triggered. For example, it may + * apply the "Glass Jaw" flaw or interact with existing abilities like "Toughness".

+ * + * @param characterAge The age of the character, used to determine applicable aging milestones and effects. + * @param person The person to whom the aging-related effects will be applied. + * + * @author Illiani + * @since 0.50.05 + */ + public static void applyAgingSPA(int characterAge, Person person) { + PersonnelOptions options = person.getOptions(); + for (AgingMilestone milestone : AgingMilestone.values()) { + if (characterAge == milestone.getMilestone()) { + // Glass Jaw + if (milestone.isGlassJaw()) { + boolean hasGlassJaw = options.booleanOption(FLAW_GLASS_JAW); + boolean hasToughness = options.booleanOption(ATOW_TOUGHNESS); + + if (hasToughness) { + person.getOptions().getOption(ATOW_TOUGHNESS).setValue(false); + } else if (!hasGlassJaw) { + options.acquireAbility(LVL3_ADVANTAGES, FLAW_GLASS_JAW, true); + } + } + + // Slow Learner + if (milestone.isSlowLearner()) { + boolean hasSlowLearner = options.booleanOption(FLAW_SLOW_LEARNER); + boolean hasFastLearner = options.booleanOption(ATOW_FAST_LEARNER); + + if (hasFastLearner) { + person.getOptions().getOption(ATOW_FAST_LEARNER).setValue(false); + } else if (!hasSlowLearner) { + options.acquireAbility(LVL3_ADVANTAGES, FLAW_SLOW_LEARNER, true); + } + } + + break; + } + } + } + /** * Determines the appropriate {@link AgingMilestone} for a given character's age. * diff --git a/MekHQ/src/mekhq/campaign/personnel/skills/enums/AgingMilestone.java b/MekHQ/src/mekhq/campaign/personnel/skills/enums/AgingMilestone.java index 5f107f68c6..948d2997ce 100644 --- a/MekHQ/src/mekhq/campaign/personnel/skills/enums/AgingMilestone.java +++ b/MekHQ/src/mekhq/campaign/personnel/skills/enums/AgingMilestone.java @@ -35,17 +35,23 @@ public enum AgingMilestone { NONE(0, 25, 0, 0, 0, 0, 0, 0, 0, 0, false, false), TWENTY_FIVE(25, 31, 50, 50, 0, 50, 50, 50, 50, 0, false, false), - THIRTY_ONE(31, 14, 50, 50, 0, 50, 50, 50, 0, -150, false, false), - FORTY_ONE(41, 51, 0, 0, -50, 0, 0, 0, 0, 0, false, false), - FIFTY_ONE(51, 61, 0, -100, 0, -100, 0, 0, -50, -300, false, false), - SIXTY_ONE(61, 71, -100, -100, -100, 0, 50, 0, -50, 0, true, false), - SEVENTY_ONE(71, 81, -100, -125, 0, -100, 0, -50, -75, 0, true, true), - EIGHTY_ONE(81, 91, -150, -150, -100, -100, -100, -50, -100, 0, true, true), - NINETY_ONE(91, 101, -150, -175, -150, -125, -150, -100, -100, 0, true, true), - ONE_HUNDRED_ONE(101, MAX_VALUE, -200, -200, -200, -150, -200, -100, -1500, 0, true, true); + THIRTY_ONE(31, 14, 50, 50, 0, 50, 50, 50, 0, 1, false, false), + FORTY_ONE(41, 51, 0, 0, -50, 0, 0, 0, 0, 1, false, false), + FIFTY_ONE(51, 61, 0, -100, 0, -100, 0, 0, -50, 2, false, false), + SIXTY_ONE(61, 71, -100, -100, -100, 0, 50, 0, -50, 2, true, false), + SEVENTY_ONE(71, 81, -100, -125, 0, -100, 0, -50, -75, 2, true, true), + EIGHTY_ONE(81, 91, -150, -150, -100, -100, -100, -50, -100, 2, true, true), + NINETY_ONE(91, 101, -150, -175, -150, -125, -150, -100, -100, 2, true, true), + ONE_HUNDRED_ONE(101, MAX_VALUE, -200, -200, -200, -150, -200, -100, -1500, 2, true, true); private static final MMLogger logger = MMLogger.create(AgingMilestone.class); + public static final int CLAN_REPUTATION_MULTIPLIER = 150; + public static final int STAR_CAPTAIN_RANK_INDEX = 34; + public static final int STAR_CAPTAIN_REPUTATION_MULTIPLIER = 1; + public static final int STAR_COLONEL_RANK_INDEX = 38; + public static final int STAR_COLONEL_REPUTATION_MULTIPLIER = 2; + // Attributes private final int milestone; private final int maximumAge; @@ -100,7 +106,7 @@ public enum AgingMilestone { // Constructor AgingMilestone(int milestone, int maximumAge, int strength, int body, int dexterity, int reflexes, int intelligence, - int willpower, int charisma, int reputation, boolean slowLearner, boolean glassJaw) { + int willpower, int charisma, int reputation, boolean slowLearner, boolean glassJaw) { this.milestone = milestone; this.maximumAge = maximumAge; this.strength = strength; diff --git a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java index ea5ede8203..af036e37a8 100644 --- a/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java +++ b/MekHQ/src/mekhq/campaign/rating/CamOpsReputation/CommandRating.java @@ -32,6 +32,7 @@ import static megamek.common.options.OptionsConstants.ATOW_COMBAT_SENSE; import static mekhq.campaign.randomEvents.personalities.PersonalityController.getPersonalityValue; +import java.time.LocalDate; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; @@ -70,7 +71,11 @@ protected static Map calculateCommanderRating(Campaign campaign commandRating.put("strategy", getSkillValue(commander, SkillType.S_STRATEGY)); commandRating.put("negotiation", getSkillValue(commander, SkillType.S_NEG)); - commandRating.put("traits", getATOWTraitValues(commander)); + commandRating.put("traits", + getATOWTraitValues(commander, + campaign.getCampaignOptions().isUseAgeEffects(), + campaign.isClanCampaign(), + campaign.getLocalDate())); int personalityValue = 0; CampaignOptions campaignOptions = campaign.getCampaignOptions(); @@ -116,7 +121,8 @@ protected static Map calculateCommanderRating(Campaign campaign * * @return The calculated trait score for the commander, with a minimum value of 1. */ - private static int getATOWTraitValues(Person commander) { + private static int getATOWTraitValues(Person commander, boolean isUseAgingEffects, boolean isClanCampaign, + LocalDate today) { if (commander == null) { return 0; } @@ -131,7 +137,10 @@ private static int getATOWTraitValues(Person commander) { traitScore += commander.getWealth() >= 7 ? 1 : 0; // Reputation - int reputation = commander.getReputation(); + int reputation = commander.getAdjustedReputation(isUseAgingEffects, + isClanCampaign, + today, + commander.getRankLevel()); if (reputation < 0) { traitScore -= 1; } else if (reputation > 0) { diff --git a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java index e903ea54b5..19b91a8fae 100644 --- a/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java @@ -601,7 +601,6 @@ public void actionPerformed(ActionEvent action) { case CMD_IMPROVE: { String type = data[1]; int cost = MathUtility.parseInt(data[2]); - int oldExpLevel = selectedPerson.getExperienceLevel(getCampaign(), false); selectedPerson.improveSkill(type); selectedPerson.spendXP(cost); @@ -609,8 +608,7 @@ public void actionPerformed(ActionEvent action) { selectedPerson, getCampaign().getLocalDate(), selectedPerson.getSkill(type).getType().getName(), - selectedPerson.getSkill(type) - .toString(selectedPerson.getOptions(), selectedPerson.getReputation())); + selectedPerson.getSkill(type).toString()); getCampaign().addReport(String.format(resources.getString("improved.format"), selectedPerson.getHyperlinkedName(), type)); @@ -2793,7 +2791,10 @@ protected Optional createPopupMenu() { traitsMenu.add(menuItem); // Reputation - int reputation = person.getReputation(); + int reputation = person.getAdjustedReputation(getCampaignOptions().isUseAgeEffects(), + getCampaign().isClanCampaign(), + getCampaign().getLocalDate(), + person.getRankLevel()); target = reputation + 1; menuItem = new JMenuItem(String.format(resources.getString("spendOnReputation.text"), target, traitCost)); menuItem.setToolTipText(wordWrap(String.format(resources.getString("spendOnReputation.tooltip"), diff --git a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java index dd03e44ecd..94e9c58b2a 100644 --- a/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/BatchXPDialog.java @@ -377,7 +377,7 @@ private void spendXP() { person, campaign.getLocalDate(), person.getSkill(skillName).getType().getName(), - person.getSkill(skillName).toString(person.getOptions(), person.getReputation())); + person.getSkill(skillName).toString()); campaign.personUpdated(person); } diff --git a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java index d1b179a2ea..cd802712bf 100644 --- a/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CreateCharacterDialog.java @@ -723,7 +723,7 @@ public Component getListCellRendererComponent(final JList list, final Object lblUnlucky.setText(resourceMap.getString("lblUnlucky.text")); lblReputation.setName("lblUnlucky"); - textUnlucky.setText(Integer.toString(person.getReputation())); + textUnlucky.setText(Integer.toString(person.getUnlucky())); textUnlucky.setName("textUnlucky"); gridBagConstraints = new GridBagConstraints(); diff --git a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java index c5aca49e5c..803109923b 100644 --- a/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java +++ b/MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java @@ -29,6 +29,7 @@ import static mekhq.campaign.personnel.turnoverAndRetention.Fatigue.getEffectiveFatigue; +import java.time.LocalDate; import java.util.Comparator; import java.util.ResourceBundle; import java.util.stream.Collectors; @@ -534,6 +535,10 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person PersonnelOptions options = person.getOptions(); String sign; + boolean isUseAgeEffects = campaign.getCampaignOptions().isUseAgeEffects(); + boolean isClanCampaign = campaign.isClanCampaign(); + LocalDate today = campaign.getLocalDate(); + switch (this) { case PERSON: return ""; @@ -790,7 +795,11 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person case NEGOTIATION: return person.hasSkill(SkillType.S_NEG) ? Integer.toString(person.getSkill(SkillType.S_NEG) - .getFinalSkillValue(options, person.getReputation())) : + .getFinalSkillValue(options, + person.getAdjustedReputation(isUseAgeEffects, + isClanCampaign, + today, + person.getRankLevel()))) : "-"; case SCROUNGE: return person.hasSkill(SkillType.S_SCROUNGE) ? @@ -852,7 +861,10 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person case WEALTH: return Integer.toString(person.getWealth()); case REPUTATION: - return Integer.toString(person.getReputation()); + return Integer.toString(person.getAdjustedReputation(isUseAgeEffects, + isClanCampaign, + today, + person.getRankLevel())); case UNLUCKY: return Integer.toString(person.getUnlucky()); case FATIGUE: diff --git a/MekHQ/src/mekhq/gui/model/CrewListModel.java b/MekHQ/src/mekhq/gui/model/CrewListModel.java index 5228ec1827..129db95a68 100644 --- a/MekHQ/src/mekhq/gui/model/CrewListModel.java +++ b/MekHQ/src/mekhq/gui/model/CrewListModel.java @@ -39,7 +39,6 @@ import megamek.common.Tank; import megamek.common.VTOL; import mekhq.campaign.personnel.Person; -import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.personnel.PersonnelOptions; import mekhq.campaign.personnel.skills.SkillType; import mekhq.campaign.unit.Unit; @@ -52,14 +51,14 @@ */ public class CrewListModel extends AbstractListModel { enum CrewRole { - COMMANDER (0, "Commander"), - CONSOLE_CMDR (1, "Commander"), - PILOT (2, "Pilot"), - NAVIGATOR (3, "Navigator"), - DRIVER (4, "Driver"), - GUNNER (5, "Gunner"), - TECH_OFFICER (6, "Tech Officer"), - CREW (7, "Crew"); + COMMANDER(0, "Commander"), + CONSOLE_CMDR(1, "Commander"), + PILOT(2, "Pilot"), + NAVIGATOR(3, "Navigator"), + DRIVER(4, "Driver"), + GUNNER(5, "Gunner"), + TECH_OFFICER(6, "Tech Officer"), + CREW(7, "Crew"); private final int sortOrder; private final String displayName; @@ -117,6 +116,7 @@ public void setData(final Unit u) { public int getSize() { return crew.size(); } + @Override public Person getElementAt(int index) { if (index < 0 || index >= crew.size()) { @@ -135,21 +135,28 @@ public CrewRenderer() { } @Override - public Component getListCellRendererComponent(JList list, Person value, - int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(JList list, Person value, int index, + boolean isSelected, boolean cellHasFocus) { setOpaque(true); Person person = getElementAt(index); String gunSkill = SkillType.getGunnerySkillFor(unit.getEntity()); String driveSkill = SkillType.getDrivingSkillFor(unit.getEntity()); PersonnelOptions options = person.getOptions(); - int reputation = person.getReputation(); - String sb = "" + person.getFullTitle() + "
" - + CrewRole.getCrewRole(person, unit).getDisplayName() - + " (" - + (person.hasSkill(gunSkill) ? person.getSkill(gunSkill).getFinalSkillValue(options, reputation) : "-") - + '/' - + (person.hasSkill(driveSkill) ? person.getSkill(driveSkill).getFinalSkillValue(options, reputation) : "-") - + ")
"; + String sb = "" + + person.getFullTitle() + + "
" + + CrewRole.getCrewRole(person, unit).getDisplayName() + + " (" + // Shooting and driving don't benefit from Reputation, so no need to pass that in. + + + (person.hasSkill(gunSkill) ? + person.getSkill(gunSkill).getFinalSkillValue(options, 0) : + "-") + + '/' + + (person.hasSkill(driveSkill) ? + person.getSkill(driveSkill).getFinalSkillValue(options, 0) : + "-") + + ")
"; setHtmlText(sb); if (isSelected) { highlightBorder(); diff --git a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java index 1c4aef5c7d..b69efa5501 100644 --- a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java @@ -1507,7 +1507,11 @@ private JPanel fillSkills() { } else { lblName = new JLabel(String.format(resourceMap.getString("format.itemHeader"), skillName)); } - lblValue = new JLabel(person.getSkill(skillName).toString(person.getOptions(), person.getReputation())); + int reputation = person.getAdjustedReputation(campaign.getCampaignOptions().isUseAgeEffects(), + campaign.isClanCampaign(), + campaign.getLocalDate(), + person.getRankLevel()); + lblValue = new JLabel(person.getSkill(skillName).toString(person.getOptions(), reputation)); lblName.setLabelFor(lblValue); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = addition; @@ -1699,7 +1703,12 @@ private JPanel fillSkills() { firsty++; } - if (person.getReputation() != 0) { + int reputation = person.getAdjustedReputation(campaign.getCampaignOptions().isUseAgeEffects(), + campaign.isClanCampaign(), + campaign.getLocalDate(), + person.getRankLevel()); + + if (reputation != 0) { lblReputation1.setName("lblReputation1"); lblReputation1.setText(resourceMap.getString("lblReputation1.text")); gridBagConstraints = new GridBagConstraints(); @@ -1710,7 +1719,7 @@ private JPanel fillSkills() { pnlSkills.add(lblReputation1, gridBagConstraints); lblReputation2.setName("lblReputation2"); - lblReputation2.setText(person.getReputation() + ""); + lblReputation2.setText(reputation + ""); lblReputation1.setLabelFor(lblReputation2); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1;