Interface BattleRandomContext
- All Superinterfaces:
BattleStateView,ContextHolder
- All Known Subinterfaces:
BattleController
- All Known Implementing Classes:
MultiLaneBattleController,StandardBattleController
This interface groups together the random state and damage-randomisation strategy used while resolving battle effects. It allows live battles, simulations, tests, and copied battle states to control how random outcomes are produced.
The BattleRandomness implementation is responsible for chance
checks and random values used by battle logic. The
AttackDamageCalculator is responsible for calculating the damage
random multiplier used by attacks.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidEnables forced chance handling for this battle context.default voidforceChance(boolean force) Sets whether supported chance checks should be forced for this battle context.Returns the attack damage calculator used by this battle.Returns the battle randomness provider used by this battle.voidsetAttackDamageCalculator(AttackDamageCalculator attackDamageCalculator) Sets the attack damage calculator used by this battle.default voidsetRandom(BattleRandomSource random) Replaces the underlying random source used by this battle's randomness provider.voidsetRandomness(BattleRandomness randomness) Sets the battle randomness provider used by this battle.default booleanReturns whether supported chance checks should be forced for this battle context.Methods inherited from interface com.pixelmonmod.pixelmon.battles.controller.BattleStateView
actionIndex, battleEnded, battleIndex, battleIndex, battleLog, battleTicks, battleTicksPerSecond, battleTurn, containsParticipantType, getActiveFaintedPokemon, getActivePokemon, getActiveUnfaintedPokemon, getBattleType, getParticipantForEntity, getParticipantFromPokemon, getParticipants, getPartyPokemonFromUUID, getPlayer, getPlayer, getPlayerEntities, getPlayers, getPokemonFromUUID, getStage, globalStatusController, isInverseBattle, isPvE, isPvP, isRaid, isTeamDefeated, isTeamHomogeneous, isWaiting, oldGen, oldGen, onBattlefield, otherParticipant, outcome, participants, playerCount, team, teams, timeElapsedMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.context.ContextHolder
get, getContext, getOrDefault, has, remove, set, update
-
Method Details
-
getAttackDamageCalculator
AttackDamageCalculator getAttackDamageCalculator()Returns the attack damage calculator used by this battle.The damage calculator controls how the attack damage random multiplier is resolved. Different implementations may use normal random damage rolls, average damage, minimum damage, maximum damage, or another deterministic strategy for simulations and tests.
- Returns:
- the attack damage calculator
-
setAttackDamageCalculator
Sets the attack damage calculator used by this battle.- Parameters:
attackDamageCalculator- the attack damage calculator to use
-
randomness
BattleRandomness randomness()Returns the battle randomness provider used by this battle.The randomness provider should be used by battle logic for random battle behaviour so live battles, tests, and simulations can control randomness consistently.
- Returns:
- the battle randomness provider
-
setRandomness
Sets the battle randomness provider used by this battle.- Parameters:
randomness- the battle randomness provider to use
-
setRandom
Replaces the underlying random source used by this battle's randomness provider.This preserves the current
BattleRandomnesspolicy while swapping the lower-levelBattleRandomSource. This is useful when copied battles or tests need to provide a deterministic random source without changing the higher-level randomness behaviour.- Parameters:
random- the random source to use
-
forceChance
default void forceChance()Enables forced chance handling for this battle context.When enabled, supported chance checks should bypass their normal random roll and resolve as successful. This is primarily useful for deterministic tests or controlled simulations that need chance-dependent behaviour to be forced explicitly.
-
forceChance
default void forceChance(boolean force) Sets whether supported chance checks should be forced for this battle context.When
true, battle randomness checks that consultContextKeys.FORCE_CHANCEshould resolve as successful without using their normal random roll. Whenfalse, those checks should use the activeBattleRandomnessbehaviour normally.This flag should only affect chance checks that explicitly support forced outcomes. Random values that are not chance checks, or random behaviour that must remain genuinely random, should not be affected by this setting.
- Parameters:
force- whether supported chance checks should be forced to succeed
-
shouldForceChance
default boolean shouldForceChance()Returns whether supported chance checks should be forced for this battle context.If this returns
true, chance checks that support forced outcomes and consultContextKeys.FORCE_CHANCEshould skip their normal random roll and resolve as successful. If no value has been set, this defaults tofalse.- Returns:
trueif supported chance checks should be forced to succeed;falseotherwise
-