public class ExampleCommand1 extends UserDefinedCommand
Trade
RETURN_KEY
Constructor and Description |
---|
ExampleCommand1() |
Modifier and Type | Method and Description |
---|---|
void |
endCommand(boolean finished)
Called by the framework when the command is finished.
You can override this method to clean up after the command if needed. |
static int |
exec(int fuel,
int organics,
int equipment)
Simple trading at the port in the current sector.
|
java.lang.String |
getName()
Called by the framework to get the name of the command.
You should override this method. |
boolean |
initCommand()
Called by the framework to initialise the command.
You should override this method to make your own initialisation. |
void |
onEvent(EventIfc event)
This method is called for each posted event.
You can override this method to handle events. |
void |
onText(java.lang.String buffer,
java.lang.String text)
This method is called when new text has arrived from the game server.
You can override this method to scan for incoming text. The current text buffer contains both the previous text and the new text that just arrived. |
void |
startCommand()
Called by the framework to start executing the command.
You should override this method. Normally you send some text to the TW server and then handle all incoming text and events using the methods onText and onEvent . |
atPrompt, execInstance, getClassName, getParams, getResource, initInstance, isInternal, isUserDefined, postEvent, printTrace, printTrace, registerParam, sendString, setBufferText, setResult, skipBufferText
public java.lang.String getName()
UserDefinedCommand
getName
in interface CommandIfc
getName
in class UserDefinedCommand
public boolean initCommand() throws java.lang.Exception
UserDefinedCommand
initCommand
in class UserDefinedCommand
true
if the initialisation was successful,
otherwise false
.java.lang.Exception
UserDefinedCommand.atPrompt(int)
,
UserDefinedCommand.printTrace(java.lang.String)
,
UserDefinedCommand.setResult(java.lang.Object)
public void startCommand() throws java.lang.Exception
UserDefinedCommand
onText
and onEvent
.startCommand
in class UserDefinedCommand
java.lang.Exception
UserDefinedCommand.sendString(java.lang.String)
,
UserDefinedCommand.postEvent(com.swath.UserDefinedEvent)
,
UserDefinedCommand.printTrace(java.lang.String)
,
UserDefinedCommand.setResult(java.lang.Object)
,
UserDefinedCommand.onText(java.lang.String, java.lang.String)
,
UserDefinedCommand.onEvent(com.swath.EventIfc)
public void endCommand(boolean finished) throws java.lang.Exception
UserDefinedCommand
endCommand
in class UserDefinedCommand
finished
- true
if the command finished correctly or
false
if the command was interrupted in some way.java.lang.Exception
public void onText(java.lang.String buffer, java.lang.String text) throws java.lang.Exception
UserDefinedCommand
skipBufferText
and setBufferText
methods.onText
in class UserDefinedCommand
buffer
- The current text buffer.text
- The new incoming text.java.lang.Exception
UserDefinedCommand.skipBufferText(int)
,
UserDefinedCommand.setBufferText(java.lang.String)
,
UserDefinedCommand.sendString(java.lang.String)
,
UserDefinedCommand.postEvent(com.swath.UserDefinedEvent)
,
UserDefinedCommand.printTrace(java.lang.String)
,
UserDefinedCommand.setResult(java.lang.Object)
public void onEvent(EventIfc event) throws java.lang.Exception
UserDefinedCommand
onEvent
in class UserDefinedCommand
event
- The event.java.lang.Exception
UserDefinedCommand.sendString(java.lang.String)
,
UserDefinedCommand.postEvent(com.swath.UserDefinedEvent)
,
UserDefinedCommand.printTrace(java.lang.String)
,
UserDefinedCommand.setResult(java.lang.Object)
public static int exec(int fuel, int organics, int equipment) throws java.lang.Exception
fuel
- The amount of Fuel Ore to buy/sell.organics
- The amount of Organics to buy/sell.equipment
- The amount of Equipment to buy/sell.java.lang.Exception