|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.message.SOCMessage soc.message.SOCBoardLayout2
public class SOCBoardLayout2
This message contains the board's layout information and its encoding version. The layout is represented as a series of named integer arrays and named integer parameters. These contain the hex layout, the number layout, where the robber is, and possibly the port layout. This message does not contain information about where the player's pieces are on the board.
Typical parts of the board layout: (Not all layouts include all these parts)
SOCBoard.getHexLayout()
.SOCBoard.getNumberLayout()
SOCBoard.getRobberHex()
, if > 0
SOCBoard.getPortsLayout()
SOCBoardLarge.getPirateHex()
, if > 0
SOCBoardLarge.getLandHexLayout()
.SOCPotentialSettlements
.
getAddedParts()
.
_SC_WOND
: After Initial Placement,
the lists referred here are added to all players' legal nodes / legal edges.
AL
refer to layout parts E1
through E9
for edges to add.
N1
through N9
for nodes to add.
A positive number is always followed in AL
by a Land Area Number, or 0, to add the nodes to.
For each added node, its edges to adjacent legal nodes will also be added if not already there.
If a layout part's set of nodes is used only during initial placement, and its contents should be
emptied after that, the Land Area Number will be negative here.
_SC_CLVI
, from SOCBoardLarge.getVillageAndClothLayout()
;
at the client, call SOCBoardLarge.setVillageAndClothLayout(int[])
if this layout part is sent.
_SC_FTRI
; edge coordinates where ship placement gives a free development card.
As these are each claimed during game play, 0 replaces their coordinate in the layout part element.
_SC_FTRI
; edge coordinates where ship placement gives a special victory point.
As these are each claimed during game play, 0 replaces their coordinate in the layout part element.
_SC_PIRI
: Node coordinates,
one per player number, for the player's lone build location on the way to the pirate fortress.
_SC_PIRI
; hex coordinates for SOCBoardLarge.movePirateHexAlongPath(int)
"AL"
).
_SC_WOND
. Can be used for any purpose by a
scenario, and/or for additional legal nodes (see layout part "AL"
).
SOCBoardSpecialEdge
message.
If you add a layout part which is a Special Edge type, be sure to update
SOCBoardLarge.SPECIAL_EDGE_LAYOUT_PARTS
and .SPECIAL_EDGE_TYPES
so players joining during the game will get updated Special Edge data.
SOCBoardLayout
, dice numbers here equal the actual rolled numbers.
SOCBoardLayout required a mapping/unmapping step.
For backwards compatibility, the HL values for SOCBoard.WATER_HEX
and
SOCBoard.DESERT_HEX
are changed to their pre-v2.0 values in the
constructor before sending over the network, and changed back in
getIntArrayPart("HL")
.
SOCBoardLayout
,
Serialized FormField Summary | |
---|---|
private int |
boardEncodingFormat
Board layout encoding version, from SOCBoard.getBoardEncodingFormat() . |
private java.lang.String |
game
Name of game |
private java.lang.String[] |
KNOWN_KEYS
Known layout part keys. |
private java.util.Hashtable<java.lang.String,java.lang.Object> |
layoutParts
Contents are int[] or String (which may be int). |
private static int |
SENTLAND_DESERT
Hex land type numbers sent over the network. |
private static int |
SENTLAND_WATER
Hex land type numbers sent over the network. |
private static long |
serialVersionUID
|
static int |
VERSION_FOR_BOARDLAYOUT2
Minimum version (1.1.08) of client/server which recognize and send VERSION_FOR_BOARDLAYOUT2. |
Constructor Summary | |
---|---|
SOCBoardLayout2(java.lang.String ga,
int bef,
java.util.Hashtable<java.lang.String,java.lang.Object> parts)
Create a SOCBoardLayout2 message; see class javadoc for parts' meanings. |
|
SOCBoardLayout2(java.lang.String ga,
int bef,
int[] hl,
int[] nl,
int[] pl,
int rh)
Create a SOCBoardLayout2 message for encoding format v1 or v2; see class javadoc for parameters' meanings. |
|
SOCBoardLayout2(java.lang.String ga,
int bef,
int[] lh,
int[] pl,
int rh,
int ph,
int[] px,
int[] rx,
java.util.Map<java.lang.String,int[]> other)
Create a SOCBoardLayout2 message for encoding format v3. |
Method Summary | |
---|---|
java.util.HashMap<java.lang.String,int[]> |
getAddedParts()
Some game scenarios may add other layout part keys and int[] values. |
int |
getBoardEncodingFormat()
Game's board SOCBoard.getBoardEncodingFormat() version |
java.lang.String |
getGame()
Game name |
int[] |
getIntArrayPart(java.lang.String pkey)
Get a layout part of type int[]. |
int |
getIntPart(java.lang.String pkey)
Get a layout part of type int |
java.lang.String |
getStringPart(java.lang.String pkey)
Get a layout part of type String |
static SOCBoardLayout2 |
parseDataStr(java.lang.String s)
Parse the command string into a BoardLayout2 message |
java.lang.String |
toCmd()
Formatted string to send this BOARDLAYOUT2 over the network. |
static java.lang.String |
toCmd(java.lang.String ga,
int bef,
java.util.Hashtable<java.lang.String,java.lang.Object> parts)
Formatted string to send this BOARDLAYOUT2 over the network. |
java.lang.String |
toString()
Render the SOCBoardLayout2 in human-readable form. |
Methods inherited from class soc.message.SOCMessage |
---|
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getMinimumVersion, getType, isSingleLineAndSafe, isSingleLineAndSafe, toMsg |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface soc.message.SOCMessageForGame |
---|
getType |
Field Detail |
---|
private static final long serialVersionUID
private final java.lang.String[] KNOWN_KEYS
getAddedParts()
because the client calls
specific SOCBoardLarge
methods for each of these, instead of generically calling
SOCBoardLarge.setAddedLayoutParts(HashMap)
. See getAddedParts()
javadoc
for details.
public static final int VERSION_FOR_BOARDLAYOUT2
private static final int SENTLAND_WATER
SOCBoard.WATER_HEX
, SOCBoard.DESERT_HEX
.
private static final int SENTLAND_DESERT
SOCBoard.WATER_HEX
, SOCBoard.DESERT_HEX
.
private final java.lang.String game
private final int boardEncodingFormat
SOCBoard.getBoardEncodingFormat()
.
private java.util.Hashtable<java.lang.String,java.lang.Object> layoutParts
getAddedParts()
, KNOWN_KEYS
,
SOCBoardLarge.getAddedLayoutParts()
,
and soc.server.SOCBoardLargeAtServer.setAddedLayoutPart(String, int[])
.
Constructor Detail |
---|
public SOCBoardLayout2(java.lang.String ga, int bef, java.util.Hashtable<java.lang.String,java.lang.Object> parts)
ga
- the name of the gamebef
- the board encoding format number, from SOCBoard.getBoardEncodingFormat()
parts
- the parts of the layout: int[] arrays or Strings or Integers.
contents are not validated here, but improper contents
may cause a ClassCastException later.public SOCBoardLayout2(java.lang.String ga, int bef, int[] hl, int[] nl, int[] pl, int rh)
SOCBoard.BOARD_ENCODING_ORIGINAL
or SOCBoard.BOARD_ENCODING_6PLAYER
.)
ga
- the name of the gamebef
- the board encoding format number, from SOCBoard.getBoardEncodingFormat()
hl
- the hex layout; not mapped yet, so the constructor will map it from the
SOCBoard.getHexLayout()
value range
to the BOARDLAYOUT2 message's value range.nl
- the number layoutpl
- the port layout, or nullrh
- the robber hexpublic SOCBoardLayout2(java.lang.String ga, int bef, int[] lh, int[] pl, int rh, int ph, int[] px, int[] rx, java.util.Map<java.lang.String,int[]> other)
SOCBoardLarge
, SOCBoard.BOARD_ENCODING_LARGE
.)
ga
- the name of the gamebef
- the board encoding format number, from SOCBoard.getBoardEncodingFormat()
lh
- the land hex layout, or null if all water (before makeNewBoard is called)pl
- the port layout, or nullrh
- the robber hex, or -1ph
- the pirate hex, or 0px
- the player exclusion land areas, or null, from SOCBoardLarge.getPlayerExcludedLandAreas()
rx
- the robber exclusion land areas, or null, from SOCBoardLarge.getRobberExcludedLandAreas()
other
- any other layout parts to add, or null; see getAddedParts()
.
Please make sure that new keys don't conflict with ones already listed in the class javadoc.Method Detail |
---|
public java.lang.String getGame()
getGame
in interface SOCMessageForGame
SOCMessage.GAME_NONE
public int getBoardEncodingFormat()
SOCBoard.getBoardEncodingFormat()
version
public int[] getIntArrayPart(java.lang.String pkey)
As a special case, when pkey is "HL", desert and water hexes will be mapped from the sent values to the SOCBoard values before returning the array.
pkey
- the part's key name
public int getIntPart(java.lang.String pkey)
pkey
- the part's key name
public java.lang.String getStringPart(java.lang.String pkey)
pkey
- the part's key name
public java.util.HashMap<java.lang.String,int[]> getAddedParts()
SC_PIRI
adds
"PP" = { 0x..., 0x... } for the fixed Pirate Path.
This is a generic mechanism for adding to layout information
without continually changing SOCBoardLayout2
or SOCBoardLarge
.
The returned keys of those parts will be none of the ones in the "typical parts of the board layout"
listed in this class javadoc, unlike SOCBoardLarge.getAddedLayoutParts()
which includes any key
added by the options or scenario. The difference is that the client calls
SOCBoardLarge.setAddedLayoutParts(HashMap)
once for all the parts returned here. For the keys
listed in the class javadoc, such as "CV"
, the client calls part-specific methods such as
SOCBoardLarge.setVillageAndClothLayout(int[])
to set up the board when the server sends its layout.
public java.lang.String toCmd()
Each item's format is either:
toCmd
in class SOCMessage
public static java.lang.String toCmd(java.lang.String ga, int bef, java.util.Hashtable<java.lang.String,java.lang.Object> parts)
toCmd()
for details.
public static SOCBoardLayout2 parseDataStr(java.lang.String s)
s
- the String to parse
public java.lang.String toString()
toString
in class SOCMessage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |