JavaQuest.Client
Class CClient

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--JavaQuest.Client.CClient
All Implemented Interfaces:
IClientProxy, java.rmi.Remote, java.lang.Runnable, java.io.Serializable

public class CClient
extends java.rmi.server.UnicastRemoteObject
implements IClientProxy, java.lang.Runnable

Main connection class, to control the connection from client to server and from server to client

See Also:
CClientFrame, CPlayer, IClientThreadProxy, CUtils, Serialized Form

Field Summary
private  boolean m_bOn
          Is the client to the server or not
private  boolean m_Bool
          return Component for all boolean
private  boolean m_bTimeRemaining
          Is the client on turn or not
private  javax.swing.DefaultListModel m_defaultListModel
          Contents all entries of a JList
protected  CClientFrame m_oClientFrame
          Reference on CClientFrame
private  IClientThreadProxy m_oServer
          Communication partner on Server
private  CPlayer m_Player
          Reference to Player on Server
private  java.lang.String m_sIP
          stores Server IP
private  java.lang.String m_sName
          The alias-Name of the client
private  java.lang.String m_String
          return Component for all Strings
private  java.util.Vector m_Vector
          return Component for all Vectors
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
csf, port, portFactoryParamTypes, portParamTypes, serialVersionUID, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
log, logname
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
CClient(java.lang.String _sName, CClientFrame _oClientFrame, java.lang.String _sIP)
          Constructor
 
Method Summary
 boolean activate(int _iSeconds)
          activate Method for the server to initiate the beginTurn-Method
 boolean activateItem(int _iItem)
          activateItem Method for the client to activate an Item on the server
 boolean deactivate()
          deactivate Method for the server to initiate the endTurn-Method, if the time is over
 boolean deactivateItem(int _iItem)
          deactivateItem Method for the client to deactivate an Item on the server
 void endThread()
          endThread is used to end the communication-thread
 void endTurn()
          endTurn Method for the client to end the turn on the server
protected  boolean execute(int _iCmdIndex)
          execute Method for the client to execute a command on the server
 void gameover()
          gameOver Method for the server to let the hero die, if his Health-Points are zero
protected  java.lang.String getInfo(CField _oField)
          getInfo Method for the client to get Info about a Field on the Map
protected  java.util.Vector getItemsActive()
          getItemsActive Method for the client to get an Vector of the active Items from the server
protected  java.util.Vector getItemsInactive()
          getItemsInactive Method for the client to get an Vector of the inactive Items from the server
 CPlayer getPlayer()
          getPlayer get the Player to locate the Position for center the Map
 java.util.Vector getPossibleCommands(CField _oField)
          getPossibleCommands get the possible commands from server to show it as Popup Menuitems
 boolean getServerReference()
          getServerReference to get the reference to the server when connecting
protected  boolean getTimeRemaining()
          getTimeRemaining returns if the client has some time
protected  void ListRefresh()
          ListRefresh is used to refresh the lists with the active and inactive items
it will be initiated on maprefresh and an activateItem, deactivateItem
 void maprefresh(CMap _oMap)
          maprefresh Method for the server to refresh the GUI after an action was made by client
 void printMessage(java.lang.String _sMessage, boolean _bPopup)
          printMessage Method for the server to popup a DialogBox or log the message in the errorlogfile
 void run()
          run the "main"-Method for all JAVA-Threads on communication
protected  void setTimeRemaining(boolean _bTimeRemaining)
          setTimeRemaining sets false when the time is over
 void shutdown()
          shutdown Method for the server to shutdown all clients, if the server is going shutdown
 void updateVitalForceValues()
          updateVitalForceValues Method to update the Health, Moveability, CubesAttack, CubesDefense
private  javax.swing.DefaultListModel Vector2ListModel(java.util.Vector _vector)
          Vector2ListModel parse a vector to an DefaultListModel Object
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
, clone, exportObject, exportObject, exportObject, exportObject, readObject, reexport, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

m_defaultListModel

private javax.swing.DefaultListModel m_defaultListModel
Contents all entries of a JList

m_bOn

private boolean m_bOn
Is the client to the server or not

m_bTimeRemaining

private boolean m_bTimeRemaining
Is the client on turn or not

m_sName

private java.lang.String m_sName
The alias-Name of the client

m_oServer

private IClientThreadProxy m_oServer
Communication partner on Server

m_oClientFrame

protected CClientFrame m_oClientFrame
Reference on CClientFrame

m_Player

private CPlayer m_Player
Reference to Player on Server

m_sIP

private java.lang.String m_sIP
stores Server IP

m_String

private java.lang.String m_String
return Component for all Strings

m_Vector

private java.util.Vector m_Vector
return Component for all Vectors

m_Bool

private boolean m_Bool
return Component for all boolean
Constructor Detail

CClient

