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

    • 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
  • Method Details

    • getExternalGameId

      public int getExternalGameId()
    • 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(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)
    • 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.
    • getOptions

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

      public void setOptions(@Nullable GameOptions options)
    • 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

      public int getAllEntitiesOwnedBy(Player player)
      Returns the number of entities owned by the player, regardless of their status.
    • getLiveEntitiesOwnedBy

      public int getLiveEntitiesOwnedBy(Player player)
      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.
    • 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
    • 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.
    • getEntities

      @Deprecated(since="0.50.4") public Iterator<Entity> getEntities()
      Deprecated.
      Use inGameTWEntities() instead.
      Returns:
      an enumeration of all the entities in the game.
    • 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 Entitys at that positions. Units that have no position (e.g. loaded units) will not be in the map.
      Returns:
      a Hashtable that maps the Coords positions or each unit in the game to a Vector of Entitys at that position.
    • 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 nType, int nID)
      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

      @Deprecated(since="0.50.4", forRemoval=true) public void addEntity(int id, Entity entity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 0.50.4 - Use addEntity(Entity) instead.
      Adds a new Entity. The id parameter is ignored and addEntity(Entity) is called instead. This is just to maintain compatibility.
      Parameters:
      id - Value that is ignored: the id is pulled from the passed Entity
      entity - The Entity to add to the game.
    • 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(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
    • getAllOffboardEnemyEntities

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

      public Vector<GunEmplacement> getGunEmplacements(Coords c)
      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)
      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.
    • 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

      public int getFirstHiddenEntityNum(@Nullable GameTurn turn)
      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

      public int getNextHiddenEntityNum(GameTurn turn, int start)
      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

      public ArrayList<Integer> getPlayerEntityIds(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 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 a 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
      Throws:
      Exception
    • 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()
    • getArtillerySize

      public int getArtillerySize()
    • 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()
    • addCharge

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

      public Enumeration<AttackAction> getCharges()
      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.
    • 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.
    • 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

      public void removeAttack(AttackHandler ah)
      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()
      Getter for property roundCount.
      Returns:
      Value of property roundCount.
    • 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

      public boolean isIgnorePlayerDefeatVotes()
    • 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

      public boolean isPlayerVictor(Player player)
      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)
    • 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 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.
    • getVictory

      @Deprecated(since="0.50.04", forRemoval=true) public VictoryHelper getVictory()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • 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

      public boolean checkForValidSpaceStations(int playerId)
      A set of checks for aero units to make sure that the movement order is maintained
    • checkForValidDropShips

      public boolean checkForValidDropShips(int playerId)
    • checkForValidSmallCraft

      public boolean checkForValidSmallCraft(int playerId)
    • 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

      public void removeSmokeClouds(List<SmokeCloud> cloudsToRemove)
    • removeEmptySmokeClouds

      public void removeEmptySmokeClouds()
    • removeCompletelyDissipatedSmokeClouds

      public void removeCompletelyDissipatedSmokeClouds()
    • 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.
      Parameters:
      e -
    • 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)
    • 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.