Loot Table Plugin
Loot Tables can be used for monster drops, opening card packs in a CCG , or when you cash out and sell loot boxes.
The Loot Tables allow you to combine different rewards. So you can gain an Achievement or Currency from the same table.
The Loot plugin calculates rolls on Loot tables and returns a list of Outputs that can be applied. There are three kinds of optional entries on a loot table:
always, items which always get picked.oneOf, items of which one gets picked based on itsweight.anyOf, items which individually can get picked based on apercentage.
Demo
Loot Plugin
| Type | Id | Amount |
|---|---|---|
| Let's get rolling! |
Usage
import { LootTablePlugin } from '@123ishatest/ludiek';
const lootTable = new LootTablePlugin();
lootTable.loadContent([{
id: '/table/demo',
always: [
{ output: { type: '/output/gain-currency', id: '/currency/money', amount: 1 } },
{ output: { type: '/output/gain-currency', id: '/currency/gems', amount: 1 } },
],
oneOf: [
{ output: { type: '/output/item', id: '/item/fish', amount: 3 }, weight: 10 },
{ output: { type: '/output/item', id: '/item/wood', amount: 2 }, weight: 1 },
],
anyOf: [
{ output: { type: '/output/gain-currency', id: '/currency/money', amount: 10 }, percentage: 1 / 2 },
{ output: { type: '/output/gain-currency', id: '/currency/gems', amount: 10 }, percentage: 1 / 3 },
{ output: { type: '/output/item', id: '/item/rare', amount: 1 }, percentage: 1 / 100 },
{ output: { type: '/output/item', id: '/item/ultra-rare', amount: 1 }, percentage: 1 / 10000 },
],
}]);
// Roll for loot
const result = lootTable.roll('/table/demo');
console.log(result) // Who knows, it's random :) Connect to events.
loot.onRoll.subscribe((output) => {
output.forEach(console.log);
});