Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected Award File References #4453

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions MekHQ/src/mekhq/gui/view/PersonViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,24 @@ 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();

int divisionResult = numAwards / tierSize;
int addition = (tierSize == 1) ? 0 : 1;

int awardTierCount = MathUtility.clamp(
return MathUtility.clamp(
divisionResult + addition,
1, maximumTiers
);
return awardTierCount;
}

/**
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down