Skip to content

Commit

Permalink
Merge pull request #5896 from IllianiCBT/edgeCostBug
Browse files Browse the repository at this point in the history
Corrected Edge Cost Calculations
  • Loading branch information
IllianiCBT authored Jan 28, 2025
2 parents baff23f + 8a5a1f9 commit ea736c8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.lang.Math.round;
import static megamek.client.ui.WrapLayout.wordWrap;
import static mekhq.campaign.personnel.education.Academy.skillParser;
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
Expand Down Expand Up @@ -913,8 +914,12 @@ public void actionPerformed(ActionEvent action) {
break;
}
case CMD_BUY_EDGE: {
final int cost = gui.getCampaign().getCampaignOptions().getEdgeCost();
int baseCost = gui.getCampaign().getCampaignOptions().getEdgeCost();
double costMultiplier = gui.getCampaign().getCampaignOptions().getXpCostMultiplier();
for (Person person : people) {
double intelligenceCostMultiplier = person.getIntelligenceXpCostMultiplier(gui.getCampaign().getCampaignOptions());
int cost = (int) round(baseCost * intelligenceCostMultiplier * costMultiplier);

selectedPerson.spendXP(cost);
person.changeEdge(1);
// Make the new edge point available to support personnel, but don't reset until
Expand Down Expand Up @@ -1943,7 +1948,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
if (!spa.isEligible(person)) {
continue;
}
cost = (int) Math.round((spa.getCost()
cost = (int) round((spa.getCost()
* person.getIntelligenceXpCostMultiplier(gui.getCampaign().getCampaignOptions())
* gui.getCampaign().getCampaignOptions().getXpCostMultiplier()));
String costDesc;
Expand Down Expand Up @@ -2239,8 +2244,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
String type = SkillType.getSkillList()[i];
int cost = person.hasSkill(type) ? person.getSkill(type).getCostToImprove()
: SkillType.getType(type).getCost(0);
cost = (int) Math
.round(cost * person.getIntelligenceXpCostMultiplier(gui.getCampaign().getCampaignOptions())
cost = (int) round(cost * person.getIntelligenceXpCostMultiplier(gui.getCampaign().getCampaignOptions())
* gui.getCampaign().getCampaignOptions().getXpCostMultiplier());

if (cost >= 0) {
Expand All @@ -2262,7 +2266,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
// Edge Purchasing
if (gui.getCampaign().getCampaignOptions().isUseEdge()) {
JMenu edgeMenu = new JMenu(resources.getString("edge.text"));
int cost = (int) Math.round(gui.getCampaign().getCampaignOptions().getEdgeCost()
int cost = (int) round(gui.getCampaign().getCampaignOptions().getEdgeCost()
* person.getIntelligenceXpCostMultiplier(gui.getCampaign().getCampaignOptions())
* gui.getCampaign().getCampaignOptions().getXpCostMultiplier());

Expand Down

0 comments on commit ea736c8

Please sign in to comment.