Class Game

All Implemented Interfaces:
Serializable, IGame, PlanetaryConditionsUsing

public final class Game extends AbstractGame implements Serializable, PlanetaryConditionsUsing
The game class is the root of all data about the game in progress. Both the Client and the Server should have one of these objects, and it is their job to keep it synced.
See Also:
  • Field Details

    • TEAM_HAS_COMBAT_SENSE

      public static final int TEAM_HAS_COMBAT_SENSE
      See Also:
    • TEAM_HAS_NO_INITIATIVE_APTITUDE

      public static final int TEAM_HAS_NO_INITIATIVE_APTITUDE
      See Also:
    • TEAM_HAS_COMBAT_PARALYSIS

      public static final int TEAM_HAS_COMBAT_PARALYSIS
      See Also:
    • rulesManager

      public static RulesManager rulesManager
    • uuid

      public UUID uuid
      A UUID to identify this game instance.
    • version

      public final Version version
      Stores the version of MM, so that it can be serialized in saved games.
  • Constructor Details

    • Game

      public Game()
      Constructor
    • Game

      public Game(Board board)
  • Method Details

    • getExternalGameId

      @Deprecated(since="0.51.0", forRemoval=true) public int getExternalGameId()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setExternalGameId

      public void setExternalGameId(int value)
    • getVersion

      public Version getVersion()
    • setBoard

      public void setBoard(Board board)
    • setBoardDirect

      public void setBoardDirect(Board board)
    • containsMinefield

      public boolean containsMinefield(@Nullable Coords coords)
    • getMinefields

      public Vector<Minefield> getMinefields(Coords coords)
    • getNbrMinefields

      public int getNbrMinefields(Coords coords)
    • getMinedCoords

      public Enumeration<Coords> getMinedCoords()
      Get the coordinates of all mined hexes in the game.
      Returns:
      an Enumeration of the Coords containing minefields. This will not be null.
    • addMinefield

      public void addMinefield(Minefield mf)
    • getWoodsClearingTracker

      public WoodsClearingTracker getWoodsClearingTracker()
      Returns the woods clearing tracker for this game. Serialized with game saves.
    • initializeRulesManager

      public void initializeRulesManager(String system)
    • getHexesBeingCut

      public Map<BoardLocation,Integer> getHexesBeingCut()
      Returns the map of hex locations being cleared by saws to turns remaining. Used by the board view to render cut indicators and tooltips.
    • setHexesBeingCut

      public void setHexesBeingCut(Map<BoardLocation,Integer> hexes)
      Updates the map of hex locations being cleared by saws.
      Parameters:
      hexes - the current map of hexes being cut to turns remaining
    • addMinefields

      public void addMinefields(Vector<Minefield> mines)
    • setMinefields

      public void setMinefields(Vector<Minefield> minefields)
    • resetMinefieldDensity

      public void resetMinefieldDensity(Vector<Minefield> newMinefields)
    • removeMinefield

      public void removeMinefield(Minefield mf)
    • removeMinefieldHelper

      public void removeMinefieldHelper(Minefield mf)
    • clearMinefields

      public void clearMinefields()
    • getVibraBombs

      public Vector<Minefield> getVibraBombs()
    • addVibrabomb

      public void addVibrabomb(Minefield mf)
    • removeVibrabomb

      public void removeVibrabomb(Minefield mf)
    • containsVibrabomb

      public boolean containsVibrabomb(Minefield mf)
      Checks if the game contains the specified Vibrabomb
      Parameters:
      mf - the Vibrabomb to check
      Returns:
      true if the minefield contains a vibrabomb.
    • getEMPMines

      public Vector<Minefield> getEMPMines()
    • addEMPMine

      public void addEMPMine(Minefield mf)
    • removeEMPMine

      public void removeEMPMine(Minefield mf)
    • containsEMPMine

      public boolean containsEMPMine(Minefield mf)
      Checks if the game contains the specified EMP mine
      Parameters:
      mf - the EMP mine to check
      Returns:
      true if the minefield contains an EMP mine.
    • getOptions

      public GameOptions getOptions()
      Specified by:
      getOptions in interface IGame
    • setOptions

      public void setOptions(@Nullable GameOptions options)
    • usesStandardGhostTargetMode

      public boolean usesStandardGhostTargetMode()
      Returns true if the Standard (Targeted) ghost target mode is active (TO:AR p.100). This requires both the ghost target option to be enabled and the mode set to Standard.
      Returns:
      true if Standard ghost target mode is active
    • setupTeams

      public void setupTeams()
      Set up the teams vector. Each player on a team (Team 1 ... Team X) is placed in the appropriate vector. Any player on 'No Team', is placed in their own object
      Specified by:
      setupTeams in interface IGame
    • addPlayer

      public void addPlayer(int id, Player player)
      Description copied from interface: IGame
      Adds the given Player to the game with the given game-unique id. // TODO : Can this be made a default method?
      Specified by:
      addPlayer in interface IGame
      Overrides:
      addPlayer in class AbstractGame
      Parameters:
      id - The game-unique id of this player
      player - The Player object
    • isCurrentPhasePlayable

      public boolean isCurrentPhasePlayable()
      Description copied from interface: IGame
      Returns true when the current game phase should be played, meaning it is played in the current type of game and there are possible actions in it in the present game state. The result may be different in other rounds.
      Specified by:
      isCurrentPhasePlayable in interface IGame
      Returns:
      True when the current phase should be skipped entirely in this round
      See Also:
    • setPlayer

      public void setPlayer(int id, Player player)
      Description copied from interface: IGame
      Sets the given Player to the given game-unique id. // TODO : Is this method useful? Why not use addPlayer that also sets single-blind info?
      Specified by:
      setPlayer in interface IGame
      Parameters:
      id - The game-unique id of this player
      player - The Player object
    • removePlayer

      public void removePlayer(int id)
      Description copied from interface: IGame
      Removes the player with the id from the game.
      Specified by:
      removePlayer in interface IGame
      Parameters:
      id - The player id
    • getAllEntitiesOwnedBy

      @Deprecated(since="0.51.0", forRemoval=true) public int getAllEntitiesOwnedBy(Player player)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the number of entities owned by the player, regardless of their status.
    • getLiveEntitiesOwnedBy

      @Deprecated(since="0.51.0", forRemoval=true) public int getLiveEntitiesOwnedBy(Player player)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      the number of non-destroyed entities owned by the player
    • getLiveDeployedEntitiesOwnedBy

      public int getLiveDeployedEntitiesOwnedBy(Player player)
      Returns:
      the number of non-destroyed entities owned by the player, including entities not yet deployed. Ignores off board units and captured Mek pilots.
    • getLiveCommandersOwnedBy

      public int getLiveCommandersOwnedBy(Player player)
      Returns:
      the number of non-destroyed commander entities owned by the player. Ignores off board units and captured Mek pilots.
    • hasTacticalGenius

      public boolean hasTacticalGenius(Player player)
      Returns:
      true if the player has a valid unit with the Tactical Genius pilot special ability.
    • commanderHasCombatSense

      public boolean commanderHasCombatSense(Player player)
      Checks if the specified player has a valid unit with the "Combat Sense" pilot special ability.

      A unit is considered valid if it:

      • Has the Combat Sense special ability (ATOW_COMBAT_SENSE).
      • Is marked as the commander unit.
      • Belongs to the specified player.
      • Is not destroyed.
      • Is deployed in the current scenario.
      • Is not a carcass (remains of a destroyed unit).
      • Has a conscious crew member.
      Parameters:
      player - The player whose units will be checked.
      Returns:
      true if the player has a valid unit with the "Combat Sense" ability, false otherwise.
    • commanderHasCombatParalysis

      public boolean commanderHasCombatParalysis(Player player)
      Checks if the commander unit of the specified player has the "Combat Paralysis" special ability.

      A commander is considered valid for this check if it:

      • Has the Combat Paralysis special ability (ATOW_COMBAT_PARALYSIS).
      • Is marked as the commander unit.
      • Belongs to the specified player.
      • Is not destroyed.
      • Is currently deployed in the scenario.
      • Is not a carcass (remains of a destroyed unit).
      • Has a conscious crew member.
      Parameters:
      player - The player whose commander will be checked.
      Returns:
      true if the player's commander has the "Combat Paralysis" special ability and meets all conditions, false otherwise.
    • getValidTargets

      public List<Entity> getValidTargets(Entity entity)
      Get a vector of entity objects that are "acceptable" to attack with this entity
    • getTurn

      @Nullable public GameTurn getTurn()
      Specified by:
      getTurn in interface IGame
      Returns:
      the current GameTurn object
    • getTurnForPlayer

      @Nullable public GameTurn getTurnForPlayer(int pn)
      Returns:
      the first GameTurn object for the specified player, or null if the player has no turns to play
    • changeToNextTurn

      public GameTurn changeToNextTurn()
      Changes to the next turn, returning it.
    • insertNextTurn

      public void insertNextTurn(GameTurn turn)
      Inserts a turn that will come directly after the current one
    • insertTurnAfter

      public void insertTurnAfter(GameTurn turn, int index)
      Inserts a turn after the specific index
    • swapTurnOrder

      public void swapTurnOrder(int index1, int index2)
      Swaps the turn at index 1 with the turn at index 2.
    • getTurns

      public Enumeration<GameTurn> getTurns()
      Returns an Enumeration of the current turn list
    • setTurnIndex

      public void setTurnIndex(int turnIndex, int prevPlayerId)
      Sets the current turn index
      Parameters:
      turnIndex - The new turn index.
      prevPlayerId - The ID of the player who triggered the turn index change.
    • getTurnsList

      public List<GameTurn> getTurnsList()
      Specified by:
      getTurnsList in interface IGame
      Returns:
      the current list of turns. If you're not the GameManager, don't even think about changing any of the turns.
    • setTurnVector

      public void setTurnVector(List<GameTurn> turnVector)
      Sets the current turn vector
    • getPhase

      public GamePhase getPhase()
      Specified by:
      getPhase in interface IGame
      Returns:
      The current phase of this game.
    • setPhase

      public void setPhase(GamePhase phase)
      Description copied from interface: IGame
      Sets the current game phase to the given phase. May perform phase-dependent cleanup. This method is intended for the GameManager.
      Specified by:
      setPhase in interface IGame
      Parameters:
      phase - The new phase
    • getPlayerIdsWithDemolitionCharges

      public Set<Integer> getPlayerIdsWithDemolitionCharges()
      Returns the ids of players that own at least one demolition charge set on a building. The result is computed once per phase and cached (see setPhase(megamek.common.enums.GamePhase)), so callers such as the per-entity pre-end declarations eligibility check do a constant-time lookup instead of scanning every board and building per unit.
      Returns:
      the set of owning player ids (empty if no charges are set)
    • processGameEvent

      public void processGameEvent(GameEvent event)
    • getLastPhase

      public GamePhase getLastPhase()
    • setLastPhase

      public void setLastPhase(GamePhase lastPhase)
      Description copied from interface: IGame
      Sets the previous game phase to the given phase. This method is intended for the GameManager.
      Specified by:
      setLastPhase in interface IGame
      Parameters:
      lastPhase - The phase to be remembered as the previous phase.
    • getPreviousEntityFromList

      @Nullable public Entity getPreviousEntityFromList(@Nullable Entity current)
      Parameters:
      current - The Entity whose list position you wish to start from.
      Returns:
      The previous Entity from the master list of entities. Will wrap around to the end of the list if necessary, returning null if there are no entities.
    • getNextEntityFromList

      @Nullable public Entity getNextEntityFromList(@Nullable Entity current)
      Parameters:
      current - The Entity whose list position you wish to start from.
      Returns:
      The next Entity from the master list of entities. Will wrap around to the beginning of the list if necessary, returning null if there are no entities.
    • getEntitiesVector

      public List<Entity> getEntitiesVector()
      Returns:
      the actual vector for the entities
    • setEntitiesVector

      public void setEntitiesVector(List<Entity> entities)
    • getOutOfGameEntitiesVector

      public Vector<Entity> getOutOfGameEntitiesVector()
      Returns:
      the actual vector for the out-of-game entities
    • setOutOfGameEntitiesVector

      public void setOutOfGameEntitiesVector(List<Entity> vOutOfGame)
      Swap out the current list of dead (or fled) units for a new one.
      Parameters:
      vOutOfGame - - the new Vector of dead or fled units. This value should not be null.
      Throws:
      IllegalArgumentException - if the new list is null.
    • getOutOfGameEntity

      @Nullable public Entity getOutOfGameEntity(int id)
      Returns an out-of-game entity.
      Parameters:
      id - the int ID of the out-of-game entity.
      Returns:
      the out-of-game Entity with that ID. If no out-of-game entity has that ID, returns a null.
    • getC3NetworkMembers

      public Vector<Entity> getC3NetworkMembers(Entity entity)
      Returns a Vector containing the Entitys that are in the same C3 network as the passed-in unit. The output will contain the passed-in unit, if the unit has a C3 computer. If the unit has no C3 computer, the output will be empty (but it will never be null).
      Parameters:
      entity - - the Entity whose C3 network co- members is required. This value may be null.
      Returns:
      a Vector that will contain all other Entitys that are in the same C3 network as the passed-in unit. This Vector may be empty, but it will not be null.
      See Also:
    • getC3SubNetworkMembers

      public Vector<Entity> getC3SubNetworkMembers(Entity entity)
      Returns a Vector containing the Entitys that are in the C3 subnetwork under the passed-in unit. The output will contain the passed-in unit, if the unit has a C3 computer. If the unit has no C3 computer, the output will be empty (but it will never be null). If the passed-in unit is a company commander or a member of a C3i network, this call is the same as getC3NetworkMembers.
      Parameters:
      entity - - the Entity whose C3 network sub-members is required. This value may be null.
      Returns:
      a Vector that will contain all other Entitys that are in the same C3 network under the passed-in unit. This Vector may be empty, but it will not be null.
      See Also:
    • getPositionMap

      public Hashtable<Coords,Vector<Entity>> getPositionMap()
      Returns a Hashtable that maps the Coords of each unit in this Game to a Vector of Entity's at that positions. Units that have no position (e.g. loaded units) will not be in the map. LEGACY - should be replaced with getPositionMapMulti()
      Returns:
      a Hashtable that maps the Coords positions or each unit in the game to a Vector of Entity's at that position.
    • getPositionMapMulti

      public Map<BoardLocation,List<Entity>> getPositionMapMulti()
      Returns:
      a Map that maps the location of each unit in this game to a list of Entity's at the same location. Units that have no position (e.g. loaded units) will not be in the map.
    • getGraveyardEntities

      public Enumeration<Entity> getGraveyardEntities()
      Returns an enumeration of salvageable entities.
    • getWreckedEntities

      public Enumeration<Entity> getWreckedEntities()
      Returns an enumeration of wrecked entities.
    • getRetreatedEntities

      public Enumeration<Entity> getRetreatedEntities()
      Returns an enumeration of entities that have retreated
    • getDevastatedEntities

      public Enumeration<Entity> getDevastatedEntities()
      Returns an enumeration of entities that were utterly destroyed
    • getCarcassEntities

      public Enumeration<Entity> getCarcassEntities()
      Returns an enumeration of "carcass" entities, i.e., vehicles with dead crews that are still on the map.
    • getNoOfEntities

      public int getNoOfEntities()
      Return the current number of entities in the game.
    • getTarget

      @Nullable public Targetable getTarget(int targetType, int targetId)
      Returns the appropriate target for this game given a type and id
    • getEntity

      @Nullable public Entity getEntity(int id)
      Returns:
      The entity with the given id number, if any.
    • getEntityOrThrow

      public Entity getEntityOrThrow(int id)
      When it has to exist, the entity HAS to exists. If it doesn't, throw a no such element exception. This is to be used in place of the previous getEntity method when the entity is expected to exist and the following actions will cause a null pointer exception if the entity does not exist.
      Parameters:
      id - The id number of the entity to get.
      Returns:
      The entity with the given id number or throw a no such element exception.
    • getEntityFromAllSources

      public Entity getEntityFromAllSources(int id)
      looks for an entity by id number even if out of the game
      Specified by:
      getEntityFromAllSources in interface IGame
    • addEntities

      public void addEntities(List<Entity> entities)
      Adds a collection of new Entities. Only one GameEntityNewEvent is created for the whole list.
      Parameters:
      entities - the Entity objects to be added.
    • addEntity

      public void addEntity(Entity entity)
      Adds a new Entity to this Game object and generates a GameEntityNewEvent.
      Parameters:
      entity - The Entity to add.
    • addEntity

      public void addEntity(Entity entity, boolean genEvent)
      Adds a new Entity to this Game object.
      Parameters:
      entity - The Entity to add.
      genEvent - A flag that determines whether a GameEntityNewEvent is generated.
    • setEntity

      public void setEntity(int id, Entity entity)
    • setEntity

      public void setEntity(int id, Entity entity, Vector<UnitLocation> movePath)
    • getNextEntityId

      public int getNextEntityId()
      Specified by:
      getNextEntityId in interface IGame
      Overrides:
      getNextEntityId in class AbstractGame
      Returns:
      The next free ID for InGameObjects (unit/entity/formation/others).
    • replaceUnits

      public void replaceUnits(List<InGameObject> units)
      Description copied from interface: IGame
      This is a Client-side method to replace or add units that are sent from the server. Adds the given units to the list of units or objects in the current game. When a unit's ID is already present the currently assigned unit will be replaced with the given new one.
      Specified by:
      replaceUnits in interface IGame
      Parameters:
      units - The units to add or use as a replacement for current units.
    • getGraveyard

      public List<InGameObject> getGraveyard()
      Specified by:
      getGraveyard in interface IGame
      Returns:
      a list of units that are destroyed or otherwise no longer part of the game. These should have a reason for their removal set.
    • hasEntity

      public boolean hasEntity(int entityId)
      Returns:
      true if an entity with the specified id number exists in this game.
    • removeEntity

      public void removeEntity(int id, int condition)
      Remove an entity from the master list. If we can't find that entity, (probably due to double-blind) ignore it.
    • removeEntities

      public void removeEntities(List<Integer> ids, int condition)
    • reset

      public void reset()
      Description copied from class: AbstractGame
      Resets this game, i.e. prepares it for a return to the lobby.
      Overrides:
      reset in class AbstractGame
    • getFirstEntity

      public Entity getFirstEntity(Coords c)
      Returns the first entity at the given coordinate, if any. Only returns targetable (non-dead) entities.
      Parameters:
      c - the coordinates to search at
    • getFirstEnemyEntity

      public Entity getFirstEnemyEntity(Coords c, Entity currentEntity)
      Returns the first enemy entity at the given coordinate, if any. Only returns targetable (non-dead) entities.
      Parameters:
      c - the coordinates to search at
      currentEntity - the entity that is firing
    • getEntities

      public Iterator<Entity> getEntities(Coords c)
      Returns an Enumeration of the active entities at the given coordinates.
    • getEntities

      public Iterator<Entity> getEntities(ArrayList<Coords> coordList)
      Returns an Iterator for all entities in _all_ of the coordinates provided. Coords must not be null.
      Parameters:
      coordList - ArrayList of coordinates to check.
      Returns:
      Iterator over the vector of entities. The vector must exist to get the iterator.
    • getEntities

      public Iterator<Entity> getEntities(Coords c, boolean ignore)
      Returns an Enumeration of the active entities at the given coordinates.
    • getEntitiesVector

      public List<Entity> getEntitiesVector(Coords c)
      Return an Entity List at Coords c, checking if they can be targeted.
      Parameters:
      c - The coordinates to check
      Returns:
      the Entity List
    • getEntitiesVector

      public List<Entity> getEntitiesVector(Coords c, boolean ignore)
      Return an Entity List at Coords c
      Parameters:
      c - The coordinates to check
      ignore - Flag that determines whether the ability to target is ignored
      Returns:
      the Entity List
    • getEntitiesVector

      public List<Entity> getEntitiesVector(BoardLocation location, boolean ignoreTargetable)
    • getEntitiesVector

      public List<Entity> getEntitiesVector(BoardLocation location)
    • getEntitiesVector

      public List<Entity> getEntitiesVector(Coords coord, int boardId, boolean ignoreTargetable)
    • getEntitiesVector

      public List<Entity> getEntitiesVector(Coords coord, int boardId)
    • getAllOffboardEnemyEntities

      public List<Entity> getAllOffboardEnemyEntities(Player player)
      Parameters:
      player - Player Object
      Returns:
      a list of all off-board enemy entities.
    • getGunEmplacements

      public List<GunEmplacement> getGunEmplacements(Coords c)
    • getGunEmplacements

      public List<GunEmplacement> getGunEmplacements(Coords c, int boardId)
      Return a Vector of gun emplacements at Coords c.
      Parameters:
      c - The coordinates to check
      Returns:
      the GunEmplacement Vector
    • hasRooftopGunEmplacement

      public boolean hasRooftopGunEmplacement(Coords c, int boardId)
      Determine if the given set of coordinates has a gun emplacement on the roof of a building.
      Parameters:
      c - The coordinates to check
    • getAFFATarget

      @Nullable public Entity getAFFATarget(Coords coords, Entity ignore)
      Returns a Target for an Accidental Fall From above, or null if no possible target is there
      Parameters:
      coords - The Coords of the hex in which the accidental fall from above happens
      ignore - The entity who is falling, so shouldn't be returned
      Returns:
      The Entity that should be an AFFA target.
    • getEnemyEntities

      public Iterator<Entity> getEnemyEntities(Coords coords, Entity currentEntity)
      Returns an Iterator of the enemy's active entities at the given coordinates.
      Parameters:
      coords - the Coords of the hex being examined.
      currentEntity - the Entity whose enemies are needed.
      Returns:
      an Enumeration of Entitys at the given coordinates who are enemies of the given unit.
    • getEnemyEntities

      public List<Entity> getEnemyEntities(Coords coords, int boardId, Entity currentEntity)
      Returns an Iterator of the enemy's active entities at the given coordinates.
      Parameters:
      coords - the Coords of the hex being examined.
      currentEntity - the Entity whose enemies are needed.
      Returns:
      an Enumeration of Entitys at the given coordinates who are enemies of the given unit.
    • getAllEnemyEntities

      public Iterator<Entity> getAllEnemyEntities(Entity currentEntity)
      Returns an Enumeration of active enemy entities
      Parameters:
      currentEntity - the Entity whose enemies are needed.
      Returns:
      an Enumeration of Entitys at the given coordinates who are enemies of the given unit.
    • getTeamEntities

      public Iterator<Entity> getTeamEntities(Team team)
    • getFriendlyEntities

      public Iterator<Entity> getFriendlyEntities(Coords coords, Entity currentEntity)
      Returns an Iterator of friendly active entities at the given coordinates.
      Parameters:
      coords - the Coords of the hex being examined.
      currentEntity - the Entity whose friends are needed.
      Returns:
      an Enumeration of Entitys at the given coordinates who are friends of the given unit.
    • moveToGraveyard

      public void moveToGraveyard(int id)
      Moves an entity into the graveyard, so it stops getting sent out every phase.
    • isOutOfGame

      public boolean isOutOfGame(int id)
      See if the Entity with the given ID is out of the game.
      Parameters:
      id - - the ID of the Entity to be checked.
      Returns:
      true if the Entity is in the graveyard, false otherwise.
    • isOutOfGame

      public boolean isOutOfGame(Entity entity)
      See if the Entity is out of the game.
      Parameters:
      entity - - the Entity to be checked.
      Returns:
      true if the Entity is in the graveyard, false otherwise.
    • getFirstEntity

      @Nullable public Entity getFirstEntity()
      Returns:
      the first entity that can act in the present turn, or null if none can.
    • getFirstEntity

      @Nullable public Entity getFirstEntity(@Nullable GameTurn turn)
      Parameters:
      turn - the current game turn, which may be null
      Returns:
      the first entity that can act in the specified turn, or null if none can.
    • getFirstEntityNum

      public int getFirstEntityNum()
      Returns:
      the id of the first entity that can act in the current turn, or -1 if none can.
    • getFirstEntityNum

      public int getFirstEntityNum(@Nullable GameTurn turn)
      Parameters:
      turn - the current game turn, which may be null
      Returns:
      the id of the first entity that can act in the specified turn, or -1 if none can.
    • getNextEntity

      @Nullable public Entity getNextEntity(int start)
      Parameters:
      start - the index number to start at (not an Entity ID)
      Returns:
      the next selectable entity that can act this turn, or null if none can.
    • getNextEntityNum

      public int getNextEntityNum(@Nullable GameTurn turn, int start)
      Parameters:
      turn - the turn to use, which may be null
      start - the entity id to start at
      Returns:
      the entity id of the next entity that can move during the specified turn
    • getPrevEntityNum

      public int getPrevEntityNum(GameTurn turn, int start)
      Parameters:
      turn - the turn to use
      start - the entity id to start at
      Returns:
      the entity id of the previous entity that can move during the specified turn
    • getFirstDeployableEntityNum

      public int getFirstDeployableEntityNum(@Nullable GameTurn turn)
      Parameters:
      turn - the current game turn, which may be null
      Returns:
      the number of the first deployable entity that is valid for the specified turn
    • getNextDeployableEntityNum

      public int getNextDeployableEntityNum(GameTurn turn, int start)
      Returns:
      the number of the next deployable entity that is valid for the specified turn
    • getFirstHiddenEntityNum

      @Deprecated(since="0.51.0", forRemoval=true) public int getFirstHiddenEntityNum(@Nullable GameTurn turn)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      turn - the current game turn, which may be null
      Returns:
      the number of the first hidden entity that is valid for the specified turn
    • getNextHiddenEntityNum

      @Deprecated(since="0.51.0", forRemoval=true) public int getNextHiddenEntityNum(GameTurn turn, int start)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      the number of the next hidden entity that is valid for the specified turn
    • getPlayerEntities

      public ArrayList<Entity> getPlayerEntities(Player player, boolean hide)
      Get the entities for the player.
      Parameters:
      player - - the Player whose entities are required.
      hide - - should fighters loaded into squadrons be excluded?
      Returns:
      a Vector of Entitys.
    • getPlayerEntityIds

      @Deprecated(since="0.51.0", forRemoval=true) public ArrayList<Integer> getPlayerEntityIds(Player player, boolean hide)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the entities for the player.
      Parameters:
      player - - the Player whose entities are required.
      hide - - should fighters loaded into squadrons be excluded from this list?
      Returns:
      a Vector of Entitys.
    • getPlayerRetreatedEntities

      public ArrayList<Entity> getPlayerRetreatedEntities(Player player)
      Get the entities for the player.
      Parameters:
      player - - the Player whose entities are required.
      Returns:
      a Vector of Entity that have retreadeds.
    • isEntityStranded

      public boolean isEntityStranded(Entity entity)
      Determines if the indicated entity is stranded on transport that can't move.

      According to Randall Bills, the "minimum move" rule allow stranded units to dismount at the start of the turn.

      Parameters:
      entity - the Entity that may be stranded
      Returns:
      true if the entity is stranded false otherwise.
    • getInfantryLeft

      public int getInfantryLeft(int playerId)
      Parameters:
      playerId - the player's ID
      Returns:
      number of infantry playerId has not selected yet this turn
    • getProtoMeksLeft

      public int getProtoMeksLeft(int playerId)
      Parameters:
      playerId - the player's ID
      Returns:
      number of ProtoMeks playerId has not selected yet this turn
    • getVehiclesLeft

      public int getVehiclesLeft(int playerId)
      Parameters:
      playerId - the player's ID
      Returns:
      number of vehicles playerId has not selected yet this turn
    • getMeksLeft

      public int getMeksLeft(int playerId)
      Parameters:
      playerId - the player's ID
      Returns:
      number of 'Meks playerId has not selected yet this turn
    • removeFirstTurnFor

      @Nullable public GameTurn removeFirstTurnFor(Entity entity) throws Exception
      Removes the first turn found that the specified entity can move in. Used when a turn is played out of order.
      Parameters:
      entity - the entity to remove a turn for
      Returns:
      the removed GameTurn, or null if not found
      Throws:
      Exception - if called during the movement phase
    • removeTurnFor

      public void removeTurnFor(Entity entity)
      Removes the last, next turn found that the specified entity can move in. Used when, say, an entity dies mid-phase.
    • removeSpecificEntityTurnsFor

      public int removeSpecificEntityTurnsFor(Entity entity)
      Removes any turns that can only be taken by the specified entity. Useful if the specified Entity is being removed from the game to ensure any turns that only it can take are gone.
      Parameters:
      entity - the entity to remove turns for
      Returns:
      The number of turns returned
    • setOrbitalBombardmentVector

      public void setOrbitalBombardmentVector(Vector<OrbitalBombardment> orbitalBombardments)
      Set the new vector of orbital bombardments for this round.
      Parameters:
      orbitalBombardments - A vector of OrbitalBombardment objects
    • resetOrbitalBombardmentAttacks

      public void resetOrbitalBombardmentAttacks()
      Resets the orbital bombardment attacks list.
    • getOrbitalBombardmentAttacks

      public Enumeration<OrbitalBombardment> getOrbitalBombardmentAttacks()
      Returns:
      an Enumeration of orbital bombardment attacks.
    • setArtilleryVector

      public void setArtilleryVector(Vector<ArtilleryAttackAction> v)
    • resetArtilleryAttacks

      public void resetArtilleryAttacks()
    • getArtilleryAttacks

      public Enumeration<ArtilleryAttackAction> getArtilleryAttacks()
    • setEnemyArtilleryInbound

      public void setEnemyArtilleryInbound(List<EnemyArtilleryInbound> inbound)
      Parameters:
      inbound - Redacted enemy artillery-in-flight summaries for the Rounds-in-Air window (target/munition already withheld by the server), or null to clear
    • getEnemyArtilleryInbound

      public List<EnemyArtilleryInbound> getEnemyArtilleryInbound()
      Returns:
      The redacted enemy artillery-in-flight summaries (landing time only; target and munition withheld); never null (empty when none, or after deserializing a saved game where this transient field is unset)
    • getArtillerySize

      @Deprecated(since="0.51.0", forRemoval=true) public int getArtillerySize()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getActions

      public Enumeration<EntityAction> getActions()
      Returns an Enumeration of actions scheduled for this phase.
    • addInitiativeRerollRequest

      public void addInitiativeRerollRequest(Team t)
    • rollInitAndResolveTies

      public void rollInitAndResolveTies()
    • handleInitiativeCompensation

      public void handleInitiativeCompensation()
    • getNoOfInitiativeRerollRequests

      public int getNoOfInitiativeRerollRequests()
    • addDisplacementAttack

      public void addDisplacementAttack(AttackAction ea)
      Adds a pending displacement attack to the list for this phase.
    • removeDisplacementAttack

      public void removeDisplacementAttack(AttackAction ea)
      Remove displacement attacks that were added previously
      Parameters:
      ea -
    • getDisplacementAttacks

      public Enumeration<AttackAction> getDisplacementAttacks()
      Returns:
      Enumeration of displacement attacks scheduled for the end of the physical phase.
    • resetCharges

      public void resetCharges()
      Resets the pending charges list.
    • getChargesVector

      public List<AttackAction> getChargesVector()
      Returns:
      the charges vector. Do not modify. Used for sending all charges to the client.
    • addRam

      public void addRam(AttackAction ea)
      Adds a pending ramming attack to the list for this phase.
      Parameters:
      ea - Pending Ramming Attack.
    • getRams

      public Enumeration<AttackAction> getRams()
      Returns:
      Returns an Enumeration of ramming attacks scheduled for the end of the physical phase.
    • resetRams

      public void resetRams()
      Resets the pending rams list.
    • getRamsVector

      public List<AttackAction> getRamsVector()
      Returns the rams vector. Do not modify. Used for sending all charges to the client.
    • initializeAfterLoad

      public void initializeAfterLoad()
    • addTeleMissileAttack

      public void addTeleMissileAttack(AttackAction ea)
      Adds a pending ramming attack to the list for this phase.
      Parameters:
      ea - AttackAction Object
    • getTeleMissileAttacks

      public Enumeration<AttackAction> getTeleMissileAttacks()
      Returns:
      an Enumeration of tele-missile attacks.
    • resetTeleMissileAttacks

      public void resetTeleMissileAttacks()
      Resets the pending rams list.
    • getTeleMissileAttacksVector

      public List<AttackAction> getTeleMissileAttacksVector()
      This is used to send all tele-missile attacks to the client.
      Returns:
      an unmodifiable list of pending tele-missile attacks.
    • addPSR

      public void addPSR(PilotingRollData psr)
      Adds a pending PSR to the list for this phase.
      Parameters:
      psr - Pending PSR.
      See Also:
    • getPSRs

      public Enumeration<PilotingRollData> getPSRs()
      Returns an Enumeration of pending PSRs.
    • addExtremeGravityPSR

      public void addExtremeGravityPSR(PilotingRollData psr)
      Adds a pending extreme Gravity PSR to the list for this phase.
    • getExtremeGravityPSRs

      public Enumeration<PilotingRollData> getExtremeGravityPSRs()
      Returns an Enumeration of pending extreme GravityPSRs.
    • getPSRsForEntity

      public ArrayList<PilotingRollData> getPSRsForEntity(Entity entity)
      Get PSR rolls for a given entity. These are references to the pilotingRolls ArrayList
    • removePSRsByArray

      public void removePSRsByArray(ArrayList<PilotingRollData> psrList)
    • resetPSRs

      public void resetPSRs(Entity entity)
      Resets the PSR list for a given entity.
    • resetExtremeGravityPSRs

      public void resetExtremeGravityPSRs()
      Resets the extreme Gravity PSR list.
    • resetExtremeGravityPSRs

      public void resetExtremeGravityPSRs(Entity entity)
      Resets the extreme Gravity PSR list for a given entity.
    • resetPSRs

      public void resetPSRs()
      Resets the PSR list.
    • addAttack

      public void addAttack(AttackHandler ah)
      add an AttackHandler to the attacks list
      Parameters:
      ah - - The AttackHandler to add
    • removeAttack

      @Deprecated(since="0.51.0", forRemoval=true) public void removeAttack(AttackHandler ah)
      Deprecated, for removal: This API element is subject to removal in a future version.
      remove an AttackHandler from the attacks list
      Parameters:
      ah - - The AttackHandler to remove
    • getAttacks

      public Enumeration<AttackHandler> getAttacks()
      get the attacks
      Returns:
      a Enumeration of all AttackHandlers
    • getAttacksVector

      public Vector<AttackHandler> getAttacksVector()
      get the attacks vector
      Returns:
      the Vector containing the attacks
    • resetAttacks

      public void resetAttacks()
      reset the attacks vector
    • setAttacksVector

      public void setAttacksVector(Vector<AttackHandler> v)
      set the attacks vector
      Parameters:
      v - - the Vector that should be the new attacks vector
    • getRoundCount

      public int getRoundCount()
      Returns:
      The current round of the game.
    • setRoundCount

      public void setRoundCount(int roundCount)
    • isForceVictory

      public boolean isForceVictory()
      Getter for property forceVictory. This tells us that there is an active claim for victory.
      Specified by:
      isForceVictory in interface IGame
      Returns:
      Value of property forceVictory.
    • isIgnorePlayerDefeatVotes

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isIgnorePlayerDefeatVotes()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • isEndImmediately

      public boolean isEndImmediately()
    • setForceVictory

      public void setForceVictory(boolean forceVictory)
      Setter for property forceVictory.
      Parameters:
      forceVictory - New value of property forceVictory.
    • setEndImmediately

      public void setEndImmediately(boolean endImmediately)
      Setter for property endImmediately.

      The endImmediately flag is used to signal that the game should check for victory conditions as soon as possible, instead of waiting for the end phase. This does bypass the server option to not end the game immediately, so it should be used with caution.

      Parameters:
      endImmediately - New value of property endImmediately.
    • setIgnorePlayerDefeatVotes

      public void setIgnorePlayerDefeatVotes(boolean ignorePlayerDefeatVotes)
      Setter for property ignorePlayerDefeatVotes. This flag is used to signal that the game should ignore the need for players voting for the end of the game. This is used to give the game master the ability to end the game without player input.
      Parameters:
      ignorePlayerDefeatVotes - New value of property ignorePlayerDefeatVotes.
    • addReports

      public void addReports(List<Report> v)
      Adds the given reports vector to the GameReport collection.
      Parameters:
      v - the reports vector
    • getReports

      public List<Report> getReports(int r)
      Parameters:
      r - Round number
      Returns:
      a vector of reports for the given round.
    • getAllReports

      public List<List<Report>> getAllReports()
      Returns:
      a vector of all the reports.
    • setAllReports

      public void setAllReports(List<List<Report>> v)
      Used to populate previous game reports, e.g. after a client connects to an existing game.
    • clearAllReports

      public void clearAllReports()
      Clears out all the current reports, paving the way for a new game.
    • end

      public void end(int winner, int winnerTeam)
    • getVictoryPlayerId

      public int getVictoryPlayerId()
      Getter for property victoryPlayerId.
      Returns:
      Value of property victoryPlayerId.
    • setVictoryPlayerId

      public void setVictoryPlayerId(int victoryPlayerId)
      Setter for property victoryPlayerId.
      Parameters:
      victoryPlayerId - New value of property victoryPlayerId.
    • getVictoryTeam

      public int getVictoryTeam()
      Getter for property victoryTeam.
      Returns:
      Value of property victoryTeam.
    • setVictoryTeam

      public void setVictoryTeam(int victoryTeam)
      Setter for property victoryTeam.
      Parameters:
      victoryTeam - New value of property victoryTeam.
    • isPlayerVictor

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isPlayerVictor(Player player)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      true if the specified player is either the victor, or is on the winning team. Best to call during GamePhase.VICTORY.
    • getVictoryContext

      public HashMap<String,Object> getVictoryContext()
      Returns:
      the currently active context-object for VictoryCondition checking. This should be a mutable object, and it will be modified by the victory condition checkers. Whoever saves the game state when doing saves is also responsible for saving this state. At the start of the game this should be initialized to an empty HashMap
    • setVictoryContext

      public void setVictoryContext(HashMap<String,Object> ctx)
    • getVictoryPointLevels

      public List<VictoryPointLevel> getVictoryPointLevels()
      Returns:
      The scenario's graded victory scale - ordered bands mapping the winner's final victory point total to a victory name (e.g. "Pyrrhic victory" up to 10, "Major victory" above) - or an empty list when the scenario defines none. Never null: saves from before this field existed restore it lazily.
    • setVictoryPointLevels

      public void setVictoryPointLevels(List<VictoryPointLevel> victoryPointLevels)
    • getSelectedEntities

      public Iterator<Entity> getSelectedEntities(@Nullable EntitySelector selector)
      Get all Entitys that pass the given selection criteria.
      Parameters:
      selector - the EntitySelector that implements test that an entity must pass to be included. This value may be null (in which case all entities in the game will be returned).
      Returns:
      an Enumeration of all entities that the selector accepts. This value will not be null but it may be empty.
    • getSelectedEntityCount

      public int getSelectedEntityCount(EntitySelector selector)
      Count all Entitys that pass the given selection criteria.
      Parameters:
      selector - the EntitySelector that implements test that an entity must pass to be included. This value may be null (in which case the count of all entities in the game will be returned).
      Returns:
      the int count of all entities that the selector accepts. This value will not be null but it may be empty.
    • getSelectedOutOfGameEntities

      public Enumeration<Entity> getSelectedOutOfGameEntities(EntitySelector selector)
      Get all out-of-game Entitys that pass the given selection criteria.
      Parameters:
      selector - the EntitySelector that implements test that an entity must pass to be included. This value may be null (in which case all entities in the game will be returned).
      Returns:
      an Enumeration of all entities that the selector accepts. This value will not be null but it may be empty.
    • getSelectedOutOfGameEntityCount

      public int getSelectedOutOfGameEntityCount(EntitySelector selector)
      Count all out-of-gameEntitys that pass the given selection criteria.
      Parameters:
      selector - the EntitySelector that implements test that an entity must pass to be included. This value may be null (in which case the count of all out-of-game entities will be returned).
      Returns:
      the int count of all entities that the selector accepts. This value will not be null but it may be empty.
    • checkForValidNonInfantryAndOrProtoMeks

      public boolean checkForValidNonInfantryAndOrProtoMeks(int playerId)
      Returns true if the player has any valid units this turn that are not infantry, not ProtoMeks, or not either of those. This method is utilized by the "A players Infantry moves after that players other units", and "A players ProtoMeks move after that players other units" options.
    • getNemesisTargets

      public Enumeration<Entity> getNemesisTargets(Entity attacker, Coords target)
      Get Entities that have a iNarc Nemesis pod attached and are situated between two Coords
      Parameters:
      attacker - The attacking Entity.
      target - The Coords of the original target.
      Returns:
      an Enumeration of entities that have nemesis pods attached, are located between attacker and target, and are friendly with the attacker.
    • getTagInfo

      public Vector<TagInfo> getTagInfo()
      Returns:
      this turn's TAG information
    • addTagInfo

      public void addTagInfo(TagInfo info)
      add the results of one TAG attack
    • resetTagInfo

      public void resetTagInfo()
      Resets TAG information
    • getFlares

      public Vector<Flare> getFlares()
      Returns:
      the list of flares
    • setFlares

      public void setFlares(Vector<Flare> flares)
      Set the list of flares
    • addFlare

      public void addFlare(Flare flare)
      Add a new flare
    • getIlluminatedPositions

      public HashSet<Coords> getIlluminatedPositions()
      Get a set of Coords illuminated by searchlights.

      Note: coords could be illuminated by other sources as well, it's likely that IlluminationLevel::isPositionIlluminated is desired unless the hex illuminated by the searchlight set is being sent to the client or server.

    • clearIlluminatedPositions

      public void clearIlluminatedPositions()
      Clear the set of searchlight illuminated hexes.
    • setIlluminatedPositions

      public void setIlluminatedPositions(@Nullable HashSet<Coords> ip) throws RuntimeException
      Setter for the list of Coords illuminated by search lights.
      Throws:
      RuntimeException
    • addIlluminatedPosition

      public boolean addIlluminatedPosition(Coords c)
      Add a new hex to the collection of Coords illuminated by searchlights.
      Returns:
      True if a new hex was added, else false if the set already contained the input hex.
    • ageFlares

      public Vector<Report> ageFlares()
      Ages all flares, drifts them with the wind and removes any which have burnt out or drifted off the map.
    • gameTimerIsExpired

      public boolean gameTimerIsExpired()
    • createVictoryConditions

      public void createVictoryConditions()
      Uses VictoryFactory to generate a new VictoryCondition checker provided that the VictoryContext is saved properly. Calling this method at any time is ok and should not affect anything unless the VictoryCondition Config Options have changed.
    • getVictoryResult

      public VictoryResult getVictoryResult()
    • useVectorMove

      public boolean useVectorMove()
    • addControlRoll

      public void addControlRoll(PilotingRollData control)
      Adds a pending Control roll to the list for this phase.
    • getControlRolls

      public Enumeration<PilotingRollData> getControlRolls()
      Returns:
      an Enumeration of pending Control rolls.
    • resetControlRolls

      public void resetControlRolls(Entity entity)
      Resets the Control Roll list for a given entity.
    • resetControlRolls

      public void resetControlRolls()
      Resets the Control Roll list.
    • checkForValidSpaceStations

      @Deprecated(since="0.51.0", forRemoval=true) public boolean checkForValidSpaceStations(int playerId)
      Deprecated, for removal: This API element is subject to removal in a future version.
      A set of checks for aero units to make sure that the movement order is maintained
    • checkForValidDropShips

      @Deprecated(since="0.51.0", forRemoval=true) public boolean checkForValidDropShips(int playerId)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • checkForValidSmallCraft

      @Deprecated(since="0.51.0", forRemoval=true) public boolean checkForValidSmallCraft(int playerId)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPlanetaryConditions

      public PlanetaryConditions getPlanetaryConditions()
      Specified by:
      getPlanetaryConditions in interface PlanetaryConditionsUsing
      Returns:
      This game's planetary conditions
    • setPlanetaryConditions

      public void setPlanetaryConditions(@Nullable PlanetaryConditions conditions)
      Description copied from interface: PlanetaryConditionsUsing
      Sets this game's planetary conditions.
      Specified by:
      setPlanetaryConditions in interface PlanetaryConditionsUsing
      Parameters:
      conditions - The new conditions
    • addSmokeCloud

      public void addSmokeCloud(SmokeCloud cloud)
    • getSmokeCloudList

      public List<SmokeCloud> getSmokeCloudList()
    • removeSmokeClouds

      @Deprecated(since="0.51.0", forRemoval=true) public void removeSmokeClouds(List<SmokeCloud> cloudsToRemove)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • removeEmptySmokeClouds

      public void removeEmptySmokeClouds()
    • removeCompletelyDissipatedSmokeClouds

      public void removeCompletelyDissipatedSmokeClouds()
    • addIndustrialElevator

      public void addIndustrialElevator(IndustrialElevator elevator)
      Adds an industrial elevator to the game.
      Parameters:
      elevator - The industrial elevator to add
    • getIndustrialElevator

      @Nullable public IndustrialElevator getIndustrialElevator(BoardLocation location)
      Gets an industrial elevator at the specified location.
      Parameters:
      location - The board location to check
      Returns:
      The elevator at this location, or null if none exists
    • getIndustrialElevator

      @Nullable public IndustrialElevator getIndustrialElevator(Coords coords, int boardId)
      Gets an industrial elevator at the specified coordinates and board.
      Parameters:
      coords - The coordinates to check
      boardId - The board ID
      Returns:
      The elevator at this location, or null if none exists
    • getIndustrialElevators

      public Collection<IndustrialElevator> getIndustrialElevators()
      Returns all industrial elevators in the game.
      Returns:
      An unmodifiable collection of all industrial elevators
    • hasIndustrialElevator

      public boolean hasIndustrialElevator(BoardLocation location)
      Checks if there is an industrial elevator at the specified location.
      Parameters:
      location - The board location to check
      Returns:
      true if an elevator exists at this location
    • removeIndustrialElevator

      @Nullable public IndustrialElevator removeIndustrialElevator(BoardLocation location)
      Removes an industrial elevator from the game.
      Parameters:
      location - The location of the elevator to remove
      Returns:
      The removed elevator, or null if none was found
    • clearIndustrialElevators

      public void clearIndustrialElevators()
      Clears all industrial elevators from the game.
    • setIndustrialElevators

      public void setIndustrialElevators(Collection<IndustrialElevator> elevators)
      Sets the industrial elevators from the provided collection, replacing any existing ones.
      Parameters:
      elevators - Collection of industrial elevators to set
    • addTemporaryECMField

      public void addTemporaryECMField(TemporaryECMField field)
      Adds a temporary ECM field to the game (e.g., from EMP mine detonation).
      Parameters:
      field - The temporary ECM field to add
    • getTemporaryECMFields

      public List<TemporaryECMField> getTemporaryECMFields()
      Returns:
      An unmodifiable view of all temporary ECM fields currently active
    • setTemporaryECMFields

      public void setTemporaryECMFields(List<TemporaryECMField> fields)
      Replaces all temporary ECM fields with the provided list. Used for syncing client state with server.
      Parameters:
      fields - The new list of temporary ECM fields (may be null or empty)
    • removeExpiredECMFields

      public void removeExpiredECMFields(int currentRound, GamePhase currentPhase)
      Removes expired temporary ECM fields based on the current round and phase.
      Parameters:
      currentRound - The current game round
      currentPhase - The current game phase
    • getEntityPositions

      public HashSet<Coords> getEntityPositions(Entity entity)
      Only needed for Entity's that have secondaryPositions. This method is used to make sure setPosition() doesn't get an inaccurate list of positions for an entity that changed from between using secondaryPositions and not, such as a Dropship taking off. Iterates through all cached coords to get where the provided entity is. Inefficient, and usually unnecessary.
      Parameters:
      entity - Entity we want to get the cached old positions of
      Returns:
      cached coords that contain this entity
      See Also:
    • updateEntityPositionLookup

      public void updateEntityPositionLookup(Entity e, HashSet<Coords> oldPositions)
      Updates the map that maps a position to the list of Entity's in that position.
    • getUUIDString

      public String getUUIDString()
      Returns:
      a string representation of this game's UUID.
    • getBotSettings

      public Map<String,BehaviorSettings> getBotSettings()
    • setBotSettings

      public void setBotSettings(Map<String,BehaviorSettings> botSettings)
    • setDishonoredPlayers

      public void setDishonoredPlayers(int botPlayerId, Collection<Integer> dishonoredPlayerIds)
      Records the set of players the given bot player currently considers dishonored, as reported through PacketCommand.PRINCESS_DISHONORED.
      Parameters:
      botPlayerId - the reporting bot's player ID
      dishonoredPlayerIds - the player IDs that bot considers dishonored
    • addDishonoredPlayer

      public void addDishonoredPlayer(int botPlayerId, int playerId)
      Adds a single player to the set the given bot player considers dishonored. Used to optimistically record a dishonoring action the moment the local player commits it, so the same turn's later actions are not re-warned before the bot's authoritative PacketCommand.PRINCESS_DISHONORED report arrives (that report then replaces this set wholesale). Replaces the inner set rather than mutating it in place, keeping the wholesale-replacement invariant that lets isPlayerDishonoredBy(int, int) read without locking.
      Parameters:
      botPlayerId - the bot player that now holds a grudge
      playerId - the player it now considers dishonored
    • isPlayerDishonoredBy

      public boolean isPlayerDishonoredBy(int botPlayerId, int playerId)
      Parameters:
      botPlayerId - the bot player whose honor opinion is being queried
      playerId - the player who may be dishonored
      Returns:
      true if the bot with player ID botPlayerId currently considers playerId dishonored, as last reported via PacketCommand.PRINCESS_DISHONORED. False if that bot has not reported (e.g. it is not a Princess bot, or the report has not arrived yet).
    • getBotTypes

      public Map<String,AIType> getBotTypes()
      Returns:
      which AI implementation the most recent bot connected under each player name was, as an unmodifiable view; never null - games saved before the types were recorded read as an empty map. Record entries through recordBotType(String, AIType).
    • recordBotType

      public void recordBotType(String playerName, AIType aiType)
      Records which AI implementation the bot connected under the given player name is.
      Parameters:
      playerName - the bot player's name
      aiType - the AI implementation it reported
    • setBotTypes

      public void setBotTypes(Map<String,AIType> botTypes)
    • getGroundObjects

      public List<ICarryable> getGroundObjects(Coords coords, Entity entity)
      Get a list of all objects on the ground at the given coordinates that can be picked up by the given entity
    • getGroundObjects

      @Deprecated(since="0.50.05") public Map<Coords,List<ICarryable>> getGroundObjects()
      Deprecated.
      Overrides:
      getGroundObjects in class AbstractGame
      Returns:
      Collection of objects on the ground. Best to use getGroundObjects(Coords) if looking for objects in specific hex
    • cancelVictory

      public void cancelVictory()
      Cancels a victory
    • getMapSettings

      public MapSettings getMapSettings()
    • setMapSettings

      public void setMapSettings(MapSettings mapSettings)
    • inGameTWEntities

      public List<Entity> inGameTWEntities()
      Returns:
      The TW Units (Entity) currently in the game.
    • getNewReport

      public ReportEntry getNewReport(int messageId)
      Description copied from interface: IGame
      Returns a new ReportEntry with the given report message ID. The ReportEntry subclass returned depends on the implementation in the IGame subclass.
      Specified by:
      getNewReport in interface IGame
      Parameters:
      messageId - The message ID from report-messages.properties
      Returns:
      A new report of an appropriate type and message
    • idForPlayerName

      public Optional<Integer> idForPlayerName(String playerName)
      Parameters:
      playerName - The name of the Player to find.
      Returns:
      The ID of the Player with the given name, if there is such a Player.
    • playerForPlayerName

      public Optional<Player> playerForPlayerName(String playerName)
      Parameters:
      playerName - The name of the Player to find.
      Returns:
      The ID of the Player with the given name, if there is such a Player.
    • getBuildingAt

      public Optional<IBuilding> getBuildingAt(@Nullable BoardLocation boardLocation)
      Returns the Building at the given location, if any. Shortcut to Board.getBuildingAt().
      Parameters:
      boardLocation - The location to check
      Returns:
      The building at the location, if any
    • getBuildingAt

      public Optional<IBuilding> getBuildingAt(@Nullable Coords coords, int boardId)
      Returns the Building at the given location, if any. Shortcut to Board.getBuildingAt().
      Parameters:
      coords - The position on the board
      boardId - The board ID
      Returns:
      The building at the location, if any
    • hasBuildingAt

      public boolean hasBuildingAt(@Nullable Coords coords, int boardId)
      Returns true when there is a building of any type (building, fuel tank, bridge) at the given location. This is safe to call with any parameter values.
      Parameters:
      coords - The position on the board
      boardId - The board ID
      Returns:
      True when there is a building
    • isSpaceRound

      public boolean isSpaceRound()
      Returns:
      True if the current game round counts as a round in which spaceborne units may act; when this game has only space board(s), this is true for every game round; if it has a mixture of space and other boards, only every 7th game round is a space round (TW p.78)
    • isAtmosphericRound

      public boolean isAtmosphericRound()
      Returns:
      True if the current game round counts as a round in which non-spaceborne units may act; when this game has no space boards, this is true for every game round; if it has a mixture of space and other boards, six atmospheric game rounds are followed by one space round. (TW p.78)
    • hasBridges

      public boolean hasBridges()
      Returns:
      True if any map in this game contains any bridges. Used for Princess calculations.