Skip to content

Commit

Permalink
Fixes and updates from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Jan 2, 2024
1 parent 4ca0034 commit 94ee6c8
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
38 changes: 16 additions & 22 deletions megamek/src/megamek/common/AeroSpaceFighter.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
/*
* MegaMek - Copyright (C) 2000-2003 Ben Mazur ([email protected])
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
* This file is part of MegaMek.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* MegaMek is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MegaMek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>.
*/

package megamek.common;

import megamek.client.ui.swing.calculationReport.CalculationReport;
Expand Down Expand Up @@ -145,29 +151,17 @@ public boolean isAero() {
return true;
}

/**
* Fighters may carry external ordnance;
* Other Aerospace units with cargo bays and the Internal Bomb Bay quirk may carry bombs internally.
* @return boolean
*/
@Override
public boolean isBomber() {
return true;
}

@Override
/**
* Returns true if this is an aerospace or conventional fighter
* but not a larger craft (i.e. "SmallCraft" or "Dropship" and bigger
*/
public boolean isFighter() {
return true;
}

@Override
/**
* Returns true if and only if this is an aerospace fighter.
*/
public boolean isAerospaceFighter() {
return true;
}
Expand All @@ -176,4 +170,4 @@ public boolean isAerospaceFighter() {
public long getEntityType() {
return super.getEntityType() | Entity.ETYPE_AEROSPACEFIGHTER;
}
}
}
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4184,7 +4184,7 @@ protected void resetBombAttacks() {
if (eq.getType().equals(spaceBomb) || eq.getType().equals(altBomb)
|| eq.getType().equals(diveBomb)) {
bombAttacksToRemove.add(eq);
} else if (eq.getLinked() != null && eq.getLinked().isInternalBomb()){ // Does not do what's intended!
} else if (eq.getLinked() != null && eq.getLinked().isInternalBomb()){
// Remove any used internal bombs
if (eq.getLinked().getUsableShotsLeft() <= 0) {
bombAttacksToRemove.add(eq);
Expand Down
51 changes: 47 additions & 4 deletions megamek/src/megamek/common/IBomber.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,23 @@ public interface IBomber {
String DIVE_BOMB_ATTACK = "DiveBombAttack";
String ALT_BOMB_ATTACK = "AltBombAttack";

/**
* Set count of internal bombs used; this is used to reset, revert, or increase count
* of internal bombs a unit has dropped during a turn.
* @param b
*/
void setUsedInternalBombs(int b);

/**
* Increase count of internal bombs used this turn.
* @param b
*/
void increaseUsedInternalBombs(int b);

/**
* @return the number of internal bombs used by this bomber during a turn, for
* IBB internal hit calculations.
*/
int getUsedInternalBombs();


Expand Down Expand Up @@ -65,9 +80,13 @@ default int getMaxExtBombSize() {
}

/**
* @return The number of each bomb type that was selected prior to deployment
* @return The number of each internally-mounted bomb type that was selected prior to deployment
*/
int[] getIntBombChoices();

/**
* @return The number of each externally-mounted bomb type that was selected prior to deployment
*/
int[] getExtBombChoices();

/**
Expand All @@ -76,6 +95,11 @@ default int getMaxExtBombSize() {
* @param bc An array with the count of each bomb type as the value of the bomb type's index
*/
void setIntBombChoices(int[] bc);

/**
* Sets the bomb type selections for external mounts.
* @param bc An array with the count of each bomb type as the value of the bomb type's index
*/
void setExtBombChoices(int[] bc);

/**
Expand All @@ -89,6 +113,10 @@ default int[] getBombChoices(){
return stream3.toArray();
}

/**
* Backwards compatibility bomb choice setter that only affects external stores.
* @param ebc
*/
default void setBombChoices(int[] ebc) {
setExtBombChoices(ebc);
}
Expand Down Expand Up @@ -154,9 +182,6 @@ default int getInternalBombsDamageTotal() {
}
}

// int total = getBombs().stream().filter(
// b -> b.isInternalBomb()
// ).mapToInt(b -> b.getExplosionDamage()).sum();
return total;
}

Expand Down Expand Up @@ -242,6 +267,12 @@ default void applyBombs() {
clearBombChoices();
}

/**
* Helper to apply equipment-type bombs, either externally or internally.
* @param type of bomb equipment.
* @param loc location where mounted.
* @param internal mounted internally or not.
*/
private void applyBombEquipment(int type, int loc, boolean internal){
try {
EquipmentType et = EquipmentType.get(BombType.getBombInternalName(type));
Expand All @@ -253,6 +284,12 @@ private void applyBombEquipment(int type, int loc, boolean internal){

}

/**
* Helper to apply weapon-type bombs, either externally or internally.
* @param type of bomb equipment.
* @param loc location where mounted.
* @param internal mounted internally or not.
*/
private void applyBombWeapons(int type, int loc, boolean internal){
Mounted m;
try {
Expand All @@ -276,7 +313,13 @@ private void applyBombWeapons(int type, int loc, boolean internal){

void clearBombs();

/**
* @return maximum number of bomb points this bomber can mount externally
*/
int getMaxExtBombPoints();

/**
* @return maximum number of bomb points this bomber can mount internally
*/
int getMaxIntBombPoints();
}
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/battlevalue/BVCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ protected double arcFactor(Mounted equipment) {
}

/**
* Forwards to {@link #maintainUsedSearchlight(Mounted, boolean, boolean, int)} with a weaponCount
* Forwards to {@link #processWeapon(Mounted, boolean, boolean, int)} with a weaponCount
* parameter of 1 (single weapon).
*/
protected double processWeapon(Mounted weapon, boolean showInReport,
Expand Down

0 comments on commit 94ee6c8

Please sign in to comment.