Package megamek.server
Class ServerHelper
java.lang.Object
megamek.server.ServerHelper
This class contains computations carried out by the Server class. Methods put in here should be static and
self-contained.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDedicated logger name for hidden-unit probe detection diagnostics ([HiddenUnits] tag). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckAndApplyMagmaCrust(Hex hex, int elevation, Entity entity, Coords curPos, boolean jumpLanding, Vector<Report> vPhaseReport, TWGameManager gameManager) static booleancheckEnteringBlackIce(TWGameManager gameManager, Coords curPos, Hex curHex, boolean useBlackIce, boolean goodTemp, boolean isIceStorm) Check for black ice when moving into pavement hex.static voidcheckEnteringHazardousLiquid(Hex hex, int elevation, Entity entity, TWGameManager gameManager) Check for movement into hazardous liquid and apply damage.static voidcheckEnteringMagma(Hex hex, int elevation, Entity entity, TWGameManager gameManager) Check for movement into magma hex and apply damage.static voidcheckEnteringUltraSublevel(Hex hex, int elevation, Entity entity, TWGameManager gameManager) static voidclearBloodStalkers(Game game, int stalkeeID, TWGameManager gameManager) Loop through the game and clear 'blood stalker' flag for any entities that have the given unit as the blood stalker target.static booleandetectHiddenUnits(Game game, Entity detector, Coords detectorCoords, Vector<Report> vPhaseReport, TWGameManager gameManager) Checks to see if any units can detected hidden units.static voiddetectMinefields(Game game, Vector<Report> vPhaseReport, TWGameManager gameManager) Loops through all active entities in the game and performs mine detectionstatic booleandetectMinefields(Game game, Entity entity, Coords coords, Vector<Report> vPhaseReport, TWGameManager gameManager) Checks for minefields within the entity's active probe range.static booleaninfantryInOpen(Entity te, Hex te_hex, Game game, boolean isPlatoon, boolean ammoExplosion, boolean ignoreInfantryDoubleDamage) Determines if the given entity is an infantry unit in the given hex is "in the open" (and thus subject to double damage from attacks)static booleanisEcmDeactivationBlockedByStealth(Entity entity, Mounted<?> mounted, int newMode) Checks whether a requested equipment mode change must be rejected because it would deactivate an ECM suite while the unit's stealth armor system is engaged - or queued to engage this round.static booleanisStealthActivationBlockedByEcmShutdown(Entity entity, Mounted<?> mounted, int newMode) Checks whether a requested equipment mode change must be rejected because it would engage the stealth armor system while no ECM suite will be operating next round (all deactivated or switching to"Off").static voidsinkToBottom(Entity entity) Helper function that causes an entity to sink to the bottom of the water hex it's currently in.
-
Field Details
-
HIDDEN_UNITS_DIAGNOSTIC_LOGGER
Dedicated logger name for hidden-unit probe detection diagnostics ([HiddenUnits] tag). A feature logger rather than a host-class logger so it can be enabled in log4j2.xml without the host classes' debug noise.- See Also:
-
-
Method Details
-
infantryInOpen
public static boolean infantryInOpen(Entity te, Hex te_hex, Game game, boolean isPlatoon, boolean ammoExplosion, boolean ignoreInfantryDoubleDamage) Determines if the given entity is an infantry unit in the given hex is "in the open" (and thus subject to double damage from attacks)- Parameters:
te- Target entity.te_hex- Hex where target entity is located.game- The currentGameisPlatoon- Whether the target unit is a platoon.ammoExplosion- Whether we're considering a "big boom" ammo explosion from TacOps.ignoreInfantryDoubleDamage- Whether we should ignore double damage to infantry.- Returns:
- Whether the infantry unit can be considered to be "in the open"
-
sinkToBottom
Helper function that causes an entity to sink to the bottom of the water hex it's currently in. -
checkAndApplyMagmaCrust
-
checkEnteringMagma
public static void checkEnteringMagma(Hex hex, int elevation, Entity entity, TWGameManager gameManager) Check for movement into magma hex and apply damage. -
checkEnteringHazardousLiquid
public static void checkEnteringHazardousLiquid(Hex hex, int elevation, Entity entity, TWGameManager gameManager) Check for movement into hazardous liquid and apply damage. -
checkEnteringUltraSublevel
public static void checkEnteringUltraSublevel(Hex hex, int elevation, Entity entity, TWGameManager gameManager) -
checkEnteringBlackIce
public static boolean checkEnteringBlackIce(TWGameManager gameManager, Coords curPos, Hex curHex, boolean useBlackIce, boolean goodTemp, boolean isIceStorm) Check for black ice when moving into pavement hex. -
detectMinefields
public static void detectMinefields(Game game, Vector<Report> vPhaseReport, TWGameManager gameManager) Loops through all active entities in the game and performs mine detection -
detectMinefields
public static boolean detectMinefields(Game game, Entity entity, Coords coords, Vector<Report> vPhaseReport, TWGameManager gameManager) Checks for minefields within the entity's active probe range.- Returns:
- True if any minefields have been detected.
-
detectHiddenUnits
public static boolean detectHiddenUnits(Game game, Entity detector, Coords detectorCoords, Vector<Report> vPhaseReport, TWGameManager gameManager) Checks to see if any units can detected hidden units. -
isEcmDeactivationBlockedByStealth
public static boolean isEcmDeactivationBlockedByStealth(Entity entity, Mounted<?> mounted, int newMode) Checks whether a requested equipment mode change must be rejected because it would deactivate an ECM suite while the unit's stealth armor system is engaged - or queued to engage this round. Stealth armor requires an operating ECM, so the player has to switch the stealth armor off first; checking the pending stealth mode closes the loophole of queueing "stealth On" and "ECM Off" in the same round.- Parameters:
entity- the entity whose equipment is being switchedmounted- the equipment being switchednewMode- the requested mode index- Returns:
trueif the mode change would switch an ECM suite to"Off"while stealth armor is on or switching on
-
isStealthActivationBlockedByEcmShutdown
public static boolean isStealthActivationBlockedByEcmShutdown(Entity entity, Mounted<?> mounted, int newMode) Checks whether a requested equipment mode change must be rejected because it would engage the stealth armor system while no ECM suite will be operating next round (all deactivated or switching to"Off"). This is the mirror ofisEcmDeactivationBlockedByStealth(Entity, Mounted, int)and closes the other ordering of the same-round loophole: first queueing "ECM Off", then "stealth On".- Parameters:
entity- the entity whose equipment is being switchedmounted- the equipment being switchednewMode- the requested mode index- Returns:
trueif the mode change would switch stealth armor to"On"while no ECM suite will be operating next round
-
clearBloodStalkers
Loop through the game and clear 'blood stalker' flag for any entities that have the given unit as the blood stalker target.
-