### robocode.control.events

# Class BattleCompletedEvent

- `java.lang.Object`
- - `robocode.control.events.BattleEvent`
  - - `robocode.control.events.BattleCompletedEvent`

`public class BattleCompletedEvent`
`extends BattleEvent`

A BattleCompletedEvent is sent to `onBattleCompleted()` when the battle is completed successfully and results are available. This event will not occur if the battle is terminated or aborted by the user before the battle is completed.

Authors:
  Pavel Savara (original)
  Flemming N. Larsen (contributor)

Since:
  1.6.2

See Also:
  `IBattleListener`, `BattleStartedEvent`, `BattleFinishedEvent`

  ## Constructor Summary

  `BattleCompletedEvent(BattleRules battleRules, BattleResults[] results)`
    Creates a new BattleCompletedEvent.

  ## Method Summary

  `BattleRules`

  `getBattleRules()`
    Returns the rules that was used in the battle.

  `BattleResults[]`

  `getIndexedResults()`
    Returns the unsorted battle results so that robot indexes can be used.

  `BattleResults[]`

  `getSortedResults()`
    Returns the battle results sorted on score, meaning that robot indexes cannot be used.

## Constructor Details

### BattleCompletedEvent

    public BattleCompletedEvent(BattleRules battleRules,
                                BattleResults[] results)

> Creates a new BattleCompletedEvent.
> Parameters:
>   `battleRules` - the rules that was used in the battle.
>   `results` - the indexed results of the battle. These are unsorted, but using robot indexes.

## Method Details

### getBattleRules

    public BattleRules getBattleRules()

> Returns the rules that was used in the battle.
> Returns:
>   the rules of the battle.

### getIndexedResults

    public BattleResults[] getIndexedResults()

> Returns the unsorted battle results so that robot indexes can be used.
> Returns:
>   an unsorted array of BattleResults, where each index matches an index of a specific robot.

### getSortedResults

    public BattleResults[] getSortedResults()

> Returns the battle results sorted on score, meaning that robot indexes cannot be used.
> Returns:
>   a sorted array of BattleResults, where the results with the biggest score are placed first in the list.