Record Class RaidShieldState

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.battles.raids.RaidShieldState
Record Components:
active - Whether the boss currently has an active shield.
activated - Whether the shield has already been activated during the raid.
shieldsRaised - The visible shield segments or discrete shield charges currently shown. Dynamax shields use this as their mechanical charge count.
health - The underlying barrier durability currently remaining. For Dynamax this is normally the same value as shieldsRaised; Tera shields can use this as a continuous durability value while deriving visible segments from it.
maxHealth - The maximum barrier durability for this phase. This is used by shields with continuous durability to calculate their visible segment count.
shieldStrength - The generated strength used when raising a new shield phase.
remainingUses - The number of shield phases still available after the current phase.
lastHitter - The last Pokemon to damage the shield this turn, used to avoid multi-hit moves removing multiple shield charges.

public record RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth, int shieldStrength, int remainingUses, Optional<UUID> lastHitter) extends Record
Immutable runtime state for a raid boss shield.

The shield state is stored on battle context so raid strategies can share shield progress without depending on a specific raid implementation. A shield may be inactive, active, or previously activated and broken/cleared.

  • Field Details

  • Constructor Details

    • RaidShieldState

      public RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth)
    • RaidShieldState

      public RaidShieldState(boolean active, boolean activated, int shieldsRaised, float health, float maxHealth, int shieldStrength, int remainingUses, Optional<UUID> lastHitter)
      Creates an instance of a RaidShieldState record class.
      Parameters:
      active - the value for the active record component
      activated - the value for the activated record component
      shieldsRaised - the value for the shieldsRaised record component
      health - the value for the health record component
      maxHealth - the value for the maxHealth record component
      shieldStrength - the value for the shieldStrength record component
      remainingUses - the value for the remainingUses record component
      lastHitter - the value for the lastHitter record component
  • Method Details

    • inactive

      public static RaidShieldState inactive(int shieldStrength, int remainingUses)
      Creates an inactive state for a raid that can still raise shields later.
      Parameters:
      shieldStrength - The generated strength for future shield phases.
      remainingUses - The number of shield phases still available.
      Returns:
      An inactive shield state with the supplied future shield values.
    • raised

      public static RaidShieldState raised(int shieldStrength, int remainingUses)
      Creates an active discrete shield phase.

      This is the usual shape for Dynamax shields, where the visible shield count and mechanical durability are the same value.

      Parameters:
      shieldStrength - The number of shield charges to raise.
      remainingUses - The number of shield phases available after this phase is raised.
      Returns:
      An active shield state.
    • raised

      public static RaidShieldState raised(int shieldsRaised, float health, float maxHealth)
      Creates an active continuous-durability shield phase.

      This is the usual shape for Tera shields, where visible shield segments and mechanical durability are intentionally separate values.

      Parameters:
      shieldsRaised - The visible shield segment count.
      health - The current barrier durability.
      maxHealth - The maximum barrier durability.
      Returns:
      An active shield state.
    • visibleSegments

      public int visibleSegments()
      Gets the visible shield segment count.
      Returns:
      The shield value that should be shown to clients.
    • durability

      public float durability()
      Gets the current underlying barrier durability.
      Returns:
      The mechanical durability remaining for this shield phase.
    • maxDurability

      public float maxDurability()
      Gets the maximum underlying barrier durability.
      Returns:
      The maximum durability for this shield phase.
    • wasLastHitBy

      public boolean wasLastHitBy(UUID pokemon)
      Checks whether a Pokemon has already damaged this shield during the current turn.
      Parameters:
      pokemon - The Pokemon UUID to check.
      Returns:
      Whether this Pokemon is the last shield hitter.
    • hasLastHitter

      public boolean hasLastHitter()
      Checks whether any Pokemon has damaged this shield during the current turn.
      Returns:
      Whether a last shield hitter is stored.
    • withActivated

      public RaidShieldState withActivated(boolean activated)
      Creates a copy of this shield state with a different activation flag.
      Parameters:
      activated - Whether the shield phase should be marked as activated.
      Returns:
      A copy of this state with the supplied activation value.
    • withActive

      public RaidShieldState withActive(boolean active)
      Creates a copy of this shield state with a different active flag.
      Parameters:
      active - Whether the shield is currently active.
      Returns:
      A copy of this state with the supplied active value.
    • withRemainingUses

      public RaidShieldState withRemainingUses(int remainingUses)
      Creates a copy of this shield state with a different remaining-use count.
      Parameters:
      remainingUses - The number of shield phases still available.
      Returns:
      A copy of this state with the supplied remaining-use count.
    • withShieldStrength

      public RaidShieldState withShieldStrength(int shieldStrength)
      Creates a copy of this shield state with a different shield strength.
      Parameters:
      shieldStrength - The generated strength used by future shield phases.
      Returns:
      A copy of this state with the supplied shield strength.
    • withDiscreteShields

      public RaidShieldState withDiscreteShields(int shieldsRaised)
      Creates a copy of this shield state with discrete shield charges.

      This updates both the visible shield segments and durability to the same value.

      Parameters:
      shieldsRaised - The visible shield segment and durability value.
      Returns:
      A copy of this state with the supplied discrete shield value.
    • withDurability

      public RaidShieldState withDurability(float health, int shieldsRaised)
      Creates a copy of this shield state with continuous durability and visible segments.
      Parameters:
      health - The remaining barrier durability.
      shieldsRaised - The visible shield segment count.
      Returns:
      A copy of this state with the supplied durability and visible segment count.
    • withHealth

      public RaidShieldState withHealth(float health, int shieldsRaised)
      Creates a copy of this shield state with continuous durability and visible segments.
      Parameters:
      health - The remaining barrier durability.
      shieldsRaised - The visible shield segment count.
      Returns:
      A copy of this state with the supplied durability and visible segment count.
    • broken

      public RaidShieldState broken()
      Creates a copy of this shield state marked as broken for the current phase.
      Returns:
      A copy of this state with no active shield or visible segments.
    • withLastHitter

      public RaidShieldState withLastHitter(UUID lastHitter)
      Creates a copy of this shield state with a different last hitter value.
      Parameters:
      lastHitter - The UUID of the last Pokemon to hit the shield, or empty if no Pokemon has hit the shield this turn.
      Returns:
      A copy of this state with the supplied last hitter value.
    • withNoLastHitter

      public RaidShieldState withNoLastHitter()
      Creates a copy of this shield state with an empty last hitter value.
      Returns:
      A copy of this state with an empty last hitter value.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • active

      public boolean active()
      Returns the value of the active record component.
      Returns:
      the value of the active record component
    • activated

      public boolean activated()
      Returns the value of the activated record component.
      Returns:
      the value of the activated record component
    • shieldsRaised

      public int shieldsRaised()
      Returns the value of the shieldsRaised record component.
      Returns:
      the value of the shieldsRaised record component
    • health

      public float health()
      Returns the value of the health record component.
      Returns:
      the value of the health record component
    • maxHealth

      public float maxHealth()
      Returns the value of the maxHealth record component.
      Returns:
      the value of the maxHealth record component
    • shieldStrength

      public int shieldStrength()
      Returns the value of the shieldStrength record component.
      Returns:
      the value of the shieldStrength record component
    • remainingUses

      public int remainingUses()
      Returns the value of the remainingUses record component.
      Returns:
      the value of the remainingUses record component
    • lastHitter

      public Optional<UUID> lastHitter()
      Returns the value of the lastHitter record component.
      Returns:
      the value of the lastHitter record component