Class SBFVisibilityHelper

java.lang.Object
megamek.common.strategicBattleSystems.SBFVisibilityHelper
All Implemented Interfaces:
SBFRuleOptionsUser

public final class SBFVisibilityHelper extends Object implements SBFRuleOptionsUser
This class holds visibility information for an SBF game. In SBF games, visibility is not instantaneous but checked and updated in the Detection and Recon phase, see IO:BF p.194. Note that this class checks the game options by itself and will always indicate that formations are visible when detection and recon is not used.

Note that while this class is used by SBFGame (as it needs to be saved with the game) it should only be used by the server (SBFGameManager). The Clients must accept what they get from the server as a result of testing visibility.

  • Constructor Details

    • SBFVisibilityHelper

      public SBFVisibilityHelper(SBFGame game)
  • Method Details

    • isVisible

      public boolean isVisible(int viewingPlayer, int formationID)
      Returns true when the given formation is fully visible to the given player, depending on the game's options. When double-blind rules are not used, this is always true. Otherwise, it depends on previous detection. Players always see their own units.
      Parameters:
      viewingPlayer - the player that is doing the looking
      formationID - the formation in question
      Returns:
      True when the formation is fully visible, false otherwise
    • getVisibility

      public SBFVisibilityStatus getVisibility(int viewingPlayer, int formationID)
      Returns the visibility status for the given formation to the given player, depending on the game's options. When double-blind rules are not used, the status is always SBFVisibilityStatus.VISIBLE. Otherwise, it depends on previous detection. Players always see their own units.
      Parameters:
      viewingPlayer - the player that is doing the looking
      formationID - the formation in question
      Returns:
      The SBFVisibilityStatus
      See Also:
    • setVisible

      public void setVisible(int viewingPlayer, int formationID)
      Sets the given formation as fully visible to the given player.

      Note: that the ID values are not checked; when they don't map to anything, no error will happen, and they will have no effect.

      Parameters:
      viewingPlayer - The player
      formationID - The formation to make visible
    • setInvisible

      public void setInvisible(int viewingPlayer, int formationID)
      Sets the given formation as invisible to the given player.

      Note: that the ID values are not checked; when they don't map to anything, no error will happen, and they will have no effect.

      Parameters:
      viewingPlayer - The player
      formationID - The formation to make invisible
    • setVisibility

      public void setVisibility(int viewingPlayer, int formationID, SBFVisibilityStatus visibilityStatus)
      Sets the given SBFVisibilityStatus for the given formation as viewed by the given player.

      Note: that the ID values are not checked; when they don't map to anything, no error will happen, and they will have no effect.

      Parameters:
      viewingPlayer - The player
      formationID - The formation
      visibilityStatus - The new visibility status
      See Also:
    • getOptions

      public SBFRuleOptions getOptions()
      Description copied from interface: SBFRuleOptionsUser
      This method must be implemented to provide access to the SBF options used in the present game so that the convenience methods of this interface work correctly.
      Specified by:
      getOptions in interface SBFRuleOptionsUser
      Returns:
      the SBFRuleOptions used by the present SBF game