|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PlayerClientListener
A listener on the SOCPlayerClient
to decouple the presentation from the networking.
This presents the facade of the UI to the networking layer.
The game data (SOCGame
, SOCPlayer
methods) will be updated before
these methods are called, so you can call game-object methods for more details on the new event.
The classic presentation implementing this interface is SOCPlayerInterface.ClientBridge
.
Nested Class Summary | |
---|---|
static class |
PlayerClientListener.UpdateType
Player data update types for playerElementUpdated(SOCPlayer, UpdateType) . |
Method Summary | |
---|---|
void |
boardLayoutUpdated()
|
void |
boardPotentialsUpdated()
|
void |
boardReset(SOCGame newGame,
int newSeatNumber,
int requestingPlayerNumber)
|
void |
boardResetVoteCast(SOCPlayer voter,
boolean vote)
|
void |
boardResetVoteRejected()
|
void |
boardResetVoteRequested(SOCPlayer requestor)
|
void |
boardUpdated()
|
void |
buildRequestCanceled(SOCPlayer player)
|
void |
debugFreePlaceModeToggled(boolean isEnabled)
|
void |
devCardDeckUpdated()
|
void |
diceRolled(SOCPlayer player,
int resultSum)
Receive a notification that the current player has rolled the dice. |
void |
diceRolledResources(java.util.List<java.lang.Integer> pnum,
java.util.List<SOCResourceSet> rsrc)
Receive a notification that the dice roll resulted in players gaining resources. |
void |
gameDisconnected(java.lang.String errorMessage)
|
void |
gameEnded(java.util.Map<SOCPlayer,java.lang.Integer> scores)
|
void |
gameStarted()
Game play is starting (leaving state SOCGame.NEW ). |
void |
gameStateChanged(int gameState)
Update interface after game state has changed. |
void |
invItemPlayRejected(int type,
int reasonCode)
Client player's request to play a special SOCInventoryItem was rejected by the server. |
void |
largestArmyRefresh(SOCPlayer old,
SOCPlayer potentialNew)
The largest army might have changed, so update |
void |
longestRoadRefresh(SOCPlayer old,
SOCPlayer potentialNew)
The longest road might have changed, so update |
void |
membersListed(java.util.Collection<java.lang.String> names)
The current game members (players and observers) are listed, and the game is about to start. |
void |
messageBroadcast(java.lang.String message)
|
void |
messageSent(java.lang.String nickname,
java.lang.String message)
A game text message was received from server, or a chat message from another player. |
void |
pieceValueUpdated(SOCPlayingPiece piece)
A playing piece's value was updated: _SC_CLVI village cloth count, or
_SC_PIRI pirate fortress strength. |
void |
playerCanCancelInvItemPlay(SOCPlayer player,
boolean canCancel)
A player is playing or placing a special SOCInventoryItem , such as
a gift trade port in scenario _SC_FTRI . |
void |
playerDevCardUpdated(SOCPlayer player,
boolean addedPlayable)
A player is drawing or playing a development card, or a card or special SOCInventoryItem has been added or removed from their hand's inventory. |
void |
playerElementUpdated(SOCPlayer player,
PlayerClientListener.UpdateType utype)
Update one part of the player's status, such as their number of settlements remaining. |
void |
playerFaceChanged(SOCPlayer player,
int faceId)
A player has changed their face icon. |
void |
playerJoined(java.lang.String nickname)
A client (us or someone else) has joined the game. |
void |
playerLeft(java.lang.String nickname,
SOCPlayer player)
A client player or observer is leaving the game. |
void |
playerPickSpecialItem(java.lang.String typeKey,
SOCGame ga,
SOCPlayer pl,
int gi,
int pi,
boolean isPick,
int coord,
int level,
java.lang.String sv)
Show the results of a player's PICK of a known Special Item ,
or the server's DECLINE of the client player's pick request. |
void |
playerPieceMoved(SOCPlayer player,
int sourceCoordinate,
int targetCoordinate,
int pieceType)
A player has moved a piece on the board. |
void |
playerPiecePlaced(SOCPlayer player,
int coordinate,
int pieceType)
A player has placed a piece on the board. |
void |
playerPieceRemoved(SOCPlayer player,
int pieceCoordinate,
int pieceType)
A player's piece has been removed from the board. |
void |
playerResourcesUpdated(SOCPlayer player)
A player's total resource count has been updated. |
void |
playerSetSpecialItem(java.lang.String typeKey,
SOCGame ga,
SOCPlayer pl,
int gi,
int pi,
boolean isSet)
Show the results of a player's SET or CLEAR of a known Special Item . |
void |
playerSitdown(int playerNumber,
java.lang.String nickname)
A client has sat down to become an active player. |
void |
playerStats(java.util.EnumMap<PlayerClientListener.UpdateType,java.lang.Integer> stats)
A player's game stats, such as resource totals received from dice rolls, should be displayed. |
void |
playerSVPAwarded(SOCPlayer player,
int numSvp,
java.lang.String awardDescription)
A player has been awarded Special Victory Point(s). |
void |
playerTurnSet(int playerNumber)
Game's current player has changed. |
void |
requestedChoosePlayer(java.util.List<SOCPlayer> choices,
boolean isNoneAllowed)
This player must choose a player for robbery. |
void |
requestedChooseRobResourceType(SOCPlayer player)
|
void |
requestedDiceRoll()
|
void |
requestedDiscard(int countToDiscard)
The game requests that the client player discard a particular number of resource cards. |
void |
requestedGoldResourceCountUpdated(SOCPlayer player,
int countToSelect)
This player must pick this many gold-hex resources, or no longer needs to pick them. |
void |
requestedResourceSelect(int countToSelect)
The client player gets some free resources of their choice. |
void |
requestedSpecialBuild(SOCPlayer player)
|
void |
requestedTrade(SOCPlayer offerer)
|
void |
requestedTradeClear(SOCPlayer offerer)
|
void |
requestedTradeRejection(SOCPlayer rejecter)
|
void |
requestedTradeReset(SOCPlayer playerToReset)
|
void |
robberMoved()
|
void |
scen_SC_PIRI_pirateFortressAttackResult(boolean wasRejected,
int defStrength,
int resultShipsLost)
In scenario _SC_PIRI, present the server's response to a Pirate Fortress Attack request from the current player (the client or another player), which may be: Rejected, Lost, Tied, or Won. |
void |
seatLockUpdated()
|
void |
simpleAction(int pn,
int acttype,
int value1,
int value2)
A "simple action" has occurred in the game and should be displayed. |
void |
simpleRequest(int pn,
int reqtype,
int value1,
int value2)
A player's "simple request" has been sent to the entire game, or the server
has replied to our own simple request, and this should be displayed. |
Method Detail |
---|
void diceRolled(SOCPlayer player, int resultSum)
diceRolled
, diceRolledResources(List, List)
is often called next.
player
- May be null
if the current player was null when the dice roll was received from the server.resultSum
- The sum of the dice rolled. May be -1 for some game events.void diceRolledResources(java.util.List<java.lang.Integer> pnum, java.util.List<SOCResourceSet> rsrc)
diceRolled(SOCPlayer, int)
.
pnum
- Player numbers, same format as SOCDiceResultResources.playerNum
rsrc
- Resources gained by each pn
, same format as SOCDiceResultResources.playerRsrc
void playerJoined(java.lang.String nickname)
playerSitdown(int, String)
is called,
then they will be an active player.
nickname
- New client's player/observer namevoid playerLeft(java.lang.String nickname, SOCPlayer player)
nickname
- The player name. Will not be null
player
- May be null
if the current player is an observer.void playerSitdown(int playerNumber, java.lang.String nickname)
playerJoined(String)
was called earlier on this client.
SOCGame.addPlayer(String, int)
has just been called.
playerNumber
- New player's playerNumber in the game; the seat number they've sat down atnickname
- New player's namevoid playerTurnSet(int playerNumber)
playerNumber
- New current player number whose turn it is.void playerPiecePlaced(SOCPlayer player, int coordinate, int pieceType)
pieceType
- A piece type identifier, such as SOCPlayingPiece.CITY
void playerPieceMoved(SOCPlayer player, int sourceCoordinate, int targetCoordinate, int pieceType)
SOCShip
pieces can sometimes be moved.
Not used when the robber or pirate is moved; see robberMoved()
.
pieceType
- A piece type identifier, such as SOCPlayingPiece.CITY
void playerPieceRemoved(SOCPlayer player, int pieceCoordinate, int pieceType)
_SC_PIRI
.
player
- Player who owns the shippieceCoordinate
- Ship's node coordinatepieceType
- The piece type identifier SOCPlayingPiece.SHIP
void playerSVPAwarded(SOCPlayer player, int numSvp, java.lang.String awardDescription)
player
- The player awarded special victory points. Will not be null
numSvp
- The count of how many new special victory points were awardedawardDescription
- A user-display message describing the reason for the awardvoid playerDevCardUpdated(SOCPlayer player, boolean addedPlayable)
SOCInventoryItem
has been added or removed from their hand's inventory.
If this inventory update comes from playing a special SOCInventoryItem
, call
playerCanCancelInvItemPlay(SOCPlayer, boolean)
after calling this method.
player
- The playeraddedPlayable
- True if the update added a dev card or item that's playable nowvoid playerCanCancelInvItemPlay(SOCPlayer player, boolean canCancel)
SOCInventoryItem
, such as
a gift trade port in scenario _SC_FTRI
. Set a flag that indicates
if this play or placement can be canceled (returned to player's inventory).
It makes sense to call this for only the client player, since we don't cancel other players' item plays.
player
- The playercanCancel
- True if SOCInventoryItem.canCancelPlay
void playerFaceChanged(SOCPlayer player, int faceId)
player
- The playerfaceId
- New face icon number;
1 and higher are human face images, 0 is the default robot, -1 is the smarter robot.void playerElementUpdated(SOCPlayer player, PlayerClientListener.UpdateType utype)
player
- May be null
utype
- The type of element to updatevoid playerResourcesUpdated(SOCPlayer player)
player
- The playervoid playerStats(java.util.EnumMap<PlayerClientListener.UpdateType,java.lang.Integer> stats)
stats
- Player statistic detailsvoid requestedDiscard(int countToDiscard)
countToDiscard
- Must choose and discard this many cardsvoid requestedResourceSelect(int countToSelect)
countToSelect
- Must choose this many resourcesrequestedGoldResourceCountUpdated(SOCPlayer, int)
void requestedGoldResourceCountUpdated(SOCPlayer player, int countToSelect)
requestedResourceSelect(int)
is used for that.
player
- The playercountToSelect
- Number of free resources they must pick, or 0 if they've just picked themvoid requestedChoosePlayer(java.util.List<SOCPlayer> choices, boolean isNoneAllowed)
choices
- The potential victim players to choose fromisNoneAllowed
- If true, player can choose to rob no one (game scenario SC_PIRI)SOCPlayerClient.GameManager.choosePlayer(SOCGame, int)
void requestedChooseRobResourceType(SOCPlayer player)
void requestedTrade(SOCPlayer offerer)
void requestedTradeClear(SOCPlayer offerer)
offerer
- May be null
void requestedTradeRejection(SOCPlayer rejecter)
void requestedTradeReset(SOCPlayer playerToReset)
playerToReset
- May be null
to clear all seatsvoid requestedSpecialBuild(SOCPlayer player)
void requestedDiceRoll()
void largestArmyRefresh(SOCPlayer old, SOCPlayer potentialNew)
void longestRoadRefresh(SOCPlayer old, SOCPlayer potentialNew)
void membersListed(java.util.Collection<java.lang.String> names)
names
- Game member names; to see if each is a player, call SOCGame.getPlayer(String)
.void boardLayoutUpdated()
void boardUpdated()
void pieceValueUpdated(SOCPlayingPiece piece)
_SC_CLVI
village cloth count, or
_SC_PIRI
pirate fortress strength.
Repaint that piece (if needed) on the board.
piece
- Piece that was updated, includes its new valuevoid boardPotentialsUpdated()
void boardReset(SOCGame newGame, int newSeatNumber, int requestingPlayerNumber)
void boardResetVoteRequested(SOCPlayer requestor)
void boardResetVoteCast(SOCPlayer voter, boolean vote)
void boardResetVoteRejected()
void robberMoved()
void devCardDeckUpdated()
void seatLockUpdated()
void gameStarted()
SOCGame.NEW
).
Next move is for players to make their starting placements.
Call SOCGame.setGameState(int)
before calling this method.
Call this method before calling gameStateChanged(int)
.
void gameStateChanged(int gameState)
SOCGame.setGameState(int)
first.
If the game is now starting, please call in this order:
game.setGameState(newState);
gameStarted()
;
gameStateChanged(int)
;
gameState
- One of the codes from SOCGame, such as SOCGame.NEW
void gameEnded(java.util.Map<SOCPlayer,java.lang.Integer> scores)
void gameDisconnected(java.lang.String errorMessage)
void messageBroadcast(java.lang.String message)
void messageSent(java.lang.String nickname, java.lang.String message)
nickname
- Player's nickname, or null
for messages from the server itselfmessage
- Message textvoid simpleRequest(int pn, int reqtype, int value1, int value2)
"simple request"
has been sent to the entire game, or the server
has replied to our own simple request, and this should be displayed.
This method lets us display simple things from the server without defining a lot of small similar methods.
If other game data messages are sent (resource gains/loss, etc), or other client code must update that data
based on info in the SOCSimpleRequest, this method will be called only after other game data is updated.
Some SimpleRequest reqtype
s update the game data: Client must call
SOCDisplaylessPlayerClient.handleSIMPLEREQUEST(Map, soc.message.SOCSimpleRequest)
to update game before calling this method.
pn
- The player number requesting or acting, or -1 if our own request was declinedreqtype
- The request type, from SOCSimpleRequest
constants for simplicityvalue1
- First optional detail value, or 0value2
- Second optional detail value, or 0simpleAction(int, int, int, int)
void simpleAction(int pn, int acttype, int value1, int value2)
"simple action"
has occurred in the game and should be displayed.
This method lets us show simple things from the server without defining a lot of small similar methods.
This will be called only after other game data is updated (number of dev cards, resource gains/loss, etc).
pn
- The player number acting or acted onacttype
- The action type, from SOCSimpleAction
constants for simplicityvalue1
- First optional detail value, or 0value2
- Second optional detail value, or 0simpleRequest(int, int, int, int)
void buildRequestCanceled(SOCPlayer player)
void invItemPlayRejected(int type, int reasonCode)
SOCInventoryItem
was rejected by the server.
type
- Item type from SOCInventoryItem.itype
reasonCode
- Optional reason code for the SOCInventoryItemAction.CANNOT_PLAY
action,
corresponding to SOCGame.canPlayInventoryItem(int, int)
return codes, or 0void playerPickSpecialItem(java.lang.String typeKey, SOCGame ga, SOCPlayer pl, int gi, int pi, boolean isPick, int coord, int level, java.lang.String sv)
PICK
of a known Special Item
,
or the server's DECLINE
of the client player's pick request.
To see which scenario and option typeKey
s pick Special Items,
and scenario-specific usage details, see the SOCSpecialItem
class javadoc.
coord
and level
are sent for convenience, and sometimes may not be from the Special Item you need;
see SOCSetSpecialItem.OP_PICK
for details.
typeKey
- Item's typeKey
, as described in the SOCSpecialItem
class javadocga
- Game containing pl
and special itemspl
- Player who picked: Never null
when isPick
,
is null
if server declined our player's requestgi
- Picked this index within game's Special Item list, or -1pi
- Picked this index within pl
's Special Item list, or -1isPick
- True if calling for PICK
, false if server has DECLINE
d the client player's requestcoord
- Optional coordinates on the board for this item, or -1. An edge or a node, depending on item typelevel
- Optional level of construction or strength, or 0sv
- Optional string value from SOCSpecialItem.getStringValue()
, or null
playerSetSpecialItem(String, SOCGame, SOCPlayer, int, int, boolean)
,
SOCSpecialItem.playerPickItem(String, SOCGame, SOCPlayer, int, int)
void playerSetSpecialItem(java.lang.String typeKey, SOCGame ga, SOCPlayer pl, int gi, int pi, boolean isSet)
SET
or CLEAR
of a known Special Item
.
To see which scenario and option typeKey
s set or clear Special Items,
and scenario-specific usage details, see the SOCSpecialItem
class javadoc.
typeKey
- Item's typeKey
, as described in the SOCSpecialItem
class javadocga
- Game containing pl
and special itemspl
- Requesting player; never null
gi
- Set or clear this index within game's Special Item list, or -1pi
- Set or clear this index within pl
's Special Item list, or -1isSet
- True if player has set, false if player has cleared, this item indexplayerPickSpecialItem(String, SOCGame, SOCPlayer, int, int, boolean, int, int, String)
,
SOCSpecialItem.playerSetItem(String, SOCGame, SOCPlayer, int, int, boolean)
void scen_SC_PIRI_pirateFortressAttackResult(boolean wasRejected, int defStrength, int resultShipsLost)
This will be called only after other game pieces are updated (fortress strength, player's ships lost).
wasRejected
- True if the server rejected our player's request to attackdefStrength
- Pirate defense strength, unless wasRejected
resultShipsLost
- Result and number of ships lost by the player:
0 if player won (or if rejected); 1 if tied; 2 if player lost to the pirates.void debugFreePlaceModeToggled(boolean isEnabled)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |