### robocode

# Class CustomEvent

- `java.lang.Object`
- - `robocode.Event`
  - - `robocode.CustomEvent`

Implemented Interfaces:
  Comparable, Serializable

`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 robocode.Event

  `compareTo`, `getPriority`, `getTime`

## Constructor Details

### 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 met
>   `priority` - the priority of the condition

## Method Details

### 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