Class SBFGame
java.lang.Object
megamek.common.game.AbstractGame
megamek.common.strategicBattleSystems.SBFGame
- All Implemented Interfaces:
IGame,PlanetaryConditionsUsing,SBFRuleOptionsUser
public final class SBFGame
extends AbstractGame
implements PlanetaryConditionsUsing, SBFRuleOptionsUser
This is an SBF game's game object that holds all game information. As of 2024, this is under construction.
-
Field Summary
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 TypeMethodDescriptionvoidaddActionHandler(SBFActionHandler handler) voidAdds the given Player to the game with the given game-unique id.voidaddReports(List<SBFReportEntry> reports) Adds the given reports this game's reports.voidaddUnit(InGameObject unit) booleanareHostile(SBFFormation formation, Player player) Advances the turn index and returns the then-current turn.voidforget(int unitId) Returns the list of formations that are in the game's InGameObject list, i.e.getActiveFormationsAt(BoardLocation location) Returns the list of formations that are in the game's InGameObject list, i.e.getFormation(int formationID) Returns the formation of the given ID, if one can be found.getFullyVisibleUnits(Player viewingPlayer) getNewReport(int messageId) Returns a new ReportEntry with the given report message ID.getNextEligibleFormation(int currentFormationID) This method must be implemented to provide access to the SBF options used in the present game so that the convenience methods of this interface work correctly.getPhase()getPlayerFor(SBFTurn turn) Returns the Player that has to act in the given turn.Deprecated, for removal: This API element is subject to removal in a future version.getPreviousEligibleFormation(int currentFormationID) getTurn()Returns the current list of turns.getVisibility(Player player, int unitId) booleanbooleanbooleanReturns 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.booleanbooleanisHostileActiveFormationAt(BoardLocation location, SBFFormation formation) booleanisVisible(int viewingPlayer, int formationID) booleanonSameBoard(SBFFormation unit1, SBFFormation unit2) voidreceivePhase(GamePhase phase) Sets the current game phase to the given phase.voidreceiveUnit(InGameObject unit) Adds or overwrites the received unit in the game's unit list.voidremoveActionHandler(SBFActionHandler handler) Deprecated, for removal: This API element is subject to removal in a future version.voidremovePlayer(int id) Removes the player with the id from the game.voidreplaceAllReports(Map<Integer, List<SBFReportEntry>> newReports) Replaces this game's entire reports with the given reports.voidreplaceUnits(List<InGameObject> units) This is a Client-side method to replace or add units that are sent from the server.voidsetGraveyard(List<InGameObject> graveyard) voidsetLastPhase(GamePhase lastPhase) Sets the previous game phase to the given phase.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.voidsetTurnIndex(int turnIndex, int prevPlayerId) Sets the current turn indexvoidSets the current list of turns to the given one, replacing any currently present turns.voidsetUnitList(List<InGameObject> units) voidMethods 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, getGroundObjects, getInGameObjects, getNextEntityId, getNoOfPlayers, getNoOfTeams, getPlayer, getPlayersList, getTeams, getTurnIndex, incrementCurrentRound, isDeploymentComplete, lastDeploymentRound, placeGroundObject, receiveBoard, receiveBoards, removeAction, removeActionsFor, removeGameListener, removeGroundObject, reset, 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, getEntityFromAllSources, getHex, getHex, getHexOf, getInGameObject, getInGameObjects, getOutOfGameUnit, getTeamByPlayer, getTeamForPlayer, hasBoard, hasBoard, hasBoardLocation, hasBoardLocation, hasBoardLocationOf, hasConnectedBoard, hasEnclosingBoard, hasGroundBoard, hasNonSpaceBoard, hasPlayer, hasSpaceAndAtmosphericBoards, hasSpaceBoard, isOnAtmosphericMap, isOnAtmosphericMap, isOnGroundMap, isOnGroundMap, isOnSpaceMap, isOnSpaceMap, onConnectedBoards, onDirectlyConnectedBoards, onTheSameBoard, shouldSkipCurrentPhaseMethods inherited from interface megamek.common.strategicBattleSystems.SBFRuleOptionsUser
usesAdjustingFormations, usesAdvancedInitiative, usesBattlefieldInt, usesDoubleBlind, usesSprintingMove, usesTeamVision
-
Constructor Details
-
SBFGame
public SBFGame()
-
-
Method Details
-
getTurn
-
getOptions
Description copied from interface:SBFRuleOptionsUserThis method must be implemented to provide access to the SBF options used in the present game so that the convenience methods of this interface work correctly.- Specified by:
getOptionsin interfaceIGame- Specified by:
getOptionsin interfaceSBFRuleOptionsUser- Returns:
- the SBFRuleOptions used by the present SBF game
-
getPhase
-
getLastPhase
-
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. -
receivePhase
Description copied from interface:IGameSets the current game phase to the given phase. May perform phase-dependent cleanup and fire game events. This method is intended for the Client. By default, this method callsIGame.setPhase(GamePhase). When overridden, it'll usually make sense to call super(phase).- Specified by:
receivePhasein interfaceIGame- Parameters:
phase- The new phase
-
isForceVictory
public boolean isForceVictory()- Specified by:
isForceVictoryin interfaceIGame- Returns:
- Whether there is an active claim for victory.
-
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
-
setupTeams
public void setupTeams()- Specified by:
setupTeamsin interfaceIGame
-
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.
-
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
-
addUnit
-
receiveUnit
Adds or overwrites the received unit in the game's unit list.- Parameters:
unit- The new or changed unit
-
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.
-
addReports
Adds the given reports this game's reports.- Parameters:
reports- the new reports to add
-
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
-
getGameReport
-
replaceAllReports
Replaces this game's entire reports with the given reports.- Parameters:
newReports- The new reports to keep as this game's reports
-
setTurns
Sets the current list of turns to the given one, replacing any currently present turns.- Parameters:
newTurns- The new list of turns to use
-
getTurnsList
Returns the current list of turns. The returned list is unmodifiable but not a deep copy. If you're not the SBFGameManager, don't even think about changing any of the turns.- 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.
-
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.
-
setUnitList
-
setGraveyard
-
visibilityHelper
-
isVisible
public boolean isVisible(int viewingPlayer, int formationID) -
getFullyVisibleUnits
-
getVisibility
-
changeToNextTurn
Advances the turn index and returns the then-current turn.- Returns:
- The current turn (after advancing the turn index)
-
hasEligibleFormation
-
getActiveFormations
Returns the list of formations that are in the game's InGameObject list, i.e. that aren't destroyed or otherwise removed from play.- Returns:
- The currently active formations
-
getActiveFormationsAt
Returns the list of formations that are in the game's InGameObject list, i.e. that aren't destroyed or otherwise removed from play.- Returns:
- The currently active formations
-
isHostileActiveFormationAt
-
areHostile
-
getNextEligibleFormation
- Returns:
- the first formation in the list of formations that is alive and eligible for the current game phase.
-
getPreviousEligibleFormation
@Deprecated(since="0.51.0", forRemoval=true) public Optional<SBFFormation> getPreviousEligibleFormation()Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- the preceding formation in the list of formations that is alive and eligible for the current game phase.
-
getNextEligibleFormation
- Returns:
- the next in the list of formations that is alive and eligible for the current game phase, counting from the given current formation id. If no matching formation can be found for the given id, returns the first eligible formation in the list of formations that is alive and eligible.
-
getPreviousEligibleFormation
- Returns:
- the previous in the list of formations that is alive and eligible for the current game phase, counting from the given current formation id. If no matching formation can be found for the given id, returns the last eligible formation from the list of formations that is alive and eligible.
-
getFormation
Returns the formation of the given ID, if one can be found.- Parameters:
formationID- the ID to look for- Returns:
- The formation or an empty Optional
-
hasMoreTurns
public boolean hasMoreTurns()- Specified by:
hasMoreTurnsin interfaceIGame- Returns:
- True when there is at least one more player turn waiting to be played in the current game phase. //TODO this code from Game is surprising; the last available turn should be at size()-1, but apparently this works
-
getPlayerFor
Returns the Player that has to act in the given turn. The result should rarely be empty.- Parameters:
turn- The SBFTurn to check- Returns:
- The Player whose turn it is
-
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.
-
onSameBoard
-
forget
public void forget(int unitId) -
addActionHandler
-
removeActionHandler
@Deprecated(since="0.51.0", forRemoval=true) public void removeActionHandler(SBFActionHandler handler) Deprecated, for removal: This API element is subject to removal in a future version. -
getActionHandlers
- Returns:
- The currently active action handlers.
-