|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttoroidwars.engine.Engine
public final class Engine
| Field Summary | |
|---|---|
protected Player |
neutralPlayer
The neutral player |
protected Player[] |
players
List of players |
protected World |
world
Country holder |
| Constructor Summary | |
|---|---|
Engine(EngineUpdateAPI engineApi)
Constructor. |
|
| Method Summary | |
|---|---|
void |
changeGameSetting(java.lang.String key,
java.lang.String value)
Attempts to change the game settings Possible keys are: game.changeGameSettings game.turnsPerPlayer game.turnTimePause game.initialUnitsPerPlayer game.maxTurnTime play.numberOfStrikes play.useSimpleAttack play.countriesPerPlayer play.neutralCountriesPerPlayer play.maxNumberOfUnitsInCountry play.maxNumberOfUnitsToTransfer play.maxNumberOfUnitsToAttack play.maxNumberOfUnitsToDefend play.allowUnfriendlyTransfer |
AttackResult |
computeAttack(Country country,
Direction direction,
int numberOfUnits)
Computes an attack result fot a country |
void |
computeBuild(Country country)
Works out a build action for a country |
int |
computeScout(Country country,
Direction direction)
Computes the result for scouting from a particular country |
TransferResult |
computeTransfer(Country country,
Direction direction,
int numberOfUnits)
Computes a transfer turn for a country |
static BasePlayer |
createPlayer(java.lang.Class<? extends BasePlayer> playerClass)
Calls the constructor for the passed player |
void |
disqualifyPlayer(Player player,
java.lang.String reason)
Removes a player from the game by giving his countries to the neutral player |
void |
exit()
Only method allowed to exit the jvm |
Player |
getNeutralPlayer()
Gets the games neutral player |
Player[] |
getPlayers()
Gets the player list |
int |
getTurnLimit()
Returns the total number of turns |
World |
getWorld()
Returns the world (holds the countries) |
void |
initialiseGame(Player[] players,
int turnLimit)
Sets the game up |
boolean |
isGameInitialised()
Returns whether or not the game is initialised |
static java.lang.Class<? extends BasePlayer> |
LoadPlayerClass(java.lang.String location,
java.lang.String classPath)
Load a player class from a jar given the jar location and the player class name, the player class must override BasePlayer |
java.util.HashMap<Player,java.lang.Integer> |
play()
Actual play method |
void |
run()
Method that runs the game |
void |
stop()
Stops the current playing game |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected World world
protected Player[] players
protected Player neutralPlayer
| Constructor Detail |
|---|
public Engine(EngineUpdateAPI engineApi)
throws GameNotInitialisedException
engineApi - the api to be notified for various bit of engine information
GameNotInitialisedException - Thrown if there is already an existing engine instance,| Method Detail |
|---|
public void exit()
public void initialiseGame(Player[] players,
int turnLimit)
players - The players which will be taking partturnLimit - the total number of turnspublic Player getNeutralPlayer()
public Player[] getPlayers()
public World getWorld()
public void run()
run in interface java.lang.Runnablepublic void stop()
public int getTurnLimit()
public java.util.HashMap<Player,java.lang.Integer> play()
throws java.lang.Exception
java.lang.Exception - for passing to to the engineAPI
public void disqualifyPlayer(Player player,
java.lang.String reason)
player - Player to disqualifyreason - Reason for disqualification
public void computeBuild(Country country)
throws CheatingException,
BuildActionException,
TurnTimedOutException
country - country on which to build
CheatingException
BuildActionException
TurnTimedOutException
public AttackResult computeAttack(Country country,
Direction direction,
int numberOfUnits)
throws AttackActionException,
CheatingException,
TurnTimedOutException
country - Country doing the attackingdirection - Direction to attack innumberOfUnits - Number of units to attack with
AttackActionException
CheatingException
blindrisk.exceptions.AttackActionException - Thrown if your
attack was illegal, (too few troops in your country etc...)
TurnTimedOutException
blindrisk.exceptions.CheatingException - Thrown if the country is not
yours or if it's already had a turn taken on this go
blindrisk.exceptions.TurnTimedOutException - Thrown if this turn has
timed out.
public int computeScout(Country country,
Direction direction)
throws CheatingException,
ScoutActionException,
TurnTimedOutException
country - Country to scout fromdirection - Direction to scout in
CheatingException
ScoutActionException
TurnTimedOutException
blindrisk.exceptions.TurnTimedOutException - Thrown if this turn has
timed out.
public TransferResult computeTransfer(Country country,
Direction direction,
int numberOfUnits)
throws CheatingException,
TransferActionException,
TurnTimedOutException
country - Country transferringdirection - Direction tansferring tonumberOfUnits - Number of units to transfer
CheatingException
TransferActionException
blindrisk.exceptions.TransferActionException - thrown if your transfer
was illegal (too few units to tranfer etc...)
TurnTimedOutException
blindrisk.exceptions.TurnTimedOutException - Thrown if this turn has
timed out.
public static BasePlayer createPlayer(java.lang.Class<? extends BasePlayer> playerClass)
throws PlayerCreationException,
IllegalExitException
playerClass - The player class
PlayerCreationException
IllegalExitException
public static java.lang.Class<? extends BasePlayer> LoadPlayerClass(java.lang.String location,
java.lang.String classPath)
throws PlayerLoadException
location - The location of the jarclassPath - The the canonical name of the player class
PlayerLoadException
blindrisk.exceptions.PlayerLoadException - Throw if the player
could not be found.
public void changeGameSetting(java.lang.String key,
java.lang.String value)
throws GameSettingsCanNotBeChangedException,
InvalidGameSettingException
key - The setting to changevalue - String representation of value to change
GameSettingsCanNotBeChangedException
blindrisk.exceptions.GameSettingsCanNotBeChangedException - Thrown
if the game settings are set to being unchangeable
InvalidGameSettingExceptionpublic boolean isGameInitialised()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||