soc.client
Class SOCPlayerClient.GameManager

java.lang.Object
  extended by soc.client.SOCPlayerClient.GameManager
Enclosing class:
SOCPlayerClient

public static class SOCPlayerClient.GameManager
extends java.lang.Object

Nested class for processing outgoing messages (putting).

Before v2.0.00, most of these fields and methods were part of the main SOCPlayerClient class.

Since:
2.0.00
Author:
paulbilnoski

Field Summary
private  SOCPlayerClient client
           
private  SOCPlayerClient.ClientNetwork net
           
 
Constructor Summary
SOCPlayerClient.GameManager(SOCPlayerClient client)
           
 
Method Summary
 void acceptOffer(SOCGame ga, int from)
          the user is accepting an offer
 void bankTrade(SOCGame ga, SOCResourceSet give, SOCResourceSet get)
          the user wants to trade with the bank or a port.
 void buildRequest(SOCGame ga, int piece)
          request to build something
 void buyDevCard(SOCGame ga)
          request to buy a development card
 void cancelBuildRequest(SOCGame ga, int piece)
          request to cancel building something
 void changeFace(SOCGame ga, int id)
          the user is changing the face image
 void choosePirate(SOCGame ga)
          The user is reacting to the move pirate request.
 void choosePlayer(SOCGame ga, int ch)
          The user chose a player to steal from, or (game state SOCGame.WAITING_FOR_ROBBER_OR_PIRATE) chose whether to move the robber or the pirate, or (game state SOCGame.WAITING_FOR_ROB_CLOTH_OR_RESOURCE) chose whether to steal a resource or cloth.
 void chooseRobber(SOCGame ga)
          The user is reacting to the move robber request.
 void clearOffer(SOCGame ga)
          the user is clearing an offer
 void considerMove(SOCGame ga, java.lang.String pname, SOCPlayingPiece piece)
          send a command to the server with a message asking a robot to show the debug info for a possible move after a move has been made
 void considerTarget(SOCGame ga, java.lang.String pname, SOCPlayingPiece piece)
          send a command to the server with a message asking a robot to show the debug info for a possible move before a move has been made
 void discard(SOCGame ga, SOCResourceSet rs)
          the user wants to discard
 void discoveryPick(SOCGame ga, SOCResourceSet rscs)
          the user picked 2 resources to discover
 void endTurn(SOCGame ga)
          the user is done with the turn
 void leaveGame(SOCGame ga)
          the user leaves the given game
 void monopolyPick(SOCGame ga, int res)
          the user picked a resource to monopolize
 void movePieceRequest(SOCGame ga, int pn, int ptype, int fromCoord, int toCoord)
          Ask the server to move this piece to a different coordinate.
 void moveRobber(SOCGame ga, SOCPlayer pl, int coord)
          the player wants to move the robber or the pirate ship.
 void offerTrade(SOCGame ga, SOCTradeOffer offer)
          the user is making an offer to trade with another player.
 void pickResources(SOCGame ga, SOCResourceSet rs)
          The user has picked these resources to gain from the gold hex.
 void pickSpecialItem(SOCGame ga, java.lang.String typeKey, int gi, int pi)
          The current user wants to pick a Special Item.
 void playDevCard(SOCGame ga, int dc)
          the user wants to play a development card
 void playInventoryItem(SOCGame ga, int itype)
          The current user wants to play a special SOCInventoryItem.
private  boolean put(java.lang.String s, boolean isPractice)
          Write a message to the net or practice server.
 void putPiece(SOCGame ga, SOCPlayingPiece pp)
          put a piece on the board, using the SOCPutPiece message.
 void rejectOffer(SOCGame ga)
          the user is rejecting the current offers
 void resetBoardRequest(SOCGame ga)
          Player wants to request to reset the board (same players, new game, new layout).
 void resetBoardVote(SOCGame ga, int pn, boolean voteYes)
          Player is responding to a board-reset vote from another player.
 void rollDice(SOCGame ga)
          the user rolls the dice
 void sendSimpleRequest(SOCPlayer pl, int reqtype)
          The player wants to send a simple request to the server, such as SOCSimpleRequest.SC_PIRI_FORT_ATTACK to attack their pirate fortress in scenario option _SC_PIRI.
 void sendSimpleRequest(SOCPlayer pl, int reqtype, int value1, int value2)
          The player wants to send a simple request to the server, such as SOCSimpleRequest.SC_PIRI_FORT_ATTACK to attack their pirate fortress in scenario option _SC_PIRI, with optional value1 and value2 parameters.
 void sendText(SOCGame ga, java.lang.String me)
          send a text message to the people in the game
 void setSeatLock(SOCGame ga, int pn, SOCGame.SeatLockState sl)
          The user is locking or unlocking a seat.
 void sitDown(SOCGame ga, int pn)
          the user sits down to play
 void startGame(SOCGame ga)
          the user is starting the game
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

private final SOCPlayerClient client

net

