40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
const Reward = require("../Game/Reward");
|
|
const rewardCallback = require("../Callbacks/reward");
|
|
|
|
const MAXIMUM_COUNT_MOJO = 1000;
|
|
|
|
const cauldronReward = new Reward({
|
|
distributionType: 2,
|
|
baseReward: {
|
|
3: {
|
|
5: { amountMinimum: 1500, chance: 16.5 },
|
|
6: { amountMinimum: 1500, chance: 16.5 },
|
|
7: { amountMinimum: 1500, chance: 16.5 },
|
|
8: { amountMinimum: 1500, chance: 16.5 },
|
|
9: { amountMinimum: 1500, chance: 16.5 },
|
|
10: { amountMinimum: 1500, chance: 16.5 },
|
|
}/*,
|
|
5: {
|
|
17: { amount: 1, chance: 1 }
|
|
}*/
|
|
}
|
|
});
|
|
|
|
module.exports = function (ws, message, player) {
|
|
let amount = message.getUint16(1);
|
|
if (!amount) return;
|
|
|
|
if (amount > MAXIMUM_COUNT_MOJO) amount = MAXIMUM_COUNT_MOJO;
|
|
// const usedItem = player.inventory.use(1, 3, amount);
|
|
// const economy = player.inventory.getEconomy();
|
|
const usedAmount = player.inventory.alterAmount(1, 3, amount);
|
|
if (!usedAmount) return console.log("not enough mojo");
|
|
|
|
console.log("mojo thrown | amount:", usedAmount);
|
|
|
|
const playerInventory = player.inventory.getPosessions();
|
|
cauldronReward.single(usedAmount, playerInventory, rewards => {
|
|
rewardCallback({ isRegular: false, death: { authorID: player.id }, rewards })
|
|
console.info(rewards)
|
|
});
|
|
}; |