energyTycoon.game
Class ClientGame

java.lang.Object
  extended by java.lang.Thread
      extended by energyTycoon.game.Game
          extended by energyTycoon.game.ClientGame
All Implemented Interfaces:
PowerStationListener, java.lang.Runnable

public class ClientGame
extends Game
implements PowerStationListener

Client Game engine, will connect to server

Author:
Léo CARNAUT-DELORD

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class energyTycoon.game.Game
MESS_ALERT, MESS_INFO, MESS_PERSO, MESS_SUCCESS
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ClientGame(Client client, int gameId, int playerId, java.lang.String gameName, int scriptId, int startMoney, int nbMaxPlayer, int nbPlayer)
          Client Game engine constructor
 
Method Summary
 void addCustomer(Customer cust)
          add a customer to the list
 void addPlayer(int playerId, java.lang.String playerName)
          add a distant player
 void addPowerStationGroup(PowerStationGroup psg)
          add a power station group
 void addPowerStationType(PowerStationType pst)
          add a power station type
 void changeDate(int day, Season season, int year)
          change date
 void compute()
          compute a frame
 java.util.Vector<Customer> getAllCustomers()
           
 java.util.List<ExchangeClient> getAllExchanges()
          return exchange list
 City getCity(int id)
          get the city with the given id
 NetworkDistantPlayer getPlayerFromId(int playerId)
          get a distant player from his id
 int getPlayerId()
          get the player Id
 PowerStationGroup getPowerStationGroupFromId(int id)
          get a power group from its id
 PowerStationType getPowerStationTypeFromId(int id)
           
 boolean isCustomerCity(int id)
          knowing if a customer is a city
 void looseOnePlayer(int playerId)
          A player disconnect
 void newPlayer(int playerId, java.lang.String playerName)
           
 void powerStation_askBuild(int playerId, int powerStationTypeId)
           
 void powerStation_askChangeUseRate(int powerStationId, int useRate)
           
 void powerStation_askDelete(int powerStationId)
           
 void powerStation_askRestore(int powerStationId)
           
 void powerStation_askUpdate(int powerStationId, int generation)
           
 void run()
          run the thread
 void sendNetworkMessage(java.lang.String message)
          send network message
 void setIsNight(boolean isNight)
          set if it is the night or not
 void setTime(int time)
          set game timer
 void setWeather(int weather)
           
 void setWind(int wind)
           
 
Methods inherited from class energyTycoon.game.Game
getDay, getGameId, getGameName, getHour, getNbFramePerYear, getNbMaxPlayer, getNbPlayer, getScriptId, getSeason, getStringDate, getTime, getWeather, getWind, getYearTime, isNight, setStartDate
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientGame

public ClientGame(Client client,
                  int gameId,
                  int playerId,
                  java.lang.String gameName,
                  int scriptId,
                  int startMoney,
                  int nbMaxPlayer,
                  int nbPlayer)
Client Game engine constructor

Parameters:
client - client reference
gameId - game identifier
gameName - name of the game
scriptId - script identifier
startMoney - money the player start with
nbMaxPlayer - maximum number of player
nbPlayer - current players
Method Detail

compute

public void compute()
Description copied from class: Game
compute a frame

Specified by:
compute in class Game

run

public void run()
Description copied from class: Game
run the thread

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class Game

getPlayerId

public int getPlayerId()
get the player Id

Returns:

powerStation_askUpdate

public void powerStation_askUpdate(int powerStationId,
                                   int generation)
Parameters:
powerStationId -
generation -

powerStation_askRestore

public void powerStation_askRestore(int powerStationId)
Parameters:
powerStationId -

powerStation_askChangeUseRate

public void powerStation_askChangeUseRate(int powerStationId,
                                          int useRate)
Parameters:
powerStationId -
useRate -

powerStation_askDelete

public void powerStation_askDelete(int powerStationId)
Parameters:
powerStationId -

powerStation_askBuild

public void powerStation_askBuild(int playerId,
                                  int powerStationTypeId)
Parameters:
playerId -
powerStationTypeId -

looseOnePlayer

public void looseOnePlayer(int playerId)
A player disconnect

Parameters:
playerId -

newPlayer

public void newPlayer(int playerId,
                      java.lang.String playerName)
Parameters:
playerId -
playerName -

addPowerStationType

public void addPowerStationType(PowerStationType pst)
add a power station type

Specified by:
addPowerStationType in interface PowerStationListener
Parameters:
pst -

addPowerStationGroup

public void addPowerStationGroup(PowerStationGroup psg)
add a power station group

Parameters:
psg -

getPowerStationGroupFromId

public PowerStationGroup getPowerStationGroupFromId(int id)
get a power group from its id

Parameters:
id -
Returns:

getPowerStationTypeFromId

public PowerStationType getPowerStationTypeFromId(int id)

addCustomer

public void addCustomer(Customer cust)
add a customer to the list

Parameters:
cust -

getAllCustomers

public java.util.Vector<Customer> getAllCustomers()
Returns:

isCustomerCity

public boolean isCustomerCity(int id)
knowing if a customer is a city

Parameters:
id - customer id
Returns:
true if the customer is a city

getCity

public City getCity(int id)
get the city with the given id

Overrides:
getCity in class Game
Parameters:
id - customer id
Returns:
null if customer isn't a city

changeDate

public void changeDate(int day,
                       Season season,
                       int year)
change date

Parameters:
day -
season -
year -

setTime

public void setTime(int time)
set game timer

Parameters:
time -

setWeather

public void setWeather(int weather)

setWind

public void setWind(int wind)

addPlayer

public void addPlayer(int playerId,
                      java.lang.String playerName)
add a distant player

Parameters:
playerId -
playerName -

getAllExchanges

public java.util.List<ExchangeClient> getAllExchanges()
return exchange list

Returns:

sendNetworkMessage

public void sendNetworkMessage(java.lang.String message)
send network message

Parameters:
message -

getPlayerFromId

public NetworkDistantPlayer getPlayerFromId(int playerId)
get a distant player from his id

Parameters:
playerId -
Returns:

setIsNight

public void setIsNight(boolean isNight)
set if it is the night or not

Parameters:
isNight -