Class LootPoolCommand

java.lang.Object
wtf.choco.dragoneggdrop.dragon.loot.pool.LootPoolCommand
All Implemented Interfaces:
ILootPool<DragonLootElementCommand>

public class LootPoolCommand
extends Object
Represents a ILootPool implementation for DragonLootElementCommands.
Author:
Parker Hawke - Choco
  • Constructor Details

    • LootPoolCommand

      public LootPoolCommand​(String name, double chance, int minRolls, int maxRolls, Collection<DragonLootElementCommand> commandElements)
      Create a command loot pool.
      Parameters:
      name - this pool's name. Can be null
      chance - the chance that this loot pool will generate
      minRolls - the minimum amount of times this loot pool should be rolled (inclusive).
      maxRolls - the maximum amount of times this loot pool should be rolled (inclusive).
      commandElements - the elements in this loot pool
    • LootPoolCommand

      public LootPoolCommand​(String name, double chance, int rolls, Collection<DragonLootElementCommand> commandElements)
      Create a command loot pool.
      Parameters:
      name - this pool's name. Can be null
      chance - the chance that this loot pool will generate
      rolls - the amount of times this loot pool should be rolled
      commandElements - the elements in this loot pool
    • LootPoolCommand

      public LootPoolCommand​(String name, int minRolls, int maxRolls, Collection<DragonLootElementCommand> commandElements)
      Create a command loot pool.
      Parameters:
      name - this pool's name. Can be null
      minRolls - the minimum amount of times this loot pool should be rolled (inclusive).
      maxRolls - the maximum amount of times this loot pool should be rolled (inclusive).
      commandElements - the elements in this loot pool
    • LootPoolCommand

      public LootPoolCommand​(String name, int rolls, Collection<DragonLootElementCommand> commandElements)
      Create a command loot pool.
      Parameters:
      name - this pool's name. Can be null
      rolls - the amount of times this loot pool should be rolled
      commandElements - the elements in this loot pool
  • Method Details

    • toJson

      public com.google.gson.JsonObject toJson()
      Description copied from interface: ILootPool
      Write this loot pool as a JsonObject.
      Returns:
      the JSON representation
    • fromJson

      public static LootPoolCommand fromJson​(com.google.gson.JsonObject root)
      Parse a LootPoolCommand instance from a JsonObject.
      Parameters:
      root - the root element that represents this pool
      Returns:
      the created instance
      Throws:
      com.google.gson.JsonParseException - if parsing the object has failed
    • getName

      public String getName()
      Description copied from interface: ILootPool
      Get this loot pool's name. Can return null if no name was specified.
      Specified by:
      getName in interface ILootPool<T extends IDragonLootElement>
      Returns:
      the loot pool name
    • getChance

      public double getChance()
      Description copied from interface: ILootPool
      Get the chance that this loot pool will generate when created.
      Specified by:
      getChance in interface ILootPool<T extends IDragonLootElement>
      Returns:
      the chance (0.0 - 100.0) of generation
    • getMinRolls

      public int getMinRolls()
      Description copied from interface: ILootPool
      Get the minimum amount of times this loot pool should be rolled (inclusive).
      Specified by:
      getMinRolls in interface ILootPool<T extends IDragonLootElement>
      Returns:
      the min rolls
    • getMaxRolls

      public int getMaxRolls()
      Description copied from interface: ILootPool
      Get the maximum amount of times this loot pool should be rolled (inclusive).
      Specified by:
      getMaxRolls in interface ILootPool<T extends IDragonLootElement>
      Returns:
      the max rolls
    • roll

      public DragonLootElementCommand roll​(Random random)
      Description copied from interface: ILootPool
      Roll this loot pool using the supplied Random instance. Each roll should result in a different element from this pool.
      Specified by:
      roll in interface ILootPool<T extends IDragonLootElement>
      Parameters:
      random - the random instance with which random numbers should be generated
      Returns:
      the randomly generated loot from this pool