|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmegamek.client.Client
public class Client
This class is instanciated for each client and for each bot running on that client. non-local clients are not also instantiated on the local server.
| Field Summary | |
|---|---|
java.util.Map<java.lang.String,Client> |
bots
|
static java.lang.String |
CLIENT_COMMAND
|
IGame |
game
|
int |
local_pn
|
java.lang.String |
phaseReport
|
java.lang.String |
roundReport
|
| Constructor Summary | |
|---|---|
Client(java.lang.String name,
java.lang.String host,
int port)
Construct a client which will try to connect. |
|
| Method Summary | |
|---|---|
void |
addCloseClientListener(CloseClientListener l)
Adds the specified close client listener to receive close client events. |
boolean |
canUnloadStranded()
Can I unload entities stranded on immobile transports? |
void |
changePhase(IGame.Phase phase)
Changes the game phase, and the displays that go along with it. |
protected void |
changeTurnIndex(int index)
Change whose turn it is. |
boolean |
connect()
Attempt to connect to the specified host |
void |
deploy(int id,
Coords c,
int nFacing,
int elevation)
Maintain backwards compatability. |
void |
deploy(int id,
Coords c,
int nFacing,
int elevation,
java.util.List<Entity> loadedUnits,
boolean assaultDrop)
Deploy an entity at the given coordinates, with the given facing, and starting with the given units already loaded. |
void |
die()
Shuts down threads and sockets |
protected void |
disconnected()
The client has become disconnected from the server |
protected void |
flushConn()
send all buffered packets on their way this should be called after everything which causes us to wait for a reply. |
java.util.Enumeration<java.lang.String> |
getAllCommandNames()
|
java.util.Vector<Coords> |
getArtilleryAutoHit()
Get hexes designated for automatic artillery hits. |
IBoard |
getBoard()
Shortcut to game.board |
ClientCommand |
getCommand(java.lang.String commandName)
Returns the command associated with the specified name |
java.util.Enumeration<Entity> |
getEntities()
Returns an enumeration of the entities in game.entities |
Entity |
getEntity(int id)
|
int |
getFirstDeployableEntityNum()
Returns the number of the first deployable entity |
int |
getFirstEntityNum()
Returns the number of first selectable entity |
java.lang.String |
getHost()
|
Player |
getLocalPlayer()
Return the local player |
MapSettings |
getMapSettings()
|
GameTurn |
getMyTurn()
|
java.lang.String |
getName()
|
int |
getNextDeployableEntityNum(int entityId)
Returns the number of the next deployable entity |
int |
getNextEntityNum(int entityId)
Returns the number of the next selectable entity after the one given |
Player |
getPlayer(int idx)
Returns the individual player assigned the index parameter. |
java.util.Enumeration<Player> |
getPlayers()
Return an enumeration of the players in the game |
int |
getPort()
|
java.util.Enumeration<Entity> |
getSelectedEntities(EntitySelector selector)
Returns an Enumeration of the entities that match the
selection criteria. |
protected void |
handlePacket(Packet c)
|
boolean |
isMyTurn()
is it my turn? |
void |
moveEntity(int id,
MovePath md)
Send movement data for the given entity to the server. |
protected void |
receiveAttack(Packet c)
Loads entity firing data from the data in the net command |
protected void |
receiveBoard(Packet c)
Loads the board from the data in the net command. |
protected void |
receiveBuildingCollapse(Packet packet)
|
protected void |
receiveBuildingUpdateCF(Packet packet)
|
protected void |
receiveDeployMinefields(Packet packet)
|
protected void |
receiveEntities(Packet c)
Loads the entities from the data in the net command. |
protected void |
receiveEntityAdd(Packet packet)
|
protected void |
receiveEntityRemove(Packet packet)
|
protected void |
receiveEntityUpdate(Packet c)
Loads entity update data from the data in the net command. |
protected void |
receiveEntityVisibilityIndicator(Packet packet)
|
protected void |
receivePlayerInfo(Packet c)
Receives player information from the message packet. |
protected void |
receiveRemoveMinefield(Packet packet)
|
java.lang.String |
receiveReport(java.util.Vector<Report> v)
|
protected void |
receiveRevealMinefield(Packet packet)
|
protected void |
receiveSendingMinefields(Packet packet)
|
protected void |
receiveTurns(Packet packet)
Loads the turn list from the data in the packet |
protected void |
receiveUpdateMinefields(Packet packet)
|
void |
registerCommand(ClientCommand command)
Registers a new command in the client command table |
void |
retrieveServerInfo()
wtf is this? |
java.lang.String |
runCommand(java.lang.String cmd)
|
java.lang.String |
runCommand(java.lang.String[] args)
Runs the command |
protected void |
send(Packet packet)
send the message to the server |
void |
sendAddEntity(Entity entity)
Sends an "add entity" packet |
void |
sendAddSquadron(java.util.Vector<Entity> fighters)
Sends an "add squadron" packet This is not working, don't use it |
void |
sendAmmoChange(int nEntity,
int nWeapon,
int nAmmo)
Send mode-change data to the server |
void |
sendArtyAutoHitHexes(java.util.Vector<Coords> hexes)
Sends a "set Artillery Autohit Hexes" packet |
void |
sendAttackData(int aen,
java.util.Vector<EntityAction> attacks)
Send a weapon fire command to the server. |
void |
sendCalledShotChange(int nEntity,
int nEquip)
Send called shot change data to the server |
void |
sendChat(java.lang.String message)
Broadcast a general chat message from the local player |
void |
sendCustomInit(Player player)
Sends an "update custom initiative" packet |
void |
sendDeleteEntity(int id)
Sends a "delete entity" packet |
void |
sendDeployMinefields(java.util.Vector<Minefield> minefields)
Sends an "deploy minefields" packet |
void |
sendDone(boolean done)
Sends a "player done" message to the server. |
void |
sendGameOptions(java.lang.String password,
java.util.Vector<IBasicOption> options)
Send the game options to the server |
void |
sendLoadGame(java.io.File f)
sends a load game file to the server |
void |
sendMapDimensions(MapSettings settings)
Send the new map dimensions to the server |
void |
sendMapSettings(MapSettings settings)
Send the new map selection to the server |
void |
sendModeChange(int nEntity,
int nEquip,
int nMode)
Send mode-change data to the server |
void |
sendPlanetaryConditions(PlanetaryConditions conditions)
Send the planetary Conditions to the server |
void |
sendPlayerInfo()
Sends the info associated with the local player. |
void |
sendRerollInitiativeRequest()
Sends a "reroll initiative" message to the server. |
void |
sendSystemModeChange(int nEntity,
int nSystem,
int nMode)
Send system mode-change data to the server |
void |
sendUnloadStranded(int[] entityIds)
Send command to unload stranded entities to the server |
void |
sendUpdateEntity(Entity entity)
Sends an "update entity" packet |
void |
setName(java.lang.String newN)
|
protected void |
updateConnection()
call this once to update the connection |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CLIENT_COMMAND
public int local_pn
public IGame game
public java.lang.String phaseReport
public java.lang.String roundReport
public java.util.Map<java.lang.String,Client> bots
| Constructor Detail |
|---|
public Client(java.lang.String name,
java.lang.String host,
int port)
name - the player name for this clienthost - the hostnameport - the host port| Method Detail |
|---|
protected void updateConnection()
public boolean connect()
public void die()
protected void disconnected()
public java.util.Vector<Coords> getArtilleryAutoHit()
public java.util.Enumeration<Player> getPlayers()
public Entity getEntity(int id)
public Player getPlayer(int idx)
public Player getLocalPlayer()
public java.util.Enumeration<Entity> getSelectedEntities(EntitySelector selector)
Enumeration of the entities that match the
selection criteria.
public int getFirstEntityNum()
public int getNextEntityNum(int entityId)
public int getFirstDeployableEntityNum()
public int getNextDeployableEntityNum(int entityId)
public IBoard getBoard()
public java.util.Enumeration<Entity> getEntities()
public MapSettings getMapSettings()
public void changePhase(IGame.Phase phase)
public void addCloseClientListener(CloseClientListener l)
l - the game listener.public void retrieveServerInfo()
public boolean isMyTurn()
public GameTurn getMyTurn()
public boolean canUnloadStranded()
public void sendUnloadStranded(int[] entityIds)
protected void changeTurnIndex(int index)
public void sendModeChange(int nEntity,
int nEquip,
int nMode)
public void sendCalledShotChange(int nEntity,
int nEquip)
public void sendSystemModeChange(int nEntity,
int nSystem,
int nMode)
public void sendAmmoChange(int nEntity,
int nWeapon,
int nAmmo)
public void moveEntity(int id,
MovePath md)
public void deploy(int id,
Coords c,
int nFacing,
int elevation)
id - - the int ID of the deployed entityc - - the Coords where the entity should be deployednFacing - - the int direction the entity should face
public void deploy(int id,
Coords c,
int nFacing,
int elevation,
java.util.List<Entity> loadedUnits,
boolean assaultDrop)
id - - the int ID of the deployed entityc - - the Coords where the entity should be deployednFacing - - the int direction the entity should faceloadedUnits - - a List of units that start the game being
transported byt the deployed entity.assaultDrop - - true if deployment is an assault drop
public void sendAttackData(int aen,
java.util.Vector<EntityAction> attacks)
public void sendGameOptions(java.lang.String password,
java.util.Vector<IBasicOption> options)
public void sendMapSettings(MapSettings settings)
public void sendMapDimensions(MapSettings settings)
public void sendPlanetaryConditions(PlanetaryConditions conditions)
public void sendChat(java.lang.String message)
public void sendDone(boolean done)
public void sendRerollInitiativeRequest()
public void sendPlayerInfo()
public void sendAddEntity(Entity entity)
public void sendAddSquadron(java.util.Vector<Entity> fighters)
public void sendDeployMinefields(java.util.Vector<Minefield> minefields)
public void sendArtyAutoHitHexes(java.util.Vector<Coords> hexes)
public void sendUpdateEntity(Entity entity)
public void sendCustomInit(Player player)
public void sendDeleteEntity(int id)
public void sendLoadGame(java.io.File f)
protected void receivePlayerInfo(Packet c)
protected void receiveTurns(Packet packet)
protected void receiveBoard(Packet c)
protected void receiveEntities(Packet c)
protected void receiveEntityUpdate(Packet c)
protected void receiveEntityAdd(Packet packet)
protected void receiveEntityRemove(Packet packet)
protected void receiveEntityVisibilityIndicator(Packet packet)
protected void receiveDeployMinefields(Packet packet)
protected void receiveSendingMinefields(Packet packet)
protected void receiveRevealMinefield(Packet packet)
protected void receiveRemoveMinefield(Packet packet)
protected void receiveUpdateMinefields(Packet packet)
protected void receiveBuildingUpdateCF(Packet packet)
protected void receiveBuildingCollapse(Packet packet)
protected void receiveAttack(Packet c)
public java.lang.String receiveReport(java.util.Vector<Report> v)
protected void send(Packet packet)
protected void flushConn()
protected void handlePacket(Packet c)
public java.lang.String getName()
public int getPort()
public java.lang.String getHost()
public void setName(java.lang.String newN)
public java.lang.String runCommand(java.lang.String cmd)
text - a client command with CLIENT_COMMAND prepended.public java.lang.String runCommand(java.lang.String[] args)
args - the command and it's arguments with the CLIENT_COMMAND already
removed, and the string tokenized.public void registerCommand(ClientCommand command)
registerCommand in interface IClientCommandHandlerpublic ClientCommand getCommand(java.lang.String commandName)
getCommand in interface IClientCommandHandlerpublic java.util.Enumeration<java.lang.String> getAllCommandNames()
getAllCommandNames in interface IClientCommandHandler
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||