public abstract class Event extends Object implements Comparable<Event>, Serializable
Constructor and Description |
---|
Event()
Default constructor used by the game to create a new event.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Event event)
Compares this event to another event regarding precedence.
|
int |
getPriority()
Returns the priority of this event.
|
long |
getTime()
Returns the time when this event occurred.
|
void |
setPriority(int newPriority)
Changes the priority of this event.
|
void |
setTime(long newTime)
Changes the time when this event occurred.
|
public int compareTo(Event event)
This method will first compare the time of each event. If the event time is the same for both events, then this method compared the priority of each event. If the event priorities are equals, then this method will compare the two event based on specific event information.
This method is called by the game in order to sort the event queue of a robot to make sure the events are listed in chronological order.
compareTo
in interface Comparable<Event>
event
- the event to compare to this event.public long getTime()
Note that the time is equal to the turn of a battle round.
public void setTime(long newTime)
Note that the time is equal to the turn of a battle round.
This method is intended for letting robot developers create their own event types. It is not possible to change the time of an event after it has been added to the event queue of the robot.
newTime
- the time this event occurredpublic int getPriority()
An event priority is a value from 0 - 99. The higher value, the higher priority.
The default priority is 80, but varies depending on the type of event.
public final void setPriority(int newPriority)
The default priority is 80, but varies depending on the type of event.
This method is intended for letting robot developers create their own event types. It is not possible to change the priority of an event after it has been added to the event queue of the robot.
newPriority
- the new priority of this eventAdvancedRobot.setEventPriority(String, int)
Copyright © 2021 Robocode. All Rights Reserved.