Package megamek.common
Class Game
java.lang.Object
megamek.common.AbstractGame
megamek.common.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 TypeFieldDescriptionA UUID to identify this game instance.final Version
Stores the version of MM, so that it can be serialized in saved games.Fields inherited from class megamek.common.AbstractGame
currentRound, forces, gameListeners, groundObjects, inGameObjects, pendingActions, players, scriptedEvents, teams, turnIndex
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add an AttackHandler to the attacks listvoid
Adds a pending displacement attack to the list for this phase.void
addControlRoll
(PilotingRollData control) Adds a pending Control roll to the list for this phase.void
addEntities
(List<Entity> entities) Adds a collection of new Entities.void
Deprecated, for removal: This API element is subject to removal in a future version.void
Adds a new Entity to this Game object and generates a GameEntityNewEvent.void
Adds a new Entity to this Game object.void
Adds a pending extreme Gravity PSR to the list for this phase.void
Add a new flareboolean
Add a new hex to the collection of Coords illuminated by searchlights.void
void
void
addMinefields
(Vector<Minefield> mines) void
Adds the given Player to the game with the given game-unique id.void
addPSR
(PilotingRollData psr) Adds a pending PSR to the list for this phase.void
addRam
(AttackAction ea) Adds a pending ramming attack to the list for this phase.void
addReports
(List<Report> v) Adds the given reports vector to the GameReport collection.void
addSmokeCloud
(SmokeCloud cloud) void
addTagInfo
(TagInfo info) add the results of one TAG attackvoid
Adds a pending ramming attack to the list for this phase.void
Ages all flares, drifts them with the wind and removes any which have burnt out or drifted off the map.void
Cancels a victoryChanges to the next turn, returning it.boolean
checkForValidDropShips
(int playerId) 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.boolean
checkForValidSmallCraft
(int playerId) boolean
checkForValidSpaceStations
(int playerId) A set of checks for aero units to make sure that the movement order is maintainedvoid
Clears out all the current reports, paving the way for a new game.void
Clear the set of searchlight illuminated hexes.void
boolean
containsMinefield
(Coords coords) boolean
Checks if the game contains the specified Vibrabombvoid
Uses VictoryFactory to generate a new VictoryCondition checker provided that the VictoryContext is saved properly.void
end
(int winner, int winnerTeam) boolean
Returns 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 anEnumeration
of active enemy entitiesint
getAllEntitiesOwnedBy
(Player player) Returns the number of entities owned by the player, regardless of their status.getAllOffboardEnemyEntities
(Player player) int
get the attacksget the attacks vectorgetC3NetworkMembers
(Entity entity) Returns aVector
containing theEntity
s that are in the same C3 network as the passed-in unit.getC3SubNetworkMembers
(Entity entity) Returns aVector
containing theEntity
s 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, Entity currentEntity) Returns anIterator
of the enemy's active entities at the given coordinates.Deprecated.UseinGameTWEntities()
instead.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
(Coords c, boolean ignore) 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.int
Returns an Enumeration of pending extreme GravityPSRs.int
getFirstEnemyEntity
(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) int
int
getFirstEntityNum
(GameTurn turn) int
getFriendlyEntities
(Coords coords, Entity currentEntity) Returns anIterator
of 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 entityReturn a Vector of gun emplacements at Coordsc
Get a set of Coords illuminated by searchlights.int
getInfantryLeft
(int playerId) int
getLiveCommandersOwnedBy
(Player player) int
getLiveDeployedEntitiesOwnedBy
(Player player) int
getLiveEntitiesOwnedBy
(Player player) int
getMeksLeft
(int playerId) Get the coordinates of all mined hexes in the game.getMinefields
(Coords coords) int
getNbrMinefields
(Coords coords) getNemesisTargets
(Entity attacker, Coords target) Get Entities that have have a iNarc Nemesis pod attached and are situated between two CoordsgetNewReport
(int messageId) Returns a new ReportEntry with the given report message Id.int
getNextDeployableEntityNum
(GameTurn turn, int start) getNextEntity
(int start) getNextEntityFromList
(Entity current) int
int
getNextEntityNum
(GameTurn turn, int start) int
getNextHiddenEntityNum
(GameTurn turn, int start) int
Return the current number of entities in the game.int
getOutOfGameEntity
(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) Get the entities for the player.getPlayerRetreatedEntities
(Player player) Get the entities for the player.Returns aHashtable
that maps theCoords
of each unit in thisGame
to aVector
ofEntity
s at that positions.int
getPrevEntityNum
(GameTurn turn, int start) getPreviousEntityFromList
(Entity current) int
getProtoMeksLeft
(int playerId) getPSRs()
Returns an Enumeration of pending PSRs.getRams()
Returns the rams vector.getReports
(int r) Returns an enumeration of entities that have retreatedint
Getter for property roundCount.getSelectedEntities
(EntitySelector selector) Get allEntity
s that pass the given selection criteria.int
getSelectedEntityCount
(EntitySelector selector) Count allEntity
s that pass the given selection criteria.getSelectedOutOfGameEntities
(EntitySelector selector) Get all out-of-gameEntity
s that pass the given selection criteria.int
Count all out-of-gameEntity
s that pass the given selection criteria.getTarget
(int nType, int nID) 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 entityint
getVehiclesLeft
(int playerId) Deprecated, for removal: This API element is subject to removal in a future version.int
Getter for property victoryPlayerId.int
Getter for property victoryTeam.Returns an enumeration of wrecked entities.void
boolean
hasEntity
(int entityId) boolean
Determine if the given set of coordinates has a gun emplacement on the roof of a building.boolean
hasTacticalGenius
(Player player) idForPlayername
(String playerName) void
insertNextTurn
(GameTurn turn) Inserts a turn that will come directly after the current onevoid
insertTurnAfter
(GameTurn turn, int index) Inserts a turn after the specific indexboolean
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.boolean
boolean
isEntityStranded
(Entity entity) Determines if the indicated entity is stranded on a transport that can't move.boolean
Getter for property forceVictory.boolean
boolean
isOutOfGame
(int id) See if theEntity
with the given ID is out of the game.boolean
isOutOfGame
(Entity entity) See if theEntity
is out of the game.boolean
isPlayerVictor
(Player player) void
moveToGraveyard
(int id) Moves an entity into the graveyard, so it stops getting sent out every phase.playerForPlayername
(String playerName) void
processGameEvent
(GameEvent event) void
remove an AttackHandler from the attacks listvoid
void
void
removeEntities
(List<Integer> ids, int condition) void
removeEntity
(int id, int condition) Remove an entity from the master list.removeFirstTurnFor
(Entity entity) Removes the first turn found that the specified entity can move in.void
void
void
removePlayer
(int id) Removes the player with the id from the game.void
removeSmokeClouds
(List<SmokeCloud> cloudsToRemove) int
removeSpecificEntityTurnsFor
(Entity entity) Removes any turns that can only be taken by the specified entity.void
removeTurnFor
(Entity entity) Removes the last, next turn found that the specified entity can move in.void
void
replaceUnits
(List<InGameObject> units) This is a Client-side method to replace or add units that are sent from the server.void
reset()
Resets this game, i.e.void
void
reset the attacks vectorvoid
Resets the pending charges list.void
Resets the Control Roll list.void
resetControlRolls
(Entity entity) Resets the Control Roll list for a given entity.void
Resets the extreme Gravity PSR list.void
resetExtremeGravityPSRs
(Entity entity) Resets the extreme Gravity PSR list for a given entity.void
resetMinefieldDensity
(Vector<Minefield> newMinefields) void
Resets the orbital bombardment attacks list.void
Resets the PSR list.void
Resets the PSR list for a given entity.void
Resets the pending rams list.void
Resets TAG informationvoid
Resets the pending rams list.void
void
setAllReports
(List<List<Report>> v) Used to populate previous game reports, e.g.void
void
set the attacks vectorvoid
void
setBoardDirect
(Board board) void
setBotSettings
(Map<String, BehaviorSettings> botSettings) void
setEndImmediately
(boolean endImmediately) Setter for property endImmediately.void
setEntitiesVector
(List<Entity> entities) void
void
setEntity
(int id, Entity entity, Vector<UnitLocation> movePath) void
setExternalGameId
(int value) void
Set the list of flaresvoid
setForceVictory
(boolean forceVictory) Setter for property forceVictory.void
setIgnorePlayerDefeatVotes
(boolean ignorePlayerDefeatVotes) Setter for property ignorePlayerDefeatVotes.void
Setter for the list of Coords illuminated by search lights.void
setLastPhase
(GamePhase lastPhase) Sets the previous game phase to the given phase.void
setMapSettings
(MapSettings mapSettings) void
setMinefields
(Vector<Minefield> minefields) void
setOptions
(GameOptions options) void
setOrbitalBombardmentVector
(Vector<OrbitalBombardment> orbitalBombardments) Set the new vector of orbital bombardments for this round.void
setOutOfGameEntitiesVector
(List<Entity> vOutOfGame) Swap out the current list of dead (or fled) units for a new one.void
Sets the current game phase to the given phase.void
setPlanetaryConditions
(PlanetaryConditions conditions) Sets this game's planetary conditions.void
Sets the given Player to the given game-unique id.void
setRoundCount
(int roundCount) void
setTurnIndex
(int turnIndex, int prevPlayerId) Sets the current turn indexvoid
setTurnVector
(List<GameTurn> turnVector) Sets the current turn vectorvoid
Set up the teams vector.void
setVictoryContext
(HashMap<String, Object> ctx) void
setVictoryPlayerId
(int victoryPlayerId) Setter for property victoryPlayerId.void
setVictoryTeam
(int victoryTeam) Setter for property victoryTeam.void
swapTurnOrder
(int index1, int index2) Swaps the turn at index 1 with the turn at index 2.void
updateEntityPositionLookup
(Entity e, HashSet<Coords> oldPositions) Updates the map that maps a position to the list of Entity's in that position.boolean
Methods inherited from class megamek.common.AbstractGame
addAction, addGameListener, addScriptedEvent, canFleeFrom, clearActions, clearDeploymentThisRound, clearScriptedEvents, deployableInGameObjects, fireGameEvent, getActionsVector, getBoards, getCurrentRound, getFleeZone, getForces, getGameListeners, getGroundObjects, getInGameObjects, getNoOfPlayers, getNoOfTeams, getPlayer, getPlayersList, getTeams, getTurnIndex, hasBoard, hasBoard, hasBoardLocation, hasBoardLocation, incrementCurrentRound, isDeploymentComplete, lastDeploymentRound, placeGroundObject, receiveBoard, receiveBoards, removeAction, removeActionsFor, removeGameListener, removeGroundObject, resetTurnIndex, scriptedEvents, setBoard, setCurrentRound, setForces, setGroundObjects, setTurnIndex, setupDeployment, shouldDeployForRound, shouldDeployThisRound
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface megamek.common.IGame
getBoard, getBoard, getEntitiesOwnedBy, getInGameObject, getInGameObjects, getOutOfGameUnit, getTeamByPlayer, getTeamForPlayer, hasMoreTurns, hasPlayer, receivePhase, shouldSkipCurrentPhase
-
Field Details
-
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
-
-
Method Details
-
getExternalGameId
public int getExternalGameId() -
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
Enumeration
of theCoords
containing minefields. This will not benull
.
-
addMinefield
-
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.
-
getOptions
- Specified by:
getOptions
in interfaceIGame
-
setOptions
-
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 interfaceIGame
-
addPlayer
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 interfaceIGame
- Overrides:
addPlayer
in classAbstractGame
- Parameters:
id
- The game-unique id of this playerplayer
- 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 interfaceIGame
- Returns:
- True when the current phase should be skipped entirely in this round
- See Also:
-
setPlayer
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? -
removePlayer
public void removePlayer(int id) Description copied from interface:IGame
Removes the player with the id from the game.- Specified by:
removePlayer
in interfaceIGame
- Parameters:
id
- The player id
-
getAllEntitiesOwnedBy
Returns the number of entities owned by the player, regardless of their status. -
getLiveEntitiesOwnedBy
- 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.
-
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:
getTurnsList
in 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:IGame
Sets the current game phase to the given phase. May perform phase-dependent cleanup. This method is intended for the GameManager. -
processGameEvent
-
getLastPhase
-
setLastPhase
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 interfaceIGame
- Parameters:
lastPhase
- The phase to be remembered as the previous phase.
-
getEntities
Deprecated.UseinGameTWEntities()
instead.- Returns:
- an enumeration of all the entities in the game.
-
getPreviousEntityFromList
- Parameters:
current
- TheEntity
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
- Parameters:
current
- TheEntity
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
- 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 newVector
of 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
- theint
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 anull
.
-
getC3NetworkMembers
Returns aVector
containing theEntity
s 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
- - theEntity
whose C3 network co- members is required. This value may benull
.- Returns:
- a
Vector
that will contain all otherEntity
s that are in the same C3 network as the passed-in unit. ThisVector
may be empty, but it will not benull
. - See Also:
-
getC3SubNetworkMembers
Returns aVector
containing theEntity
s 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
- - theEntity
whose C3 network sub- members is required. This value may benull
.- Returns:
- a
Vector
that will contain all otherEntity
s that are in the same C3 network under the passed-in unit. ThisVector
may be empty, but it will not benull
. - See Also:
-
getPositionMap
Returns aHashtable
that maps theCoords
of each unit in thisGame
to aVector
ofEntity
s at that positions. Units that have no position (e.g. loaded units) will not be in the map.- Returns:
- a
Hashtable
that maps theCoords
positions or each unit in the game to aVector
ofEntity
s at that position.
-
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:
getEntityFromAllSources
in 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
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.4 - UseaddEntity(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 Entityentity
- The Entity to add to the game.
-
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:
getNextEntityId
in interfaceIGame
- Overrides:
getNextEntityId
in classAbstractGame
- Returns:
- The next free ID for InGameObjects (unit/entity/formation/others).
-
replaceUnits
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 interfaceIGame
- Parameters:
units
- The units to add or use as a replacement for current units.
-
getGraveyard
- Specified by:
getGraveyard
in 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:
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
-
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 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 Enumeration of the active entities at the given coordinates. -
getEntitiesVector
- Parameters:
c
- The coordinates to check- Returns:
- the
Entity
List
-
getEntitiesVector
- Parameters:
c
- The coordinates to checkignore
- Flag that determines whether the ability to target is ignored- Returns:
- the
Entity
List
-
getAllOffboardEnemyEntities
- Parameters:
player
-Player
Object- Returns:
- a list of all off-board enemy entities.
-
getGunEmplacements
Return a Vector of gun emplacements at Coordsc
- Parameters:
c
- The coordinates to check- Returns:
- the
GunEmplacement
Vector
-
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
- TheCoords
of the hex in which the accidental fall from above happensignore
- The entity who is falling, so shouldn't be returned- Returns:
- The
Entity
that should be an AFFA target.
-
getEnemyEntities
Returns anIterator
of the enemy's active entities at the given coordinates.- Parameters:
coords
- theCoords
of the hex being examined.currentEntity
- theEntity
whose enemies are needed.- Returns:
- an
Enumeration
ofEntity
s at the given coordinates who are enemies of the given unit.
-
getAllEnemyEntities
Returns anEnumeration
of active enemy entities- Parameters:
currentEntity
- theEntity
whose enemies are needed.- Returns:
- an
Enumeration
ofEntity
s at the given coordinates who are enemies of the given unit.
-
getTeamEntities
-
getFriendlyEntities
Returns anIterator
of friendly active entities at the given coordinates.- Parameters:
coords
- theCoords
of the hex being examined.currentEntity
- theEntity
whose friends are needed.- Returns:
- an
Enumeration
ofEntity
s 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 theEntity
with the given ID is out of the game.- Parameters:
id
- - the ID of theEntity
to be checked.- Returns:
true
if theEntity
is in the graveyard,false
otherwise.
-
isOutOfGame
See if theEntity
is out of the game.- Parameters:
entity
- - theEntity
to be checked.- Returns:
true
if theEntity
is in the graveyard,false
otherwise.
-
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
- 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
- Returns:
- the number of the next hidden entity that is valid for the specified turn
-
getPlayerEntities
Get the entities for the player.- Parameters:
player
- - thePlayer
whose entities are required.hide
- - should fighters loaded into squadrons be excluded?- Returns:
- a
Vector
ofEntity
s.
-
getPlayerEntityIds
Get the entities for the player.- Parameters:
player
- - thePlayer
whose entities are required.hide
- - should fighters loaded into squadrons be excluded from this list?- Returns:
- a
Vector
ofEntity
s.
-
getPlayerRetreatedEntities
Get the entities for the player.- Parameters:
player
- - thePlayer
whose entities are required.- Returns:
- a
Vector
ofEntity that have retreaded
s.
-
isEntityStranded
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
- theEntity
that may be stranded- Returns:
true
if the entity is strandedfalse
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
Removes the first turn found that the specified entity can move in. Used when a turn is played out of order- Throws:
Exception
-
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 ofOrbitalBombardment
objects
-
resetOrbitalBombardmentAttacks
public void resetOrbitalBombardmentAttacks()Resets the orbital bombardment attacks list. -
getOrbitalBombardmentAttacks
- Returns:
- an Enumeration of orbital bombardment attacks.
-
setArtilleryVector
-
resetArtilleryAttacks
public void resetArtilleryAttacks() -
getArtilleryAttacks
-
getArtillerySize
public int getArtillerySize() -
getActions
Returns an Enumeration of actions scheduled for this phase. -
addInitiativeRerollRequest
-
rollInitAndResolveTies
public void rollInitAndResolveTies() -
handleInitiativeCompensation
public void handleInitiativeCompensation() -
getNoOfInitiativeRerollRequests
public int getNoOfInitiativeRerollRequests() -
addCharge
Adds a pending displacement attack to the list for this phase. -
getCharges
- 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. -
addTeleMissileAttack
Adds a pending ramming attack to the list for this phase.- Parameters:
ea
-AttackAction
Object
-
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. -
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
- - TheAttackHandler
to add
-
removeAttack
remove an AttackHandler from the attacks list- Parameters:
ah
- - TheAttackHandler
to remove
-
getAttacks
get the attacks- Returns:
- a
Enumeration
of allAttackHandler
s
-
getAttacksVector
get the attacks vector- Returns:
- the
Vector
containing the attacks
-
resetAttacks
public void resetAttacks()reset the attacks vector -
setAttacksVector
set the attacks vector- Parameters:
v
- - theVector
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 interfaceIGame
- 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
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
- 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
-
getSelectedEntities
Get allEntity
s that pass the given selection criteria.- Parameters:
selector
- theEntitySelector
that 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
Enumeration
of all entities that the selector accepts. This value will not benull
but it may be empty.
-
getSelectedEntityCount
Count allEntity
s that pass the given selection criteria.- Parameters:
selector
- theEntitySelector
that 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
int
count of all entities that the selector accepts. This value will not benull
but it may be empty.
-
getSelectedOutOfGameEntities
Get all out-of-gameEntity
s that pass the given selection criteria.- Parameters:
selector
- theEntitySelector
that 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
Enumeration
of all entities that the selector accepts. This value will not benull
but it may be empty.
-
getSelectedOutOfGameEntityCount
Count all out-of-gameEntity
s that pass the given selection criteria.- Parameters:
selector
- theEntitySelector
that 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
int
count of all entities that the selector accepts. This value will not benull
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
Get Entities that have have a iNarc Nemesis pod attached and are situated between two Coords- Parameters:
attacker
- The attackingEntity
.target
- TheCoords
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
- 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. -
getVictory
Deprecated, for removal: This API element is subject to removal in a future version. -
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
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
- Specified by:
getPlanetaryConditions
in interfacePlanetaryConditionsUsing
- Returns:
- This game's planetary conditions
-
setPlanetaryConditions
Description copied from interface:PlanetaryConditionsUsing
Sets this game's planetary conditions.- Specified by:
setPlanetaryConditions
in interfacePlanetaryConditionsUsing
- Parameters:
conditions
- The new conditions
-
addSmokeCloud
-
getSmokeCloudList
-
removeSmokeClouds
-
removeEmptySmokeClouds
public void removeEmptySmokeClouds() -
removeCompletelyDissipatedSmokeClouds
public void removeCompletelyDissipatedSmokeClouds() -
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.- Parameters:
e
-
-
getUUIDString
- Returns:
- a string representation of this game's UUID.
-
getBotSettings
-
setBotSettings
-
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:
getGroundObjects
in 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: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 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.
-
addEntity(Entity)
instead.