robocode.control.events
Class BattleCompletedEvent

java.lang.Object
  extended by robocode.control.events.BattleEvent
      extended by robocode.control.events.BattleCompletedEvent
Direct Known Subclasses:
NavalBattleCompletedEvent

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.

Since:
1.6.2
Author:
Pavel Savara (original), Flemming N. Larsen (contributor)
See Also:
IBattleListener, IBattleListener.onBattleCompleted(BattleCompletedEvent), BattleStartedEvent, BattleFinishedEvent

Field Summary
protected  BattleResults[] results
           
 
Constructor Summary
BattleCompletedEvent(BattleRules battleRules, BattleResults[] results)
          Called by the game to create a new BattleCompletedEvent.
 
Method Summary
 BattleRules getBattleRules()
          Returns the rules used in the battle.
 BattleResults[] getIndexedResults()
          Returns the battle results that can be used to determine the score for the individual robot based on the robot index.
 BattleResults[] getSortedResults()
          Returns the battle results sorted on score.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

results

protected final BattleResults[] results
Constructor Detail

BattleCompletedEvent

public BattleCompletedEvent(BattleRules battleRules,
                            BattleResults[] results)
Called by the game to create a new BattleCompletedEvent. Please don't use this constructor as it might change.

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 Detail

getBattleRules

public BattleRules getBattleRules()
Returns the rules used in the battle.

Returns:
the rules used in the battle.

getSortedResults

public BattleResults[] getSortedResults()
Returns the battle results sorted on score. Note that the robot index cannot be used to determine the score with the sorted results.

Returns:
an array of sorted BattleResults, where the results with the bigger score are placed first in the list.
See Also:
getIndexedResults()

getIndexedResults

public BattleResults[] getIndexedResults()
Returns the battle results that can be used to determine the score for the individual robot based on the robot index.

Returns:
an array of indexed BattleResults, where each index matches an index of a specific robot.
See Also:
getSortedResults()


Copyright © 2015 Robocode. All Rights Reserved.