robocode
Class CustomEvent
java.lang.Object
robocode.Event
robocode.CustomEvent
- All Implemented Interfaces:
- Comparable<Event>
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 recurring repeatedly (see the
example for the getCondition()
method.
- Author:
- Mathew A. Nelson (original)
- 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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CustomEvent
public CustomEvent(Condition condition)
- Called by the game to create a new CustomEvent when a condition is met.
- Parameters:
condition
- the condition that must be 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.
An event priority is a value from 0 - 99. The higher value, the higher
priority. The default priority is 80.
This is equivalent to calling
Condition.setPriority(int)
on the
Condition.
- Parameters:
condition
- the condition that must be metpriority
- the priority of 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());
// do something else
}
}
- Returns:
- the condition that fired, causing this event to be generated