|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.game.SOCPlayingPiece
public abstract class SOCPlayingPiece
Playing pieces for Settlers of Catan.
For the resources needed to build a piece type, see getResourcesToBuild(int)
.
See also soc.robot.SOCPossiblePiece.
Field Summary | |
---|---|
protected SOCBoard |
board
Board, for coordinate-related operations. |
static int |
CITY
Types of playing pieces: City . |
protected int |
coord
Coordinates on the board for this piece. |
static int |
FORTRESS
Types of playing pieces: Fortress . |
static int |
MAXPLUSONE
One past the maximum type number of playing piece. |
static int |
MIN
Minimum type number of playing piece (currently Road). |
protected int |
pieceType
The type of this playing piece, within range MIN to (MAXPLUSONE - 1) |
protected SOCPlayer |
player
The player who owns this piece, if any. |
static int |
ROAD
Types of playing pieces: Road . |
static int |
SETTLEMENT
Types of playing pieces: Settlement . |
static int |
SHIP
Types of playing pieces: Ship. |
(package private) int |
specialVP
Special Victory Points (SVP) awarded for placing this piece, if any. |
(package private) SOCScenarioPlayerEvent |
specialVPEvent
If specialVP != 0, the event for which the SVP was awarded. |
static int |
VILLAGE
Types of playing pieces: Village . |
Constructor Summary | |
---|---|
protected |
SOCPlayingPiece(int ptype,
int co,
SOCBoard pboard)
Make a new piece, which belongs to the board and never to players. |
protected |
SOCPlayingPiece(int ptype,
SOCPlayer pl,
int co,
SOCBoard pboard)
Make a new piece, which is owned by a player. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object other)
Compare this SOCPlayingPiece to another SOCPlayingPiece, or another object. |
java.util.Vector<java.lang.Integer> |
getAdjacentEdges()
Which edges touch this piece's node on the board? Should not be called for roads, because they aren't placed at a node. |
int |
getCoordinates()
|
SOCPlayer |
getPlayer()
Get the player who owns this piece, if any. |
int |
getPlayerNumber()
Get the owner's player number. |
static SOCResourceSet |
getResourcesToBuild(int pieceType)
the set of resources a player needs to build a playing piece. |
int |
getType()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ROAD
Road
.
getResourcesToBuild(int)
,
Constant Field Valuespublic static final int SETTLEMENT
Settlement
.
getResourcesToBuild(int)
,
Constant Field Valuespublic static final int CITY
City
.
getResourcesToBuild(int)
,
Constant Field Valuespublic static final int SHIP
SOCGame.hasSeaBoard
.
Requires client and server version 2.0.00 or newer.
getResourcesToBuild(int)
,
Constant Field Valuespublic static final int FORTRESS
Fortress
.
Used only when SOCGame.hasSeaBoard
and scenario
option _SC_PIRI
.
Requires client and server version 2.0.00 or newer.
New fortresses cannot be built after the game starts.
public static final int VILLAGE
Village
.
Used only when SOCGame.hasSeaBoard
.
Requires client and server version 2.0.00 or newer.
Villages belong to the game board, not to any player,
and new villages cannot be built after the game starts.
public static final int MIN
public static final int MAXPLUSONE
protected int pieceType
MIN
to (MAXPLUSONE
- 1)
protected SOCPlayer player
SOCVillage
which belong to the board and not to players.
Player is from same game as board
.
protected int coord
protected SOCBoard board
player
.
int specialVP
large sea board
game scenarios.
When specialVP
!= 0, the source is specialVPEvent
.
Note: This is set when the piece was placed, so it's always accurate at server. At client it may be 0 if the client joined the game after this piece was placed.
Package access for SOCPlayer's benefit.
SOCScenarioPlayerEvent specialVPEvent
specialVP
!= 0, the event for which the SVP was awarded. Otherwise null.
Note: This is set when the piece was placed, so it's always accurate at server. At client it may be null if the client joined the game after this piece was placed.
Package access for SOCPlayer's benefit.
Constructor Detail |
---|
protected SOCPlayingPiece(int ptype, SOCPlayer pl, int co, SOCBoard pboard) throws java.lang.IllegalArgumentException
ptype
- the type of piece, such as SETTLEMENT
pl
- player who owns the piececo
- coordinatespboard
- board if known; otherwise will extract from pl.
Board should be from same game as pl.
java.lang.IllegalArgumentException
- if pl null, or board null and pl.board also nullSOCPlayingPiece(int, int, SOCBoard)
protected SOCPlayingPiece(int ptype, int co, SOCBoard pboard) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if board nullSOCPlayingPiece(int, SOCPlayer, int, SOCBoard)
Method Detail |
---|
public java.util.Vector<java.lang.Integer> getAdjacentEdges()
SOCBoard.getAdjacentEdgesToNode(int)
public int getType()
ROAD
public SOCPlayer getPlayer() throws java.lang.UnsupportedOperationException
SOCVillage
belong to the board and not to players.
java.lang.UnsupportedOperationException
- if this piece type has no player and is owned by the boardgetPlayerNumber()
public int getPlayerNumber() throws java.lang.UnsupportedOperationException
getPlayer()
.getPlayerNumber()
java.lang.UnsupportedOperationException
- if this piece type has no player and is owned by the boardpublic int getCoordinates()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- The object to compare with, or null.public static SOCResourceSet getResourcesToBuild(int pieceType) throws java.lang.IllegalArgumentException
pieceType
- The type of this playing piece, in range MIN
to (MAXPLUSONE
- 1).
ROAD
, CITY
, etc.
For convenience, can also pass -2 or MAXPLUSONE
for SOCGame.CARD_SET
.
SOCGame.SETTLEMENT_SET
java.lang.IllegalArgumentException
- if pieceType is out of range, or can never be built by players
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |