Class WeaponsStatsComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.WeaponsStatsComponent

public class WeaponsStatsComponent extends Component
Component used to store weapon-related combat statistics such as attack damage, cooldown, upgrade stages, and cheat modifiers.

Any entity that uses weapons in combat should have an instance of this component.

  • Constructor Details

    • WeaponsStatsComponent

      public WeaponsStatsComponent(WeaponConfig config)
      Constructs a WeaponsStatsComponent from a weapon configuration.
      Parameters:
      config - the weapon configuration (must specify non-negative damage)
    • WeaponsStatsComponent

      public WeaponsStatsComponent(int baseAttack)
      Constructs a WeaponsStatsComponent with a base attack value.
      Parameters:
      baseAttack - the initial base attack damage (must be >= 0)
  • Method Details

    • setCoolDown

      public void setCoolDown(float coolDown)
      Sets the cooldown time between attacks.
      Parameters:
      coolDown - cooldown in seconds (clamped to minimum 0)
    • getCoolDown

      public float getCoolDown()
      Gets the cooldown time between attacks.
      Returns:
      cooldown in seconds
    • getBaseAttack

      public int getBaseAttack()
      Gets the current effective attack damage for this weapon.

      The effective damage is calculated as: baseAttack × damageMultiplier.

      The value is clamped to the range of an int.
      Returns:
      effective attack damage
    • setBaseAttack

      public void setBaseAttack(int attack)
      Sets the base attack damage (before multipliers).
      Parameters:
      attack - base attack damage (must be >= 0)
    • setProjectileTexturePath

      public void setProjectileTexturePath(String projectileTexturePath)
      Sets the texture path for this weapon's projectile, if applicable.
      Parameters:
      projectileTexturePath - path to the projectile texture
    • getProjectileTexturePath

      public String getProjectileTexturePath()
      Gets the texture path for this weapon's projectile, if applicable.
      Returns:
      projectile texture path, or null if none
    • getUpgradeStage

      public int getUpgradeStage()
      Gets the current upgrade stage.
      Returns:
      current upgrade stage (starts at 1)
    • getMaxUpgradeStage

      public int getMaxUpgradeStage()
      Gets the maximum upgrade stage.
      Returns:
      maximum upgrade stage
    • isMaxUpgraded

      public boolean isMaxUpgraded()
      Checks if this weapon is already fully upgraded.
      Returns:
      true if the upgrade stage is at maximum, false otherwise
    • upgrade

      public void upgrade()
      Upgrades this weapon to the next stage, if not already maxed out.

      Each upgrade doubles the base attack damage.

    • setDisableDamage

      public void setDisableDamage(boolean status)
      Enables or disables damage output for this weapon.
      Parameters:
      status - true to disable damage, false to allow damage
    • setDamageMultiplier

      public void setDamageMultiplier(float multiplier)
      Sets the damage multiplier for this weapon.

      The multiplier must be non-negative and finite. For example:

      • 1.0 = normal damage (default)
      • 2.0 = double damage
      • 0.5 = half damage
      Parameters:
      multiplier - the new damage multiplier
    • getDamageMultiplier

      public float getDamageMultiplier()
      Gets the current damage multiplier applied to this weapon.
      Returns:
      current damage multiplier (default 1.0)