public class ExampleCommand1 extends UserDefinedCommand
TradeRETURN_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, skipBufferTextpublic java.lang.String getName()
UserDefinedCommandgetName in interface CommandIfcgetName in class UserDefinedCommandpublic boolean initCommand()
throws java.lang.Exception
UserDefinedCommandinitCommand in class UserDefinedCommandtrue if the initialisation was successful,
otherwise false.java.lang.ExceptionUserDefinedCommand.atPrompt(int),
UserDefinedCommand.printTrace(java.lang.String),
UserDefinedCommand.setResult(java.lang.Object)public void startCommand()
throws java.lang.Exception
UserDefinedCommandonText and onEvent.startCommand in class UserDefinedCommandjava.lang.ExceptionUserDefinedCommand.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
UserDefinedCommandendCommand in class UserDefinedCommandfinished - true if the command finished correctly or
false if the command was interrupted in some way.java.lang.Exceptionpublic void onText(java.lang.String buffer,
java.lang.String text)
throws java.lang.Exception
UserDefinedCommandskipBufferText and setBufferText methods.onText in class UserDefinedCommandbuffer - The current text buffer.text - The new incoming text.java.lang.ExceptionUserDefinedCommand.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
UserDefinedCommandonEvent in class UserDefinedCommandevent - The event.java.lang.ExceptionUserDefinedCommand.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