Skip to content

Commit

Permalink
Align BayData verifier with new Bay and UnitBay defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Dec 27, 2024
1 parent 2efef4d commit 08dec3e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
1 change: 1 addition & 0 deletions megamek/src/megamek/common/Bay.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public int getDoors() {
public int getMinDoors() {
return minDoors;
}

public void setDoors(int d) {
doors = d;
doorsNext = d;
Expand Down
5 changes: 2 additions & 3 deletions megamek/src/megamek/common/UnitBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
*/
public class UnitBay extends Bay{

// Minimum number of doors for all unit bays (except infantry) is 1
int minDoors = 1;

/**
* The default constructor is only for serialization.
*/
protected UnitBay() {
super();
minDoors = 1;
}

/**
Expand All @@ -46,5 +44,6 @@ protected UnitBay() {
*/
public UnitBay(double space, int doors, int bayNumber) {
super(space, doors, bayNumber);
minDoors = 1;
}
}
45 changes: 33 additions & 12 deletions megamek/src/megamek/common/verifier/BayData.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package megamek.common.verifier;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;

import megamek.common.*;
Expand All @@ -36,19 +38,19 @@ public enum BayData {
VEHICLE_SH ("Superheavy Vehicle", 200.0, 15, SuperHeavyVehicleBay.techAdvancement(),
(size, num) -> new SuperHeavyVehicleBay(size, 1, num)),
INFANTRY_FOOT ("Infantry (Foot)", 5.0, 0, InfantryBay.techAdvancement(),
(size, num) -> new InfantryBay(size, 1, num, InfantryBay.PlatoonType.FOOT)),
(size, num) -> new InfantryBay(size, 0, num, InfantryBay.PlatoonType.FOOT)),
INFANTRY_JUMP ("Infantry (Jump)", 6.0, 0, InfantryBay.techAdvancement(),
(size, num) -> new InfantryBay(size, 1, num, InfantryBay.PlatoonType.JUMP)),
(size, num) -> new InfantryBay(size, 0, num, InfantryBay.PlatoonType.JUMP)),
INFANTRY_MOTORIZED ("Infantry (Motorized)", 7.0, 0, InfantryBay.techAdvancement(),
(size, num) -> new InfantryBay(size, 1, num, InfantryBay.PlatoonType.MOTORIZED)),
(size, num) -> new InfantryBay(size, 0, num, InfantryBay.PlatoonType.MOTORIZED)),
INFANTRY_MECHANIZED ("Infantry (Mek. Squad)", 8.0, 0, InfantryBay.techAdvancement(),
(size, num) -> new InfantryBay(size, 1, num, InfantryBay.PlatoonType.MECHANIZED)),
(size, num) -> new InfantryBay(size, 0, num, InfantryBay.PlatoonType.MECHANIZED)),
IS_BATTLE_ARMOR ("BattleArmor (IS)", 8.0, 6, BattleArmorBay.techAdvancement(),
(size, num) -> new BattleArmorBay(size, 1, num, false, false)),
(size, num) -> new BattleArmorBay(size, 0, num, false, false)),
CLAN_BATTLE_ARMOR ("BattleArmor (Clan)", 10.0, 6, BattleArmorBay.techAdvancement(),
(size, num) -> new BattleArmorBay(size, 1, num, true, false)),
(size, num) -> new BattleArmorBay(size, 0, num, true, false)),
CS_BATTLE_ARMOR ("BattleArmor (CS)", 12.0, 6, BattleArmorBay.techAdvancement(),
(size, num) -> new BattleArmorBay(size, 1, num, false, true)),
(size, num) -> new BattleArmorBay(size, 0, num, false, true)),
FIGHTER ("Fighter", 150.0, 2, ASFBay.techAdvancement(),
(size, num) -> new ASFBay(size, 1, num)),
SMALL_CRAFT ("Small Craft", 200.0, 5, SmallCraftBay.techAdvancement(),
Expand All @@ -70,22 +72,32 @@ public enum BayData {
ARTS_REPAIR_PRESSURIZED ("ARTS Standard Repair Facility (Pressurized)", 0.09375, 0, Bay.artsTechAdvancement(),
(size, num) -> new NavalRepairFacility(size, 1, num, 0, true, true)),
CARGO ("Cargo", 1.0, 0, CargoBay.techAdvancement(),
(size, num) -> new CargoBay(size, 1, num)),
(size, num) -> new CargoBay(size, 0, num)),
LIQUID_CARGO ("Cargo (Liquid)", 1/0.91, 0, CargoBay.techAdvancement(),
(size, num) -> new LiquidCargoBay(size, 1, num)),
(size, num) -> new LiquidCargoBay(size, 0, num)),
REFRIGERATED_CARGO ("Cargo (Refrigerated)", 1/0.87, 0, CargoBay.techAdvancement(),
(size, num) -> new RefrigeratedCargoBay(size, 1, num)),
(size, num) -> new RefrigeratedCargoBay(size, 0, num)),
INSULATED_CARGO ("Cargo (Insulated)", 1/0.87, 0, CargoBay.techAdvancement(),
(size, num) -> new InsulatedCargoBay(size, 1, num)),
(size, num) -> new InsulatedCargoBay(size, 0, num)),
LIVESTOCK_CARGO ("Cargo Livestock)", 1/0.83, 0, CargoBay.techAdvancement(),
(size, num) -> new LivestockCargoBay(size, 1, num));
(size, num) -> new LivestockCargoBay(size, 0, num));

private final String name;
private final double weight;
private final int personnel;
private final TechAdvancement techAdvancement;
private final BiFunction<Double,Integer,Bay> init;

static final List<Enum> noMinDoorBayTypes = new ArrayList<>();

static {
noMinDoorBayTypes.addAll(List.of(
INFANTRY_FOOT, INFANTRY_JUMP, INFANTRY_MECHANIZED, INFANTRY_MOTORIZED,
IS_BATTLE_ARMOR, CLAN_BATTLE_ARMOR, CS_BATTLE_ARMOR,
CARGO, INSULATED_CARGO, LIQUID_CARGO, LIVESTOCK_CARGO, REFRIGERATED_CARGO
));
}

BayData(String name, double weight, int personnel,
TechAdvancement techAdvancement, BiFunction<Double,Integer,Bay> init) {
this.name = name;
Expand Down Expand Up @@ -119,6 +131,15 @@ public int getPersonnel() {
return personnel;
}

/**
* Return the minimum number of doors required for the Bay type this BayType
* encapsulates.
* @return 0 if no minimum door count applies, or 1 otherwise.
*/
public int getMinDoors() {
return noMinDoorBayTypes.contains(this) ? 0 : 1;
}

/**
* Creates a new bay of the type.
*
Expand Down

0 comments on commit 08dec3e

Please sign in to comment.