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

Infantry refactor #3944

Merged
merged 8 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/bot/CEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ private static double[] getExpectedDamage(Infantry attacker, int gunskill) {

// If there are two secondary weapons per squad then use that weapons
// range. Otherwise use the primary weapons range.
if ((null != secondary_weapon) && (attacker.getSecondaryN() >= 2)) {
if ((null != secondary_weapon) && (attacker.getSecondaryWeaponsPerSquad() >= 2)) {
base_range = secondary_weapon.getInfantryRange();
} else {
base_range = primary_weapon.getInfantryRange();
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/ui/swing/EquipChoicePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public EquipChoicePanel(Entity entity, ClientGUI clientgui, Client client) {

// Can't set up munitions on infantry.
if (!((entity instanceof Infantry) && !((Infantry) entity)
.hasFieldGun()) || (entity instanceof BattleArmor)) {
.hasFieldWeapon()) || (entity instanceof BattleArmor)) {
setupMunitions();
panMunitions.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(),
Messages.getString("CustomMechDialog.MunitionsPanelTitle"),
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/client/ui/swing/UnitEditorDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private void initInfantryArmorPanel() {

int men = Math.max(infantry.getShootingStrength(), 0);
spnInternal[0] = new JSpinner(new SpinnerNumberModel(men, 0,
infantry.getSquadN() * infantry.getSquadSize(), 1));
infantry.getSquadCount() * infantry.getSquadSize(), 1));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ private void btnOkayActionPerformed(java.awt.event.ActionEvent evt) {
}
}
if (entity instanceof Infantry) {
((Infantry) entity).damageOrRestoreFieldGunsAndArty();
((Infantry) entity).damageOrRestoreFieldWeapons();
entity.applyDamage();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public void prepare() {
// draw facing
graph.setColor(Color.white);
if ((entity.getFacing() != -1)
&& !(isInfantry && !((Infantry) entity).hasFieldGun()
&& !(isInfantry && !((Infantry) entity).hasFieldWeapon()
&& !((Infantry) entity).isTakingCover())
&& !(isAero && ((IAero) entity).isSpheroid() && !board.inSpace())) {
// Indicate a stacked unit with the same facing that can still move
Expand Down
22 changes: 5 additions & 17 deletions megamek/src/megamek/common/BattleArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import org.apache.logging.log4j.LogManager;

import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Vector;
import java.util.*;

/**
* This class represents a squad or point of battle armor equipped infantry,
Expand Down Expand Up @@ -341,7 +340,7 @@ public BattleArmor() {
setArmorType(EquipmentType.T_ARMOR_BA_STANDARD);

// BA are always one squad
squadn = 1;
squadCount = 1;

// All Battle Armor squads are Clan until specified otherwise.
setTechLevel(TechConstants.T_CLAN_TW);
Expand Down Expand Up @@ -736,16 +735,6 @@ public HitData getTransferLocation(HitData hit) {
return new HitData(Entity.LOC_DESTROYED);
}

/**
* Battle Armor units use default behavior for armor and internals.
*
* @see megamek.common.Infantry#isPlatoon()
*/
@Override
protected boolean isPlatoon() {
return false;
}

/**
* Battle Armor units have no armor on their squad location.
*
Expand Down Expand Up @@ -2214,8 +2203,7 @@ public int getSpriteDrawPriority() {
}

@Override
public void damageOrRestoreFieldGunsAndArty() { }

@Override
protected void damageFieldGunsAndArty() { }
protected boolean isFieldWeapon(Mounted equipment) {
return false;
}
}
Empty file.
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -7043,7 +7043,7 @@ public static int getFullCrewSize(Entity entity) {
}
return ntroopers;
} else if (entity instanceof Infantry) {
return ((Infantry) entity).getSquadN() * ((Infantry) entity).getSquadSize();
return ((Infantry) entity).getSquadCount() * ((Infantry) entity).getSquadSize();
} else if (entity instanceof Jumpship || entity instanceof SmallCraft) {
return getAeroCrewNeeds(entity) + getTotalGunnerNeeds(entity);
} else {
Expand Down
Loading