Skip to content

Commit

Permalink
Don't print Edge abilities of troopers
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbraginskiy committed Jun 19, 2024
1 parent 784d110 commit 1f6fb7f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions megameklab/src/megameklab/printing/PrintInfantry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import megamek.common.*;
import megamek.common.options.IOption;
import megamek.common.options.IOptionGroup;
import megamek.common.weapons.artillery.ArtilleryCannonWeapon;
import megamek.common.weapons.artillery.ArtilleryWeapon;
import megamek.common.weapons.infantry.InfantryWeapon;
Expand All @@ -26,6 +27,7 @@
import java.util.Enumeration;
import java.util.StringJoiner;

import static megamek.common.options.PilotOptions.EDGE_ADVANTAGES;
import static megameklab.printing.InventoryEntry.DASH;

/**
Expand Down Expand Up @@ -286,10 +288,20 @@ && isFlameBased(infantry.getSecondaryWeapon()))) {
}

StringJoiner enhancements = new StringJoiner(", ");
for (Enumeration<IOption> e = infantry.getCrew().getOptions().getOptions(); e.hasMoreElements(); ) {
final IOption option = e.nextElement();
if (option.booleanValue()) {
enhancements.add(option.getDisplayableName().replaceAll("\\s+\\(Not Implemented\\)", ""));
var spas = infantry.getCrew().getOptions();
for (Enumeration<IOptionGroup> e = spas.getGroups(); e.hasMoreElements(); ) {
final IOptionGroup optiongroup = e.nextElement();
if (optiongroup.getKey().equals(EDGE_ADVANTAGES)) {
// Don't print Edge abilities, only SPAs and Cybernetics
continue;
}
if (spas.count(optiongroup.getKey()) > 0) {
for (Enumeration<IOption> options = optiongroup.getOptions(); options.hasMoreElements();) {
IOption option = options.nextElement();
if (option != null && option.booleanValue()) {
enhancements.add(option.getDisplayableNameWithValue().replaceAll("\\s+\\(Not Implemented\\)", ""));
}
}
}
}
if (enhancements.length() > 0) {
Expand Down

0 comments on commit 1f6fb7f

Please sign in to comment.