Package net.sf.colossus.server
Class ClientHandlerStub
- java.lang.Object
-
- net.sf.colossus.server.ClientHandlerStub
-
- All Implemented Interfaces:
IClient
- Direct Known Subclasses:
ClientHandler
public class ClientHandlerStub extends java.lang.Object implements IClient
-
-
Field Summary
Fields Modifier and Type Field Description private int
alreadyHandled
protected static int
counter
protected boolean
isCommitPoint
protected boolean
isGone
private static java.util.logging.Logger
LOGGER
protected int
messageCounter
protected java.lang.String
playerName
private java.lang.String
previousInfoStringsString
protected java.util.ArrayList<MessageForClient>
redoQueue
protected static java.lang.String
sep
protected Server
server
protected java.lang.String
signonName
-
Constructor Summary
Constructors Constructor Description ClientHandlerStub(Server server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCreature(Legion legion, CreatureType creature, java.lang.String reason)
void
appendToConnectionLog(java.lang.String message)
void
askAcquireAngel(Legion legion, java.util.List<CreatureType> recruits)
void
askChooseStrikePenalty(java.util.List<java.lang.String> choices)
void
askConcede(Legion ally, Legion enemy)
void
askFlee(Legion ally, Legion enemy)
void
askNegotiate(Legion attacker, Legion defender)
void
askPickColor(java.util.List<PlayerColor> colorsLeft)
void
askPickFirstMarker()
boolean
canHandleAdvancedSync()
protected boolean
canHandlePingRequest()
void
cleanupBattle()
protected void
commitPoint()
void
confirmWhenCaughtUp()
void
createSummonAngel(Legion legion)
void
didMove(Legion legion, MasterHex startingHex, MasterHex currentHex, EntrySide entrySide, boolean teleport, CreatureType teleportingLord, boolean splitLegionHasForcedMove)
void
didRecruit(Legion legion, CreatureType recruit, CreatureType recruiter, int numRecruiters)
void
didSplit(MasterHex hex, Legion parent, Legion child, int childHeight, java.util.List<CreatureType> splitoffs, int turn)
void
didSummon(Legion summoner, Legion donor, CreatureType summon)
void
disposeClient()
Server side disposes a client (and informs it about it first) To be used only for "disposeAllClients()", otherwise setIsGone reason is misleading.void
doReinforce(Legion legion)
protected void
enqueueToRedoQueue(int messageNr, java.lang.String message)
protected void
flushQueuedContent()
Selector reported that client became writable again (after a prior write attempt had not written all bytes).java.lang.String
getClientName()
java.lang.String
getPlayerName()
java.lang.String
getSignonName()
void
initBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender)
void
initBoard()
protected boolean
isStub()
void
kickPhase()
void
log(java.lang.String message)
void
messageFromServer(java.lang.String message)
void
nak(java.lang.String reason, java.lang.String errmsg)
void
nextEngagement()
void
pingRequest()
void
placeNewChit(java.lang.String imageName, boolean inverted, int tag, BattleHex hex)
void
removeCreature(Legion legion, CreatureType creature, java.lang.String reason)
void
removeDeadBattleChits()
void
removeLegion(Legion legion)
void
revealCreatures(Legion legion, java.util.List<CreatureType> creatures, java.lang.String reason)
void
revealEngagedCreatures(Legion legion, java.util.List<CreatureType> creatures, boolean isAttacker, java.lang.String reason)
print the 'revealEngagagedCreature'-message, args: markerId, isAttacker, list of creature namesprotected void
sendToClient(java.lang.String message)
void
serverConfirmsConnection()
void
setBoardActive(boolean val)
void
setColor(PlayerColor color)
void
setIsGone(java.lang.String reason)
void
setLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit)
void
setPlayerName(java.lang.String playerName)
void
setupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)
void
setupBattleMove(Player battleActivePlayer, int battleTurnNumber)
void
setupBattleRecruit(Player battleActivePlayer, int battleTurnNumber)
void
setupBattleSummon(Player battleActivePlayer, int battleTurnNumber)
void
setupFight()
void
setupMove()
void
setupMuster()
void
setupSplit(Player activePlayer, int turnNumber)
void
setupTurnState(Player activePlayer, int turnNumber)
protected boolean
supportsReconnect()
void
syncOption(java.lang.String optname, java.lang.String value)
void
tellBattleMove(int tag, BattleHex startingHex, BattleHex endingHex, boolean undo)
void
tellEngagement(MasterHex hex, Legion attacker, Legion defender)
void
tellEngagementResults(Legion winner, java.lang.String method, int points, int turns)
void
tellGameOver(java.lang.String message, boolean disposeFollows)
void
tellInitialGameInfo(java.lang.String variantName, java.util.Collection<java.lang.String> playerNames)
void
tellLegionLocation(Legion legion, MasterHex hex)
void
tellMovementRoll(int roll)
void
tellPlayerElim(Player player, Player slayer)
void
tellProposal(java.lang.String proposalString)
void
tellRedo(boolean val)
void
tellReplay(boolean val, int maxTurn)
void
tellSlowResults(int targetTag, int slowValue)
void
tellStrikeResults(int strikerTag, int targetTag, int strikeNumber, java.util.List<java.lang.String> rolls, int damage, boolean killed, boolean wasCarry, int carryDamageLeft, java.util.Set<java.lang.String> carryTargetDescriptions)
void
tellSyncCompleted(int syncRequestNumber)
void
tellWhatsHappening(java.lang.String message)
void
undidMove(Legion legion, MasterHex formerHex, MasterHex currentHex, boolean splitLegionHasForcedMove)
void
undidRecruit(Legion legion, CreatureType recruit)
void
undidSplit(Legion splitoff, Legion survivor, int turn)
void
updateCreatureCount(CreatureType type, int count, int deadCount)
void
updateOnePlayersInfo(boolean redundant, java.lang.String reason, java.lang.String ShouldBeSeveralSeparateVariablesHerePerhaps)
A new way to pass changed player info to clients.void
updatePlayerInfo(java.util.List<java.lang.String> infoStrings)
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
sep
protected static final java.lang.String sep
- See Also:
- Constant Field Values
-
server
protected Server server
-
counter
protected static int counter
-
isGone
protected boolean isGone
-
playerName
protected java.lang.String playerName
-
signonName
protected java.lang.String signonName
-
messageCounter
protected int messageCounter
-
isCommitPoint
protected boolean isCommitPoint
-
redoQueue
protected final java.util.ArrayList<MessageForClient> redoQueue
-
previousInfoStringsString
private java.lang.String previousInfoStringsString
-
alreadyHandled
private int alreadyHandled
-
-
Constructor Detail
-
ClientHandlerStub
public ClientHandlerStub(Server server)
-
-
Method Detail
-
isStub
protected boolean isStub()
-
canHandlePingRequest
protected boolean canHandlePingRequest()
-
canHandleAdvancedSync
public boolean canHandleAdvancedSync()
-
supportsReconnect
protected boolean supportsReconnect()
-
setIsGone
public void setIsGone(java.lang.String reason)
-
sendToClient
protected void sendToClient(java.lang.String message)
-
flushQueuedContent
protected void flushQueuedContent()
Selector reported that client became writable again (after a prior write attempt had not written all bytes). Now start/try writing the message(s) which are still in the queue.
-
enqueueToRedoQueue
protected void enqueueToRedoQueue(int messageNr, java.lang.String message)
-
commitPoint
protected void commitPoint()
-
disposeClient
public void disposeClient()
Server side disposes a client (and informs it about it first) To be used only for "disposeAllClients()", otherwise setIsGone reason is misleading.- Specified by:
disposeClient
in interfaceIClient
-
tellEngagement
public void tellEngagement(MasterHex hex, Legion attacker, Legion defender)
- Specified by:
tellEngagement
in interfaceIClient
-
tellEngagementResults
public void tellEngagementResults(Legion winner, java.lang.String method, int points, int turns)
- Specified by:
tellEngagementResults
in interfaceIClient
-
tellWhatsHappening
public void tellWhatsHappening(java.lang.String message)
- Specified by:
tellWhatsHappening
in interfaceIClient
-
tellMovementRoll
public void tellMovementRoll(int roll)
- Specified by:
tellMovementRoll
in interfaceIClient
-
syncOption
public void syncOption(java.lang.String optname, java.lang.String value)
- Specified by:
syncOption
in interfaceIClient
-
updatePlayerInfo
public void updatePlayerInfo(java.util.List<java.lang.String> infoStrings)
- Specified by:
updatePlayerInfo
in interfaceIClient
-
updateOnePlayersInfo
public void updateOnePlayersInfo(boolean redundant, java.lang.String reason, java.lang.String ShouldBeSeveralSeparateVariablesHerePerhaps)
A new way to pass changed player info to clients. Shortened info (e.g. color, dead state, ...) not sent every time; Includes a reason why sent (mostly used internally on server side for debugging/development purposes), and a flag whether this info should be redundant; idea behind it: on the long run, clients should be able to update game/player info "autonomously" (same logic implemented on client as on server) instead of server doing it and synching to all clients. So this redundant is meant to be used as safety net to detect where that new approach might miss something.- Specified by:
updateOnePlayersInfo
in interfaceIClient
-
setColor
public void setColor(PlayerColor color)
-
updateCreatureCount
public void updateCreatureCount(CreatureType type, int count, int deadCount)
- Specified by:
updateCreatureCount
in interfaceIClient
-
removeLegion
public void removeLegion(Legion legion)
- Specified by:
removeLegion
in interfaceIClient
-
setLegionStatus
public void setLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit)
- Specified by:
setLegionStatus
in interfaceIClient
-
addCreature
public void addCreature(Legion legion, CreatureType creature, java.lang.String reason)
- Specified by:
addCreature
in interfaceIClient
-
removeCreature
public void removeCreature(Legion legion, CreatureType creature, java.lang.String reason)
- Specified by:
removeCreature
in interfaceIClient
-
revealCreatures
public void revealCreatures(Legion legion, java.util.List<CreatureType> creatures, java.lang.String reason)
- Specified by:
revealCreatures
in interfaceIClient
-
revealEngagedCreatures
public void revealEngagedCreatures(Legion legion, java.util.List<CreatureType> creatures, boolean isAttacker, java.lang.String reason)
print the 'revealEngagagedCreature'-message, args: markerId, isAttacker, list of creature names- Specified by:
revealEngagedCreatures
in interfaceIClient
- Parameters:
markerId
- legion marker name that is currently in battlecreatures
- List of creatures in this legionisAttacker
- true for attacker, false for defenderreason
- why this was revealed
-
removeDeadBattleChits
public void removeDeadBattleChits()
- Specified by:
removeDeadBattleChits
in interfaceIClient
-
placeNewChit
public void placeNewChit(java.lang.String imageName, boolean inverted, int tag, BattleHex hex)
- Specified by:
placeNewChit
in interfaceIClient
-
tellReplay
public void tellReplay(boolean val, int maxTurn)
- Specified by:
tellReplay
in interfaceIClient
-
setPlayerName
public void setPlayerName(java.lang.String playerName)
- Specified by:
setPlayerName
in interfaceIClient
-
getSignonName
public java.lang.String getSignonName()
-
getClientName
public java.lang.String getClientName()
-
getPlayerName
public java.lang.String getPlayerName()
-
createSummonAngel
public void createSummonAngel(Legion legion)
- Specified by:
createSummonAngel
in interfaceIClient
-
askAcquireAngel
public void askAcquireAngel(Legion legion, java.util.List<CreatureType> recruits)
- Specified by:
askAcquireAngel
in interfaceIClient
-
askChooseStrikePenalty
public void askChooseStrikePenalty(java.util.List<java.lang.String> choices)
- Specified by:
askChooseStrikePenalty
in interfaceIClient
-
tellGameOver
public void tellGameOver(java.lang.String message, boolean disposeFollows)
- Specified by:
tellGameOver
in interfaceIClient
-
tellPlayerElim
public void tellPlayerElim(Player player, Player slayer)
- Specified by:
tellPlayerElim
in interfaceIClient
-
askConcede
public void askConcede(Legion ally, Legion enemy)
- Specified by:
askConcede
in interfaceIClient
-
askNegotiate
public void askNegotiate(Legion attacker, Legion defender)
- Specified by:
askNegotiate
in interfaceIClient
-
tellProposal
public void tellProposal(java.lang.String proposalString)
- Specified by:
tellProposal
in interfaceIClient
-
tellSlowResults
public void tellSlowResults(int targetTag, int slowValue)
- Specified by:
tellSlowResults
in interfaceIClient
-
tellStrikeResults
public void tellStrikeResults(int strikerTag, int targetTag, int strikeNumber, java.util.List<java.lang.String> rolls, int damage, boolean killed, boolean wasCarry, int carryDamageLeft, java.util.Set<java.lang.String> carryTargetDescriptions)
- Specified by:
tellStrikeResults
in interfaceIClient
-
initBattle
public void initBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender)
- Specified by:
initBattle
in interfaceIClient
-
cleanupBattle
public void cleanupBattle()
- Specified by:
cleanupBattle
in interfaceIClient
-
nextEngagement
public void nextEngagement()
- Specified by:
nextEngagement
in interfaceIClient
-
doReinforce
public void doReinforce(Legion legion)
- Specified by:
doReinforce
in interfaceIClient
-
didRecruit
public void didRecruit(Legion legion, CreatureType recruit, CreatureType recruiter, int numRecruiters)
- Specified by:
didRecruit
in interfaceIClient
-
undidRecruit
public void undidRecruit(Legion legion, CreatureType recruit)
- Specified by:
undidRecruit
in interfaceIClient
-
setupTurnState
public void setupTurnState(Player activePlayer, int turnNumber)
- Specified by:
setupTurnState
in interfaceIClient
-
setupSplit
public void setupSplit(Player activePlayer, int turnNumber)
- Specified by:
setupSplit
in interfaceIClient
-
setupFight
public void setupFight()
- Specified by:
setupFight
in interfaceIClient
-
setupMuster
public void setupMuster()
- Specified by:
setupMuster
in interfaceIClient
-
setupBattleSummon
public void setupBattleSummon(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleSummon
in interfaceIClient
-
setupBattleRecruit
public void setupBattleRecruit(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleRecruit
in interfaceIClient
-
setupBattleMove
public void setupBattleMove(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleMove
in interfaceIClient
-
setupBattleFight
public void setupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)
- Specified by:
setupBattleFight
in interfaceIClient
-
tellLegionLocation
public void tellLegionLocation(Legion legion, MasterHex hex)
- Specified by:
tellLegionLocation
in interfaceIClient
-
tellBattleMove
public void tellBattleMove(int tag, BattleHex startingHex, BattleHex endingHex, boolean undo)
- Specified by:
tellBattleMove
in interfaceIClient
-
didMove
public void didMove(Legion legion, MasterHex startingHex, MasterHex currentHex, EntrySide entrySide, boolean teleport, CreatureType teleportingLord, boolean splitLegionHasForcedMove)
-
undidMove
public void undidMove(Legion legion, MasterHex formerHex, MasterHex currentHex, boolean splitLegionHasForcedMove)
-
didSummon
public void didSummon(Legion summoner, Legion donor, CreatureType summon)
-
undidSplit
public void undidSplit(Legion splitoff, Legion survivor, int turn)
- Specified by:
undidSplit
in interfaceIClient
-
didSplit
public void didSplit(MasterHex hex, Legion parent, Legion child, int childHeight, java.util.List<CreatureType> splitoffs, int turn)
-
askPickColor
public void askPickColor(java.util.List<PlayerColor> colorsLeft)
- Specified by:
askPickColor
in interfaceIClient
-
askPickFirstMarker
public void askPickFirstMarker()
- Specified by:
askPickFirstMarker
in interfaceIClient
-
nak
public void nak(java.lang.String reason, java.lang.String errmsg)
-
setBoardActive
public void setBoardActive(boolean val)
- Specified by:
setBoardActive
in interfaceIClient
-
tellInitialGameInfo
public void tellInitialGameInfo(java.lang.String variantName, java.util.Collection<java.lang.String> playerNames)
-
confirmWhenCaughtUp
public void confirmWhenCaughtUp()
- Specified by:
confirmWhenCaughtUp
in interfaceIClient
-
serverConfirmsConnection
public void serverConfirmsConnection()
- Specified by:
serverConfirmsConnection
in interfaceIClient
-
pingRequest
public void pingRequest()
- Specified by:
pingRequest
in interfaceIClient
-
messageFromServer
public void messageFromServer(java.lang.String message)
- Specified by:
messageFromServer
in interfaceIClient
-
appendToConnectionLog
public void appendToConnectionLog(java.lang.String message)
- Specified by:
appendToConnectionLog
in interfaceIClient
-
tellSyncCompleted
public void tellSyncCompleted(int syncRequestNumber)
- Specified by:
tellSyncCompleted
in interfaceIClient
-
-