Record Class Weapon

java.lang.Object
java.lang.Record
idlab.colonyops.model.entities.inventory.Weapon
Record Components:
type - the weapon's behaviour profile
damage - HP removed from the target per hit, before armour mitigation
range - the maximum Chebyshev distance at which the weapon can hit a target
unlimitedUse - true if the weapon never runs out of uses (e.g. the Energy Sword), in which case usesLeft() is not decremented
usesLeft - remaining shots before the weapon is depleted, ignored when unlimitedUse is true
maxUses - the weapon's uses capacity, restored e.g. by the Ammo Pack consumable

public record Weapon(WeaponType type, int damage, int range, boolean unlimitedUse, int usesLeft, int maxUses) extends Record
A weapon held in a squad member's weapon slot. Exact stats depend on the colony's tech research and are subject to balance changes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Weapon(WeaponType type, int damage, int range, boolean unlimitedUse, int usesLeft, int maxUses)
    Creates an instance of a Weapon record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the damage record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxUses record component.
    int
    Returns the value of the range record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.
    boolean
    Returns the value of the unlimitedUse record component.
    int
    Returns the value of the usesLeft record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Weapon

      public Weapon(WeaponType type, int damage, int range, boolean unlimitedUse, int usesLeft, int maxUses)
      Creates an instance of a Weapon record class.
      Parameters:
      type - the value for the type record component
      damage - the value for the damage record component
      range - the value for the range record component
      unlimitedUse - the value for the unlimitedUse record component
      usesLeft - the value for the usesLeft record component
      maxUses - the value for the maxUses record component
  • Method Details

    • 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 the compare method from their corresponding wrapper classes.
      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.
    • type

      public WeaponType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • damage

      public int damage()
      Returns the value of the damage record component.
      Returns:
      the value of the damage record component
    • range

      public int range()
      Returns the value of the range record component.
      Returns:
      the value of the range record component
    • unlimitedUse

      public boolean unlimitedUse()
      Returns the value of the unlimitedUse record component.
      Returns:
      the value of the unlimitedUse record component
    • usesLeft

      public int usesLeft()
      Returns the value of the usesLeft record component.
      Returns:
      the value of the usesLeft record component
    • maxUses

      public int maxUses()
      Returns the value of the maxUses record component.
      Returns:
      the value of the maxUses record component