Record Class CatalogEntry

java.lang.Object
java.lang.Record
com.csse3200.game.components.shop.CatalogEntry

public record CatalogEntry(Entity item, int price, boolean enabled, int maxStack, int bundleQuantity) extends Record
Represents a purchasable catalog entry in the in-game shop.

A catalog entry stores metadata about a specific Entity item, including its price, whether it is currently enabled for purchase, the maximum stack size in the player's inventory, and how many units of the item are sold in one bundle.

  • Constructor Summary

    Constructors
    Constructor
    Description
    CatalogEntry(Entity item, int price, boolean enabled, int maxStack, int bundleQuantity)
    Constructs a CatalogEntry, storing the details around an item that can be purchased from the shop
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the bundleQuantity record component.
    boolean
    Returns the value of the enabled record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    com.badlogic.gdx.scenes.scene2d.Actor
    getIconActor(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
    Creates an icon actor representing this catalog entry's item.
    Gets the item entity associated with this entry.
    Gets the display name of the item.
    final int
    Returns a hash code value for this object.
    Returns the value of the item record component.
    int
    Returns the value of the maxStack record component.
    int
    Returns the value of the price record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • CatalogEntry

      public CatalogEntry(Entity item, int price, boolean enabled, int maxStack, int bundleQuantity)
      Constructs a CatalogEntry, storing the details around an item that can be purchased from the shop
      Parameters:
      item - The unique identifiable itemKey
      price - The price (per unit) of the item
      enabled - Whether this item can currently be purchased by the player. (E.g., disabled due to max stack, not enough processors, etc.)
      maxStack - The max number of this item that can be stored in one inventory slot (1 if stackable is false)
      bundleQuantity - How many units of the item sold per purchase.
      Throws:
      IllegalArgumentException - if any of the arguments are invalid (e.g., null item, non-positive price, invalid stack/bundle size).
  • Method Details

    • getIconActor

      public com.badlogic.gdx.scenes.scene2d.Actor getIconActor(com.badlogic.gdx.scenes.scene2d.ui.Skin skin)
      Creates an icon actor representing this catalog entry's item.

      This is typically used for rendering the item in the shop UI.

      Parameters:
      skin - The game skin to style UI elements (currently unused).
      Returns:
      An Actor displaying the item's icon.
    • getItem

      public Entity getItem()
      Gets the item entity associated with this entry.
      Returns:
      The item entity.
    • getItemName

      public String getItemName()
      Gets the display name of the item.
      Returns:
      The item's name as defined in its ItemComponent.
    • 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.
    • item

      public Entity item()
      Returns the value of the item record component.
      Returns:
      the value of the item record component
    • price

      public int price()
      Returns the value of the price record component.
      Returns:
      the value of the price record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • maxStack

      public int maxStack()
      Returns the value of the maxStack record component.
      Returns:
      the value of the maxStack record component
    • bundleQuantity

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