hm now it's "Unexpected token :" var drops = (function() {
'use strict';
var commands = {
'dropswolves': function(msg, args) {
var wolves = ['Nothing'], i,
accumulator = {},
count = 1;
if (args.length > 0) {
count = parseInt(args[0]);
if (!count && count !== 0) {
count = 1;
}
}
for (i = 0; i < count; i++) {
wolves = generateDrops('Raw Wolves Meat', 3, 'Wolves Pelt', 2, 'Wolves Fang', 3, 'NA', 1, 'NA', 1, 'CP', [5, 10],
[11, 40], [26, 40], [31, 40], [0], [0], [1, 40], accumulator);
}
postDrops('Wolf', wolves);
}
'dropsboars': function(msg, args) {
var boars = ['Nothing'], i,
accumulator = {},
count = 1;
if (args.length > 0) {
count = parseInt(args[0]);
if (!count && count !== 0) {
count = 1;
}
}
for (i = 0; i < count; i++) {
boars = generateDrops('L1', 2, 'L2', 2, 'L3', 2, 'NA', 1, 'NA', 1, 'GP', [3, 10],
[11, 40], [26, 40], [31, 40], [0], [0], [1, 40], accumulator);
}
postDrops('Boars', boars);
}
};
function postDrops(enemy, drops) {
var message = '<span style="font-weight:bold">' + enemy + ' ' + 'Item Drops</span>';
_.each(drops, function(outputLine) {
message += '<br>' + outputLine;
});
sendChat('System', message);
}
function generateDrops(commonItem, commonAmount, uncommonItem, uncommonAmount, rareItem, rareAmount, uniqueItem, uniqueAmount, legendaryItem, legendaryAmount, coinType, coinAmount, commonDrop, uncommonDrop, rareDrop, uniqueDrop, legendaryDrop, coinDrop, result) {
var rngRange = _.flatten([commonDrop, uncommonDrop, rareDrop, uniqueDrop, legendaryDrop, coinDrop]),
max = _.max(rngRange),
min = _.min(rngRange),
rng = randomInteger(max - min + 1) + min - 1,
output = [];
result = result || {};
if (!result[commonItem]) {
result[commonItem] = 0;
}
if (!result[uncommonItem]) {
result[uncommonItem] = 0;
}
if (!result[rareItem]) {
result[rareItem] = 0;
}
if (!result[uniqueItem]) {
result[uniqueItem] = 0;
}
if (!result[legendaryItem]) {
result[legendaryItem] = 0;
}
if (commonDrop[0] <= rng && rng <= commonDrop[1]) {
result[commonItem] += randomInteger(commonAmount);
}
if (uncommonDrop[0] <= rng && rng <= uncommonDrop[1]) {
result[uncommonItem] += randomInteger(uncommonAmount);
}
if (rareDrop[0] <= rng && rng <= rareDrop[1]) {
result[rareItem] += randomInteger(rareAmount);
}
if (uniqueDrop[0] <= rng && rng <= uniqueDrop[1]) {
result[uniqueItem] += randomInteger(uniqueAmount);
}
if (legendaryDrop[0] <= rng && rng <= legendaryDrop[1]) {
result[legendaryItem] += randomInteger(legendaryAmount);
}
if (coinDrop[0] <= rng && rng <= coinDrop[1]) {
result[coinType] += randomInteger(coinAmount[1] - coinAmount[0] + 1) + coinAmount[0] - 1;
}
if (result[commonItem] > 0) {
output.push('<span style="color:black">' + commonItem + ' ' + result[commonItem] + '</span>');
}
if (result[uncommonItem] > 0) {
output.push('<span style="color:green">' + uncommonItem + ' ' + result[uncommonItem] + '</span>');
}
if (result[rareItem] > 0) {
output.push('<span style="color:blue">' + rareItem + ' ' + result[rareItem] + '</span>');
}
if (result[uniqueItem] > 0) {
output.push('<span style="color:orange">' + uniqueItem + ' ' + result[uniqueItem] + '</span>');
}
if (result[legendaryItem] > 0) {
output.push('<span style="color:red">' + legendaryItem + ' ' + result[legendaryItem] + '</span>');
}
if (result[coinType] > 0) {
output.push(result[coinType] + ' ' + coinType);
}
return output;
}
function handleInput(msg) {
var args = msg.content.split(' '),
command = args.shift().substring(1).toLowerCase();
if (commands[command]) {
commands[command](msg, args);
}
}
function registerEventHandlers() {
on('chat:message', handleInput);
}
return {
registerEventHandlers: registerEventHandlers
};
}());
on('ready', function() {
'use strict';
drops.registerEventHandlers();
});