net.sf.colossus.client
Class GameClientSide

java.lang.Object
  extended by net.sf.colossus.game.Game
      extended by net.sf.colossus.client.GameClientSide
All Implemented Interfaces:
IOracle

public class GameClientSide
extends Game
implements IOracle


Field Summary
private  Player activePlayer
           
private  BattleClientSide battle
           
private  Client client
           
private  PlayerClientSide noone
          This is used as a placeholder for activePlayer and battleActivePlayer since they are sometimes accessed when they are not available.
 
Fields inherited from class net.sf.colossus.game.Game
phase, players, turnNumber
 
Constructor Summary
GameClientSide(Variant variant, java.lang.String[] playerNames)
           
 
Method Summary
 void cleanupBattle()
           
 Player getActivePlayer()
           
 int getAverageLegionPointValue()
          Return the average point value of all legions in the game.
 BattleClientSide getBattle()
           
 Legion getBattleActiveLegion()
           
 Player getBattleActivePlayer()
           
 BattlePhase getBattlePhase()
           
 int getBattleTurnNumber()
           
 Legion getLegionByMarkerId(java.lang.String markerId)
           
 java.util.List<java.lang.Boolean> getLegionCreatureCertainties(Legion legion)
          Return a list of Booleans
 java.util.List<java.lang.String> getLegionImageNames(Legion legion)
          Return a list of Strings.
 Player getNoonePlayer()
           
 Player getPlayerByMarkerId(java.lang.String markerId)
           
(package private)  Player getPlayerByName(java.lang.String playerName)
          Resolve playerName into Player object.
(package private)  Player getPlayerByNameIgnoreNull(java.lang.String playerName)
          Resolve playerName into Player object.
 Player getPlayerByTag(int tag)
           
private  Player getPlayerUsingColor(java.lang.String shortColor)
           
 void initBattle(MasterHex hex, int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase, Legion attacker, Legion defender)
           
 PlayerClientSide initPlayerInfo(java.util.List<java.lang.String> infoStrings, java.lang.String searchedName)
           
 boolean isBattleOngoing()
           
 boolean isBattlePhase(BattlePhase phase)
           
 boolean isTurnStateStillUninitialized()
          ActivePlayer is set first time to something different than "noone" when setupTurnState is called first time.
 void setActivePlayer(Player player)
           
 void setBattleActivePlayer(Player battleActivePlayer)
           
 void setBattlePhase(BattlePhase battlePhase)
           
 void setBattleTurnNumber(int battleTurnNumber)
           
 void setClient(Client client)
           
 void updatePlayerInfo(java.util.List<java.lang.String> infoStrings)
           
 
Methods inherited from class net.sf.colossus.game.Game
clearEngagementData, findEngagements, findLegionsWithSummonables, getAllEnemyLegions, getAllLegions, getAttacker, getBattleSite, getCaretaker, getDefender, getEnemyLegions, getEnemyLegions, getEngagement, getFirstEnemyLegion, getFirstFriendlyLegion, getFirstLegion, getFriendlyLegions, getGameOverMessage, getLegionsByHex, getMovementRoll, getNumEnemyLegions, getNumFriendlyLegions, getNumHumansRemaining, getNumLegions, getNumLivingCreatures, getNumLivingPlayers, getNumPlayers, getNumRemoteRemaining, getPhase, getPlayers, getPreliminaryPlayerNames, getTurnNumber, getVariant, isEngagement, isEngagementOngoing, isGameOver, isOccupied, isPhase, onlyAIsRemain, setEngagementData, setGameOver, setMovementRoll, setPhase, setTurnNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.colossus.client.IOracle
getEngagement, getNumPlayers, getTurnNumber
 

Field Detail

client

private Client client

noone

private final PlayerClientSide noone
This is used as a placeholder for activePlayer and battleActivePlayer since they are sometimes accessed when they are not available. TODO this is a hack. Those members should just not be accessed at times where they are not available. It seems to happen during startup (the not yet set case) and in some GUI parts after battles, when battleActivePlayer has been reset already.


activePlayer

private Player activePlayer

battle

private BattleClientSide battle
Constructor Detail

GameClientSide

public GameClientSide(Variant variant,
                      java.lang.String[] playerNames)
Method Detail

setClient

public void setClient(Client client)

initPlayerInfo

public PlayerClientSide initPlayerInfo(java.util.List<java.lang.String> infoStrings,
                                       java.lang.String searchedName)

getNoonePlayer

public Player getNoonePlayer()

updatePlayerInfo

public void updatePlayerInfo(java.util.List<java.lang.String> infoStrings)

getPlayerByNameIgnoreNull

Player getPlayerByNameIgnoreNull(java.lang.String playerName)
Resolve playerName into Player object. Name might be null, then returns null.

Parameters:
playerName -
Returns:
The player object for given player name, null if name was null

getPlayerByName

Player getPlayerByName(java.lang.String playerName)
Resolve playerName into Player object. Name must not be null. If no player for given name found, it would throw IllegalArgumentException

Parameters:
playerName -
Returns:
Player object for given name.

getPlayerByTag

public Player getPlayerByTag(int tag)

getPlayerUsingColor

private Player getPlayerUsingColor(java.lang.String shortColor)

getPlayerByMarkerId

public Player getPlayerByMarkerId(java.lang.String markerId)

getAverageLegionPointValue

public int getAverageLegionPointValue()
Return the average point value of all legions in the game.


getLegionByMarkerId

public Legion getLegionByMarkerId(java.lang.String markerId)
Overrides:
getLegionByMarkerId in class Game

setActivePlayer

public void setActivePlayer(Player player)

getActivePlayer

public Player getActivePlayer()
Specified by:
getActivePlayer in interface IOracle

isTurnStateStillUninitialized

public boolean isTurnStateStillUninitialized()
ActivePlayer is set first time to something different than "noone" when setupTurnState is called first time.

Returns:
true if activePlayer is still "noone".

initBattle

public void initBattle(MasterHex hex,
                       int battleTurnNumber,
                       Player battleActivePlayer,
                       BattlePhase battlePhase,
                       Legion attacker,
                       Legion defender)

getBattle

public BattleClientSide getBattle()
Specified by:
getBattle in interface IOracle

isBattleOngoing

public boolean isBattleOngoing()

getBattlePhase

public BattlePhase getBattlePhase()
Specified by:
getBattlePhase in interface IOracle

setBattlePhase

public void setBattlePhase(BattlePhase battlePhase)

isBattlePhase

public boolean isBattlePhase(BattlePhase phase)

setBattleActivePlayer

public void setBattleActivePlayer(Player battleActivePlayer)

setBattleTurnNumber

public void setBattleTurnNumber(int battleTurnNumber)

getBattleTurnNumber

public int getBattleTurnNumber()

getBattleActiveLegion

public Legion getBattleActiveLegion()

getBattleActivePlayer

public Player getBattleActivePlayer()
Specified by:
getBattleActivePlayer in interface IOracle

cleanupBattle

public void cleanupBattle()

getLegionImageNames

public java.util.List<java.lang.String> getLegionImageNames(Legion legion)
Return a list of Strings. Use the proper string for titans and unknown creatures.

Specified by:
getLegionImageNames in interface IOracle

getLegionCreatureCertainties

public java.util.List<java.lang.Boolean> getLegionCreatureCertainties(Legion legion)
Return a list of Booleans

Specified by:
getLegionCreatureCertainties in interface IOracle