j4cevo
Class Player

java.lang.Object
  extended byj4cevo.MemoryBasedObject
      extended byj4cevo.Player
All Implemented Interfaces:
ChangeInformer, PlayerBase

public class Player
extends j4cevo.MemoryBasedObject
implements PlayerBase, ChangeInformer

Player is the root for all j4cEvo managed objects - according get methods are provided. Additionally Player has methods to control nationwide stuff: eg. what is researched, government and taxrate.


Nested Class Summary
static class Player.ChangeAdapter
           
static interface Player.ChangeListener
           
 class Player.Domain
           
static class Player.ListChangeAdapter
           
static interface Player.ListChangeListener
           
 class Player.Movement
          A Movement has all information about a movement that occurs during an enemy turn.
static interface Player.Research
          Research contains the information about the research of a particular advance.
 class Player.Wonder
          Wonders have different effects, see the game rules.
 
Constructor Summary
Player()
           
 
Method Summary
 int acceptContact()
          Accepts diplomatic contact with enemy who tried to contact this player
 int acceptOffer()
          Accepts latest offer of negotiation opponent.
 int breakNegotiation()
          Unagreed break of negotiation
 int cancelTreaty()
          Cancels current treaty with the enemy who was contacted lately.
 boolean canPerform(Job job, Tile location)
          Tests, whether all required advances and wonders are owned, to perform a job at a location
 void continueTurn()
          continueTurn is called after ending a negotiation call deactivation-code before returning
 void createLogger()
          hook for subclasses which want to use a different logger.
 int createModel(Domain domain)
          Create a model for a domain.
 void DebugMessage(java.lang.String s)
          Sends a debug message of level 1 to the server
 Age getAge()
           
 int getAnarchyStart()
          Gets the turn, when Anarchy started or 0 if there is no anarchy actually
 Brain getBrain()
           
 int getBuildCostModifier()
           
 ListenerSlot getChangeSlot()
          gets the slot for ChangeListener by convention there should be a local ChangeListener class
 Chart getChart(int type)
          request a chart
 java.util.Collection getCities()
          Gets all cities
 City getCity(Tile destination)
           
 int getCredibility()
           
 Player.Research getCurrentResearch()
          Gets advance researched.
 Model getCurrentResearchModel()
           
 int getDifficulty()
           
 Player.Domain getDomain(Domain domain)
           
 java.util.Collection getEnemies()
          Gets collection with all enemies, even dead ones
 java.util.Collection getEnemyUnits()
           
 int getExpectedIncome()
           
 int getExpectedResearch()
           
 Government getGovernment()
          Get the current government
 int getIndex()
           
 ListenerSlot getListChangeSlot()
           
 java.util.logging.Logger getLogger()
          The logger for this player. j4cEvo will use this logger to log events happening during this players turn.
 int getLuxuryRate()
          Gets the luxury rate in percent, each 3 luxury points in a city make one unhappy citizen happy
 Map getMap()
           
 int getMaxCredibility()
          maximum credibility still possible to achieve
 java.util.List getModels()
           
 int getMoney()
          Gets the actual amount of money
 int getNrPlayer()
           
 int getOptionFlags()
          Gets the options turned on in the Manipulation menu.
static Player getPlayer()
           
 int getProductionCost(Improvement improvement)
           
 int getRequiredResearchPoints()
          Gets the required research points for currently researched advance or model
 Player.Research getResearchFor(Advance advance)
           
 int getResearchPointsAccumulated()
           
 int getResearchRate()
          Gets the research rate in percent
 ShipInfo getShipInfo()
           
 int getStorageSizePerCitizen()
           
 int getTaxRate()
          Gets the tax rate in percent
 int getTributeDefined()
          defined each turn payment with other nations (+ received, - payed)
 int getTributePaid()
          last turn payment with other nations (+ received, - payed)
 int getTurn()
          Gets the current turn
 Unit getUnit(int key)
          Gets the unit for a key
 java.util.List getUnits()
          Gets all units of this player
 int getWhatHappend()
          Gets flag what has happened last turn
 Player.Wonder getWonder(Wonder wonder)
          For some unknown reason wonder is not provided as part of GameData but for each Player.
 ByteMap getZOCMap()
           
 boolean hasHappend(int flag)
          Gets whether event has happend
 boolean hasNationalProject(Improvement improvement)
          Checks whether a National Project is built already ( National Projects can be built once per player)
 boolean isAlive()
          Queries whether this Player is still alive
 int makeOffer(Offer offer)
          Makes an offer to the enemy.
 int noticeDecision()
          Notices latest decision of negotiation opponent.
 int rejectContact()
          Refuses diplomatic contact with enemy who tried to contact this player
 int researchModel()
          Starts research of a prior created model instead of researching an advance.
 int setGovernment(Government government)
          Set government form.
 int setModelCapability(Capability capability, int value)
          Sets the value for a capability of the model that will be researched Capabilities are available if the required advances are researched.
 int setRates(int tax, int luxury)
          Sets tax and luxury rates.
 int startAnarchy()
          Changes to anarchy.
 int stealAdvance(Advance advance)
          After capturing a city, this command might be possible, indicated by the phStealTech flag in getWhatHappened.
 java.lang.String toString()
           
 int turnDone()
          Signals the server this turn is finally done
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Player

