soc.message
Class SOCBoardLayout

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCBoardLayout
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, SOCMessageForGame

public class SOCBoardLayout
extends SOCMessage
implements SOCMessageForGame

This message contains the board layout information. That is, the hex layout, the number layout, and where the robber is. This does not contain information about where the player's pieces are on the board.

This message sends the standard board layout of the original game, SOCBoard.BOARD_ENCODING_ORIGINAL. As of version 1.1.08, there is a newer board layout for game expansions. See the new message type BOARDLAYOUT2.

Unlike SOCBoardLayout2, the dice numbers are mapped before sending over the network, and unmapped when received. This is because of a change in SOCBoard.getNumberLayout() in 1.1.08, the version which introduced SOCBoardLayout2. Older clients/servers will still need the mapping done, so it's now done here instead of in SOCBoard.

In v2.0.00 and newer, the hex layout values for WATER_HEX and DESERT_HEX were changed to allow new types of land hex. Just like the dice numbers, this is mapped in the constructor, sent over the network, and unmapped in getHexLayout(), for backwards compatibility with older clients.

Author:
Robert S. Thomas
See Also:
Serialized Form

Field Summary
private static int[] boardNum2sentNum
          Map of dice rolls to values in numberLayout.
private  java.lang.String game
          Name of game
private  int[] hexLayout
          The hex layout; a mapping/unmapping step is done in constructor/getHexLayout().
private  int[] numberLayout
          The dice number layout; a mapping/unmapping step is done in constructor/getNumberLayout().
private  int robberHex
          Where the robber is
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 int[] sentNum2BoardNum
          Map of values in numberLayout to dice rolls:
private static long serialVersionUID
           
 
Fields inherited from class soc.message.SOCMessage
ACCEPTOFFER, ADMINPING, ADMINRESET, AUTHREQUEST, BANKTRADE, BCASTTEXTMSG, BOARDLAYOUT, BOARDLAYOUT2, BOARDSPECIALEDGE, BUILDREQUEST, BUYCARDREQUEST, CANCELBUILDREQUEST, CHANGEFACE, CHANNELS, CHOOSEPLAYER, CHOOSEPLAYERREQUEST, CLEAROFFER, CLEARTRADEMSG, CREATEACCOUNT, DEBUGFREEPLACE, DELETECHANNEL, DELETEGAME, DEVCARDACTION, DEVCARDCOUNT, DICERESULT, DICERESULTRESOURCES, DISCARD, DISCARDREQUEST, DISCOVERYPICK, ENDTURN, FIRSTPLAYER, GAME_NONE, GAMEMEMBERS, GAMEOPTIONGETDEFAULTS, GAMEOPTIONGETINFOS, GAMEOPTIONINFO, GAMES, GAMESERVERTEXT, GAMESTATE, GAMESTATS, GAMESWITHOPTIONS, GAMETEXTMSG, IMAROBOT, INVENTORYITEMACTION, JOIN, JOINAUTH, JOINGAME, JOINGAMEAUTH, LARGESTARMY, LASTSETTLEMENT, LEAVE, LEAVEALL, LEAVEGAME, LEGALEDGES, LOCALIZEDSTRINGS, LONGESTROAD, MAKEOFFER, MEMBERS, messageType, MONOPOLYPICK, MOVEPIECE, MOVEPIECEREQUEST, MOVEROBBER, NEWCHANNEL, NEWGAME, NEWGAMEWITHOPTIONS, NEWGAMEWITHOPTIONSREQUEST, NULLMESSAGE, PICKRESOURCES, PICKRESOURCESREQUEST, PIECEVALUE, PLAYDEVCARDREQUEST, PLAYERELEMENT, PLAYERELEMENTS, PLAYERSTATS, POTENTIALSETTLEMENTS, PUTPIECE, REJECTCONNECTION, REJECTOFFER, REMOVEPIECE, RESETBOARDAUTH, RESETBOARDREJECT, RESETBOARDREQUEST, RESETBOARDVOTE, RESETBOARDVOTEREQUEST, RESOURCECOUNT, REVEALFOGHEX, ROBOTDISMISS, ROBOTJOINGAMEREQUEST, ROLLDICE, ROLLDICEPROMPT, ROLLDICEREQUEST, SCENARIOINFO, sep, sep_char, sep2, sep2_char, SERVERPING, SETPLAYEDDEVCARD, SETSEATLOCK, SETSPECIALITEM, SETTURN, SETUPDONE, SIMPLEACTION, SIMPLEREQUEST, SITDOWN, STARTGAME, STATUSMESSAGE, SVPTEXTMSG, TEXTMSG, TIMINGPING, TURN, UPDATEROBOTPARAMS, VERSION
 
Constructor Summary
  SOCBoardLayout(java.lang.String ga, int[] hl, int[] nl, int rh)
          Create a SOCBoardLayout message
private SOCBoardLayout(java.lang.String ga, int[] hl, int[] nl, int rh, boolean alreadyMapped)
          Create a SOCBoardLayout message
 
