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 intalreadyHandledprotected static intcounterprotected booleanisCommitPointprotected booleanisGoneprivate static java.util.logging.LoggerLOGGERprotected intmessageCounterprotected java.lang.StringplayerNameprivate java.lang.StringpreviousInfoStringsStringprotected java.util.ArrayList<MessageForClient>redoQueueprotected static java.lang.Stringsepprotected Serverserverprotected java.lang.StringsignonName
-
Constructor Summary
Constructors Constructor Description ClientHandlerStub(Server server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCreature(Legion legion, CreatureType creature, java.lang.String reason)voidappendToConnectionLog(java.lang.String message)voidaskAcquireAngel(Legion legion, java.util.List<CreatureType> recruits)voidaskChooseStrikePenalty(java.util.List<java.lang.String> choices)voidaskConcede(Legion ally, Legion enemy)voidaskFlee(Legion ally, Legion enemy)voidaskNegotiate(Legion attacker, Legion defender)voidaskPickColor(java.util.List<PlayerColor> colorsLeft)voidaskPickFirstMarker()booleancanHandleAdvancedSync()protected booleancanHandlePingRequest()voidcleanupBattle()protected voidcommitPoint()voidconfirmWhenCaughtUp()voidcreateSummonAngel(Legion legion)voiddidMove(Legion legion, MasterHex startingHex, MasterHex currentHex, EntrySide entrySide, boolean teleport, CreatureType teleportingLord, boolean splitLegionHasForcedMove)voiddidRecruit(Legion legion, CreatureType recruit, CreatureType recruiter, int numRecruiters)voiddidSplit(MasterHex hex, Legion parent, Legion child, int childHeight, java.util.List<CreatureType> splitoffs, int turn)voiddidSummon(Legion summoner, Legion donor, CreatureType summon)voiddisposeClient()Server side disposes a client (and informs it about it first) To be used only for "disposeAllClients()", otherwise setIsGone reason is misleading.voiddoReinforce(Legion legion)protected voidenqueueToRedoQueue(int messageNr, java.lang.String message)protected voidflushQueuedContent()Selector reported that client became writable again (after a prior write attempt had not written all bytes).java.lang.StringgetClientName()java.lang.StringgetPlayerName()java.lang.StringgetSignonName()voidinitBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender)voidinitBoard()protected booleanisStub()voidkickPhase()voidlog(java.lang.String message)voidmessageFromServer(java.lang.String message)voidnak(java.lang.String reason, java.lang.String errmsg)voidnextEngagement()voidpingRequest()voidplaceNewChit(java.lang.String imageName, boolean inverted, int tag, BattleHex hex)voidremoveCreature(Legion legion, CreatureType creature, java.lang.String reason)voidremoveDeadBattleChits()voidremoveLegion(Legion legion)voidrevealCreatures(Legion legion, java.util.List<CreatureType> creatures, java.lang.String reason)voidrevealEngagedCreatures(Legion legion, java.util.List<CreatureType> creatures, boolean isAttacker, java.lang.String reason)print the 'revealEngagagedCreature'-message, args: markerId, isAttacker, list of creature namesprotected voidsendToClient(java.lang.String message)voidserverConfirmsConnection()voidsetBoardActive(boolean val)voidsetColor(PlayerColor color)voidsetIsGone(java.lang.String reason)voidsetLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit)voidsetPlayerName(java.lang.String playerName)voidsetupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)voidsetupBattleMove(Player battleActivePlayer, int battleTurnNumber)voidsetupBattleRecruit(Player battleActivePlayer, int battleTurnNumber)voidsetupBattleSummon(Player battleActivePlayer, int battleTurnNumber)voidsetupFight()voidsetupMove()voidsetupMuster()voidsetupSplit(Player activePlayer, int turnNumber)voidsetupTurnState(Player activePlayer, int turnNumber)protected booleansupportsReconnect()voidsyncOption(java.lang.String optname, java.lang.String value)voidtellBattleMove(int tag, BattleHex startingHex, BattleHex endingHex, boolean undo)voidtellEngagement(MasterHex hex, Legion attacker, Legion defender)voidtellEngagementResults(Legion winner, java.lang.String method, int points, int turns)voidtellGameOver(java.lang.String message, boolean disposeFollows)voidtellInitialGameInfo(java.lang.String variantName, java.util.Collection<java.lang.String> playerNames)voidtellLegionLocation(Legion legion, MasterHex hex)voidtellMovementRoll(int roll)voidtellPlayerElim(Player player, Player slayer)voidtellProposal(java.lang.String proposalString)voidtellRedo(boolean val)voidtellReplay(boolean val, int maxTurn)voidtellSlowResults(int targetTag, int slowValue)voidtellStrikeResults(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)voidtellSyncCompleted(int syncRequestNumber)voidtellWhatsHappening(java.lang.String message)voidundidMove(Legion legion, MasterHex formerHex, MasterHex currentHex, boolean splitLegionHasForcedMove)voidundidRecruit(Legion legion, CreatureType recruit)voidundidSplit(Legion splitoff, Legion survivor, int turn)voidupdateCreatureCount(CreatureType type, int count, int deadCount)voidupdateOnePlayersInfo(boolean redundant, java.lang.String reason, java.lang.String ShouldBeSeveralSeparateVariablesHerePerhaps)A new way to pass changed player info to clients.voidupdatePlayerInfo(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:
disposeClientin interfaceIClient
-
tellEngagement
public void tellEngagement(MasterHex hex, Legion attacker, Legion defender)
- Specified by:
tellEngagementin interfaceIClient
-
tellEngagementResults
public void tellEngagementResults(Legion winner, java.lang.String method, int points, int turns)
- Specified by:
tellEngagementResultsin interfaceIClient
-
tellWhatsHappening
public void tellWhatsHappening(java.lang.String message)
- Specified by:
tellWhatsHappeningin interfaceIClient
-
tellMovementRoll
public void tellMovementRoll(int roll)
- Specified by:
tellMovementRollin interfaceIClient
-
syncOption
public void syncOption(java.lang.String optname, java.lang.String value)- Specified by:
syncOptionin interfaceIClient
-
updatePlayerInfo
public void updatePlayerInfo(java.util.List<java.lang.String> infoStrings)
- Specified by:
updatePlayerInfoin 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:
updateOnePlayersInfoin interfaceIClient
-
setColor
public void setColor(PlayerColor color)
-
updateCreatureCount
public void updateCreatureCount(CreatureType type, int count, int deadCount)
- Specified by:
updateCreatureCountin interfaceIClient
-
removeLegion
public void removeLegion(Legion legion)
- Specified by:
removeLegionin interfaceIClient
-
setLegionStatus
public void setLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit)
- Specified by:
setLegionStatusin interfaceIClient
-
addCreature
public void addCreature(Legion legion, CreatureType creature, java.lang.String reason)
- Specified by:
addCreaturein interfaceIClient
-
removeCreature
public void removeCreature(Legion legion, CreatureType creature, java.lang.String reason)
- Specified by:
removeCreaturein interfaceIClient
-
revealCreatures
public void revealCreatures(Legion legion, java.util.List<CreatureType> creatures, java.lang.String reason)
- Specified by:
revealCreaturesin 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:
revealEngagedCreaturesin 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:
removeDeadBattleChitsin interfaceIClient
-
placeNewChit
public void placeNewChit(java.lang.String imageName, boolean inverted, int tag, BattleHex hex)- Specified by:
placeNewChitin interfaceIClient
-
tellReplay
public void tellReplay(boolean val, int maxTurn)- Specified by:
tellReplayin interfaceIClient
-
setPlayerName
public void setPlayerName(java.lang.String playerName)
- Specified by:
setPlayerNamein 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:
createSummonAngelin interfaceIClient
-
askAcquireAngel
public void askAcquireAngel(Legion legion, java.util.List<CreatureType> recruits)
- Specified by:
askAcquireAngelin interfaceIClient
-
askChooseStrikePenalty
public void askChooseStrikePenalty(java.util.List<java.lang.String> choices)
- Specified by:
askChooseStrikePenaltyin interfaceIClient
-
tellGameOver
public void tellGameOver(java.lang.String message, boolean disposeFollows)- Specified by:
tellGameOverin interfaceIClient
-
tellPlayerElim
public void tellPlayerElim(Player player, Player slayer)
- Specified by:
tellPlayerElimin interfaceIClient
-
askConcede
public void askConcede(Legion ally, Legion enemy)
- Specified by:
askConcedein interfaceIClient
-
askNegotiate
public void askNegotiate(Legion attacker, Legion defender)
- Specified by:
askNegotiatein interfaceIClient
-
tellProposal
public void tellProposal(java.lang.String proposalString)
- Specified by:
tellProposalin interfaceIClient
-
tellSlowResults
public void tellSlowResults(int targetTag, int slowValue)- Specified by:
tellSlowResultsin 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:
tellStrikeResultsin interfaceIClient
-
initBattle
public void initBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender)
- Specified by:
initBattlein interfaceIClient
-
cleanupBattle
public void cleanupBattle()
- Specified by:
cleanupBattlein interfaceIClient
-
nextEngagement
public void nextEngagement()
- Specified by:
nextEngagementin interfaceIClient
-
doReinforce
public void doReinforce(Legion legion)
- Specified by:
doReinforcein interfaceIClient
-
didRecruit
public void didRecruit(Legion legion, CreatureType recruit, CreatureType recruiter, int numRecruiters)
- Specified by:
didRecruitin interfaceIClient
-
undidRecruit
public void undidRecruit(Legion legion, CreatureType recruit)
- Specified by:
undidRecruitin interfaceIClient
-
setupTurnState
public void setupTurnState(Player activePlayer, int turnNumber)
- Specified by:
setupTurnStatein interfaceIClient
-
setupSplit
public void setupSplit(Player activePlayer, int turnNumber)
- Specified by:
setupSplitin interfaceIClient
-
setupFight
public void setupFight()
- Specified by:
setupFightin interfaceIClient
-
setupMuster
public void setupMuster()
- Specified by:
setupMusterin interfaceIClient
-
setupBattleSummon
public void setupBattleSummon(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleSummonin interfaceIClient
-
setupBattleRecruit
public void setupBattleRecruit(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleRecruitin interfaceIClient
-
setupBattleMove
public void setupBattleMove(Player battleActivePlayer, int battleTurnNumber)
- Specified by:
setupBattleMovein interfaceIClient
-
setupBattleFight
public void setupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)
- Specified by:
setupBattleFightin interfaceIClient
-
tellLegionLocation
public void tellLegionLocation(Legion legion, MasterHex hex)
- Specified by:
tellLegionLocationin interfaceIClient
-
tellBattleMove
public void tellBattleMove(int tag, BattleHex startingHex, BattleHex endingHex, boolean undo)- Specified by:
tellBattleMovein 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:
undidSplitin 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:
askPickColorin interfaceIClient
-
askPickFirstMarker
public void askPickFirstMarker()
- Specified by:
askPickFirstMarkerin interfaceIClient
-
nak
public void nak(java.lang.String reason, java.lang.String errmsg)
-
setBoardActive
public void setBoardActive(boolean val)
- Specified by:
setBoardActivein interfaceIClient
-
tellInitialGameInfo
public void tellInitialGameInfo(java.lang.String variantName, java.util.Collection<java.lang.String> playerNames)
-
confirmWhenCaughtUp
public void confirmWhenCaughtUp()
- Specified by:
confirmWhenCaughtUpin interfaceIClient
-
serverConfirmsConnection
public void serverConfirmsConnection()
- Specified by:
serverConfirmsConnectionin interfaceIClient
-
pingRequest
public void pingRequest()
- Specified by:
pingRequestin interfaceIClient
-
messageFromServer
public void messageFromServer(java.lang.String message)
- Specified by:
messageFromServerin interfaceIClient
-
appendToConnectionLog
public void appendToConnectionLog(java.lang.String message)
- Specified by:
appendToConnectionLogin interfaceIClient
-
tellSyncCompleted
public void tellSyncCompleted(int syncRequestNumber)
- Specified by:
tellSyncCompletedin interfaceIClient
-
-