energyTycoon.player
Class NetworkServerPlayer

java.lang.Object
  extended by energyTycoon.player.Player
      extended by energyTycoon.player.FullPlayer
          extended by energyTycoon.player.NetworkServerPlayer

public class NetworkServerPlayer
extends FullPlayer

represent a player seen by the server

Author:
Leo CARNAUT-DELORD

Field Summary
 java.util.List<Supplying> supplyings
           
 
Constructor Summary
NetworkServerPlayer(ServerGame server, ServerClient client, int playerId, java.lang.String playerName, int money)
           
 
Method Summary
 void addExchange(ExchangeServer exchange)
          add the exchange to exchange list
 void buildPowerStation(int groupId, int generation)
           
 void buy()
          Buy to all provider, but providers control all
 void changeCityPrice(int cityId, int price)
          the player change his price in the city
 void changeExchangeValues(int providerId, int sellPrice, int sellMax, int buyMaxPrice, int buyMax)
          change exchange properties
 void compute(int time)
          compute the player
 void computeEndFrame()
          computed at the end of the frame
 void computeEndOfMonth()
          to do at the end of the month
 void countProCustomers(boolean reset)
          Count pro customer number
 void delete()
           
 void deletePowerStation(int powerStationId)
          delete the power station
 void disconnectClient()
           
 void earn(int money)
          the player earns money
 void explodeStation(int powerStationId, int pollution, java.lang.String message)
          destroy the given central
 void gainEnergy(int quantity)
          the player gains some energy
 int getEnergyLeft()
          compute the amount of energy still available for this frame
 ServerGame getGame()
           
 int getMaxStockPerPro()
          compute how much energy is available for each pro customer
 void leaveGame(java.lang.String message)
          End the game for this player
 void looseEnergy(int quantity)
          the player loose some energy
 void looseMoney(int money)
          the player looses money
 boolean needBuy()
          knowing if the player still need to buy
 void powerStation_generationHasBeenChangedTo(int generation)
          Say the client his power station has been updated
 void powerStation_useRateHasBeenChangedTo(int useRate)
          Say the client that his power station changed its use rate
 void provide()
          Provide all customers
 void receiveMessage(java.lang.String message)
           
 void sell()
          Try to sell energy left to everyone
 void sendFrameMessage(java.lang.String message)
          Send frame informations
 void sendMessageToThisPlayer(java.lang.String message)
          send message to this player
 void sendPlayerList(java.util.Vector<NetworkServerPlayer> players)
          send player list to the client
 void setAndSendName(java.lang.String name)
          change player name and send it to the client
 void setInCity(int cityId, int price)
          the player set in the city
 boolean startGame()
           
 
Methods inherited from class energyTycoon.player.FullPlayer
addPowerStationGeneration, addPowerStationGroup, askChangeClientPrice, build, changeExchangeMinAndMax, changeMoney, citySetting, deletePowerStationsInRemoveList, deleteStation, eraseBuilding, getAllAvailablePowerStationGroup, getAllAvailablePowerStationType, getBattery, getGroupMaxGenerationAvailable, getMaximumStock, getMinimumStock, getMoney, getNbPowerStationByType, getPowerStation, getResearchKnownEnergyBudget, getResearchNewEnergyBudget, getTotalPollution, newMessage, quitCity, setMaximumStock, setMinimumStock, setMoney, setResearchBudget
 
Methods inherited from class energyTycoon.player.Player
getEcology, getId, getName, setEcology
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supplyings

public java.util.List<Supplying> supplyings
Constructor Detail

NetworkServerPlayer

public NetworkServerPlayer(ServerGame server,
                           ServerClient client,
                           int playerId,
                           java.lang.String playerName,
                           int money)
Method Detail

delete

public void delete()
Specified by:
delete in class FullPlayer

startGame

public boolean startGame()

receiveMessage

public void receiveMessage(java.lang.String message)

sendMessageToThisPlayer

public void sendMessageToThisPlayer(java.lang.String message)
send message to this player

Parameters:
message - message to send

setAndSendName

public void setAndSendName(java.lang.String name)
change player name and send it to the client

Parameters:
name - new name

leaveGame

public void leaveGame(java.lang.String message)
End the game for this player

Parameters:
message - message to send

compute

public void compute(int time)
compute the player

Parameters:
time - timer in second

computeEndFrame

public void computeEndFrame()
computed at the end of the frame


provide

public void provide()
Provide all customers


powerStation_useRateHasBeenChangedTo

public void powerStation_useRateHasBeenChangedTo(int useRate)
Say the client that his power station changed its use rate

Parameters:
useRate - new use rate

powerStation_generationHasBeenChangedTo

public void powerStation_generationHasBeenChangedTo(int generation)
Say the client his power station has been updated

Parameters:
generation - new power station generation

sendFrameMessage

public void sendFrameMessage(java.lang.String message)
Send frame informations

Parameters:
message - shared informations about game

countProCustomers

public void countProCustomers(boolean reset)
Count pro customer number

Parameters:
reset - true if we must reset the frame transaction

getMaxStockPerPro

public int getMaxStockPerPro()
compute how much energy is available for each pro customer

Returns:
available energy for each customer

buy

public void buy()
Buy to all provider, but providers control all


sell

public void sell()
Try to sell energy left to everyone


earn

public void earn(int money)
the player earns money

Parameters:
money - money he earns

looseMoney

public void looseMoney(int money)
the player looses money

Parameters:
money - money he looses

looseEnergy

public void looseEnergy(int quantity)
the player loose some energy

Parameters:
quantity - energy lost

gainEnergy

public void gainEnergy(int quantity)
the player gains some energy

Parameters:
quantity - energy gained

getEnergyLeft

public int getEnergyLeft()
compute the amount of energy still available for this frame

Returns:
energy available : left + battery

needBuy

public boolean needBuy()
knowing if the player still need to buy

Returns:
true if the player need energy

disconnectClient

public void disconnectClient()

buildPowerStation

public void buildPowerStation(int groupId,
                              int generation)
Parameters:
groupId -
generation -

setInCity

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

Parameters:
cityId - city Id
price - energy price

changeCityPrice

public void changeCityPrice(int cityId,
                            int price)
the player change his price in the city

Parameters:
cityId - city Id
price - energy price

sendPlayerList

public void sendPlayerList(java.util.Vector<NetworkServerPlayer> players)
send player list to the client

Parameters:
players -

addExchange

public void addExchange(ExchangeServer exchange)
add the exchange to exchange list

Parameters:
exchange -

changeExchangeValues

public void changeExchangeValues(int providerId,
                                 int sellPrice,
                                 int sellMax,
                                 int buyMaxPrice,
                                 int buyMax)
change exchange properties

Parameters:
providerId -
sellPrice -
sellMax -
buyMaxPrice -
buyMax -

computeEndOfMonth

public void computeEndOfMonth()
to do at the end of the month


getGame

public ServerGame getGame()
Returns:

explodeStation

public void explodeStation(int powerStationId,
                           int pollution,
                           java.lang.String message)
destroy the given central

Overrides:
explodeStation in class FullPlayer
Parameters:
powerStationId -
pollution -
message -

deletePowerStation

public void deletePowerStation(int powerStationId)
delete the power station

Overrides:
deletePowerStation in class FullPlayer
Parameters:
powerStationId -