public Player()
Method Detail

setGovernment

public int setGovernment(Government government)
Set government form. Only valid if period of anarchy has just ended this turn (phChangeGov flag set in RO.Happened). in Subject - desired government form (gAnarchy..gDemocracy)

Parameters:
government - The new government value
Returns:
serverCode
See Also:
startAnarchy()

setModelCapability

public int setModelCapability(Capability capability,
                              int value)
Sets the value for a capability of the model that will be researched Capabilities are available if the required advances are researched. Most basic capabilities are defense and attack (aka mcOffense). Capabilities usually add to weight and/or cost of a model (exception is conscript, which reduces cost)

Parameters:
capability - the requested capability
value - The new value for the capability
Returns:
serverCode
See Also:
researchModel()

setRates

public int setRates(int tax,
                    int luxury)
Sets tax and luxury rates. Trade will be utilized accordingly, percent remaining are utilized for research

Parameters:
tax - percent of trade to be converted to money
luxury - percent of trade to be converted to luxury points
Returns:
serverCode

getAge

public Age getAge()
Specified by:
getAge in interface PlayerBase

getAnarchyStart

public int getAnarchyStart()
Gets the turn, when Anarchy started or 0 if there is no anarchy actually

Returns:
turn, when Anarchy started or 0 if there is no anarchy actually
See Also:
setGovernment(j4cevo.Government), startAnarchy()

getBrain

public Brain getBrain()

getBuildCostModifier

public int getBuildCostModifier()

getChangeSlot

public ListenerSlot getChangeSlot()
Description copied from interface: ChangeInformer
gets the slot for ChangeListener by convention there should be a local ChangeListener class

Specified by:
getChangeSlot in interface ChangeInformer
Returns:
The changeSlot value
See Also:
Player.ChangeListener

getChart

public Chart getChart(int type)
request a chart

Parameters:
type - one of
Protocol.ChartType.stExplore - number of discovered tiles
Protocol.ChartType.stPop - sum of all city sizes
Protocol.ChartType.stScience - number of technologies in 1/100
Protocol.ChartType.stWork - number of MP spent by settlers for tile improvement
Protocol.ChartType.stMil - sum of combat unit cost
Returns:
the requested chart or null, if the server returns other than eOK
See Also:
Protocol.ChartType

getCities

public java.util.Collection getCities()
Gets all cities

Returns:
the cities, cast elements to City

getCity

public City getCity(Tile destination)

getCredibility

public int getCredibility()
Specified by:
getCredibility in interface PlayerBase

getCurrentResearch

public Player.Research getCurrentResearch()
Gets advance researched.

Returns:
serverCode

getCurrentResearchModel

public Model getCurrentResearchModel()

getDifficulty

public int getDifficulty()
Specified by:
getDifficulty in interface PlayerBase

getDomain

public Player.Domain getDomain(Domain domain)

getEnemies

public java.util.Collection getEnemies()
Gets collection with all enemies, even dead ones

Returns:
The enemies value

getEnemyUnits

public java.util.Collection getEnemyUnits()

getExpectedIncome

public int getExpectedIncome()

getExpectedResearch

public int getExpectedResearch()

getGovernment

public Government getGovernment()
Get the current government

Specified by:
getGovernment in interface PlayerBase
Returns:
the current government

getIndex

public int getIndex()
Specified by:
getIndex in interface PlayerBase

getListChangeSlot

public ListenerSlot getListChangeSlot()
Returns:
The listChangeSlot value
See Also:
Player.ListChangeListener

getLogger

public final java.util.logging.Logger getLogger()
The logger for this player. j4cEvo will use this logger to log events happening during this players turn. If you are unhappy with the logger and really need a special logger, overwrite createLogger. Normally changing handlers should be sufficient

Returns:
The logger value
See Also:
createLogger()

getLuxuryRate

public int getLuxuryRate()
Gets the luxury rate in percent, each 3 luxury points in a city make one unhappy citizen happy

Returns:
the current tax rate

getMap

public Map getMap()

getMaxCredibility

public int getMaxCredibility()
maximum credibility still possible to achieve

Returns:
The maxCredibility

getModels

public java.util.List getModels()
Specified by:
getModels in interface PlayerBase

getMoney

public int getMoney()
Gets the actual amount of money

Returns:
The money

getNrPlayer

public int getNrPlayer()

getOptionFlags

public int getOptionFlags()
Gets the options turned on in the Manipulation menu.

Returns:
might be testetd against the flags, eg. getOptionFlags() & Protocol.tfUncover
See Also:
Protocol.TestFlags

getProductionCost

public int getProductionCost(Improvement improvement)

getRequiredResearchPoints

public int getRequiredResearchPoints()
Gets the required research points for currently researched advance or model

Returns:
the required research points

getResearchFor

