Class LootBoxFactory

java.lang.Object
com.csse3200.game.entities.factories.LootBoxFactory

public class LootBoxFactory extends Object
Factory class responsible for creating different types of loot boxes based on a JSON configuration file. The loot boxes are dynamically generated using reflection, allowing for flexible and easily modifiable loot tables and loot box properties without needing to hard-code specific classes.
  • Constructor Details

    • LootBoxFactory

      public LootBoxFactory()
  • Method Details

    • createLootBox

      public UniversalLootBox createLootBox(String lootBoxName, Entity player) throws ClassNotFoundException
      Creates a loot box for a player based on its name, using the configuration defined in the JSON file. The loot box is dynamically generated based on its name, rolls, description, image, and loot table.
      Parameters:
      lootBoxName - The name of the loot box to create.
      player - The player entity that will receive the loot box.
      Returns:
      A UniversalLootBox object that is configured for the specified player and loot box name.
      Throws:
      ClassNotFoundException - If any class referenced in the loot table is not found.
      IllegalArgumentException - If the specified loot box name does not exist in the JSON configuration.