Skip to content

Commit

Permalink
Initial pass to update MekHQ for fix 1152 on MM
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Sep 12, 2023
1 parent 48b1432 commit 8c9120e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,10 @@ private void processShipSearch() {
// TODO : mos zero should make ship available on retainer
if (roll >= target.getValue()) {
report.append("<br/>Search successful. ");

MechSummary ms = getUnitGenerator().generate(getFactionCode(), shipSearchType, -1,
getGameYear(), getUnitRatingMod());

if (ms == null) {
ms = getAtBConfig().findShip(shipSearchType);
}
Expand Down Expand Up @@ -2340,7 +2340,7 @@ && acquireEquipment(shoppingItem, person, system, transitTime)) {
continue;
}
}

// if we didn't find everything on this planet, then add to the remaining list
if (shoppingItem.getQuantity() > 0 || shoppingItem.getDaysToWait() > 0) {
// if we can't afford it, then don't keep searching for it on other planets
Expand Down Expand Up @@ -2422,11 +2422,11 @@ public boolean canPayFor(IAcquisitionWork acquisition) {
*/
public PartAcquisitionResult findContactForAcquisition(IAcquisitionWork acquisition, Person person, PlanetarySystem system) {
TargetRoll target = getTargetForAcquisition(acquisition, person);

String impossibleSentencePrefix = person == null ? "Can't search for " : person.getFullName() + " can't search for ";
String failedSentencePrefix = person == null ? "No contacts available for " : person.getFullName() + " is unable to find contacts for ";
String succeededSentencePrefix = person == null ? "Possible contact for " : person.getFullName() + " has found a contact for ";

// if it's already impossible, don't bother with the rest
if (target.getValue() == TargetRoll.IMPOSSIBLE) {
if (getCampaignOptions().isPlanetAcquisitionVerbose()) {
Expand All @@ -2435,7 +2435,7 @@ public PartAcquisitionResult findContactForAcquisition(IAcquisitionWork acquisit
}
return PartAcquisitionResult.PartInherentFailure;
}

target = system.getPrimaryPlanet().getAcquisitionMods(target, getLocalDate(), getCampaignOptions(), getFaction(),
acquisition.getTechBase() == Part.T_CLAN);

Expand Down Expand Up @@ -5081,7 +5081,8 @@ public TargetRoll getTargetForAcquisition(final IAcquisitionWork acquisition,
partAvailabilityLog.append(";(gauss ammo): -1");
break;
}
if (((megamek.common.AmmoType) et).getMunitionType() == megamek.common.AmmoType.M_STANDARD) {
if (EnumSet.of(AmmoType.Munitions.M_STANDARD).containsAll(
((megamek.common.AmmoType) et).getMunitionType())){
partAvailability--;
partAvailabilityLog.append(";(standard ammo): -1");
}
Expand Down
5 changes: 3 additions & 2 deletions MekHQ/src/mekhq/campaign/parts/equipment/AmmoBin.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.w3c.dom.NodeList;

import java.io.PrintWriter;
import java.util.EnumSet;
import java.util.Objects;

/**
Expand Down Expand Up @@ -117,7 +118,7 @@ public int getFullShots() {

if (unit.getEntity() instanceof Protomech) {
// If protomechs are using alternate munitions then cut in half
if (getType().getMunitionType() != AmmoType.M_STANDARD) {
if (!EnumSet.of(AmmoType.Munitions.M_STANDARD).containsAll(getType().getMunitionType())){
fullShots = fullShots / 2;
}
}
Expand Down Expand Up @@ -235,7 +236,7 @@ protected void loadFieldsFromXmlNode(Node wn) {

// FIXME: does not take into account BombType
@Deprecated
public long getMunitionType() {
public EnumSet<AmmoType.Munitions> getMunitionType() {
return getType().getMunitionType();
}

Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/SmallSVAmmoSwapDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public SmallSVAmmoSwapDialog(final JFrame frame, final Unit unit) {
// from there.
for (Part part : unit.getParts()) {
if ((part instanceof InfantryAmmoBin)
&& (((InfantryAmmoBin) part).getType().getMunitionType() == AmmoType.M_INFERNO)) {
&& (((InfantryAmmoBin) part).getType().getMunitionType().contains(AmmoType.Munitions.M_INFERNO))) {
WeaponRow row = new WeaponRow((InfantryAmmoBin) part);
rows.add(row);
panMain.add(row);
Expand Down

0 comments on commit 8c9120e

Please sign in to comment.