|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsoc.game.SOCPlayer
A class for holding and manipulating player data. The player exists within one SOCGame, not persistent between games like SOCClient.
| Field Summary | |
private boolean |
boardResetAskedThisTurn
this is true if the player asked to reset the board this turn |
private int |
buildingVP
the number of victory points for settlements and cities |
private java.util.Vector |
cities
a list of this player's cities in play |
private SOCTradeOffer |
currentOffer
this is the current trade offer that this player is making |
private SOCDevCardSet |
devCards
how many of each type of development card this player has |
private int |
faceId
which face image this player is using |
private int |
finalTotalVP
the final total score (pushed from server at end of game), or 0 if no score has been forced. |
private SOCGame |
game
the game that this player is in |
protected int |
lastRoadCoord
The coordinates of our most recent road |
protected int |
lastSettlementCoord
The coordinates of our most recent settlement |
private boolean[] |
legalRoads
a list of edges where it is legal to place a road. |
private boolean[] |
legalSettlements
a list of nodes where it is legal to place a settlement. |
private int |
longestRoadLength
length of the longest road for this player |
private java.util.Vector |
lrPaths
list of longest paths |
private java.lang.String |
name
the name of the player |
private boolean |
needToDiscard
this flag is true if the player needs to discard |
private int |
numKnights
how many knights this player has in play |
private int[] |
numPieces
the number of pieces not in play |
private SOCPlayerNumbers |
ourNumbers
the numbers that our settlements are touching |
private java.util.Vector |
pieces
a list of this player's pieces in play |
private boolean |
playedDevCard
this is true if the player played a development card this turn |
private int |
playerNumber
The integer id for this player (0 to n-1). |
private boolean[] |
ports
a boolean array stating wheather this player is touching a particular kind of port |
private boolean[] |
potentialCities
a list of nodes where a city could be placed on the next turn. |
private boolean[] |
potentialRoads
a list of edges where a road could be placed on the next turn. |
private boolean[] |
potentialSettlements
a list of nodes where a settlement could be placed on the next turn. |
private SOCResourceSet |
resources
how many of each resource this player has |
private boolean[][] |
roadNodeGraph
a graph of what nodes are connected by this player's roads |
private java.util.Vector |
roadNodes
all of the nodes that this player's roads touch this is used to calculate longest road |
private java.util.Vector |
roads
a list of this player's roads in play |
private boolean |
robotFlag
this is true if this player is a robot |
private java.util.Vector |
settlements
a list of this player's settlements in play |
| Fields inherited from interface soc.game.SOCResourceConstants |
CLAY, MAXPLUSONE, MIN, ORE, SHEEP, UNKNOWN, WHEAT, WOOD |
| Fields inherited from interface soc.game.SOCDevCardConstants |
CAP, DISC, KNIGHT, LIB, MAX_KNOWN, MAXPLUSONE, MIN, MONO, ROADS, TEMP, TOW, UNIV, UNKNOWN |
| Constructor Summary | |
SOCPlayer(int pn,
SOCGame ga)
create a new player |
|
SOCPlayer(SOCPlayer player)
create a copy of the player |
|
| Method Summary | |
int |
calcLongestRoad2()
Calculates the longest road for a player |
void |
clearPotentialSettlements()
Set all nodes to not be potential settlements |
SOCPlayer |
copy()
|
void |
destroyPlayer()
set vars to null so gc can clean up |
void |
forceFinalVP(int score)
If game is over, server can push the final score for each player to the client. |
java.util.Vector |
getCities()
|
SOCTradeOffer |
getCurrentOffer()
|
SOCDevCardSet |
getDevCards()
|
int |
getFaceId()
get the face image id |
SOCGame |
getGame()
|
int |
getLastRoadCoord()
|
int |
getLastSettlementCoord()
|
int |
getLongestRoadLength()
|
java.util.Vector |
getLRPaths()
|
java.lang.String |
getName()
|
boolean |
getNeedToDiscard()
|
SOCPlayerNumbers |
getNumbers()
|
int |
getNumKnights()
|
int |
getNumPieces(int ptype)
|
java.util.Vector |
getPieces()
|
int |
getPlayerNumber()
|
boolean |
getPortFlag(int portType)
|
boolean[] |
getPortFlags()
|
int |
getPublicVP()
This player's number of publicly known victory points. |
SOCResourceSet |
getResources()
|
java.util.Vector |
getRoadNodes()
|
java.util.Vector |
getRoads()
|
java.util.Vector |
getSettlements()
|
int |
getTotalVP()
|
boolean |
hasAskedBoardReset()
|
boolean |
hasLargestArmy()
|
boolean |
hasLongestRoad()
|
boolean |
hasPlayedDevCard()
|
boolean |
hasPotentialCity()
|
boolean |
hasPotentialRoad()
|
boolean |
hasPotentialSettlement()
|
boolean |
hasUnplayedDevCards()
|
void |
incrementNumKnights()
increment the number of knights in play |
private void |
initLegalAndPotentialSettlements()
initialize the legal settlements array |
private void |
initLegalRoads()
initialize the legalRoads array |
boolean |
isConnectedByRoad(int node1,
int node2)
|
boolean |
isLegalRoad(int edge)
|
boolean |
isPotentialCity(int node)
|
boolean |
isPotentialRoad(int edge)
|
boolean |
isPotentialSettlement(int node)
|
boolean |
isRobot()
|
void |
putPiece(SOCPlayingPiece piece)
put a piece into play note: placing a city automatically removes the settlement there |
void |
removePiece(SOCPlayingPiece piece)
remove a player's piece from the board2 and put it back in the player's hand NOTE: Does NOT update the potential building lists for removing settlements or cities. |
void |
setAskedBoardReset(boolean value)
set the flag indicating if the player asked to reset the board this turn |
void |
setCurrentOffer(SOCTradeOffer of)
set the current offer for this player |
void |
setFaceId(int id)
set the face image id |
void |
setLongestRoadLength(int len)
set the longest road length |
void |
setLRPaths(java.util.Vector vec)
set the longest paths vector |
void |
setName(java.lang.String na)
set the name of the player |
void |
setNeedToDiscard(boolean value)
set the "need to discard" flag |
void |
setNumKnights(int nk)
set the number of knights in play |
void |
setNumPieces(int ptype,
int amt)
set the amount of pieces not in play for a particular type of piece |
void |
setPlayedDevCard(boolean value)
set the playedDevCard flag |
void |
setPortFlag(int portType,
boolean value)
set a port flag |
void |
setPotentialSettlements(java.util.Vector psList)
set which nodes are potential settlements |
void |
setRobotFlag(boolean value)
set the robot flag |
void |
undoPutPiece(SOCPlayingPiece piece)
undo the putting of a piece |
protected void |
undoPutPieceAuxSettlement(int settlementNode)
Auxiliary function for undoing settlement placement |
void |
updatePotentials(SOCPlayingPiece piece)
update the arrays that keep track of where this player can play a piece |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.lang.String name
private int playerNumber
private SOCGame game
private int[] numPieces
private java.util.Vector pieces
private java.util.Vector roads
private java.util.Vector settlements
private java.util.Vector cities
protected int lastSettlementCoord
protected int lastRoadCoord
private int longestRoadLength
private java.util.Vector lrPaths
private SOCResourceSet resources
private SOCDevCardSet devCards
private int numKnights
private int buildingVP
private int finalTotalVP
forceFinalVP(int)private boolean needToDiscard
private java.util.Vector roadNodes
private boolean[][] roadNodeGraph
private boolean[] legalRoads
private boolean[] legalSettlements
private boolean[] potentialRoads
private boolean[] potentialSettlements
private boolean[] potentialCities
private boolean[] ports
private SOCTradeOffer currentOffer
private boolean playedDevCard
private boolean boardResetAskedThisTurn
private boolean robotFlag
private int faceId
private SOCPlayerNumbers ourNumbers
| Constructor Detail |
public SOCPlayer(SOCPlayer player)
player - the player to copy
public SOCPlayer(int pn,
SOCGame ga)
pn - the player numberga - the game that the player is in| Method Detail |
private final void initLegalRoads()
private final void initLegalAndPotentialSettlements()
public void clearPotentialSettlements()
public void setName(java.lang.String na)
na - the namepublic java.lang.String getName()
public int getPlayerNumber()
public SOCGame getGame()
public boolean hasPlayedDevCard()
public void setPlayedDevCard(boolean value)
value - the value of the flagpublic boolean hasAskedBoardReset()
public void setAskedBoardReset(boolean value)
value - true to set, false to clearpublic void setNeedToDiscard(boolean value)
value - the value of the flagpublic boolean getNeedToDiscard()
public void setRobotFlag(boolean value)
value - public boolean isRobot()
public void setFaceId(int id)
id - the image idpublic int getFaceId()
public SOCPlayerNumbers getNumbers()
public int getNumPieces(int ptype)
ptype - the type of piece
public void setNumPieces(int ptype,
int amt)
ptype - the type of pieceamt - the amountpublic java.util.Vector getPieces()
public java.util.Vector getRoads()
public java.util.Vector getSettlements()
public java.util.Vector getCities()
public int getLastSettlementCoord()
public int getLastRoadCoord()
public int getLongestRoadLength()
public java.util.Vector getLRPaths()
public void setLRPaths(java.util.Vector vec)
vec - the vectorpublic void setLongestRoadLength(int len)
len - the lengthpublic SOCResourceSet getResources()
public SOCDevCardSet getDevCards()
public boolean hasUnplayedDevCards()
getDevCards()public int getNumKnights()
public void setNumKnights(int nk)
nk - the number of knightspublic void incrementNumKnights()
public boolean hasLongestRoad()
public boolean hasLargestArmy()
public int getPublicVP()
forceFinalVP(int)public int getTotalVP()
forceFinalVP(int)public void forceFinalVP(int score)
score - Total score for the player, or 0 for no forced total.public java.util.Vector getRoadNodes()
public SOCTradeOffer getCurrentOffer()
public void setCurrentOffer(SOCTradeOffer of)
of - the offer
public boolean isConnectedByRoad(int node1,
int node2)
node1 - coordinates of first nodenode2 - coordinates of second node
public void putPiece(SOCPlayingPiece piece)
piece - the piece to be put into playpublic void undoPutPiece(SOCPlayingPiece piece)
piece - the piece to be put into play
For removing second initial settlement (state START2B),
will zero the player's resource cards.protected void undoPutPieceAuxSettlement(int settlementNode)
settlementNode - the node we want to considerpublic void removePiece(SOCPlayingPiece piece)
public void updatePotentials(SOCPlayingPiece piece)
piece - a piece that has just been playedpublic void setPotentialSettlements(java.util.Vector psList)
psList - the list of potential settlementspublic boolean isPotentialSettlement(int node)
node - the coordinates of a node on the board
public boolean isPotentialCity(int node)
node - the coordinates of a node on the board
public boolean isPotentialRoad(int edge)
edge - the coordinates of an edge on the board
public boolean isLegalRoad(int edge)
edge - the coordinates of an edge on the board
public boolean hasPotentialRoad()
public boolean hasPotentialSettlement()
public boolean hasPotentialCity()
public int calcLongestRoad2()
public void setPortFlag(int portType,
boolean value)
portType - the type of port, see SOCBoardvalue - true or falsepublic boolean getPortFlag(int portType)
portType - the type of port, see SOCBoard
public boolean[] getPortFlags()
public SOCPlayer copy()
public void destroyPlayer()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||