|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.empireclassic.Remote.RemoteEmpire
public class RemoteEmpire
This class provides the abstraction of retrieving all data and passing all commands to the server.
Implemented as a Singleton, so you must use getInstance() to make use of this class.
Two different versions of getInstance() are provided: The version with arguments must be used the first time to set the host name and port number. Following that the version with no arguments should always be used. Also provides cacheing RemoteEmpire is thread safe. All server transactions are atomic per call, and each is synchronized. The server always provides a numeric error code (0 is OK) and an error message string. In general the error code is pretty generic and the error message string is quite specific, so pay more attention to the message string. Occasionally the server returns some small piece of information with an OK. Generally these will be returned in a special error return format.
getInstance(String, int)
,
getInstance()
,
setCacheStrategy(CacheStrategy)
,
RemoteEmpire.CacheStrategy
,
LoginResponse
Nested Class Summary | |
---|---|
class |
RemoteEmpire.AssaultReply
|
class |
RemoteEmpire.AssaultTestReply
|
class |
RemoteEmpire.AttackReply
|
class |
RemoteEmpire.BuildPlanesReply
|
class |
RemoteEmpire.CacheData
|
static class |
RemoteEmpire.CacheStrategy
|
class |
RemoteEmpire.LoginReply
|
class |
RemoteEmpire.Mail
|
static class |
RemoteEmpire.MailStatus
|
static class |
RemoteEmpire.PlaneType
|
class |
RemoteEmpire.SpreadTestReply
|
class |
RemoteEmpire.UserInfo
Simple data structure representing currently logged on user info. |
Field Summary | |
---|---|
protected RemoteEmpire.CacheStrategy |
cacheStrategy
|
protected java.net.Socket |
comSocket
|
protected static RemoteEmpire |
instance
|
protected java.util.Map<java.lang.Integer,IslandInfo> |
islands
|
protected java.util.LinkedList<RemoteEmpire.CacheData> |
mruCache
|
protected int |
mruCacheLimit
|
protected EmpireStreamReader |
reader
|
protected java.util.Map<java.lang.Integer,RemoteEmpire.CacheData> |
sectorCache
|
protected java.lang.String |
serverName
|
protected int |
serverPortNum
|
static java.util.List<ShipType> |
shipTypeList
Information from server on types of ships |
static EmpireDimension |
worldSize
Publicly available info on the size of the world |
protected java.io.BufferedWriter |
writer
|
Method Summary | |
---|---|
EmpireError |
assignShipToFleet(int shipNum,
int fleetNum)
|
RemoteEmpire.AttackReply |
attack(int islandNum,
IslandCoord from,
IslandCoord to,
int numAttacking)
|
RemoteEmpire.AttackReply |
attackTest(int islandNum,
IslandCoord from,
IslandCoord to)
|
RemoteEmpire.BuildPlanesReply |
BuildPlanes(int islandNum,
RemoteEmpire.PlaneType type,
int numRequested)
|
RemoteEmpire.BuildPlanesReply |
buildPlanesTest(int islandNum,
RemoteEmpire.PlaneType type)
|
void |
close()
|
double |
date()
|
java.lang.String |
date(java.lang.String gameDate)
|
EmpireError |
enlist(int islandNum,
IslandCoord coord,
int enlistNum)
|
EmpireError |
gatherToShip(int islandNum,
int what,
int howMuch,
int maxTime)
|
java.util.List<java.lang.String> |
getAlerts()
|
RemoteEmpire.CacheStrategy |
getCacheStrategy()
|
static RemoteEmpire |
getInstance()
This version of getInstance() is used for all subsequent calls. |
static RemoteEmpire |
getInstance(java.lang.String serverName,
int portNum)
This version of getInstance() must always be called first in order to provide the host/port to connect to. |
IslandInfo |
getIsland(int islandNumber)
|
java.util.Map<java.lang.Integer,IslandInfo> |
getIslandList()
Return a list of islands of which we have some knowledge. |
EmpireError |
getMail(int id)
|
java.util.List<RemoteEmpire.Mail> |
getMailList()
|
int |
getMruCacheLimit()
|
NationInfo |
getNation(int nationNumber)
|
java.util.Map<java.lang.Integer,NationInfo> |
getNationList()
Get the list of nations in the game. |
ParamInfo |
getParams()
|
java.util.Map<IslandCoord,Sector> |
getSectors(int islandNum)
Get information about every sector on an island. |
java.lang.String |
getServerName()
|
int |
getServerPortNum()
|
MyShip |
getShip(int shipNum)
|
java.util.Map<java.lang.Integer,MyShip> |
getShipList()
|
java.util.List<ShipType> |
getShipTypeList()
|
java.util.List<RemoteEmpire.UserInfo> |
getUserList()
Return the list of currently logged on players |
EmpireDimension |
getWorldSize()
|
EmpireError |
islandUpdate(int islandNum,
int updateTime)
|
EmpireError |
launch(int islandNum,
IslandCoord coord,
java.lang.String shipType)
|
RemoteEmpire.LoginReply |
login(java.lang.String nationName,
java.lang.String password)
Log into an empire game. |
EmpireError |
move(int islandNum,
char thing,
java.lang.String from,
java.lang.String to,
int quantity,
boolean test)
|
RemoteEmpire.LoginReply |
newNation(java.lang.String nationName,
java.lang.String password)
|
java.util.Map<java.lang.Integer,YourShip> |
radar()
|
EmpireError |
radioSend(java.lang.String message)
|
EmpireError |
sendMail(int to,
java.lang.String subject,
java.lang.String message)
|
void |
setCacheStrategy(RemoteEmpire.CacheStrategy cacheStrategy)
|
EmpireError |
setDes(int islandNumber,
IslandCoord coord,
int selection)
|
EmpireError |
setFleetCourse(int nationNum,
int fleetNum,
WorldCoord dest)
|
EmpireError |
setIslandName(int islandNum,
java.lang.String newName)
|
void |
setMruCacheLimit(int mruCacheLimit)
|
void |
setWorldSize(EmpireDimension worldSize)
|
RemoteEmpire.AssaultReply |
shipAssault(int shipNum,
int numAttacking)
|
RemoteEmpire.AssaultTestReply |
shipAssaultTest(int shipNum)
|
EmpireError |
shipEmerge(int shipNum)
|
EmpireError |
shipLoadUnload(int shipNum,
java.lang.String what,
int quantity)
|
EmpireError |
shipMine(int shipNum,
int numMines)
|
EmpireError |
shipMove(int shipNum,
double direction,
double distance)
|
EmpireError |
shipSetCourse(int shipNum,
WorldCoord dest,
double speed)
|
EmpireError |
shipSubmerge(int shipNum)
|
EmpireError |
shipUndock(int shipNum)
|
EmpireError |
spread(int islandNum,
java.awt.Rectangle area,
IslandCoord fromCoord,
boolean mountains,
boolean own,
int civsPerSec,
IslandCoord dumpCoord)
|
RemoteEmpire.SpreadTestReply |
spreadTest(int islandNum,
java.awt.Rectangle area,
IslandCoord fromCoord,
boolean mountains,
boolean own)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.net.Socket comSocket
protected java.io.BufferedWriter writer
protected EmpireStreamReader reader
protected static RemoteEmpire instance
protected java.lang.String serverName
protected int serverPortNum
protected RemoteEmpire.CacheStrategy cacheStrategy
protected int mruCacheLimit
protected java.util.Map<java.lang.Integer,IslandInfo> islands
protected java.util.Map<java.lang.Integer,RemoteEmpire.CacheData> sectorCache
protected java.util.LinkedList<RemoteEmpire.CacheData> mruCache
public static java.util.List<ShipType> shipTypeList
public static EmpireDimension worldSize
Method Detail |
---|
public static RemoteEmpire getInstance(java.lang.String serverName, int portNum) throws java.net.UnknownHostException, java.io.IOException
serverName
- Host name of an empire serverportNum
- Port the empire server is listening on
java.net.UnknownHostException
java.io.IOException
public static RemoteEmpire getInstance()
java.lang.Error
- If the argument version of getInstance() wasn't called first.public RemoteEmpire.LoginReply login(java.lang.String nationName, java.lang.String password)
nationName
- A name or number of an existing nation.password
- A password
public java.util.List<RemoteEmpire.UserInfo> getUserList()
List
of UserInfo
public java.util.Map<java.lang.Integer,IslandInfo> getIslandList()
Map
of IslandInfo
IslandInfo
public java.util.Map<IslandCoord,Sector> getSectors(int islandNum)
CacheStrategy
set at the beginning.
Sector
is the main thing we are interested in cacheing.
We check the IslandInfo
to see if the version has changed.
If not, we can return what's in the cache.
islandNum
-
Map
of Sector
Sector
,
RemoteEmpire.CacheStrategy
,
setCacheStrategy(CacheStrategy)
public java.util.Map<java.lang.Integer,NationInfo> getNationList()
Map
of Nation
NationInfo
public RemoteEmpire.LoginReply newNation(java.lang.String nationName, java.lang.String password)
public IslandInfo getIsland(int islandNumber)
public NationInfo getNation(int nationNumber)
public ParamInfo getParams()
public double date()
public java.lang.String date(java.lang.String gameDate)
public java.util.List<ShipType> getShipTypeList()
public java.util.Map<java.lang.Integer,MyShip> getShipList()
public MyShip getShip(int shipNum)
public java.util.List<java.lang.String> getAlerts()
public java.util.Map<java.lang.Integer,YourShip> radar()
public EmpireError setDes(int islandNumber, IslandCoord coord, int selection)
public EmpireError move(int islandNum, char thing, java.lang.String from, java.lang.String to, int quantity, boolean test)
public EmpireError islandUpdate(int islandNum, int updateTime)
public RemoteEmpire.SpreadTestReply spreadTest(int islandNum, java.awt.Rectangle area, IslandCoord fromCoord, boolean mountains, boolean own)
public EmpireError spread(int islandNum, java.awt.Rectangle area, IslandCoord fromCoord, boolean mountains, boolean own, int civsPerSec, IslandCoord dumpCoord)
public EmpireError setIslandName(int islandNum, java.lang.String newName)
public EmpireError launch(int islandNum, IslandCoord coord, java.lang.String shipType)
public EmpireError enlist(int islandNum, IslandCoord coord, int enlistNum)
public EmpireError radioSend(java.lang.String message)
public RemoteEmpire.BuildPlanesReply buildPlanesTest(int islandNum, RemoteEmpire.PlaneType type)
public RemoteEmpire.BuildPlanesReply BuildPlanes(int islandNum, RemoteEmpire.PlaneType type, int numRequested)
public EmpireError assignShipToFleet(int shipNum, int fleetNum)
public EmpireError gatherToShip(int islandNum, int what, int howMuch, int maxTime)
public EmpireError setFleetCourse(int nationNum, int fleetNum, WorldCoord dest)
public RemoteEmpire.AttackReply attackTest(int islandNum, IslandCoord from, IslandCoord to)
public RemoteEmpire.AttackReply attack(int islandNum, IslandCoord from, IslandCoord to, int numAttacking)
public EmpireError shipUndock(int shipNum)
public EmpireError shipLoadUnload(int shipNum, java.lang.String what, int quantity)
public RemoteEmpire.AssaultTestReply shipAssaultTest(int shipNum)
public RemoteEmpire.AssaultReply shipAssault(int shipNum, int numAttacking)
public EmpireError shipSubmerge(int shipNum)
public EmpireError shipEmerge(int shipNum)
public EmpireError shipMine(int shipNum, int numMines)
public EmpireError shipMove(int shipNum, double direction, double distance)
public EmpireError shipSetCourse(int shipNum, WorldCoord dest, double speed)
public java.lang.String getServerName()
public int getServerPortNum()
public void close()
public EmpireDimension getWorldSize()
public void setWorldSize(EmpireDimension worldSize)
public java.util.List<RemoteEmpire.Mail> getMailList()
public EmpireError getMail(int id)
public EmpireError sendMail(int to, java.lang.String subject, java.lang.String message)
public RemoteEmpire.CacheStrategy getCacheStrategy()
public void setCacheStrategy(RemoteEmpire.CacheStrategy cacheStrategy)
public int getMruCacheLimit()
public void setMruCacheLimit(int mruCacheLimit)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |