Package megamek.client
Interface IClient
- All Known Implementing Classes:
AbstractClient
,BotClient
,Client
,HeadlessClient
,Princess
,SBFClient
,SimulatedClient
public interface IClient
-
Method Summary
Modifier and TypeMethodDescriptionboolean
connect()
Attempt to connect to the specified hostvoid
die()
Cleans up and closes resources of this Client.default AbstractClient
getBotClient
(Player player) Returns the Client associated with the given local bot player.getBots()
Returns the map containing this Client's local bots, wherein the key is the bot's player name and the value the Client.getGame()
Returns the game of this client as a game-type independent IGame.getHost()
default Optional<InGameObject>
getInGameObject
(int id) default List<InGameObject>
default Player
int
getName()
default Player
getPlayer
(int id) int
getPort()
default boolean
isLocalBot
(Player player) boolean
isMyTurn()
default boolean
playerExists
(int id) void
void
sendDone
(boolean done) Sends a "this player is done/not done" message to the server.void
void
setLocalPlayerNumber
(int localPlayerNumber) Sets the ID of the player playing at this Client.
-
Method Details
-
connect
boolean connect()Attempt to connect to the specified host- Returns:
- true if successful.
-
getName
String getName()- Returns:
- The name of Client, typically the same as the local player's name.
-
getPort
int getPort()- Returns:
- The port that this Client uses to connect to the server.
-
getHost
String getHost()- Returns:
- The server host address.
-
die
void die()Cleans up and closes resources of this Client. -
getGame
IGame getGame()Returns the game of this client as a game-type independent IGame. Note that the game object is only updated, not replaced and a reference to it can therefore be kept.- Returns:
- The game of this client
-
getInGameObject
- Parameters:
id
- The in-game object associated with the given ID.- Returns:
- An Optional of
InGameObject
if it exists.
-
getInGameObjects
- Returns:
- A list of all in-game objects of the game. This list is copied and may be safely modified.
-
getPlayer
- Parameters:
id
- The player with the given ID, or null if there is no such player.- Returns:
- The player object.
-
getLocalPlayerNumber
int getLocalPlayerNumber()- Returns:
- The ID of the player playing at this Client.
-
isMyTurn
boolean isMyTurn()- Returns:
- True when the currently active turn is a turn for the local player
-
setLocalPlayerNumber
void setLocalPlayerNumber(int localPlayerNumber) Sets the ID of the player playing at this Client.- Parameters:
localPlayerNumber
- The new local player's ID
-
getLocalPlayer
- Returns:
- The local player (playing at this Client).
-
playerExists
default boolean playerExists(int id) - Parameters:
id
- ID of player- Returns:
- True when there is a player (incl. bot) with the given ID in the game.
-
getBots
Map<String,AbstractClient> getBots()Returns the map containing this Client's local bots, wherein the key is the bot's player name and the value the Client.- Returns:
- This Client's local bots mapped to their player name
-
isLocalBot
- Parameters:
player
- thePlayer
that we need to know is a bot or not.- Returns:
- True when the given player is a bot added/controlled by this Client.
-
getBotClient
Returns the Client associated with the given local bot player. If the player is not a local bot, returns null.- Parameters:
player
- The player whose client we're looking for.- Returns:
- The Client for the given player if it's a bot, null otherwise
-
sendDone
void sendDone(boolean done) Sends a "this player is done/not done" message to the server.- Parameters:
done
- Is the player done or not.
-
sendChat
-
sendPause
void sendPause()
-