Method Summary
 java.lang.String getGame()
          Name of game this message is for.
 int[] getHexLayout()
          Get the hex layout, already mapped from the BOARDLAYOUT message value range to the SOCBoard.setHexLayout(int[]) value range.
 int[] getNumberLayout()
          Get the dice number layout, already mapped from the BOARDLAYOUT message value range to the SOCBoard.setNumberLayout(int[]) value range.
 int getRobberHex()
           
static SOCBoardLayout parseDataStr(java.lang.String s)
          Parse the command String into a BoardLayout message
 java.lang.String toCmd()
          Formatted string to send this BOARDLAYOUT over the network.
static java.lang.String toCmd(java.lang.String ga, int[] hl, int[] nl, int rh)
          Formatted string to send this BOARDLAYOUT over the network.
 java.lang.String toString()
          Render the SOCBoardLayout 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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

boardNum2sentNum

private static final int[] boardNum2sentNum
Map of dice rolls to values in numberLayout. Formerly in SOCBoard.

Since:
1.1.08

sentNum2BoardNum

private static final int[] sentNum2BoardNum
Map of values in numberLayout to dice rolls:
    -1 : robber
     0 : 2
     1 : 3
     2 : 4
     3 : 5
     4 : 6
     5 : 8 (7 is skipped)         
     6 : 9
     7 : 10
     8 : 11
     9 : 12 
Formerly in SOCBoard.

Since:
1.1.08

SENTLAND_WATER

private static final int SENTLAND_WATER
Hex land type numbers sent over the network. Compare to SOCBoard.WATER_HEX, SOCBoard.DESERT_HEX.

Since:
2.0.00
See Also:
Constant Field Values

SENTLAND_DESERT

private static final int SENTLAND_DESERT
Hex land type numbers sent over the network. Compare to SOCBoard.WATER_HEX, SOCBoard.DESERT_HEX.

Since:
2.0.00
See Also:
Constant Field Values

game

private java.lang.String game
Name of game


hexLayout

private int[] hexLayout
The hex layout; a mapping/unmapping step is done in constructor/getHexLayout().


numberLayout

private int[] numberLayout
The dice number layout; a mapping/unmapping step is done in constructor/getNumberLayout().


robberHex

private int robberHex
Where the robber is

Constructor Detail

SOCBoardLayout

public SOCBoardLayout(java.lang.String ga,
                      int[] hl,
                      int[] nl,
                      int rh)
Create a SOCBoardLayout message

Parameters:
ga - the name of the game
hl - the hex layout; not mapped yet from SOCBoard's value range, so the constructor will map it.
nl - the dice number layout; not mapped yet, so the constructor will map it from the SOCBoard.getNumberLayout() value range to the BOARDLAYOUT message's value range.
rh - the robber hex

SOCBoardLayout

private SOCBoardLayout(java.lang.String ga,
                       int[] hl,
                       int[] nl,
                       int rh,
                       boolean alreadyMapped)
Create a SOCBoardLayout message

Parameters:
ga - the name of the game
hl - the hex layout
nl - the number layout
rh - the robber hex
alreadyMapped - have the hex layout and number layout already been mapped?
Since:
1.1.08
Method Detail

getGame

public java.lang.String getGame()
Description copied from interface: SOCMessageForGame
Name of game this message is for. Must not be null if message is in per-game structures or code.

At the server, the message treater dispatches incoming SOCMessageForGames based on their getGame():

Specified by:
getGame in interface SOCMessageForGame
Returns:
the name of the game
See Also:
SOCMessage.GAME_NONE

getHexLayout

public int[] getHexLayout()
Get the hex layout, already mapped from the BOARDLAYOUT message value range to the SOCBoard.setHexLayout(int[]) value range.

Returns:
the hex layout

getNumberLayout

public int[] getNumberLayout()
Get the dice number layout, already mapped from the BOARDLAYOUT message value range to the SOCBoard.setNumberLayout(int[]) value range.

Returns:
the number layout

getRobberHex

public int getRobberHex()
Returns:
the robber hex

toCmd

public java.lang.String toCmd()
Formatted string to send this BOARDLAYOUT over the network. BOARDLAYOUT sep game sep2 hexLayout[0] sep2 ... sep2 hexLayout[36] sep2 numberLayout[0] sep2 ... sep2 numberLayout[36] sep2 robberHex

Specified by:
toCmd in class SOCMessage
Returns:
the command string

toCmd

public static java.lang.String toCmd(java.lang.String ga,
                                     int[] hl,
                                     int[] nl,
                                     int rh)
Formatted string to send this BOARDLAYOUT over the network. BOARDLAYOUT sep game sep2 hexLayout[0] sep2 ... sep2 hexLayout[36] sep2 numberLayout[0] sep2 ... sep2 numberLayout[36] sep2 robberHex

Returns:
the command string

parseDataStr

public static SOCBoardLayout parseDataStr(java.lang.String s)
Parse the command String into a BoardLayout message

Parameters:
s - the String to parse
Returns:
a BoardLayout message

toString

public java.lang.String toString()
Render the SOCBoardLayout in human-readable form. In version 1.1.09 and later, the hexLayout and numberLayout contents are included, and for convenience, robberHex is in hexadecimal instead of base-10

Specified by:
toString in class SOCMessage
Returns:
a human readable form of the message