robocode
Class CustomEvent
java.lang.Object
|
+--robocode.Event
|
+--robocode.CustomEvent
- All Implemented Interfaces:
- Comparable
- public class CustomEvent
- extends Event
This event is sent to onCustomEvent
when a custom condition is met. Be sure to reset or remove the custom condition
to avoid having it fire repeatedly.
- See Also:
getCondition()
Constructor Summary |
CustomEvent(Condition condition)
Called by the game to create a new CustomEvent when a condition is met. |
CustomEvent(Condition condition,
int priority)
Called by the game to create a new CustomEvent when a condition is met. |
Method Summary |
Condition |
getCondition()
Returns the condition that fired, causing this event to be generated. |
CustomEvent
public CustomEvent(Condition condition)
- Called by the game to create a new CustomEvent when a condition is met.
CustomEvent
public CustomEvent(Condition condition,
int priority)
- Called by the game to create a new CustomEvent when a condition is met.
The event will have the given priority.
This is equivalent to calling setPriority() on the Condition.
getCondition
public Condition getCondition()
- Returns the condition that fired, causing this event to be generated.
Use this to determine which condition fired, and to remove the custom event.
public void onCustomEvent(CustomEvent event) {
if (event.getCondition().getName().equals("mycondition")) {
removeCustomEvent(event.getCondition());
doSomethingElse();
}
}
- Returns:
- the condition that fired, causing this event to be generated.