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 DragonLootElementCommand
s.- Author:
- Parker Hawke - Choco
-
Constructor Summary
Constructors Constructor Description LootPoolCommand(String name, double chance, int minRolls, int maxRolls, Collection<DragonLootElementCommand> commandElements)
Create a command loot pool.LootPoolCommand(String name, double chance, int rolls, Collection<DragonLootElementCommand> commandElements)
Create a command loot pool.LootPoolCommand(String name, int minRolls, int maxRolls, Collection<DragonLootElementCommand> commandElements)
Create a command loot pool.LootPoolCommand(String name, int rolls, Collection<DragonLootElementCommand> commandElements)
Create a command loot pool. -
Method Summary
Modifier and Type Method Description static LootPoolCommand
fromJson(com.google.gson.JsonObject root)
Parse aLootPoolCommand
instance from aJsonObject
.double
getChance()
Get the chance that this loot pool will generate when created.int
getMaxRolls()
Get the maximum amount of times this loot pool should be rolled (inclusive).int
getMinRolls()
Get the minimum amount of times this loot pool should be rolled (inclusive).String
getName()
Get this loot pool's name.DragonLootElementCommand
roll(Random random)
Roll this loot pool using the supplied Random instance.com.google.gson.JsonObject
toJson()
Write this loot pool as a JsonObject.
-
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 nullchance
- the chance that this loot pool will generateminRolls
- 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 nullchance
- the chance that this loot pool will generaterolls
- the amount of times this loot pool should be rolledcommandElements
- 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 nullminRolls
- 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 nullrolls
- the amount of times this loot pool should be rolledcommandElements
- 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
Parse aLootPoolCommand
instance from aJsonObject
.- 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
Description copied from interface:ILootPool
Get this loot pool's name. Can return null if no name was specified.- Specified by:
getName
in interfaceILootPool<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 interfaceILootPool<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 interfaceILootPool<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 interfaceILootPool<T extends IDragonLootElement>
- Returns:
- the max rolls
-
roll
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 interfaceILootPool<T extends IDragonLootElement>
- Parameters:
random
- the random instance with which random numbers should be generated- Returns:
- the randomly generated loot from this pool
-