energyTycoon.client
Class ClientManagement

java.lang.Object
  extended by energyTycoon.client.ClientManagement
All Implemented Interfaces:
GameListener, MenuListener

public class ClientManagement
extends java.lang.Object
implements MenuListener, GameListener

client management class

Author:
Léo CARNAUT-DELORD

Constructor Summary
ClientManagement()
           
 
Method Summary
 void buildPowerStation(PowerStationGroup psg, int generation)
          build a power station
 void changeBudget(int newBudget, int knowingBudget)
          change research budget
 void changePriceInCity(int cityId, int price)
          the player change his price
 void createDistantGame(java.lang.String gameName, int scriptId, int startingMoney, int maxPlayer)
          open a game on a server
 PhysicPlayer createPhysicPlayer(int playerId)
           
 java.util.List<PowerStationType> getAllAvailablePowerStationType(int groupId)
           
 java.util.Vector<Customer> getAllCustomers()
          get all customers
 java.util.List<PowerStationGroup> getAllGroupsAvailable()
          get all groups that player can build
 java.util.List<PowerStation> getAllStations()
          get all player stations
 ClientGame getGame()
          get the game
 java.util.Vector<java.lang.String> getLocalScripts()
          return all existing scripts
 PhysicPlayer getPlayer()
          get the user player
 java.lang.String[] getScripts()
          return all existing scripts
 void giveUpConnection()
          forget server connection
 void joinGame(int gameId)
          join a distant game
 void joinServer(java.lang.String server, int port)
          try to connect to server
 void leaveGame()
           
 void leaveServer()
          Disconnect from server
 void lostConnection()
           
 void quitGame()
          Quit the current game
 void quitMenu()
          exit menu (cross)
 void runServer(java.lang.String gameName, int scriptId, int startingMoney, int maxPlayer, int port)
          host a game on the client computer
 void sendChatMessage(java.lang.String message)
          Send a chat message to other players
 void setGame(ClientGame game)
           
 void setInCity(int cityId, int price)
          the player want to set in a city
 void setScripts(java.lang.String[] scripts)
          Change script list
 void startGame()
          start the game (play button pressed)
 void startMenu()
          launch menu
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientManagement

public ClientManagement()
Method Detail

startMenu

public void startMenu()
launch menu


quitMenu

public void quitMenu()
exit menu (cross)

Specified by:
quitMenu in interface MenuListener

getScripts

public java.lang.String[] getScripts()
return all existing scripts

Specified by:
getScripts in interface MenuListener
Returns:
all available scripts

getLocalScripts

public java.util.Vector<java.lang.String> getLocalScripts()
return all existing scripts

Specified by:
getLocalScripts in interface MenuListener
Returns:
all available scripts

joinServer

public void joinServer(java.lang.String server,
                       int port)
try to connect to server

Specified by:
joinServer in interface MenuListener
Parameters:
server - server name
port - port to connect on

giveUpConnection

public void giveUpConnection()
forget server connection

Specified by:
giveUpConnection in interface MenuListener

runServer

public void runServer(java.lang.String gameName,
                      int scriptId,
                      int startingMoney,
                      int maxPlayer,
                      int port)
host a game on the client computer

Specified by:
runServer in interface MenuListener
Parameters:
scriptId - script id
gameName - game name
startingMoney - the money players start with
maxPlayer - maximum player number
port - server port

joinGame

public void joinGame(int gameId)
join a distant game

Specified by:
joinGame in interface MenuListener
Parameters:
gameId - game identifier

createDistantGame

public void createDistantGame(java.lang.String gameName,
                              int scriptId,
                              int startingMoney,
                              int maxPlayer)
open a game on a server

Specified by:
createDistantGame in interface MenuListener
Parameters:
scriptId - script id
gameName - game name
startingMoney - money players start with
maxPlayer - maximum number of player in this game

quitGame

public void quitGame()
Quit the current game

Specified by:
quitGame in interface GameListener
Specified by:
quitGame in interface MenuListener

startGame

public void startGame()
start the game (play button pressed)

Specified by:
startGame in interface MenuListener

sendChatMessage

public void sendChatMessage(java.lang.String message)
Send a chat message to other players

Specified by:
sendChatMessage in interface GameListener
Specified by:
sendChatMessage in interface MenuListener
Parameters:
message - message the user send

setScripts

public void setScripts(java.lang.String[] scripts)
Change script list

Parameters:
scripts - scripts array

leaveGame

public void leaveGame()
Specified by:
leaveGame in interface MenuListener

leaveServer

public void leaveServer()
Disconnect from server

Specified by:
leaveServer in interface MenuListener

lostConnection

public void lostConnection()

getAllStations

public java.util.List<PowerStation> getAllStations()
Description copied from interface: GameListener
get all player stations

Specified by:
getAllStations in interface GameListener
Returns:
power station list

getAllAvailablePowerStationType

public java.util.List<PowerStationType> getAllAvailablePowerStationType(int groupId)
Specified by:
getAllAvailablePowerStationType in interface GameListener
Returns:

createPhysicPlayer

public PhysicPlayer createPhysicPlayer(int playerId)

getAllGroupsAvailable

public java.util.List<PowerStationGroup> getAllGroupsAvailable()
Description copied from interface: GameListener
get all groups that player can build

Specified by:
getAllGroupsAvailable in interface GameListener
Returns:

getAllCustomers

public java.util.Vector<Customer> getAllCustomers()
get all customers

Specified by:
getAllCustomers in interface GameListener
Returns:

setGame

public void setGame(ClientGame game)
Parameters:
game -

buildPowerStation

public void buildPowerStation(PowerStationGroup psg,
                              int generation)
build a power station

Specified by:
buildPowerStation in interface GameListener
Parameters:
psg - group
generation - power generation

getGame

public ClientGame getGame()
get the game

Specified by:
getGame in interface GameListener
Returns:

setInCity

public void setInCity(int cityId,
                      int price)
the player want to set in a city

Specified by:
setInCity in interface GameListener
Parameters:
cityId - the city Id where we want to set
price - energy price for this city

changePriceInCity

public void changePriceInCity(int cityId,
                              int price)
the player change his price

Specified by:
changePriceInCity in interface GameListener
Parameters:
cityId - the city Id where we want to change price
price - energy price for this city

changeBudget

public void changeBudget(int newBudget,
                         int knowingBudget)
change research budget

Specified by:
changeBudget in interface GameListener
Parameters:
newBudget -
knowingBudget -

getPlayer

public PhysicPlayer getPlayer()
get the user player

Specified by:
getPlayer in interface GameListener