Skip to content

Commit

Permalink
Refactor bonus calculation in EducationController
Browse files Browse the repository at this point in the history
The bonus calculation has been refactored in the EducationController. Specifically, we've introduced a bonusPercentage that is determined by the bonusCount divided by 5. Then, this bonusPercentage is utilized to calculate the bonusAmount, which gets factored into the final XP award.
  • Loading branch information
IllianiCBT committed Jul 11, 2024
1 parent 1200751 commit 12d1683
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,14 +947,18 @@ private static void addFacultyXp(Campaign campaign, Person person, Academy acade
academyDuration = academy.getDurationDays() - person.getEduEducationTime();
}

double bonusPercentage = (double) bonusCount / 5;

if (EducationLevel.parseToInt(person.getEduHighestEducation()) < academy.getEducationLevel(person)) {
int xpRate = Math.max(1, (12 - academy.getFacultySkill()) * (academyDuration / 600));

xpRate *= campaign.getCampaignOptions().getFacultyXpRate();

person.awardXP(campaign, xpRate + bonusCount);
int bonusAmount = (int) Math.max(bonusCount, xpRate * bonusPercentage);
person.awardXP(campaign, xpRate + bonusAmount);
} else {
person.awardXP(campaign, 1 + bonusCount);
int bonusAmount = (int) Math.max(bonusCount, 1 * bonusPercentage);
person.awardXP(campaign, 1 + bonusAmount);
}
}

Expand Down

0 comments on commit 12d1683

Please sign in to comment.