Interface IGameManager

All Known Implementing Classes:
AbstractGameManager, SBFGameManager, SimulationManager, TWGameManager

public interface IGameManager
Provides common interface for the server to interact with different types of games. Currently only used for Total Warfare scale, but allows expansion to BattleFore or Alpha Strike.
  • Method Details

    • getGame

      IGame getGame()
      Returns:
      The current game instance.
    • setGame

      void setGame(IGame g)
      Sets the current game instance.
    • resetGame

      void resetGame()
      Resets the game instance. Resetting the game removes all content and returns to the lobby but keeps connected players.
    • disconnect

      void disconnect(Player player)
      Handles housekeeping for a disconnected player. Removes player from the game in the lounge or victory phase, or during other phases if the player has no units. Otherwise, the player becomes a ghost.
      Parameters:
      player - The player that disconnected.
    • sendCurrentInfo

      void sendCurrentInfo(int connId)
      Sends a player all information they need to update their Client game state to the GameManager's game state. This should always include units, forces, map info, active attacks, round reports, among others. This is triggered when a player first connects to the server. When the game is past the lobby phase, this also triggers generating and sending a current player turn or advancing the phase if there are no remaining turns; in other words, this sets the game in motion when the first player connects. A game starts past the lobby phase when it is loaded from a save.
      Parameters:
      connId - The id of the player to update
    • send

      void send(Packet packet)
      Sends the given packet to all connections (all connected Clients = players).
    • send

      void send(int connId, Packet p)
      Sends the given packet to the given connection (= player ID).
    • saveGame

      default void saveGame(String fileName)
      Saves the game server-side. Will announce the save (or error) in chat.
      Parameters:
      fileName - The filename to use
    • saveGame

      void saveGame(String fileName, boolean sendChat)
      Saves the game server-side. Will announce the save (or error) in chat if the given sendChat is true.
      Parameters:
      fileName - The filename to use
      sendChat - When true, the saving (or error) is announced in chat
    • sendSaveGame

      void sendSaveGame(int connId, String fileName, String localPath)
      save the game and send it to the specified connection
      Parameters:
      connId - The connection id to send to
      fileName - The filename to use
      localPath - The path to the file to be used on the client
    • removeAllEntitiesOwnedBy

      void removeAllEntitiesOwnedBy(Player player)
    • handlePacket

      void handlePacket(int connId, Packet packet)
      Handles all incoming packets. When overriding this, super() should normally be called to have the base implementation of AbstractGameManager handle packets.
      Parameters:
      connId - The connection ID = player ID the packet came from
      packet - The packet to process
    • handleCfrPacket

      void handleCfrPacket(Server.ReceivedPacket rp)
      Handle CFR packets. //TODO: This concerns multi-threaded code and should be centralized!
      Parameters:
      rp - the CFR packet returned from a client
    • requestGameMaster

      void requestGameMaster(Player player)
    • getCommandList

      List<ServerCommand> getCommandList(Server server)
    • addReport

      void addReport(ReportEntry r)
    • calculatePlayerInitialCounts

      void calculatePlayerInitialCounts()
      Calculates and sets any initial unit counts and BV/PV for all players, and thus should only be called at the start of a game. The initial values are supposed to be stored for later comparison so that BV or unit losses over the course of the game can be calculated.
    • requestTeamChangeForPlayer

      void requestTeamChangeForPlayer(int teamID, Player player)
      Requests a team change for a player.
      Parameters:
      teamID - ID of the team the player will be passed to
      player - player