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
ConstructorsConstructorDescriptionCatalogEntry
(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 TypeMethodDescriptionint
Returns the value of thebundleQuantity
record component.boolean
enabled()
Returns the value of theenabled
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.getItem()
Gets the item entity associated with this entry.Gets the display name of the item.final int
hashCode()
Returns a hash code value for this object.item()
Returns the value of theitem
record component.int
maxStack()
Returns the value of themaxStack
record component.int
price()
Returns the value of theprice
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
CatalogEntry
Constructs a CatalogEntry, storing the details around an item that can be purchased from the shop- Parameters:
item
- The unique identifiable itemKeyprice
- The price (per unit) of the itemenabled
- 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
Gets the item entity associated with this entry.- Returns:
- The item entity.
-
getItemName
Gets the display name of the item.- Returns:
- The item's name as defined in its
ItemComponent
.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
item
Returns the value of theitem
record component.- Returns:
- the value of the
item
record component
-
price
public int price()Returns the value of theprice
record component.- Returns:
- the value of the
price
record component
-
enabled
public boolean enabled()Returns the value of theenabled
record component.- Returns:
- the value of the
enabled
record component
-
maxStack
public int maxStack()Returns the value of themaxStack
record component.- Returns:
- the value of the
maxStack
record component
-
bundleQuantity
public int bundleQuantity()Returns the value of thebundleQuantity
record component.- Returns:
- the value of the
bundleQuantity
record component
-