Class UniversalLootBox
java.lang.Object
com.csse3200.game.inventory.items.AbstractItem
com.csse3200.game.inventory.items.ConsumableItem
com.csse3200.game.inventory.items.lootbox.UniversalLootBox
-
Field Summary
Fields inherited from class com.csse3200.game.inventory.items.AbstractItem
description, itemCode, limit, name, onlyCombatItem, onlyMapItem, quantity
-
Constructor Summary
ConstructorsConstructorDescriptionUniversalLootBox
(BaseLootTable lootTable, int rolls, Entity player, String description, String texturePath, int code) -
Method Summary
Modifier and TypeMethodDescriptionopen()
Opens the loot box and returns a list of randomly selected items based on the loot table and number of rolls.void
useItem
(ItemUsageContext context) Consumes one instance of the loot box and adds the generated items to the player's inventory.Methods inherited from class com.csse3200.game.inventory.items.AbstractItem
add, getDescription, getItemCode, getLimit, getName, getQuantity, getTexturePath, isEmpty, numAddable, onlyCombatItem, onlyMapItem, setDescription, setTexturePath
-
Constructor Details
-
UniversalLootBox
public UniversalLootBox(BaseLootTable lootTable, int rolls, Entity player, String description, String texturePath, int code)
-
-
Method Details
-
open
Opens the loot box and returns a list of randomly selected items based on the loot table and number of rolls.- Returns:
- List of randomly selected AbstractItem objects.
-
useItem
Consumes one instance of the loot box and adds the generated items to the player's inventory. This method triggers the addition of new items to the player's inventory and updates the player's UI.- Overrides:
useItem
in classConsumableItem
- Parameters:
context
- The context in which the item is being used, typically includes information about the entity using the item.- Throws:
ConsumedException
- If the loot box has already been fully consumed and has no remaining uses.
-
getPlayer
-