private final SOCPlayerClient.ClientNetwork net
Constructor Detail

SOCPlayerClient.GameManager

SOCPlayerClient.GameManager(SOCPlayerClient client)
Method Detail

put

private boolean put(java.lang.String s,
                    boolean isPractice)
Write a message to the net or practice server. Because the player can be in both network games and practice games, we must route to the appropriate client-server connection.

Parameters:
s - the message
isPractice - Put to the practice server, not tcp network? SOCPlayerClient.ClientNetwork.localTCPServer is considered "network" here. Use isPractice only with SOCPlayerClient.ClientNetwork.practiceServer.
Returns:
true if the message was sent, false if not

buyDevCard

public void buyDevCard(SOCGame ga)
request to buy a development card

Parameters:
ga - the game

buildRequest

public void buildRequest(SOCGame ga,
                         int piece)
request to build something

Parameters:
ga - the game
piece - the type of piece, from SOCPlayingPiece constants, or -1 to request the Special Building Phase.

cancelBuildRequest

public void cancelBuildRequest(SOCGame ga,
                               int piece)
request to cancel building something

Parameters:
ga - the game
piece - the type of piece, from SOCPlayingPiece constants

putPiece

public void putPiece(SOCGame ga,
                     SOCPlayingPiece pp)
put a piece on the board, using the SOCPutPiece message. If the game is in SOCGame.debugFreePlacement mode, send the SOCDebugFreePlace message instead.

Parameters:
ga - the game where the action is taking place
pp - the piece being placed

movePieceRequest

public void movePieceRequest(SOCGame ga,
                             int pn,
                             int ptype,
                             int fromCoord,
                             int toCoord)
Ask the server to move this piece to a different coordinate.

Parameters:
ga - the game where the action is taking place
pn - The piece's player number
ptype - The piece type, such as SOCPlayingPiece.SHIP
fromCoord - Move the piece from here
toCoord - Move the piece to here
Since:
2.0.00

moveRobber

public void moveRobber(SOCGame ga,
                       SOCPlayer pl,
                       int coord)
the player wants to move the robber or the pirate ship.

Parameters:
ga - the game
pl - the player
coord - edge where the player wants the robber, or negative edge for the pirate ship

sendSimpleRequest

public void sendSimpleRequest(SOCPlayer pl,
                              int reqtype)
The player wants to send a simple request to the server, such as SOCSimpleRequest.SC_PIRI_FORT_ATTACK to attack their pirate fortress in scenario option _SC_PIRI.

Using network message request types within the client breaks abstraction, but prevents having a lot of very similar methods for simple requests.

Parameters:
pl - the requesting player
reqtype - the request type as defined in SOCSimpleRequest
Since:
2.0.00
See Also:
sendSimpleRequest(SOCPlayer, int, int, int)

sendSimpleRequest

public void sendSimpleRequest(SOCPlayer pl,
                              int reqtype,
                              int value1,
                              int value2)
The player wants to send a simple request to the server, such as SOCSimpleRequest.SC_PIRI_FORT_ATTACK to attack their pirate fortress in scenario option _SC_PIRI, with optional value1 and value2 parameters.

Using network message request types within the client breaks abstraction, but prevents having a lot of very similar methods for simple requests.

Parameters:
pl - the requesting player
reqtype - the request type as defined in SOCSimpleRequest
value1 - First optional detail value, or 0
value2 - Second optional detail value, or 0
Since:
2.0.00
See Also:
sendSimpleRequest(SOCPlayer, int)

sendText

public void sendText(SOCGame ga,
                     java.lang.String me)
send a text message to the people in the game

Parameters:
ga - the game
me - the message

leaveGame

public void leaveGame(SOCGame ga)
the user leaves the given game

Parameters:
ga - the game

sitDown

public void sitDown(SOCGame ga,
                    int pn)
the user sits down to play

Parameters:
ga - the game
pn - the number of the seat where the user wants to sit

startGame

public void startGame(SOCGame ga)
the user is starting the game

Parameters:
ga - the game

rollDice

public void rollDice(SOCGame ga)
the user rolls the dice

Parameters:
ga - the game

endTurn

public void endTurn(SOCGame ga)
the user is done with the turn

Parameters:
ga - the game

discard

public void discard(SOCGame ga,
                    SOCResourceSet rs)
the user wants to discard

Parameters:
ga - the game

pickResources

public void pickResources(SOCGame ga,
                          SOCResourceSet rs)
The user has picked these resources to gain from the gold hex. Or, in game state SOCGame.WAITING_FOR_DISCOVERY, has picked these 2 free resources from a Discovery/Year of Plenty card.

Parameters:
ga - the game
rs - The resources to pick
Since:
2.0.00

choosePlayer

public void choosePlayer(SOCGame ga,
                         int ch)
The user chose a player to steal from, or (game state SOCGame.WAITING_FOR_ROBBER_OR_PIRATE) chose whether to move the robber or the pirate, or (game state SOCGame.WAITING_FOR_ROB_CLOTH_OR_RESOURCE) chose whether to steal a resource or cloth.