public Player.Research getResearchFor(Advance advance)

getResearchPointsAccumulated

public int getResearchPointsAccumulated()

getResearchRate

public int getResearchRate()
Gets the research rate in percent

Returns:
the current research rate

getShipInfo

public ShipInfo getShipInfo()
Specified by:
getShipInfo in interface PlayerBase

getStorageSizePerCitizen

public int getStorageSizePerCitizen()

getTaxRate

public int getTaxRate()
Gets the tax rate in percent

Returns:
the current tax rate

getTributeDefined

public int getTributeDefined()
defined each turn payment with other nations (+ received, - payed)

Returns:
The tributeDefined

getTributePaid

public int getTributePaid()
last turn payment with other nations (+ received, - payed)

Returns:
The tributePaid

getTurn

public int getTurn()
Gets the current turn

Returns:
The turn

getUnit

public Unit getUnit(int key)
Gets the unit for a key

Parameters:
key - of the unit
Returns:
the unit

getUnits

public java.util.List getUnits()
Gets all units of this player

Specified by:
getUnits in interface PlayerBase
Returns:
the units, custom AIs may need to cast the elements to their custom Unit class

getWhatHappend

public int getWhatHappend()
Gets flag what has happened last turn

Returns:
flags indicate what happened within the last turnaround
See Also:
Protocol.PlayerHappened

getWonder

public Player.Wonder getWonder(Wonder wonder)
For some unknown reason wonder is not provided as part of GameData but for each Player.

Parameters:
wonder - the wonder
Returns:
The wonder
See Also:
Protocol.Wonders

getZOCMap

public ByteMap getZOCMap()

isAlive

public boolean isAlive()
Queries whether this Player is still alive

Specified by:
isAlive in interface PlayerBase
Returns:
indicates whether this Player is still alive

DebugMessage

public void DebugMessage(java.lang.String s)
Sends a debug message of level 1 to the server

Parameters:
s - the string to display in the server debug window

acceptContact

public int acceptContact()
Accepts diplomatic contact with enemy who tried to contact this player

Returns:
serverCode @type.action

acceptOffer

public int acceptOffer()
Accepts latest offer of negotiation opponent.

Returns:
serverCode @type.action

breakNegotiation

public int breakNegotiation()
Unagreed break of negotiation

Returns:
serverCode @type.action

canPerform

public final boolean canPerform(Job job,
                                Tile location)
Tests, whether all required advances and wonders are owned, to perform a job at a location

Parameters:
job -
location -
See Also:
@type.rule

cancelTreaty

public int cancelTreaty()
Cancels current treaty with the enemy who was contacted lately. May be called either if enemy rejected contact or in diplomatic negotiation

Returns:
serverCode @type.action

continueTurn

public void continueTurn()
continueTurn is called after ending a negotiation call deactivation-code before returning

See Also:
finish turn, start negotiation

createLogger

public void createLogger()
hook for subclasses which want to use a different logger. Normally configuring the handler instead should be sufficient. The default name for the logger will be packageName.seatNumber


createModel

public int createModel(Domain domain)
Create a model for a domain. After adding required capabilities the model can be researched

Parameters:
domain -
Returns:
serverCode
See Also:
setModelCapability(j4cevo.Capability, int), researchModel()

hasHappend

public final boolean hasHappend(int flag)
Gets whether event has happend

Parameters:
flag - for the event in question
Returns:
indicate whether event happend
See Also:
Protocol.PlayerHappened

hasNationalProject

public boolean hasNationalProject(Improvement improvement)
Checks whether a National Project is built already ( National Projects can be built once per player)

Parameters:
improvement -
Returns:
indicates whether a national project already exists
See Also:
PlayerCity.hasImprovement(j4cevo.Improvement)

makeOffer

public int makeOffer(Offer offer)
Makes an offer to the enemy. That offer might contain requests as well

Parameters:
offer -
Returns:
serverCode @type.action

noticeDecision

public int noticeDecision()
Notices latest decision of negotiation opponent.

Returns:
serverCode

rejectContact

public int rejectContact()
Refuses diplomatic contact with enemy who tried to contact this player

Returns:
serverCode

researchModel

public int researchModel()
Starts research of a prior created model instead of researching an advance.

Returns:
serverCode
See Also:
createModel(Domain domain), setModelCapability(j4cevo.Capability, int)

startAnarchy

public int startAnarchy()
Changes to anarchy. Required for government changes

Returns:
serverCode
See Also:
setGovernment(j4cevo.Government)

stealAdvance

public int stealAdvance(Advance advance)
After capturing a city, this command might be possible, indicated by the phStealTech flag in getWhatHappened. (With the current rules, this can only happen when you own the Temple of Zeus wonder.) Choose a technology to steal from the former city owner.

Parameters:
advance - the advance to steal
Returns:
serverCode
See Also:
getWhatHappend()

toString

public java.lang.String toString()

turnDone

public int turnDone()
Signals the server this turn is finally done

Returns:
serverCode

getPlayer

public static Player getPlayer()


generated: 20050107