public CClient(java.lang.String _sName,
               CClientFrame _oClientFrame,
               java.lang.String _sIP)
        throws java.rmi.RemoteException
Constructor
Parameters:
String - _sName the Aliasname of the player
CClientFrame - _oClientFrame reference to CClientFrame
String - _sIP the IP-Adress to connect
Throws:
java.rmi.RemoteException -  
Method Detail

getInfo

protected java.lang.String getInfo(CField _oField)
getInfo Method for the client to get Info about a Field on the Map
Parameters:
CField - _oField the clicked Field on the Map
Returns:
String the available information

activateItem

public boolean activateItem(int _iItem)
activateItem Method for the client to activate an Item on the server
Parameters:
int - _iItem
Returns:
boolean

deactivateItem

public boolean deactivateItem(int _iItem)
deactivateItem Method for the client to deactivate an Item on the server
Parameters:
int - _iItem
Returns:
boolean

execute

protected boolean execute(int _iCmdIndex)
execute Method for the client to execute a command on the server
Parameters:
int - _iCmdIndex
Returns:
boolean

getItemsActive

protected java.util.Vector getItemsActive()
getItemsActive Method for the client to get an Vector of the active Items from the server
Returns:
Vector active Itemobjects

getItemsInactive

protected java.util.Vector getItemsInactive()
getItemsInactive Method for the client to get an Vector of the inactive Items from the server
Returns:
Vector inactive Itemobjects

getPossibleCommands

public java.util.Vector getPossibleCommands(CField _oField)
getPossibleCommands get the possible commands from server to show it as Popup Menuitems
Parameters:
CField - _oField
Returns:
Vector with all Commands

endTurn

public void endTurn()
endTurn Method for the client to end the turn on the server

getPlayer

public CPlayer getPlayer()
getPlayer get the Player to locate the Position for center the Map
Returns:
CPlayer

maprefresh

public void maprefresh(CMap _oMap)
                throws java.rmi.RemoteException
maprefresh Method for the server to refresh the GUI after an action was made by client
Specified by:
maprefresh in interface IClientProxy
Parameters:
CMap - _oMap

updateVitalForceValues

public void updateVitalForceValues()
updateVitalForceValues Method to update the Health, Moveability, CubesAttack, CubesDefense

shutdown

public void shutdown()
              throws java.rmi.RemoteException
shutdown Method for the server to shutdown all clients, if the server is going shutdown
Specified by:
shutdown in interface IClientProxy
Throws:
java.rmi.RemoteException -  

gameover

public void gameover()
              throws java.rmi.RemoteException
gameOver Method for the server to let the hero die, if his Health-Points are zero
Specified by:
gameover in interface IClientProxy
Throws:
java.rmi.RemoteException -  

printMessage

public void printMessage(java.lang.String _sMessage,
                         boolean _bPopup)
                  throws java.rmi.RemoteException
printMessage Method for the server to popup a DialogBox or log the message in the errorlogfile
Specified by:
printMessage in interface IClientProxy
Parameters:
String - _sMessage the message wich the server tells
(Hey please tell me a story of a horse :) )
boolean - _bPopup if true, a DialogBox will be opened
Throws:
java.rmi.RemoteException -  

activate

public boolean activate(int _iSeconds)
                 throws java.rmi.RemoteException
activate Method for the server to initiate the beginTurn-Method
Specified by:
activate in interface IClientProxy
Parameters:
int - _iSeconds time for the client in a turn
Returns:
boolean
Throws:
java.rmi.RemoteException -  

deactivate

public boolean deactivate()
                   throws java.rmi.RemoteException
deactivate Method for the server to initiate the endTurn-Method, if the time is over
Specified by:
deactivate in interface IClientProxy
Returns:
boolean
Throws:
java.rmi.RemoteException -  

Vector2ListModel

private javax.swing.DefaultListModel Vector2ListModel(java.util.Vector _vector)
Vector2ListModel parse a vector to an DefaultListModel Object
Parameters:
Vector - _vector
Returns:
DefaultListModel

getServerReference

public boolean getServerReference()
getServerReference to get the reference to the server when connecting
Returns:
boolean is the connection successful?

getTimeRemaining

protected boolean getTimeRemaining()
getTimeRemaining returns if the client has some time
Returns:
boolean

setTimeRemaining

protected void setTimeRemaining(boolean _bTimeRemaining)
setTimeRemaining sets false when the time is over
Parameters:
boolean -  

endThread

public void endThread()
endThread is used to end the communication-thread

ListRefresh

protected void ListRefresh()
ListRefresh is used to refresh the lists with the active and inactive items
it will be initiated on maprefresh and an activateItem, deactivateItem

run

public void run()
run the "main"-Method for all JAVA-Threads on communication
Specified by:
run in interface java.lang.Runnable