Parameters:
ga - the game
ch - the player number, or SOCChoosePlayer.CHOICE_MOVE_ROBBER to move the robber or SOCChoosePlayer.CHOICE_MOVE_PIRATE to move the pirate ship. See SOCChoosePlayer.SOCChoosePlayer(String, int) for meaning of ch for game state WAITING_FOR_ROB_CLOTH_OR_RESOURCE.

chooseRobber

public void chooseRobber(SOCGame ga)
The user is reacting to the move robber request.

Parameters:
ga - the game

choosePirate

public void choosePirate(SOCGame ga)
The user is reacting to the move pirate request.

Parameters:
ga - the game

rejectOffer

public void rejectOffer(SOCGame ga)
the user is rejecting the current offers

Parameters:
ga - the game

acceptOffer

public void acceptOffer(SOCGame ga,
                        int from)
the user is accepting an offer

Parameters:
ga - the game
from - the number of the player that is making the offer

clearOffer

public void clearOffer(SOCGame ga)
the user is clearing an offer

Parameters:
ga - the game

bankTrade

public void bankTrade(SOCGame ga,
                      SOCResourceSet give,
                      SOCResourceSet get)
the user wants to trade with the bank or a port.

Parameters:
ga - the game
give - what is being offered
get - what the player wants

offerTrade

public void offerTrade(SOCGame ga,
                       SOCTradeOffer offer)
the user is making an offer to trade with another player.

Parameters:
ga - the game
offer - the trade offer

playDevCard

public void playDevCard(SOCGame ga,
                        int dc)
the user wants to play a development card

Parameters:
ga - the game
dc - the type of development card

playInventoryItem

public void playInventoryItem(SOCGame ga,
                              int itype)
The current user wants to play a special SOCInventoryItem. Send the server a SOCInventoryItemAction(currentPlayerNumber, PLAY, itype, rc=0) message.

Parameters:
ga - the game
itype - the special inventory item type picked by player, from SOCInventoryItem.itype

pickSpecialItem

public void pickSpecialItem(SOCGame ga,
                            java.lang.String typeKey,
                            int gi,
                            int pi)
The current user wants to pick a Special Item. Send the server a SOCSetSpecialItem(PICK, typeKey, gi, pi, owner=-1, coord=-1, level=0) message.

Parameters:
ga - Game
typeKey - Special item type. Typically a SOCGameOption keyname; see the SOCSpecialItem class javadoc for details.
gi - Game Item Index, as in SOCGame.getSpecialItem(String, int) or SOCSpecialItem.playerPickItem(String, SOCGame, SOCPlayer, int, int), or -1
pi - Player Item Index, as in SOCSpecialItem.playerPickItem(String, SOCGame, SOCPlayer, int, int), or -1

discoveryPick

public void discoveryPick(SOCGame ga,
                          SOCResourceSet rscs)
the user picked 2 resources to discover

Parameters:
ga - the game
rscs - the resources

monopolyPick

public void monopolyPick(SOCGame ga,
                         int res)
the user picked a resource to monopolize

Parameters:
ga - the game
res - the resource

changeFace

public void changeFace(SOCGame ga,
                       int id)
the user is changing the face image

Parameters:
ga - the game
id - the image id

setSeatLock

public void setSeatLock(SOCGame ga,
                        int pn,
                        SOCGame.SeatLockState sl)
The user is locking or unlocking a seat.

Parameters:
ga - the game
pn - the seat number
sl - new seat lock state; remember that servers older than v2.0.00 won't recognize CLEAR_ON_RESET
Since:
2.0.00

resetBoardRequest

public void resetBoardRequest(SOCGame ga)
Player wants to request to reset the board (same players, new game, new layout). Send SOCResetBoardRequest to server; it will either respond with a SOCResetBoardAuth message, or will tell other players to vote yes/no on the request. Before calling, check player.hasAskedBoardReset() and game.getResetVoteActive().


resetBoardVote

public void resetBoardVote(SOCGame ga,
                           int pn,
                           boolean voteYes)
Player is responding to a board-reset vote from another player. Send SOCResetBoardRequest to server; it will either respond with a SOCResetBoardAuth message, or will tell other players to vote yes/no on the request.

Parameters:
ga - Game to vote on
pn - Player number of our player who is voting
voteYes - If true, this player votes yes; if false, no

considerMove

public void considerMove(SOCGame ga,
                         java.lang.String pname,
                         SOCPlayingPiece piece)
send a command to the server with a message asking a robot to show the debug info for a possible move after a move has been made

Parameters:
ga - the game
pname - the robot name
piece - the piece to consider

considerTarget

public void considerTarget(SOCGame ga,
                           java.lang.String pname,
                           SOCPlayingPiece piece)
send a command to the server with a message asking a robot to show the debug info for a possible move before a move has been made

Parameters:
ga - the game
pname - the robot name
piece - the piece to consider