Tabnine Logo
IBattleListener
Code IndexAdd Tabnine to your IDE (free)

How to use
IBattleListener
in
robocode.control.events

Best Java code snippets using robocode.control.events.IBattleListener (Showing top 12 results out of 315)

origin: robo-code/robocode

  public void onBattleError(BattleErrorEvent event) {
    for (IBattleListener listener : listeners) {
      try {
        listener.onBattleError(event);
      } catch (Throwable ex) {
        Logger.realErr.println(listener.getClass() + " " + ex.getMessage());
      }
    }
  }
}
origin: robo-code/robocode

public void onBattleMessage(BattleMessageEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattleMessage(event);
    } catch (Throwable ex) {
      logError("onBattleMessage " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onBattleCompleted(BattleCompletedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattleCompleted(event);
    } catch (Throwable ex) {
      logError("onBattleCompleted " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onRoundStarted(RoundStartedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onRoundStarted(event);
    } catch (Throwable ex) {
      logError("onRoundStarted " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onBattlePaused(BattlePausedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattlePaused(event);
    } catch (Throwable ex) {
      logError("onBattlePaused " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onRoundEnded(RoundEndedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onRoundEnded(event);
    } catch (Throwable ex) {
      logError("onRoundEnded " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onBattleResumed(BattleResumedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattleResumed(event);
    } catch (Throwable ex) {
      logError("onBattleResumed " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onBattleStarted(BattleStartedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattleStarted(event);
    } catch (Throwable ex) {
      logError("onBattleStarted " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onBattleFinished(BattleFinishedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onBattleFinished(event);
    } catch (Throwable ex) {
      logError("onBattleFinished " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public void onTurnEnded(TurnEndedEvent event) {
  for (IBattleListener listener : listeners) {
    try {
      listener.onTurnEnded(event);
    } catch (Throwable ex) {
      logError("onTurnEnded " + listener.getClass(), ex);
    }
  }
}
origin: robo-code/robocode

public static void logError(String s) {
  if (logListener == null) {
    if (System.getProperty("logErrors", "true").equalsIgnoreCase("true")) {
      s = StringUtil.toBasicLatin(s);
      realErr.println(s);
    }
  } else {
    logListener.onBattleError(new BattleErrorEvent(s));
  }
}
origin: robo-code/robocode

public static void logMessage(String s, boolean newline) {
  if (logListener == null) {
    if (System.getProperty("logMessages", "true").equalsIgnoreCase("true")) {
      s = StringUtil.toBasicLatin(s);
      if (newline) {
        realOut.println(s);
      } else {
        realOut.print(s);
        realOut.flush();
      }
    }
  } else {
    synchronized (logBuffer) {
      if (!HiddenAccess.isSafeThread()) {
        // we just queue it, to not let unsafe thread travel thru system
        logBuffer.append(s);
        logBuffer.append("\n");
      } else if (newline) {
        logListener.onBattleMessage(new BattleMessageEvent(logBuffer + s));
        logBuffer.setLength(0);
      } else {
        logBuffer.append(s);
      }
    }
  }
}
robocode.control.eventsIBattleListener

Javadoc

The listener interface for receiving "interesting" battle events from the game, e.g. when a battle, round or turn is started or ended.

When implementing this battle listener you should implement the BattleAdaptor in order to only implement the event handler methods you are interested in.

Most used methods

  • onBattleError
    This method is called when the game has sent an error message. You must override this method in orde
  • onBattleMessage
    This method is called when the game has sent a new information message. You must override this metho
  • onBattleCompleted
    This method is called when the battle has completed successfully and results are available. This eve
  • onBattleFinished
    This method is called when the battle has finished. This event is always sent as the last battle eve
  • onBattlePaused
    This method is called when the battle has been paused, either by the user or the game. You must over
  • onBattleResumed
    This method is called when the battle has been resumed (after having been paused). You must override
  • onBattleStarted
    This method is called when a new battle has started. You must override this method in order to get i
  • onRoundEnded
    This method is called when the current round of a battle has ended. You must override this method in
  • onRoundStarted
    This method is called when a new round in a battle has started. You must override this method in ord
  • onTurnEnded
    This method is called when the current turn in a battle round is ended. You must override this metho
  • onTurnStarted
    This method is called when a new turn in a battle round has started. You must override this method i
  • onTurnStarted

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • String (java.lang)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now