From 504813696a384192e3ecd7100064cb603394d555 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 21 Jul 2024 18:01:42 -0500 Subject: [PATCH] Updated getAwardTierCount method and corrected file references References to RibbonFiles were corrected to MedalFiles and MiscFiles allowing the correct file to be fetched. --- MekHQ/src/mekhq/gui/view/PersonViewPanel.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java index 5182caccbe..443c3f8977 100644 --- a/MekHQ/src/mekhq/gui/view/PersonViewPanel.java +++ b/MekHQ/src/mekhq/gui/view/PersonViewPanel.java @@ -380,6 +380,13 @@ private Box drawRibbons() { return boxRibbons; } + /** + * Returns the number of image tiers for an award based on the maximum number of tiers and the number of awards received. + * + * @param award The award for which to calculate the number of tiers. + * @param maximumTiers The maximum number of tiers allowed for the award. + * @return The number of tiers for the award. The value is clamped between 1 and the maximum number of tiers. + */ private int getAwardTierCount(Award award, int maximumTiers) { int numAwards = person.getAwardController().getNumberOfAwards(award); int tierSize = campaign.getCampaignOptions().getAwardTierSize(); @@ -387,11 +394,10 @@ private int getAwardTierCount(Award award, int maximumTiers) { int divisionResult = numAwards / tierSize; int addition = (tierSize == 1) ? 0 : 1; - int awardTierCount = MathUtility.clamp( + return MathUtility.clamp( divisionResult + addition, 1, maximumTiers ); - return awardTierCount; } /** @@ -404,14 +410,14 @@ private JPanel drawMedals() { .getAwards() .stream().filter(a -> a.getNumberOfMedalFiles() > 0) .sorted() - .collect(Collectors.toList()); + .toList(); for (Award award : awards) { JLabel medalLabel = new JLabel(); Image medal; try { - int maximumTiers = award.getNumberOfRibbonFiles(); + int maximumTiers = award.getNumberOfMedalFiles(); int awardTierCount = getAwardTierCount(award, maximumTiers); String medalFileName = award.getMedalFileName(awardTierCount); @@ -460,7 +466,7 @@ private JPanel drawMiscAwards() { Image miscAward; try { - int maximumTiers = award.getNumberOfRibbonFiles(); + int maximumTiers = award.getNumberOfMiscFiles(); int awardTierCount = getAwardTierCount(award, maximumTiers); String miscFileName = award.getMiscFileName(awardTierCount);