
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A simple and flexible loot rolling system.
npm i lootastic
You can create a LootTable with:
{ chance: X, result: <item> }You can also pass in a rollModifier into the options object to increase the weights of every item.
Examples:
// plain initialization - all weights are 1
let lootTable = new LootTable(['sword', 'armor', 'potion', 'shield']);
// weight initialization - swords are common, potions are not
let lootTable = new LootTable([
{ chance: 1, result: 'potion' },
{ chance: 5, result: 'armor' },
{ chance: 10, result: 'shield' },
{ chance: 20, result: 'sword' }
]);
// weight initialization with a rollModifier - each weight is 10 higher
// a common use-case here is a "luck bonus" in item drops
let lootTable = new LootTable([
{ chance: 1, result: 'potion' },
{ chance: 5, result: 'armor' },
{ chance: 10, result: 'shield' },
{ chance: 20, result: 'sword', maxChance: 100 }, // always a 1/5 drop rate
{ chance: -1, result: 'gold' } // always drops
], { rollModifier: 10 });
You can roll a table using one of 3 methods:
Examples:
let result = lootTable.chooseWithReplacement(1) // 1 random item + gold
let result = lootTable.chooseWithReplacement(5) // 5 random items + gold
let result = lootTable.chooseWithoutReplacement(1) // 1 random item + gold
let result = lootTable.chooseWithoutReplacement(4) // the whole table + gold
let result = lootTable.chooseWithoutReplacement(5) // error - not enough items to choose
let result = lootTable.tryToDropEachItem(1) // all items will drop + gold
let result = lootTable.tryToDropEachItem(10) // shield and sword will guaranteed drop + gold
let result = lootTable.tryToDropEachItem(100) // some items might drop + gold
If you want to roll multiple loot tables at once, or the same loot table multiple times (suppose you have a monster drop table and a zone drop table), you can use the LootRoller class:
let result = LootRoller.rollTables([
{ table: lootTable, func: LootFunctions.WithoutReplacement, args: 1 }, // always picks 1 item (+ gold)
{ table: lootTable, func: LootFunctions.EachItem, args: 1 }, // try to drop each item (+ gold)
]); // 2 gold entries, 1 item, and maybe more depending on the EachItem roll
maxChance to an item to customize tryToDropForEachItem when you don't want to scale item probabilities.FAQs
a loot rolling system
We found that lootastic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.