Package megamek.common
Class BombLoadout
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<BombType.BombTypeEnum,
Integer>
Represents a collection of bombs with their quantities.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBombs
(BombType.BombTypeEnum bombType, int count) Adds a specified number of bombs of a given type to this loadout.boolean
Checks if this loadout contains bombs capable of ground attackboolean
Checks if this loadout contains bombs capable of space attackint
getCount
(BombType.BombTypeEnum bombType) Returns the count of bombs of a given type in this loadout.int
Returns the total cost of all bombs in this loadout.int
Returns the total number of bombs in this loadout.boolean
Checks if this loadout contains any guided ordnance that requires TAGput
(BombType.BombTypeEnum key, Integer count) Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Constructor Details
-
BombLoadout
public BombLoadout() -
BombLoadout
-
-
Method Details
-
put
- Specified by:
put
in interfaceMap<BombType.BombTypeEnum,
Integer> - Overrides:
put
in classHashMap<BombType.BombTypeEnum,
Integer>
-
getCount
Returns the count of bombs of a given type in this loadout. If the bomb type does not exist, returns 0.- Parameters:
bombType
- the type of bomb to check- Returns:
- the count of bombs of the specified type
-
addBombs
Adds a specified number of bombs of a given type to this loadout. If the bomb type does not exist, it will be added with the specified count. If the count is zero or negative, the bomb type will be removed from the loadout.- Parameters:
bombType
- the type of bomb to addcount
- the number of bombs to add
-
getTotalBombs
public int getTotalBombs()Returns the total number of bombs in this loadout.- Returns:
- total number of bombs
-
getTotalBombCost
public int getTotalBombCost()Returns the total cost of all bombs in this loadout.- Returns:
- total cost of bombs
-
hasGuidedOrdnance
public boolean hasGuidedOrdnance()Checks if this loadout contains any guided ordnance that requires TAG- Returns:
- true if loadout contains ordnance that requires TAG
-
canGroundBomb
public boolean canGroundBomb()Checks if this loadout contains bombs capable of ground attack- Returns:
- true if loadout contains any ground-capable bombs
-
canSpaceBomb
public boolean canSpaceBomb()Checks if this loadout contains bombs capable of space attack- Returns:
- true if loadout contains any space-capable bombs
-