Esempio n. 1
0
 /**
  * Registers the full and simple class name of the specified event and sets the default priority
  * of the event class.
  *
  * @param event an event belonging to the event class to register the class name for etc.
  */
 private void registerEventNames(Event event) {
   if (!HiddenAccess.isCriticalEvent(event)) {
     HiddenAccess.setDefaultPriority(event);
   }
   final Class<?> type = event.getClass();
   eventNames.put(type.getName(), event); // full name with package name
   eventNames.put(type.getSimpleName(), event); // only the class name
 }
Esempio n. 2
0
 /**
  * Returns the priority of events belonging to a specific class.
  *
  * @param eventClass is a string with the full class name of the event type to get the priority
  *     from.
  * @return the event priority of the specified event class.
  * @see robocode.Event#getPriority()
  */
 public int getEventPriority(String eventClass) {
   if (eventClass == null) {
     return -1;
   }
   final Event event = eventNames.get(eventClass);
   if (event == null) {
     return -1;
   }
   return event.getPriority();
 }
Esempio n. 3
0
 /**
  * Sets the event priority of events belonging to a specific class.
  *
  * @param eventClass is a string with the full class name of the event type to set the priority
  *     for.
  * @param priority is the new priority
  */
 public void setEventPriority(String eventClass, int priority) {
   if (eventClass == null) {
     return;
   }
   final Event event = eventNames.get(eventClass);
   if (event == null) {
     robotProxy.println("SYSTEM: Unknown event class: " + eventClass);
     return;
   }
   if (HiddenAccess.isCriticalEvent(event)) {
     robotProxy.println("SYSTEM: You may not change the priority of a system event.");
   }
   HiddenAccess.setEventPriority(event, priority);
 }
Esempio n. 4
0
  /**
   * Registers the full and simple class names of all events used by {@link
   * #getEventPriority(String)} and {@link #setEventPriority(String, int)} and sets the default
   * priority of each event class.
   */
  private void registerEventNames() {
    eventNames = new Hashtable<String, Event>();
    dummyScannedRobotEvent = new ScannedRobotEvent(null, 0, 0, 0, 0, 0);
    registerEventNames(new BattleEndedEvent(false, null));
    registerEventNames(new BulletHitBulletEvent(null, null));
    registerEventNames(new BulletHitEvent(null, 0, null));
    registerEventNames(new BulletMissedEvent(null));
    registerEventNames(new DeathEvent());
    registerEventNames(new HitByBulletEvent(0, null));
    registerEventNames(new HitRobotEvent(null, 0, 0, false));
    registerEventNames(new HitWallEvent(0));
    registerEventNames(new KeyPressedEvent(null));
    registerEventNames(new KeyReleasedEvent(null));
    registerEventNames(new KeyTypedEvent(null));
    registerEventNames(new MessageEvent(null, null));
    registerEventNames(new MouseClickedEvent(null));
    registerEventNames(new MouseDraggedEvent(null));
    registerEventNames(new MouseEnteredEvent(null));
    registerEventNames(new MouseExitedEvent(null));
    registerEventNames(new MouseMovedEvent(null));
    registerEventNames(new MousePressedEvent(null));
    registerEventNames(new MouseReleasedEvent(null));
    registerEventNames(new MouseWheelMovedEvent(null));
    registerEventNames(new PaintEvent());
    registerEventNames(new RobotDeathEvent(null));
    registerEventNames(new RoundEndedEvent(0, 0, 0));
    registerEventNames(dummyScannedRobotEvent);
    registerEventNames(new SkippedTurnEvent(0));
    registerEventNames(new StatusEvent(null));
    registerEventNames(new WinEvent());

    // same as any line above but for custom event
    final DummyCustomEvent customEvent = new DummyCustomEvent();
    eventNames.put("robocode.CustomEvent", customEvent); // full name with package name
    eventNames.put("CustomEvent", customEvent); // only the class name
  }