Class Client
java.lang.Object
net.sf.colossus.client.Client
- All Implemented Interfaces:
IClient, IOracle, OptionObjectProvider, IVariant
public final class Client
extends Object
implements IClient, IOracle, IVariant, OptionObjectProvider
Lives on the client side and handles all communication
with the server. It talks to the Server via the network protocol
and to Client side classes locally, but to all GUI related classes
it should only communicate via ClientGUI class.
There is one client per player.
TODO Handle GUI related issues purely via ClientGUI
TODO All GUI classes should talk to the server purely through
ClientGUI which handles it via the Client.
TODO the logic for the battles could probably be separated from the
rest of this code. At the moment the battle logic seems to bounce
back and forth between BattleBoard (which is really a GUI class) and
this class.
TODO this class also has the functionality of a GameClientSide class,
which should be separated and ideally moved up into the
Game
class. The whole IOracle interface is part of that.
One approach would be moving code from GameServerSide
up into Game and then reuse it here in the matching methods,
then inlining it into the calling code. Another one would be creating
the GameClientSide for now and relocating code there.
==> Clemens march 2009: I started the GameClientSide approach :)- Author:
- David Ripton, Romain Dolbeau
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumConstants modelling the party who closed this client.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AIprivate BattleMovementprivate List<CritterMove> For battle AI.private Client.ClosedByConstantprivate PlayerColorStarting marker color of player who owns this client.private IServerConnectionThe object that actually handles the physical server communication for this client.private Stringprivate intprivate booleanprivate final booleanClient constructor sets this to true if something goes wrong with the SocketClientThread initialization.private List<CritterMove> private final GameClientSideThe game in progress.private booleanOnce we got dispose from server (or user initiated it himself), we'll ignore it if we we get it from server again - it's then up to the user to do some "disposing" action.private final IClientGUIThis can be an actual ClientGUI, or a NullClientGUI (which does simply nothing, so that we don't need to check for null everywhere).private final booleanThis client is the very special internal spectator with the name as defined in Constants.private intis != -1 only from the point on when client abandons the connection, until sync is completed.private final Serverprivate static final Loggerprivate static final intprivate MovementClientSideprivate intprivate Runnableprivate final Objectprivate final Optionsprivate PlayerClientSidePlayer who owns this client.private booleanprivate booleanprivate booleanAt first time we get "all player info", they are created; at all later calls just update them.private IServerConnectionprivate static final intprivate final Hashtable<CreatureType, Integer> private booleanRedo of the events since last commit phase is ongoing.private booleanReplay during load of a saved game is ongoing.private final ResourceLoaderA first start to get rid of the static-access-everywhere to ResourceLoader.private IServerThis "server" is the access to the connector object which actually acts for us as server.private final booleanprivate intEverytime we request server to sync data (typically after reconnect), we pass with a request counter, so that we can distinct the syncCompleted responses.booleanbooleanprivate boolean -
Constructor Summary
ConstructorsConstructorDescriptionClient(String playerName, String playerType, WhatNextManager whatNextMgr, Server theServer, boolean byWebClient, boolean noOptionsFile, boolean createGUI, ResourceLoader resLoader, IServerConnection conn, Variant variant, boolean spectator) Client is the main hub for info exchange on client side. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidacquireAngelCallback(Legion legion, CreatureType angelType) voidaddCreature(Legion legion, CreatureType creature, String reason) Add a new creature to this legion.voidprivate voidaiPause()Wait for aiDelay.voidanswerConcede(Legion legion, boolean answer) voidanswerFlee(Legion ally, boolean answer) voidanswerPickColor(PlayerColor color) voidvoidapplyCarries(BattleHex hex) Attempt to apply carries to the critter in hex.voidaskAcquireAngel(Legion legion, List<CreatureType> recruits) recruits is the list of acquirables that can be chosen from for a certain point value reached.voidaskChooseStrikePenalty(List<String> choices) Allow the player to choose whether to take a penalty (fewer dice or higher strike number) in order to be allowed to carry.voidaskConcede(Legion ally, Legion enemy) voidvoidaskNegotiate(Legion attacker, Legion defender) voidaskPickColor(List<PlayerColor> colorsLeft) voidvoidassignFirstMarker(String markerId) voidassignStrikePenalty(String prompt) booleancanRecruit(Legion legion) chooseBestPotentialRecruit(LegionClientSide legion, MasterHex hex, List<CreatureType> recruits) private booleanPresent a dialog allowing the player to enter via land or teleport.voidvoidconcede()private voidvoidprivate AICreate the AI for this Client.static ClientcreateClient(String host, int port, String playerName, String playerType, WhatNextManager whatNextMgr, Server theServer, boolean byWebClient, boolean noOptionsFile, boolean createGUI, boolean spectator) Create a Client object and other related objectsvoidcreateSummonAngel(Legion legion) private booleanvoiddidMove(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, List<CreatureType> splitoffs, int turn) Callback from server after any successful split.voiddidSummon(Legion summoner, Legion donor, CreatureType summon) private voidvoidvoidprivate voidvoidprivate voidprivate voidHandle both forced strikes and AI strikes.voiddoBattleMove(int tag, BattleHex hex) voidvoidbooleanIf the move looks legal, forward it to server and return true; otherwise returns false.voidvoidvoidvoidvoidvoidprivate voiddoNotConcede(Legion legion) voidUsed for human players only.voidvoiddoReinforce(Legion legion) Always needs to call server.doRecruit(), even if no recruit is wanted, to get past the reinforcing phase.voidCalled by MasterBoard.actOnLegion() when human user clicked on a legion to split it.voiddoSplit(Legion parent, String childMarkerId, List<CreatureType> results) Called by AI and by doSplit()voiddoSummon(SummonInfo summonInfo) Legion target summons unit from Legion donor.voiddoTheSplitting(Legion parent, String childId) voideditAddCreature(String markerId, String creatureType) voideditRelocateLegion(String markerId, String hexLabel) voideditRemoveCreature(String markerId, String creatureType) voidvoidvoidResolve engagement in land.booleanprivate voidCease negotiations and fight a battle in land.private CreatureTypefigureTeleportingLord(Legion legion, MasterHex hex) findEligibleRecruiters(Legion legion, CreatureType recruit) Return a list of creature name strings.findEligibleRecruits(Legion legion, MasterHex hex) Return a list of Creatures (ignore reservations).findEligibleRecruits(Legion legion, MasterHex hex, boolean considerReservations) Return a list of Creatures and consider reservations if wanted.Return a set of BattleUnits.Return a set of hexLabels.private StringfindRecruiterName(Legion legion, CreatureType recruit, String hexDescription) null means cancel.findStrikes(int tag) Return a set of hexLabels for the active player's legions with 7 or more creatures, and which are not marked as skip this turn.findTallLegionHexes(int minHeight, boolean ignoreSkipFlag) Return a set of hexLabels for the active player's legions with minHeight or more creatures.findUnmovedLegionHexes(boolean considerSkippedAsMoved, HashSet<Legion> pendingLegions) private voidfireOneReconnectRunnable(boolean automatic) Creates a runnable that executes one reconnect round (several attempts)intgetColor()booleangetGame()getGUI()Get this legion's info or create if necessary.getLegionCreatureCertainties(Legion legion) intgetLegionHeight(String markerId) getLegionImageNames(Legion legion) intgetPhase()getPlayerByName(String name) Return a set of hexLabels with legions that could do a recruit or undo recruit.Return a set of hexes with legions that can (still) muster anything and are not marked as skip.getPossibleRecruits(MasterBoardTerrain terrain, MasterHex hex) TODO get from Variant instead of static TerrainRecruitLoader access Just forwarding the query, to get at least the GUI classes get rid of dependency to static TerrainRecruitLoader access.intgetReservedRemain(CreatureType recruitType) Return a collection of all possible terrains.intvoidprivate voidhandleFailedBattleMove(String errmsg) voidinitBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender) voidbooleanisAlive()booleanbooleanbooleanisInContact(BattleCritter critter, boolean countDead) booleanbooleanisMyLegion(Legion legion) booleanisMyTurn()booleanisPaused()booleanbooleanisRemote()booleanbooleanbooleanbooleanprivate voidprivate voidprivate voidprivate voidvoidprivate voidvoidCalled from BattleBoard to leave carry mode.voidlegionsNotMoved(int[] legionStatus, boolean have_roll) Returns status of client's legionslistNormalMoves(Legion legion) Return a set of hexLabels.private List<CreatureType> listTeleportingLords(Legion legion, MasterHex hex) List the lords eligible to teleport this legion to hexLabel.listTeleportMoves(Legion legion) Return a set of hexLabels.voidlocallyInitiateSaveGame(String filename) voidprivate booleanReturn true if any strikes were taken.private voidmakeProposal(Proposal proposal) private voidmarkBattleMoveSuccessful(int tag, BattleHex endingHex) voidmessageFromServer(String message) voidmulligan()Take a mulligan.voidvoidnegotiateCallback(Proposal proposal, boolean respawn) Called from both Negotiate and ReplyToProposal.voidbooleanCheck whether any legion has possibility to recruit at all, no matter whether it could or has already.voidvoidintnumberOfRecruiterNeeded(CreatureType recruiter, CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) TODO get from Variant instead of static TerrainRecruitLoader access Just forwarding the query, to get at least the GUI classes get rid of dependency to static TerrainRecruitLoader access.private voidpickCarries(int carryDamage, Set<String> carryTargetDescriptions) voidvoidplaceNewChit(String bareImageName, boolean inverted, int tag, BattleHex hex) Create a new BattleUnit and (if GUI) a new GUIBattleChit with the given parameters.private voidrecoverFromNak(String reason, String errmsg) voidrelocateLegion(Legion legion, MasterHex destination) voidremoveCreature(Legion legion, CreatureType creature, String reason) voidvoidremoveLegion(Legion legion) Remove this eliminated legion, and clean up related stuff.booleanreserveRecruit(CreatureType recruitType) private voidvoidprivate voidvoidrevealCreatures(Legion legion, List<CreatureType> creatures, String reason) Reveal creatures in this legion, some of which already may be known.voidrevealEngagedCreatures(Legion legion, List<CreatureType> names, boolean isAttacker, String reason) private booleanvoidUpon request with checkServerConnection, server sends a confirmation.voidsetBoardActive(boolean val) (package private) voidvoidsetColor(PlayerColor color) private voidvoidsetCurrentLegionMarkerId(String MarkerId) voidsetLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit) Needed when loading a game outside split phase.voidsetPauseState(boolean newState) voidsetPlayerName(String playerName) voidsetPreferencesCheckBoxValue(String name, boolean value) voidsetPreferencesRadioButtonValue(String name, boolean value) voidsetupBattleFight(BattlePhase battlePhase, Player battleActivePlayer) Used for both strike and strikeback.voidsetupBattleMove(Player battleActivePlayer, int battleTurnNumber) voidsetupBattleRecruit(Player battleActivePlayer, int battleTurnNumber) voidsetupBattleSummon(Player battleActivePlayer, int battleTurnNumber) private voidvoidvoidvoidvoidsetupSplit(Player activePlayer, int turnNumber) voidsetupTurnState(Player activePlayer, int turnNumber) Called by server when activePlayer changesshowBattleMoves(BattleCritter battleCritter) voidshowMessageDialog(String message) voidAttempt to have critter tag strike the critter in hex.private booleanstrikeMakeForcedStrikes(boolean autoRangeSingle) voidsyncOption(String optname, String value) Server sends Client some option setting (e.g.voidtellBattleMove(int tag, BattleHex startingHex, BattleHex endingHex, boolean undo) voidtellEngagement(MasterHex hex, Legion attacker, Legion defender) voidtellEngagementResults(Legion winner, String method, int points, int turns) voidtellGameOver(String message, boolean disposeFollows) voidtellLegionLocation(Legion legion, MasterHex hex) Create marker if necessary, and place it in hexLabel.voidtellMovementRoll(int roll) voidtellPlayerElim(Player deadPlayer, Player slayer) voidtellProposal(String proposalString) Inform this player about the other player's proposal.voidtellRedo(boolean val) voidtellReplay(boolean val, int maxTurn) voidtellSlowResults(int targetTag, int slowValue) voidtellStrikeResults(int strikerTag, int targetTag, int strikeNumber, List<String> rolls, int damage, boolean killed, boolean wasCarry, int carryDamageLeft, Set<String> carryTargetDescriptions) voidtellSyncCompleted(int syncRequestNumber) voidtellWhatsHappening(String message) booleantestBattleMove(BattleCritter battleUnit, BattleHex hex) booleanvoidvoidtryReconnect(boolean automatic) voidundidMove(Legion legion, MasterHex formerHex, MasterHex currentHex, boolean splitLegionHasForcedMove) voidundidRecruit(Legion legion, CreatureType recruit) voidundidSplit(Legion splitoff, Legion survivor, int turn) voidundoBattleMove(BattleHex hex) voidvoidundoRecruit(Legion legion) voidvoidupdateCreatureCount(CreatureType type, int count, int deadCount) voidupdateOnePlayersInfo(boolean redundant, String reason, String ShouldBeSeveralSeparateVariablesHerePerhaps) voidupdatePlayerInfo(List<String> infoStrings) voidThis player quits the whole game.
-
Field Details
-
LOGGER
-
server
This "server" is the access to the connector object which actually acts for us as server. Right now this is always a SocketClientThread as deputy (relay) which forwards everything that we do/tell, to the Server. Perhaps one day this could either be a SocketConnection or e.g. a Queue type of connection for local Clients... -
connection
The object that actually handles the physical server communication for this client. Issues related to set up and tear down of the connection are handled via this access to the (right now) SocketClientThread. -
resourceLoader
A first start to get rid of the static-access-everywhere to ResourceLoader. ResourceLoader is used to "load" images, variant files, readme files physically (from disk, or from remote file server thread). -
failed
private final boolean failedClient constructor sets this to true if something goes wrong with the SocketClientThread initialization. I wanted to avoid have the Client constructor throw an exception, because that caused problems in Java 1.4 with a "created but not run thread" which was then never cleaned up and thus JVM did not exit by itself. TODO perhaps that is now fixed in Java 1.5 ? I plan to change the whole "when/how SCT is created" soon anyway...- See Also:
-
replayOngoing
private boolean replayOngoingReplay during load of a saved game is ongoing. Client must NOT react (not even redraw) on any of those messages, they are mostly sent to rebuild the predict split data. -
redoOngoing
private boolean redoOngoingRedo of the events since last commit phase is ongoing. Needed right now only for "if redo ends, set flag to prevent the setupXxxxxPhase methods to clear the undo stack. -
gui
This can be an actual ClientGUI, or a NullClientGUI (which does simply nothing, so that we don't need to check for null everywhere). -
options
-
playersNotInitialized
private boolean playersNotInitializedAt first time we get "all player info", they are created; at all later calls just update them. So this flag here tells us whether it's the first time (=true) or not any more (=false). -
owningPlayer
Player who owns this client. TODO should be final but can't be until the constructor gets all the data needed -
playerAlive
private boolean playerAlive -
game
The game in progress. -
color
Starting marker color of player who owns this client. TODO most likely redundant with owningPlayer.getColor() -
ai
-
movement
-
battleMovement
-
localServer
-
spectator
private final boolean spectator -
internalSpectator
private final boolean internalSpectatorThis client is the very special internal spectator with the name as defined in Constants. The idea of this internal spectator is: it can run in standby in any game, e.g. also on the public server, and detect discrepancies between local state and updateCreatureCount or playerInfo from Server. This is part of the work, to replace "all details need to be broadcasted all the time" with "Client side does the bookkeeping autonomously; so for quite a while it would do bookkeeping and the updates are still sent but just for checking, and any discrepancy detected can/should be fixed. -
closedBy
-
MAX_RECONNECT_ATTEMPTS
private static final int MAX_RECONNECT_ATTEMPTS- See Also:
-
RECONNECT_RETRY_INTERVAL
private static final int RECONNECT_RETRY_INTERVAL- See Also:
-
tookMulligan
private boolean tookMulligan -
numSplitsThisTurn
private int numSplitsThisTurn -
delay
private int delay -
bestMoveOrder
For battle AI. -
failedBattleMoves
-
recruitReservations
-
gotDisposeAlready
private boolean gotDisposeAlreadyOnce we got dispose from server (or user initiated it himself), we'll ignore it if we we get it from server again - it's then up to the user to do some "disposing" action. -
disposeInProgress
private boolean disposeInProgress -
syncRequestCounter
private int syncRequestCounterEverytime we request server to sync data (typically after reconnect), we pass with a request counter, so that we can distinct the syncCompleted responses. -
paused
private boolean paused -
currentLegionMarkerId
-
lastMsgNr
private int lastMsgNris != -1 only from the point on when client abandons the connection, until sync is completed. When sync is completed, it's re-set back to -1. -
previousConn
-
oneConnectAttemptsRoundMutex
-
oneConnectAttemptsRound
-
testCaseAutoDontFlee
public boolean testCaseAutoDontFlee -
testCaseAutoDenyNegotiate
public boolean testCaseAutoDenyNegotiate
-
-
Constructor Details
-
Client
public Client(String playerName, String playerType, WhatNextManager whatNextMgr, Server theServer, boolean byWebClient, boolean noOptionsFile, boolean createGUI, ResourceLoader resLoader, IServerConnection conn, Variant variant, boolean spectator) Client is the main hub for info exchange on client side.- Parameters:
playerName- Name of the player (might still be one of thetemplates playerType- Type of player, e.g. Human, Network, or some concrete AI type (but not "AnyAI"). Given type must include the package name.whatNextMgr- The main controller over which to handle what to do next when this game is over and exitingtheServer- The Server object, if this is a local clientbyWebClient- If true, this was instantiated by a WebClientnoOptionsFile- E.g. AIs should not read/save any options filecreateGUI- Whether to create a GUI (AI's usually not, but server might override that e.g. in stresstest)resLoader- The ResourceLoader object that gives us access to load images, files etc (from disk or from server)conn- The connection to server (so far, SocketClientThread)variant- The variant instancespectator- true to join as spectator, false as real player
-
-
Method Details
-
createClient
public static Client createClient(String host, int port, String playerName, String playerType, WhatNextManager whatNextMgr, Server theServer, boolean byWebClient, boolean noOptionsFile, boolean createGUI, boolean spectator) throws Client.ConnectionInitException Create a Client object and other related objects- Parameters:
host- The host to which SocketClientThread shall connectport- The port to which SocketClientThread shall connectplayerName- Name of the player (might still be one of thetemplates playerType- Type of player, e.g. Human, Network, or some concrete AI type (but not "AnyAI"). Given type must include the package name.whatNextMgr- The main controller over which to handle what to do next when this game is over and exitingtheServer- The Server object, if this is a local clientbyWebClient- If true, this was instantiated by a WebClientnoOptionsFile- E.g. AIs should not read/save any options filecreateGUI- Whether to create a GUI (AI's usually not, but server might override that e.g. in stresstest)spectator- true to join as spectator, false as real player- Throws:
Client.ConnectionInitException
-
appendToConnectionLog
- Specified by:
appendToConnectionLogin interfaceIClient
-
isRemote
public boolean isRemote() -
isSpectator
public boolean isSpectator() -
isTheInternalSpectator
public boolean isTheInternalSpectator() -
isAlive
public boolean isAlive() -
isPaused
public boolean isPaused() -
setCurrentLegionMarkerId
-
getCurrentLegionMarkerId
-
setPauseState
public void setPauseState(boolean newState) -
enforcedDisconnect
public void enforcedDisconnect() -
ensureThatConnected
public boolean ensureThatConnected() -
notifyThatNotConnected
public void notifyThatNotConnected() -
enforcedDisconnectByServer
public void enforcedDisconnectByServer() -
isConnected
public boolean isConnected() -
abandonCurrentConnection
public void abandonCurrentConnection() -
tryReconnect
public void tryReconnect(boolean automatic) - Parameters:
automatic- true if was triggered automatically e.g. by a Socket Exception, false if triggered manually (e.g. MasterBoard File menu).
-
guiTriggeredTryReconnect
public void guiTriggeredTryReconnect() -
setConnectAttemptsRoundCompleted
private void setConnectAttemptsRoundCompleted() -
isConnectRoundOngoing
public boolean isConnectRoundOngoing() -
fireOneReconnectRunnable
private void fireOneReconnectRunnable(boolean automatic) Creates a runnable that executes one reconnect round (several attempts) -
tellSyncCompleted
public void tellSyncCompleted(int syncRequestNumber) - Specified by:
tellSyncCompletedin interfaceIClient
-
doCheckServerConnection
public void doCheckServerConnection() -
serverConfirmsConnection
public void serverConfirmsConnection()Upon request with checkServerConnection, server sends a confirmation. This method here processes the confirmation.- Specified by:
serverConfirmsConnectionin interfaceIClient
-
locallyInitiateSaveGame
-
getFailed
public boolean getFailed() -
undoSplit
-
mulligan
public void mulligan()Take a mulligan. -
tookMulligan
public boolean tookMulligan() -
engage
Resolve engagement in land. -
getMyEngagedLegion
-
concede
public void concede() -
concede
-
doNotConcede
-
fight
Cease negotiations and fight a battle in land. -
tellEngagement
- Specified by:
tellEngagementin interfaceIClient
-
tellEngagementResults
- Specified by:
tellEngagementResultsin interfaceIClient
-
doSummon
Legion target summons unit from Legion donor.- Parameters:
summonInfo- A SummonInfo object that contains the values for target, donor and unit.
-
didSummon
-
withdrawFromGame
public void withdrawFromGame()This player quits the whole game. The server needs to always honor this request, because if it doesn't players will just drop connections when they want to quit in a hurry. -
tellMovementRoll
public void tellMovementRoll(int roll) - Specified by:
tellMovementRollin interfaceIClient
-
tellWhatsHappening
- Specified by:
tellWhatsHappeningin interfaceIClient
-
kickPhase
-
kickMoves
private void kickMoves() -
doAutoMoves
private void doAutoMoves() -
syncOption
Server sends Client some option setting (e.g. AI type, autoPlay for stresstest (also AIs (????), ...)- Specified by:
syncOptionin interfaceIClient
-
getNumPlayers
public int getNumPlayers()- Specified by:
getNumPlayersin interfaceIOracle
-
updatePlayerInfo
- Specified by:
updatePlayerInfoin interfaceIClient
-
updateOnePlayersInfo
public void updateOnePlayersInfo(boolean redundant, String reason, String ShouldBeSeveralSeparateVariablesHerePerhaps) - Specified by:
updateOnePlayersInfoin interfaceIClient
-
getOwningPlayer
-
setColor
-
updateCreatureCount
- Specified by:
updateCreatureCountin interfaceIClient
-
setClosedByServer
void setClosedByServer() -
disposeClientOriginated
public void disposeClientOriginated() -
disposeClient
public void disposeClient()- Specified by:
disposeClientin interfaceIClient
-
disposeWholeClient
private void disposeWholeClient() -
decideWhetherClose
private boolean decideWhetherClose() -
disposeAll
private void disposeAll() -
doAdditionalCleanup
public void doAdditionalCleanup() -
leaveCarryMode
public void leaveCarryMode()Called from BattleBoard to leave carry mode. -
doneWithBattleMoves
public void doneWithBattleMoves() -
getActiveBattleUnits
-
sansLordAutoBattleApplies
private boolean sansLordAutoBattleApplies() -
getInactiveBattleUnits
-
aiDoneWithStrikes
public void aiDoneWithStrikes() -
doneWithStrikes
public void doneWithStrikes() -
makeForcedStrikes
private boolean makeForcedStrikes()Return true if any strikes were taken. -
strikeMakeForcedStrikes
private boolean strikeMakeForcedStrikes(boolean autoRangeSingle) -
doAutoStrikes
private void doAutoStrikes()Handle both forced strikes and AI strikes. -
getLegion
Get this legion's info or create if necessary. TODO move legion creation into a factory onPlayer -
removeLegion
Remove this eliminated legion, and clean up related stuff.- Specified by:
removeLegionin interfaceIClient
-
getLegionHeight
-
setLegionStatus
public void setLegionStatus(Legion legion, boolean moved, boolean teleported, EntrySide entrySide, CreatureType lastRecruit) Needed when loading a game outside split phase.- Specified by:
setLegionStatusin interfaceIClient
-
getLegionImageNames
- Specified by:
getLegionImageNamesin interfaceIOracle
-
getLegionCreatureCertainties
- Specified by:
getLegionCreatureCertaintiesin interfaceIOracle
-
addCreature
Add a new creature to this legion.- Specified by:
addCreaturein interfaceIClient
-
removeCreature
- Specified by:
removeCreaturein interfaceIClient
-
revealCreatures
Reveal creatures in this legion, some of which already may be known. - this "reveal" is related to data coming from server being revealed to the split prediction- Specified by:
revealCreaturesin interfaceIClient
-
revealEngagedCreatures
public void revealEngagedCreatures(Legion legion, List<CreatureType> names, boolean isAttacker, String reason) - Specified by:
revealEngagedCreaturesin interfaceIClient
-
removeDeadBattleChits
public void removeDeadBattleChits()- Specified by:
removeDeadBattleChitsin interfaceIClient
-
placeNewChit
Create a new BattleUnit and (if GUI) a new GUIBattleChit with the given parameters. Place them in given hex, and add them to the lists of BattleUnits (in Battle[ClientSide]) and GUIBattleChits (in GUI)- Specified by:
placeNewChitin interfaceIClient
-
chooseBestPotentialRecruit
public CreatureType chooseBestPotentialRecruit(LegionClientSide legion, MasterHex hex, List<CreatureType> recruits) -
getGUI
-
tellReplay
public void tellReplay(boolean val, int maxTurn) - Specified by:
tellReplayin interfaceIClient
-
isReplayOngoing
public boolean isReplayOngoing() -
tellRedo
-
isRedoOngoing
public boolean isRedoOngoing() -
confirmWhenCaughtUp
public void confirmWhenCaughtUp()- Specified by:
confirmWhenCaughtUpin interfaceIClient
-
initBoard
-
setPlayerName
- Specified by:
setPlayerNamein interfaceIClient
-
createSummonAngel
- Specified by:
createSummonAngelin interfaceIClient
-
askAcquireAngel
recruits is the list of acquirables that can be chosen from for a certain point value reached. E.g. for getting 180 points, going from 380 + 180 = 560, game would first call this for 400: recruits = [Angel] and then call it once more for 500: recruits = [Angel, Archangel]- Specified by:
askAcquireAngelin interfaceIClient
-
acquireAngelCallback
-
chooseWhetherToTeleport
Present a dialog allowing the player to enter via land or teleport. Return true if the player chooses to teleport. -
askChooseStrikePenalty
Allow the player to choose whether to take a penalty (fewer dice or higher strike number) in order to be allowed to carry.- Specified by:
askChooseStrikePenaltyin interfaceIClient
-
assignStrikePenalty
-
tellPlayerElim
- Specified by:
tellPlayerElimin interfaceIClient
-
tellGameOver
- Specified by:
tellGameOverin interfaceIClient
-
doFight
-
askConcede
- Specified by:
askConcedein interfaceIClient
-
askFlee
-
answerFlee
-
answerConcede
-
askNegotiate
- Specified by:
askNegotiatein interfaceIClient
-
tellProposal
Inform this player about the other player's proposal.- Specified by:
tellProposalin interfaceIClient
-
negotiateCallback
Called from both Negotiate and ReplyToProposal. -
makeProposal
-
tellSlowResults
public void tellSlowResults(int targetTag, int slowValue) - Specified by:
tellSlowResultsin interfaceIClient
-
tellStrikeResults
-
nak
-
recoverFromNak
-
pickCarries
-
initBattle
public void initBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender) - Specified by:
initBattlein interfaceIClient
-
messageFromServer
- Specified by:
messageFromServerin interfaceIClient
-
showMessageDialog
-
cleanupBattle
public void cleanupBattle()- Specified by:
cleanupBattlein interfaceIClient
-
canRecruit
-
doRecruit
Used for human players only. -
doRecruit
-
doReinforce
Always needs to call server.doRecruit(), even if no recruit is wanted, to get past the reinforcing phase.- Specified by:
doReinforcein interfaceIClient
-
didRecruit
public void didRecruit(Legion legion, CreatureType recruit, CreatureType recruiter, int numRecruiters) - Specified by:
didRecruitin interfaceIClient
-
undoRecruit
-
undidRecruit
- Specified by:
undidRecruitin interfaceIClient
-
findRecruiterName
null means cancel. "none" means no recruiter (tower creature). -
resetLegionMovesAndRecruitData
private void resetLegionMovesAndRecruitData() -
setBoardActive
public void setBoardActive(boolean val) - Specified by:
setBoardActivein interfaceIClient
-
setupTurnState
Called by server when activePlayer changes- Specified by:
setupTurnStatein interfaceIClient
-
setupSplit
- Specified by:
setupSplitin interfaceIClient
-
kickSplit
private void kickSplit() -
setupMove
-
setupFight
public void setupFight()- Specified by:
setupFightin interfaceIClient
-
kickFight
private void kickFight() -
nextEngagement
public void nextEngagement()- Specified by:
nextEngagementin interfaceIClient
-
setupMuster
public void setupMuster()- Specified by:
setupMusterin interfaceIClient
-
kickMuster
private void kickMuster() -
setupBattleSummon
- Specified by:
setupBattleSummonin interfaceIClient
-
setupBattleRecruit
- Specified by:
setupBattleRecruitin interfaceIClient
-
setupBattleMove
- Specified by:
setupBattleMovein interfaceIClient
-
kickBattleMove
private void kickBattleMove() -
tryBattleMove
-
retryFailedBattleMoves
private void retryFailedBattleMoves() -
getBattleCS
- Specified by:
getBattleCSin interfaceIOracle
-
setupBattleFight
Used for both strike and strikeback.- Specified by:
setupBattleFightin interfaceIClient
-
tellLegionLocation
Create marker if necessary, and place it in hexLabel.- Specified by:
tellLegionLocationin interfaceIClient
-
getColor
-
getShortColor
-
getBattleActivePlayer
- Specified by:
getBattleActivePlayerin interfaceIOracle
-
getEngagement
- Specified by:
getEngagementin interfaceIOracle
-
getDefender
-
getAttacker
-
getBattleSite
-
getBattlePhase
- Specified by:
getBattlePhasein interfaceIOracle
-
getBattleTurnNumber
public int getBattleTurnNumber() -
doBattleMove
-
undoBattleMove
-
markBattleMoveSuccessful
-
handleFailedBattleMove
-
tellBattleMove
- Specified by:
tellBattleMovein interfaceIClient
-
strike
Attempt to have critter tag strike the critter in hex. -
applyCarries
Attempt to apply carries to the critter in hex. -
isInContact
-
findMobileCritterHexes
-
findMobileBattleUnits
Return a set of BattleUnits. -
showBattleMoves
-
findCrittersWithTargets
-
findStrikes
-
getPlayerByName
-
getActivePlayer
- Specified by:
getActivePlayerin interfaceIOracle
-
getPhase
-
getTurnNumber
public int getTurnNumber()- Specified by:
getTurnNumberin interfaceIOracle
-
figureTeleportingLord
-
listTeleportingLords
List the lords eligible to teleport this legion to hexLabel. -
doMove
-
didMove
-
undoMove
-
undidMove
-
relocateLegion
-
resetRecruitReservations
public void resetRecruitReservations() -
reserveRecruit
-
getReservedRemain
-
findEligibleRecruits
Return a list of Creatures (ignore reservations). -
findEligibleRecruits
public List<CreatureType> findEligibleRecruits(Legion legion, MasterHex hex, boolean considerReservations) Return a list of Creatures and consider reservations if wanted.- Parameters:
legion- The legion to recruit with.hex- The hex in which to recruit (not necessarily the same as the legion's position). Not null.considerReservations- Flag to determine if reservations should be considered.- Returns:
- A list of possible recruits for the legion in the hex.
-
findEligibleRecruiters
Return a list of creature name strings. TODO return List -
getPossibleRecruitHexes
-
getPossibleRecruitActionHexes
-
noRecruitActionPossible
public boolean noRecruitActionPossible()Check whether any legion has possibility to recruit at all, no matter whether it could or has already. If there is none, autoDone can automatically be done with recruit phase; but if there is something (e.g. autoRecruit has recruited something, allow human to override/force him to really confirm "Done".- Returns:
- Whether there is any legion that could recruit or undoRecruit
-
getMovement
-
listTeleportMoves
-
listNormalMoves
-
legionsNotMoved
public void legionsNotMoved(int[] legionStatus, boolean have_roll) Returns status of client's legions- Parameters:
legionStatus- an array of integers with various status states to be set. Array should be initialized to all zeroes Current array contents: [Constants.legionStatusCount] == count of legions [Constants.legionStatusMoved] == legions that have moved [Constants.legionStatusBlocked] == unmoved legions with no legal move [Constants.legionStatusNotVisitedSkippedBlocked] == legions that have not been moved, are not blocked and have not been skipped
-
findUnmovedLegionHexes
-
findTallLegionHexes
-
findTallLegionHexes
-
notifyServer
public void notifyServer() -
isSctAlreadyDown
public boolean isSctAlreadyDown() -
undidSplit
- Specified by:
undidSplitin interfaceIClient
-
doneWithSplits
public void doneWithSplits() -
doneWithMoves
public void doneWithMoves() -
doneWithEngagements
public void doneWithEngagements() -
doneWithRecruits
public void doneWithRecruits() -
isMyLegion
-
isMyTurn
public boolean isMyTurn() -
isMyBattlePhase
public boolean isMyBattlePhase() -
doSplit
Called by MasterBoard.actOnLegion() when human user clicked on a legion to split it. This method here then: Verifies that splitting is legal and possible at all; Then get a child marker selected (either by dialog, or if autoPickMarker set, ask AI to pick one); If childMarkerId selection was not canceled (returned non-null), bring up the split dialog (which creatures go into which legion); and if that returns a list (not null) then call doSplit(...,...,...) which sends the request to server.- Parameters:
parent- The legion selected to split
-
doTheSplitting
-
doSplit
Called by AI and by doSplit() -
didSplit
-
askPickColor
- Specified by:
askPickColorin interfaceIClient
-
answerPickColor
-
askPickFirstMarker
public void askPickFirstMarker()- Specified by:
askPickFirstMarkerin interfaceIClient
-
assignFirstMarker
-
log
-
pingRequest
public void pingRequest()- Specified by:
pingRequestin interfaceIClient
-
testBattleMove
-
createAI
Create the AI for this Client. If type is some (concrete) AI type, create that type of AI (then this is an AI player). Otherwise, create a SimpleAI as default (used by Human or Remote clients for the autoplay functionality).- Parameters:
playerType- Type of player for which to create an AI- Returns:
- Some AI object, according to the situation
-
aiPause
private void aiPause()Wait for aiDelay. -
setupDelay
private void setupDelay() -
getGame
-
getGameClientSide
-
getOptions
- Specified by:
getOptionsin interfaceOptionObjectProvider
-
getPossibleRecruits
TODO get from Variant instead of static TerrainRecruitLoader access Just forwarding the query, to get at least the GUI classes get rid of dependency to static TerrainRecruitLoader access.TerrainRecruitLoader.getPossibleRecruits(MasterBoardTerrain, MasterHex)- Specified by:
getPossibleRecruitsin interfaceIVariant
-
numberOfRecruiterNeeded
public int numberOfRecruiterNeeded(CreatureType recruiter, CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) TODO get from Variant instead of static TerrainRecruitLoader access Just forwarding the query, to get at least the GUI classes get rid of dependency to static TerrainRecruitLoader access.TerrainRecruitLoader.numberOfRecruiterNeeded(CreatureType, CreatureType, MasterBoardTerrain, MasterHex)- Specified by:
numberOfRecruiterNeededin interfaceIVariant
-
getTerrains
Return a collection of all possible terrains.- Returns:
- A collection containing all instances of
MasterBoardTerrain.
-
setPreferencesCheckBoxValue
-
setPreferencesRadioButtonValue
-
editAddCreature
-
editRemoveCreature
-
editRelocateLegion
-