Interface BattleSimulationContext

All Superinterfaces:
BattleStateView, ContextHolder
All Known Subinterfaces:
BattleController, BattleMessaging
All Known Implementing Classes:
MultiLaneBattleController, StandardBattleController

public interface BattleSimulationContext extends BattleStateView
Provides simulation-related state and behaviour for a battle.

This interface groups together battle settings that affect whether the battle should behave like a live in-world battle or a controlled/simulated battle. Simulation contexts are used by tests, AI evaluation, copied battle states, and other systems that need to inspect or resolve battle behaviour without applying all normal live-battle side effects.

This interface does not guarantee that the battle is immutable. It only describes simulation-related controls and convenience checks exposed by a battle state view.

  • Method Details

    • copy

      Creates a copy of this battle controller.

      The returned battle is intended for systems that need to evaluate or simulate battle outcomes without directly mutating the original battle. The exact copied state depends on the backing BattleController implementation.

      Returns:
      a copied battle controller
    • waitTicks

      int waitTicks()
      Returns the number of battle ticks this battle must wait before normal turn progression can continue.
      Returns:
      remaining wait ticks
    • waitTicks

      void waitTicks(int waitTicks)
      Sets the number of battle ticks this battle must wait before normal turn progression can continue.
      Parameters:
      waitTicks - remaining wait ticks
    • isSimulatedBattle

      default boolean isSimulatedBattle()
      Returns whether this battle is marked as a simulated battle.

      The simulation flag is stored in the battle context using ContextKeys.SIMULATION. Simulated battles are generally used for tests, AI lookahead, or copied battle states and should avoid live-world side effects such as spawning entities, sending battle communication, or awarding normal battle progression effects where applicable.

      Returns:
      true if this battle is simulated; false otherwise
    • disableCommunication

      default boolean disableCommunication()
      Returns whether battle communication should be disabled.

      Communication is disabled when explicitly requested through ContextKeys.DISABLE_COMMUNICATION, or when the battle is simulated. This is used to prevent battle packets and messages from being sent to clients for copied battles, tests, AI simulations, or other silent battle contexts.

      Returns:
      true if battle communication should be disabled; false otherwise
    • shouldSpawnEntities

      default boolean shouldSpawnEntities()
      Returns whether Pokémon entities should be spawned for this battle.

      Entities are spawned by default, but can be disabled through ContextKeys.SPAWN_ENTITIES. Entities are also disabled for simulated battles so copied or test battles do not create live world entities.

      Returns:
      true if battle entities should be spawned; false otherwise
    • isLevelingDisabled

      default boolean isLevelingDisabled()
      Returns whether Pokémon leveling should be disabled for this battle.

      Leveling is disabled when the relevant Pixelmon battle configuration disallows experience for the battle type, when Pokémon have been raised to a temporary cap, when the battle is simulated, or when explicitly disabled through ContextKeys.DISABLE_LEVELLING.

      PvP experience is controlled by PixelmonConfigProxy.getBattle().isAllowPVPExperience(). Trainer battle experience is controlled by PixelmonConfigProxy.getBattle().isAllowTrainerExperience().

      Returns:
      true if leveling should be disabled; false otherwise
    • isFrozen

      default boolean isFrozen()
      Returns whether this battle is currently frozen.

      A frozen battle does not progress through normal turn handling. Battles with pending wait ticks are also considered frozen until those ticks have elapsed. This is primarily useful for tests or controlled battle scenarios where code needs to inspect or manipulate battle state without the regular update loop advancing the battle.

      Returns:
      true if the battle is frozen; false otherwise
    • freeze

      default void freeze()
      Freezes this battle.

      While frozen, the battle should not progress through normal turn handling. This is mainly intended for tests and controlled battle scenarios.

    • unfreeze

      default void unfreeze()
      Unfreezes this battle.

      After unfreezing, the battle may continue progressing through its normal update and turn handling.