Package megamek.common.game
Class Game
java.lang.Object
megamek.common.game.AbstractGame
megamek.common.game.Game
- All Implemented Interfaces:
Serializable,IGame,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 Summary
FieldsModifier and TypeFieldDescriptionstatic RulesManagerstatic final intstatic final intstatic final intA UUID to identify this game instance.final VersionStores the version of MM, so that it can be serialized in saved games.Fields inherited from class megamek.common.game.AbstractGame
currentRound, forces, gameListeners, groundObjects, inGameObjects, pendingActions, players, scriptedEvents, teams, turnIndexFields inherited from interface megamek.common.game.IGame
DEFAULT_BOARD_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd an AttackHandler to the attacks listvoidaddControlRoll(PilotingRollData control) Adds a pending Control roll to the list for this phase.voidaddDishonoredPlayer(int botPlayerId, int playerId) Adds a single player to the set the given bot player considers dishonored.voidAdds a pending displacement attack to the list for this phase.voidaddEMPMine(Minefield mf) voidaddEntities(List<Entity> entities) Adds a collection of new Entities.voidAdds a new Entity to this Game object and generates a GameEntityNewEvent.voidAdds a new Entity to this Game object.voidAdds a pending extreme Gravity PSR to the list for this phase.voidAdd a new flarebooleanAdd a new hex to the collection of Coords illuminated by searchlights.voidaddIndustrialElevator(IndustrialElevator elevator) Adds an industrial elevator to the game.voidvoidvoidaddMinefields(Vector<Minefield> mines) voidAdds the given Player to the game with the given game-unique id.voidaddPSR(PilotingRollData psr) Adds a pending PSR to the list for this phase.voidaddRam(AttackAction ea) Adds a pending ramming attack to the list for this phase.voidaddReports(List<Report> v) Adds the given reports vector to the GameReport collection.voidaddSmokeCloud(SmokeCloud cloud) voidaddTagInfo(TagInfo info) add the results of one TAG attackvoidAdds a pending ramming attack to the list for this phase.voidAdds a temporary ECM field to the game (e.g., from EMP mine detonation).voidAges all flares, drifts them with the wind and removes any which have burnt out or drifted off the map.voidCancels a victoryChanges to the next turn, returning it.booleancheckForValidDropShips(int playerId) Deprecated, for removal: This API element is subject to removal in a future version.booleancheckForValidNonInfantryAndOrProtoMeks(int playerId) Returns true if the player has any valid units this turn that are not infantry, not ProtoMeks, or not either of those.booleancheckForValidSmallCraft(int playerId) Deprecated, for removal: This API element is subject to removal in a future version.booleancheckForValidSpaceStations(int playerId) Deprecated, for removal: This API element is subject to removal in a future version.voidClears out all the current reports, paving the way for a new game.voidClear the set of searchlight illuminated hexes.voidClears all industrial elevators from the game.voidbooleancommanderHasCombatParalysis(Player player) Checks if the commander unit of the specified player has the "Combat Paralysis" special ability.booleancommanderHasCombatSense(Player player) Checks if the specified player has a valid unit with the "Combat Sense" pilot special ability.booleanChecks if the game contains the specified EMP minebooleancontainsMinefield(Coords coords) booleanChecks if the game contains the specified VibrabombvoidUses VictoryFactory to generate a new VictoryCondition checker provided that the VictoryContext is saved properly.voidend(int winner, int winnerTeam) booleanReturns an Enumeration of actions scheduled for this phase.getAFFATarget(Coords coords, Entity ignore) Returns a Target for an Accidental Fall From above, or null if no possible target is theregetAllEnemyEntities(Entity currentEntity) Returns anEnumerationof active enemy entitiesintgetAllEntitiesOwnedBy(Player player) Deprecated, for removal: This API element is subject to removal in a future version.getAllOffboardEnemyEntities(Player player) intDeprecated, for removal: This API element is subject to removal in a future version.get the attacksget the attacks vectorgetBuildingAt(BoardLocation boardLocation) Returns the Building at the given location, if any.getBuildingAt(Coords coords, int boardId) Returns the Building at the given location, if any.getC3NetworkMembers(Entity entity) Returns aVectorcontaining theEntitys that are in the same C3 network as the passed-in unit.getC3SubNetworkMembers(Entity entity) Returns aVectorcontaining theEntitys that are in the C3 subnetwork under the passed-in unit.Returns an enumeration of "carcass" entities, i.e., vehicles with dead crews that are still on the map.Returns an enumeration of entities that were utterly destroyedgetEnemyEntities(Coords coords, int boardId, Entity currentEntity) Returns anIteratorof the enemy's active entities at the given coordinates.getEnemyEntities(Coords coords, Entity currentEntity) Returns anIteratorof the enemy's active entities at the given coordinates.getEntities(ArrayList<Coords> coordList) Returns an Iterator for all entities in _all_ of the coordinates provided.Returns an Enumeration of the active entities at the given coordinates.getEntities(Coords c, boolean ignore) Returns an Enumeration of the active entities at the given coordinates.getEntitiesVector(BoardLocation location) getEntitiesVector(BoardLocation location, boolean ignoreTargetable) getEntitiesVector(Coords c, boolean ignore) getEntitiesVector(Coords coord, int boardId) getEntitiesVector(Coords coord, int boardId, boolean ignoreTargetable) getEntity(int id) getEntityFromAllSources(int id) looks for an entity by id number even if out of the gamegetEntityOrThrow(int id) When it has to exist, the entity HAS to exists.getEntityPositions(Entity entity) Only needed for Entity's that have secondaryPositions.intDeprecated, for removal: This API element is subject to removal in a future version.Returns an Enumeration of pending extreme GravityPSRs.intgetFirstEnemyEntity(Coords c, Entity currentEntity) Returns the first enemy entity at the given coordinate, if any.Returns the first entity at the given coordinate, if any.getFirstEntity(GameTurn turn) intintgetFirstEntityNum(GameTurn turn) intDeprecated, for removal: This API element is subject to removal in a future version.getFriendlyEntities(Coords coords, Entity currentEntity) Returns anIteratorof friendly active entities at the given coordinates.Returns an enumeration of salvageable entities.Deprecated.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 entitygetGunEmplacements(Coords c, int boardId) Return a Vector of gun emplacements at Coordsc.Returns the map of hex locations being cleared by saws to turns remaining.Get a set of Coords illuminated by searchlights.getIndustrialElevator(BoardLocation location) Gets an industrial elevator at the specified location.getIndustrialElevator(Coords coords, int boardId) Gets an industrial elevator at the specified coordinates and board.Returns all industrial elevators in the game.intgetInfantryLeft(int playerId) intgetLiveCommandersOwnedBy(Player player) intgetLiveDeployedEntitiesOwnedBy(Player player) intgetLiveEntitiesOwnedBy(Player player) Deprecated, for removal: This API element is subject to removal in a future version.intgetMeksLeft(int playerId) Get the coordinates of all mined hexes in the game.getMinefields(Coords coords) intgetNbrMinefields(Coords coords) getNemesisTargets(Entity attacker, Coords target) Get Entities that have a iNarc Nemesis pod attached and are situated between two CoordsgetNewReport(int messageId) Returns a new ReportEntry with the given report message ID.intgetNextDeployableEntityNum(GameTurn turn, int start) getNextEntity(int start) getNextEntityFromList(Entity current) intintgetNextEntityNum(GameTurn turn, int start) intgetNextHiddenEntityNum(GameTurn turn, int start) Deprecated, for removal: This API element is subject to removal in a future version.intReturn the current number of entities in the game.intgetOutOfGameEntity(int id) Returns an out-of-game entity.getPhase()getPlayerEntities(Player player, boolean hide) Get the entities for the player.getPlayerEntityIds(Player player, boolean hide) Deprecated, for removal: This API element is subject to removal in a future version.Returns the ids of players that own at least one demolition charge set on a building.getPlayerRetreatedEntities(Player player) Get the entities for the player.Returns a Hashtable that maps the Coords of each unit in this Game to a Vector of Entity's at that positions.intgetPrevEntityNum(GameTurn turn, int start) getPreviousEntityFromList(Entity current) intgetProtoMeksLeft(int playerId) getPSRs()Returns an Enumeration of pending PSRs.getPSRsForEntity(Entity entity) Get PSR rolls for a given entity.getRams()Returns the rams vector.getReports(int r) Returns an enumeration of entities that have retreatedintgetSelectedEntities(EntitySelector selector) Get allEntitys that pass the given selection criteria.intgetSelectedEntityCount(EntitySelector selector) Count allEntitys that pass the given selection criteria.getSelectedOutOfGameEntities(EntitySelector selector) Get all out-of-gameEntitys that pass the given selection criteria.intCount all out-of-gameEntitys that pass the given selection criteria.getTarget(int targetType, int targetId) Returns the appropriate target for this game given a type and idgetTeamEntities(Team team) This is used to send all tele-missile attacks to the client.getTurn()getTurnForPlayer(int pn) getTurns()Returns an Enumeration of the current turn listgetValidTargets(Entity entity) Get a vector of entity objects that are "acceptable" to attack with this entityintgetVehiclesLeft(int playerId) intGetter for property victoryPlayerId.intGetter for property victoryTeam.Returns the woods clearing tracker for this game.Returns an enumeration of wrecked entities.voidbooleanbooleanhasBuildingAt(Coords coords, int boardId) Returns true when there is a building of any type (building, fuel tank, bridge) at the given location.booleanhasEntity(int entityId) booleanhasIndustrialElevator(BoardLocation location) Checks if there is an industrial elevator at the specified location.booleanhasRooftopGunEmplacement(Coords c, int boardId) Determine if the given set of coordinates has a gun emplacement on the roof of a building.booleanhasTacticalGenius(Player player) idForPlayerName(String playerName) voidvoidinitializeRulesManager(String system) voidinsertNextTurn(GameTurn turn) Inserts a turn that will come directly after the current onevoidinsertTurnAfter(GameTurn turn, int index) Inserts a turn after the specific indexbooleanbooleanReturns 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.booleanbooleanisEntityStranded(Entity entity) Determines if the indicated entity is stranded on transport that can't move.booleanGetter for property forceVictory.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanisOutOfGame(int id) See if theEntitywith the given ID is out of the game.booleanisOutOfGame(Entity entity) See if theEntityis out of the game.booleanisPlayerDishonoredBy(int botPlayerId, int playerId) booleanisPlayerVictor(Player player) Deprecated, for removal: This API element is subject to removal in a future version.booleanvoidmoveToGraveyard(int id) Moves an entity into the graveyard, so it stops getting sent out every phase.playerForPlayerName(String playerName) voidprocessGameEvent(GameEvent event) voidrecordBotType(String playerName, AIType aiType) Records which AI implementation the bot connected under the given player name is.voidDeprecated, for removal: This API element is subject to removal in a future version.voidvoidRemove displacement attacks that were added previouslyvoidvoidvoidremoveEntities(List<Integer> ids, int condition) voidremoveEntity(int id, int condition) Remove an entity from the master list.voidremoveExpiredECMFields(int currentRound, GamePhase currentPhase) Removes expired temporary ECM fields based on the current round and phase.removeFirstTurnFor(Entity entity) Removes the first turn found that the specified entity can move in.removeIndustrialElevator(BoardLocation location) Removes an industrial elevator from the game.voidvoidvoidremovePlayer(int id) Removes the player with the id from the game.voidremovePSRsByArray(ArrayList<PilotingRollData> psrList) voidremoveSmokeClouds(List<SmokeCloud> cloudsToRemove) Deprecated, for removal: This API element is subject to removal in a future version.intremoveSpecificEntityTurnsFor(Entity entity) Removes any turns that can only be taken by the specified entity.voidremoveTurnFor(Entity entity) Removes the last, next turn found that the specified entity can move in.voidvoidreplaceUnits(List<InGameObject> units) This is a Client-side method to replace or add units that are sent from the server.voidreset()Resets this game, i.e.voidvoidreset the attacks vectorvoidResets the pending charges list.voidResets the Control Roll list.voidresetControlRolls(Entity entity) Resets the Control Roll list for a given entity.voidResets the extreme Gravity PSR list.voidresetExtremeGravityPSRs(Entity entity) Resets the extreme Gravity PSR list for a given entity.voidresetMinefieldDensity(Vector<Minefield> newMinefields) voidResets the orbital bombardment attacks list.voidResets the PSR list.voidResets the PSR list for a given entity.voidResets the pending rams list.voidResets TAG informationvoidResets the pending rams list.voidvoidsetAllReports(List<List<Report>> v) Used to populate previous game reports, e.g.voidvoidset the attacks vectorvoidvoidsetBoardDirect(Board board) voidsetBotSettings(Map<String, BehaviorSettings> botSettings) voidsetBotTypes(Map<String, AIType> botTypes) voidsetDishonoredPlayers(int botPlayerId, Collection<Integer> dishonoredPlayerIds) Records the set of players the given bot player currently considers dishonored, as reported throughPacketCommand.PRINCESS_DISHONORED.voidsetEndImmediately(boolean endImmediately) Setter for property endImmediately.voidvoidsetEntitiesVector(List<Entity> entities) voidvoidsetEntity(int id, Entity entity, Vector<UnitLocation> movePath) voidsetExternalGameId(int value) voidSet the list of flaresvoidsetForceVictory(boolean forceVictory) Setter for property forceVictory.voidsetHexesBeingCut(Map<BoardLocation, Integer> hexes) Updates the map of hex locations being cleared by saws.voidsetIgnorePlayerDefeatVotes(boolean ignorePlayerDefeatVotes) Setter for property ignorePlayerDefeatVotes.voidSetter for the list of Coords illuminated by search lights.voidsetIndustrialElevators(Collection<IndustrialElevator> elevators) Sets the industrial elevators from the provided collection, replacing any existing ones.voidsetLastPhase(GamePhase lastPhase) Sets the previous game phase to the given phase.voidsetMapSettings(MapSettings mapSettings) voidsetMinefields(Vector<Minefield> minefields) voidsetOptions(GameOptions options) voidsetOrbitalBombardmentVector(Vector<OrbitalBombardment> orbitalBombardments) Set the new vector of orbital bombardments for this round.voidsetOutOfGameEntitiesVector(List<Entity> vOutOfGame) Swap out the current list of dead (or fled) units for a new one.voidSets the current game phase to the given phase.voidsetPlanetaryConditions(PlanetaryConditions conditions) Sets this game's planetary conditions.voidSets the given Player to the given game-unique id.voidsetRoundCount(int roundCount) voidsetTemporaryECMFields(List<TemporaryECMField> fields) Replaces all temporary ECM fields with the provided list.voidsetTurnIndex(int turnIndex, int prevPlayerId) Sets the current turn indexvoidsetTurnVector(List<GameTurn> turnVector) Sets the current turn vectorvoidSet up the teams vector.voidsetVictoryContext(HashMap<String, Object> ctx) voidsetVictoryPlayerId(int victoryPlayerId) Setter for property victoryPlayerId.voidsetVictoryPointLevels(List<VictoryPointLevel> victoryPointLevels) voidsetVictoryTeam(int victoryTeam) Setter for property victoryTeam.voidswapTurnOrder(int index1, int index2) Swaps the turn at index 1 with the turn at index 2.voidupdateEntityPositionLookup(Entity e, HashSet<Coords> oldPositions) Updates the map that maps a position to the list of Entity's in that position.booleanReturns true if the Standard (Targeted) ghost target mode is active (TO:AR p.100).booleanMethods inherited from class megamek.common.game.AbstractGame
addAction, addGameListener, addScriptedEvent, canFleeFrom, clearActions, clearDeploymentThisRound, clearScriptedEvents, deployableInGameObjects, fireGameEvent, getActionsVector, getBoard, getBoardIds, getBoards, getCurrentRound, getFleeZone, getForces, getGameListeners, getGroundObjects, getInGameObjects, getNoOfPlayers, getNoOfTeams, getPlayer, getPlayersList, getTeams, getTurnIndex, incrementCurrentRound, isDeploymentComplete, lastDeploymentRound, placeGroundObject, receiveBoard, receiveBoards, removeAction, removeActionsFor, removeGameListener, removeGroundObject, resetTurnIndex, scriptedEvents, setBoard, setCurrentRound, setForces, setGroundObjects, setTurnIndex, setupDeployment, shouldDeployForRound, shouldDeployThisRoundMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.common.game.IGame
areConnectedBoards, boardExists, commonEnclosingBoard, connectBoards, getAllEnclosingBoards, getBoard, getBoard, getBoard, getEnclosingBoard, getEnclosingBoard, getEntitiesOwnedBy, getHex, getHex, getHexOf, getInGameObject, getInGameObjects, getOutOfGameUnit, getTeamByPlayer, getTeamForPlayer, hasBoard, hasBoard, hasBoardLocation, hasBoardLocation, hasBoardLocationOf, hasConnectedBoard, hasEnclosingBoard, hasGroundBoard, hasMoreTurns, hasNonSpaceBoard, hasPlayer, hasSpaceAndAtmosphericBoards, hasSpaceBoard, isOnAtmosphericMap, isOnAtmosphericMap, isOnGroundMap, isOnGroundMap, isOnSpaceMap, isOnSpaceMap, onConnectedBoards, onDirectlyConnectedBoards, onTheSameBoard, receivePhase, shouldSkipCurrentPhase
-
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
-
uuid
A UUID to identify this game instance. -
version
Stores the version of MM, so that it can be serialized in saved games.
-
-
Constructor Details
-
Game
public Game()Constructor -
Game
-
-
Method Details
-
getExternalGameId
Deprecated, for removal: This API element is subject to removal in a future version. -
setExternalGameId
public void setExternalGameId(int value) -
getVersion
-
setBoard
-
setBoardDirect
-
containsMinefield
-
getMinefields
-
getNbrMinefields
-
getMinedCoords
Get the coordinates of all mined hexes in the game.- Returns:
- an
Enumerationof theCoordscontaining minefields. This will not benull.
-
addMinefield
-
getWoodsClearingTracker
Returns the woods clearing tracker for this game. Serialized with game saves. -
initializeRulesManager
-
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
Updates the map of hex locations being cleared by saws.- Parameters:
hexes- the current map of hexes being cut to turns remaining
-
addMinefields
-
setMinefields
-
resetMinefieldDensity
-
removeMinefield
-
removeMinefieldHelper
-
clearMinefields
public void clearMinefields() -
getVibraBombs
-
addVibrabomb
-
removeVibrabomb
-
containsVibrabomb
Checks if the game contains the specified Vibrabomb- Parameters:
mf- the Vibrabomb to check- Returns:
- true if the minefield contains a vibrabomb.
-
getEMPMines
-
addEMPMine
-
removeEMPMine
-
containsEMPMine
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
- Specified by:
getOptionsin interfaceIGame
-
setOptions
-
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:
setupTeamsin interfaceIGame
-
addPlayer
Description copied from interface:IGameAdds the given Player to the game with the given game-unique id. // TODO : Can this be made a default method?- Specified by:
addPlayerin interfaceIGame- Overrides:
addPlayerin classAbstractGame- Parameters:
id- The game-unique id of this playerplayer- The Player object
-
isCurrentPhasePlayable
public boolean isCurrentPhasePlayable()Description copied from interface:IGameReturns 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:
isCurrentPhasePlayablein interfaceIGame- Returns:
- True when the current phase should be skipped entirely in this round
- See Also:
-
setPlayer
Description copied from interface:IGameSets the given Player to the given game-unique id. // TODO : Is this method useful? Why not use addPlayer that also sets single-blind info? -
removePlayer
public void removePlayer(int id) Description copied from interface:IGameRemoves the player with the id from the game.- Specified by:
removePlayerin interfaceIGame- Parameters:
id- The player id
-
getAllEntitiesOwnedBy
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, 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
- 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
- Returns:
- the number of non-destroyed commander entities owned by the player. Ignores off board units and captured Mek pilots.
-
hasTacticalGenius
- Returns:
- true if the player has a valid unit with the Tactical Genius pilot special ability.
-
commanderHasCombatSense
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 Sensespecial 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:
trueif the player has a valid unit with the "Combat Sense" ability,falseotherwise.
- Has the
-
commanderHasCombatParalysis
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 Paralysisspecial 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:
trueif the player's commander has the "Combat Paralysis" special ability and meets all conditions,falseotherwise.
- Has the
-
getValidTargets
Get a vector of entity objects that are "acceptable" to attack with this entity -
getTurn
-
getTurnForPlayer
- Returns:
- the first GameTurn object for the specified player, or null if the player has no turns to play
-
changeToNextTurn
Changes to the next turn, returning it. -
insertNextTurn
Inserts a turn that will come directly after the current one -
insertTurnAfter
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
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
- Specified by:
getTurnsListin interfaceIGame- Returns:
- the current list of turns. If you're not the GameManager, don't even think about changing any of the turns.
-
setTurnVector
Sets the current turn vector -
getPhase
-
setPhase
Description copied from interface:IGameSets the current game phase to the given phase. May perform phase-dependent cleanup. This method is intended for the GameManager. -
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 (seesetPhase(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
-
getLastPhase
-
setLastPhase
Description copied from interface:IGameSets the previous game phase to the given phase. This method is intended for the GameManager.- Specified by:
setLastPhasein interfaceIGame- Parameters:
lastPhase- The phase to be remembered as the previous phase.
-
getPreviousEntityFromList
- Parameters:
current- TheEntitywhose list position you wish to start from.- Returns:
- The previous
Entityfrom the master list of entities. Will wrap around to the end of the list if necessary, returning null if there are no entities.
-
getNextEntityFromList
- Parameters:
current- TheEntitywhose list position you wish to start from.- Returns:
- The next
Entityfrom the master list of entities. Will wrap around to the beginning of the list if necessary, returning null if there are no entities.
-
getEntitiesVector
- Returns:
- the actual vector for the entities
-
setEntitiesVector
-
getOutOfGameEntitiesVector
- Returns:
- the actual vector for the out-of-game entities
-
setOutOfGameEntitiesVector
Swap out the current list of dead (or fled) units for a new one.- Parameters:
vOutOfGame- - the newVectorof dead or fled units. This value should not benull.- Throws:
IllegalArgumentException- if the new list isnull.
-
getOutOfGameEntity
Returns an out-of-game entity.- Parameters:
id- theintID of the out-of-game entity.- Returns:
- the out-of-game
Entitywith that ID. If no out-of-game entity has that ID, returns anull.
-
getC3NetworkMembers
Returns aVectorcontaining theEntitys 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 benull).- Parameters:
entity- - theEntitywhose C3 network co- members is required. This value may benull.- Returns:
- a
Vectorthat will contain all otherEntitys that are in the same C3 network as the passed-in unit. ThisVectormay be empty, but it will not benull. - See Also:
-
getC3SubNetworkMembers
Returns aVectorcontaining theEntitys 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 benull). If the passed-in unit is a company commander or a member of a C3i network, this call is the same asgetC3NetworkMembers.- Parameters:
entity- - theEntitywhose C3 network sub-members is required. This value may benull.- Returns:
- a
Vectorthat will contain all otherEntitys that are in the same C3 network under the passed-in unit. ThisVectormay be empty, but it will not benull. - See Also:
-
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
- 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
Returns an enumeration of salvageable entities. -
getWreckedEntities
Returns an enumeration of wrecked entities. -
getRetreatedEntities
Returns an enumeration of entities that have retreated -
getDevastatedEntities
Returns an enumeration of entities that were utterly destroyed -
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
Returns the appropriate target for this game given a type and id -
getEntity
- Returns:
- The entity with the given id number, if any.
-
getEntityOrThrow
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
looks for an entity by id number even if out of the game- Specified by:
getEntityFromAllSourcesin interfaceIGame
-
addEntities
Adds a collection of new Entities. Only one GameEntityNewEvent is created for the whole list.- Parameters:
entities- the Entity objects to be added.
-
addEntity
Adds a new Entity to this Game object and generates a GameEntityNewEvent.- Parameters:
entity- The Entity to add.
-
addEntity
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
-
setEntity
-
getNextEntityId
public int getNextEntityId()- Specified by:
getNextEntityIdin interfaceIGame- Overrides:
getNextEntityIdin classAbstractGame- Returns:
- The next free ID for InGameObjects (unit/entity/formation/others).
-
replaceUnits
Description copied from interface:IGameThis 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:
replaceUnitsin interfaceIGame- Parameters:
units- The units to add or use as a replacement for current units.
-
getGraveyard
- Specified by:
getGraveyardin interfaceIGame- 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:
trueif 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
-
reset
public void reset()Description copied from class:AbstractGameResets this game, i.e. prepares it for a return to the lobby.- Overrides:
resetin classAbstractGame
-
getFirstEntity
Returns the first entity at the given coordinate, if any. Only returns targetable (non-dead) entities.- Parameters:
c- the coordinates to search at
-
getFirstEnemyEntity
Returns the first enemy entity at the given coordinate, if any. Only returns targetable (non-dead) entities.- Parameters:
c- the coordinates to search atcurrentEntity- the entity that is firing
-
getEntities
Returns an Enumeration of the active entities at the given coordinates. -
getEntities
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
Returns an Enumeration of the active entities at the given coordinates. -
getEntitiesVector
- Parameters:
c- The coordinates to check- Returns:
- the
EntityList
-
getEntitiesVector
- Parameters:
c- The coordinates to checkignore- Flag that determines whether the ability to target is ignored- Returns:
- the
EntityList
-
getEntitiesVector
-
getEntitiesVector
-
getEntitiesVector
-
getEntitiesVector
-
getAllOffboardEnemyEntities
- Parameters:
player-PlayerObject- Returns:
- a list of all off-board enemy entities.
-
getGunEmplacements
-
getGunEmplacements
Return a Vector of gun emplacements at Coordsc.- Parameters:
c- The coordinates to check- Returns:
- the
GunEmplacementVector
-
hasRooftopGunEmplacement
Determine if the given set of coordinates has a gun emplacement on the roof of a building.- Parameters:
c- The coordinates to check
-
getAFFATarget
Returns a Target for an Accidental Fall From above, or null if no possible target is there- Parameters:
coords- TheCoordsof the hex in which the accidental fall from above happensignore- The entity who is falling, so shouldn't be returned- Returns:
- The
Entitythat should be an AFFA target.
-
getEnemyEntities
Returns anIteratorof the enemy's active entities at the given coordinates.- Parameters:
coords- theCoordsof the hex being examined.currentEntity- theEntitywhose enemies are needed.- Returns:
- an
EnumerationofEntitys at the given coordinates who are enemies of the given unit.
-
getEnemyEntities
Returns anIteratorof the enemy's active entities at the given coordinates.- Parameters:
coords- theCoordsof the hex being examined.currentEntity- theEntitywhose enemies are needed.- Returns:
- an
EnumerationofEntitys at the given coordinates who are enemies of the given unit.
-
getAllEnemyEntities
Returns anEnumerationof active enemy entities- Parameters:
currentEntity- theEntitywhose enemies are needed.- Returns:
- an
EnumerationofEntitys at the given coordinates who are enemies of the given unit.
-
getTeamEntities
-
getFriendlyEntities
Returns anIteratorof friendly active entities at the given coordinates.- Parameters:
coords- theCoordsof the hex being examined.currentEntity- theEntitywhose friends are needed.- Returns:
- an
EnumerationofEntitys 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 theEntitywith the given ID is out of the game.- Parameters:
id- - the ID of theEntityto be checked.- Returns:
trueif theEntityis in the graveyard,falseotherwise.
-
isOutOfGame
See if theEntityis out of the game.- Parameters:
entity- - theEntityto be checked.- Returns:
trueif theEntityis in the graveyard,falseotherwise.
-
getFirstEntity
- Returns:
- the first entity that can act in the present turn, or null if none can.
-
getFirstEntity
- 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
- 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
- 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
- Parameters:
turn- the turn to use, which may be nullstart- the entity id to start at- Returns:
- the entity id of the next entity that can move during the specified turn
-
getPrevEntityNum
- Parameters:
turn- the turn to usestart- the entity id to start at- Returns:
- the entity id of the previous entity that can move during the specified turn
-
getFirstDeployableEntityNum
- 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
- 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
Get the entities for the player.- Parameters:
player- - thePlayerwhose entities are required.hide- - should fighters loaded into squadrons be excluded?- Returns:
- a
VectorofEntitys.
-
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- - thePlayerwhose entities are required.hide- - should fighters loaded into squadrons be excluded from this list?- Returns:
- a
VectorofEntitys.
-
getPlayerRetreatedEntities
Get the entities for the player.- Parameters:
player- - thePlayerwhose entities are required.- Returns:
- a
VectorofEntity that have retreadeds.
-
isEntityStranded
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- theEntitythat may be stranded- Returns:
trueif the entity is strandedfalseotherwise.
-
getInfantryLeft
public int getInfantryLeft(int playerId) - Parameters:
playerId- the player's ID- Returns:
- number of infantry
playerIdhas not selected yet this turn
-
getProtoMeksLeft
public int getProtoMeksLeft(int playerId) - Parameters:
playerId- the player's ID- Returns:
- number of ProtoMeks
playerIdhas not selected yet this turn
-
getVehiclesLeft
public int getVehiclesLeft(int playerId) - Parameters:
playerId- the player's ID- Returns:
- number of vehicles
playerIdhas not selected yet this turn
-
getMeksLeft
public int getMeksLeft(int playerId) - Parameters:
playerId- the player's ID- Returns:
- number of 'Meks
playerIdhas not selected yet this turn
-
removeFirstTurnFor
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
Removes the last, next turn found that the specified entity can move in. Used when, say, an entity dies mid-phase. -
removeSpecificEntityTurnsFor
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
Set the new vector of orbital bombardments for this round.- Parameters:
orbitalBombardments- A vector ofOrbitalBombardmentobjects
-
resetOrbitalBombardmentAttacks
public void resetOrbitalBombardmentAttacks()Resets the orbital bombardment attacks list. -
getOrbitalBombardmentAttacks
- Returns:
- an Enumeration of orbital bombardment attacks.
-
setArtilleryVector
-
resetArtilleryAttacks
public void resetArtilleryAttacks() -
getArtilleryAttacks
-
setEnemyArtilleryInbound
- Parameters:
inbound- Redacted enemy artillery-in-flight summaries for the Rounds-in-Air window (target/munition already withheld by the server), ornullto clear
-
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, for removal: This API element is subject to removal in a future version. -
getActions
Returns an Enumeration of actions scheduled for this phase. -
addInitiativeRerollRequest
-
rollInitAndResolveTies
public void rollInitAndResolveTies() -
handleInitiativeCompensation
public void handleInitiativeCompensation() -
getNoOfInitiativeRerollRequests
public int getNoOfInitiativeRerollRequests() -
addDisplacementAttack
Adds a pending displacement attack to the list for this phase. -
removeDisplacementAttack
Remove displacement attacks that were added previously- Parameters:
ea-
-
getDisplacementAttacks
- Returns:
- Enumeration of displacement attacks scheduled for the end of the physical phase.
-
resetCharges
public void resetCharges()Resets the pending charges list. -
getChargesVector
- Returns:
- the charges vector. Do not modify. Used for sending all charges to the client.
-
addRam
Adds a pending ramming attack to the list for this phase.- Parameters:
ea- Pending Ramming Attack.
-
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
Returns the rams vector. Do not modify. Used for sending all charges to the client. -
initializeAfterLoad
public void initializeAfterLoad() -
addTeleMissileAttack
Adds a pending ramming attack to the list for this phase.- Parameters:
ea-AttackActionObject
-
getTeleMissileAttacks
- Returns:
- an Enumeration of tele-missile attacks.
-
resetTeleMissileAttacks
public void resetTeleMissileAttacks()Resets the pending rams list. -
getTeleMissileAttacksVector
This is used to send all tele-missile attacks to the client.- Returns:
- an unmodifiable list of pending tele-missile attacks.
-
addPSR
Adds a pending PSR to the list for this phase.- Parameters:
psr- Pending PSR.- See Also:
-
getPSRs
Returns an Enumeration of pending PSRs. -
addExtremeGravityPSR
Adds a pending extreme Gravity PSR to the list for this phase. -
getExtremeGravityPSRs
Returns an Enumeration of pending extreme GravityPSRs. -
getPSRsForEntity
Get PSR rolls for a given entity. These are references to the pilotingRolls ArrayList -
removePSRsByArray
-
resetPSRs
Resets the PSR list for a given entity. -
resetExtremeGravityPSRs
public void resetExtremeGravityPSRs()Resets the extreme Gravity PSR list. -
resetExtremeGravityPSRs
Resets the extreme Gravity PSR list for a given entity. -
resetPSRs
public void resetPSRs()Resets the PSR list. -
addAttack
add an AttackHandler to the attacks list- Parameters:
ah- - TheAttackHandlerto add
-
removeAttack
Deprecated, for removal: This API element is subject to removal in a future version.remove an AttackHandler from the attacks list- Parameters:
ah- - TheAttackHandlerto remove
-
getAttacks
get the attacks- Returns:
- a
Enumerationof allAttackHandlers
-
getAttacksVector
get the attacks vector- Returns:
- the
Vectorcontaining the attacks
-
resetAttacks
public void resetAttacks()reset the attacks vector -
setAttacksVector
set the attacks vector- Parameters:
v- - theVectorthat 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:
isForceVictoryin interfaceIGame- Returns:
- Value of property forceVictory.
-
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
Adds the given reports vector to the GameReport collection.- Parameters:
v- the reports vector
-
getReports
- Parameters:
r- Round number- Returns:
- a vector of reports for the given round.
-
getAllReports
- Returns:
- a vector of all the reports.
-
setAllReports
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, 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
- 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
-
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
-
getSelectedEntities
Get allEntitys that pass the given selection criteria.- Parameters:
selector- theEntitySelectorthat implements test that an entity must pass to be included. This value may benull(in which case all entities in the game will be returned).- Returns:
- an
Enumerationof all entities that the selector accepts. This value will not benullbut it may be empty.
-
getSelectedEntityCount
Count allEntitys that pass the given selection criteria.- Parameters:
selector- theEntitySelectorthat implements test that an entity must pass to be included. This value may benull(in which case the count of all entities in the game will be returned).- Returns:
- the
intcount of all entities that the selector accepts. This value will not benullbut it may be empty.
-
getSelectedOutOfGameEntities
Get all out-of-gameEntitys that pass the given selection criteria.- Parameters:
selector- theEntitySelectorthat implements test that an entity must pass to be included. This value may benull(in which case all entities in the game will be returned).- Returns:
- an
Enumerationof all entities that the selector accepts. This value will not benullbut it may be empty.
-
getSelectedOutOfGameEntityCount
Count all out-of-gameEntitys that pass the given selection criteria.- Parameters:
selector- theEntitySelectorthat implements test that an entity must pass to be included. This value may benull(in which case the count of all out-of-game entities will be returned).- Returns:
- the
intcount of all entities that the selector accepts. This value will not benullbut 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
Get Entities that have a iNarc Nemesis pod attached and are situated between two Coords- Parameters:
attacker- The attackingEntity.target- TheCoordsof the original target.- Returns:
- an
Enumerationof entities that have nemesis pods attached, are located between attacker and target, and are friendly with the attacker.
-
getTagInfo
- Returns:
- this turn's TAG information
-
addTagInfo
add the results of one TAG attack -
resetTagInfo
public void resetTagInfo()Resets TAG information -
getFlares
- Returns:
- the list of flares
-
setFlares
Set the list of flares -
addFlare
Add a new flare -
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
Setter for the list of Coords illuminated by search lights.- Throws:
RuntimeException
-
addIlluminatedPosition
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
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
-
useVectorMove
public boolean useVectorMove() -
addControlRoll
Adds a pending Control roll to the list for this phase. -
getControlRolls
- Returns:
- an Enumeration of pending Control rolls.
-
resetControlRolls
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, for removal: This API element is subject to removal in a future version. -
checkForValidSmallCraft
Deprecated, for removal: This API element is subject to removal in a future version. -
getPlanetaryConditions
- Specified by:
getPlanetaryConditionsin interfacePlanetaryConditionsUsing- Returns:
- This game's planetary conditions
-
setPlanetaryConditions
Description copied from interface:PlanetaryConditionsUsingSets this game's planetary conditions.- Specified by:
setPlanetaryConditionsin interfacePlanetaryConditionsUsing- Parameters:
conditions- The new conditions
-
addSmokeCloud
-
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
Adds an industrial elevator to the game.- Parameters:
elevator- The industrial elevator to add
-
getIndustrialElevator
Gets an industrial elevator at the specified location.- Parameters:
location- The board location to check- Returns:
- The elevator at this location, or
nullif none exists
-
getIndustrialElevator
Gets an industrial elevator at the specified coordinates and board.- Parameters:
coords- The coordinates to checkboardId- The board ID- Returns:
- The elevator at this location, or
nullif none exists
-
getIndustrialElevators
Returns all industrial elevators in the game.- Returns:
- An unmodifiable collection of all industrial elevators
-
hasIndustrialElevator
Checks if there is an industrial elevator at the specified location.- Parameters:
location- The board location to check- Returns:
trueif an elevator exists at this location
-
removeIndustrialElevator
Removes an industrial elevator from the game.- Parameters:
location- The location of the elevator to remove- Returns:
- The removed elevator, or
nullif none was found
-
clearIndustrialElevators
public void clearIndustrialElevators()Clears all industrial elevators from the game. -
setIndustrialElevators
Sets the industrial elevators from the provided collection, replacing any existing ones.- Parameters:
elevators- Collection of industrial elevators to set
-
addTemporaryECMField
Adds a temporary ECM field to the game (e.g., from EMP mine detonation).- Parameters:
field- The temporary ECM field to add
-
getTemporaryECMFields
- Returns:
- An unmodifiable view of all temporary ECM fields currently active
-
setTemporaryECMFields
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
Removes expired temporary ECM fields based on the current round and phase.- Parameters:
currentRound- The current game roundcurrentPhase- The current game phase
-
getEntityPositions
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
Updates the map that maps a position to the list of Entity's in that position. -
getUUIDString
- Returns:
- a string representation of this game's UUID.
-
getBotSettings
-
setBotSettings
-
setDishonoredPlayers
Records the set of players the given bot player currently considers dishonored, as reported throughPacketCommand.PRINCESS_DISHONORED.- Parameters:
botPlayerId- the reporting bot's player IDdishonoredPlayerIds- 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 authoritativePacketCommand.PRINCESS_DISHONOREDreport arrives (that report then replaces this set wholesale). Replaces the inner set rather than mutating it in place, keeping the wholesale-replacement invariant that letsisPlayerDishonoredBy(int, int)read without locking.- Parameters:
botPlayerId- the bot player that now holds a grudgeplayerId- the player it now considers dishonored
-
isPlayerDishonoredBy
public boolean isPlayerDishonoredBy(int botPlayerId, int playerId) - Parameters:
botPlayerId- the bot player whose honor opinion is being queriedplayerId- the player who may be dishonored- Returns:
- true if the bot with player ID
botPlayerIdcurrently considersplayerIddishonored, as last reported viaPacketCommand.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
- 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 throughrecordBotType(String, AIType).
-
recordBotType
Records which AI implementation the bot connected under the given player name is.- Parameters:
playerName- the bot player's nameaiType- the AI implementation it reported
-
setBotTypes
-
getGroundObjects
Get a list of all objects on the ground at the given coordinates that can be picked up by the given entity -
getGroundObjects
Deprecated.- Overrides:
getGroundObjectsin classAbstractGame- 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
-
setMapSettings
-
inGameTWEntities
- Returns:
- The TW Units (Entity) currently in the game.
-
getNewReport
Description copied from interface:IGameReturns a new ReportEntry with the given report message ID. The ReportEntry subclass returned depends on the implementation in the IGame subclass.- Specified by:
getNewReportin interfaceIGame- Parameters:
messageId- The message ID from report-messages.properties- Returns:
- A new report of an appropriate type and message
-
idForPlayerName
- 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
- 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
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
Returns the Building at the given location, if any. Shortcut to Board.getBuildingAt().- Parameters:
coords- The position on the boardboardId- The board ID- Returns:
- The building at the location, if any
-
hasBuildingAt
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 boardboardId- 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.
-