Changes to pity system
This commit is contained in:
parent
39195e2445
commit
93c7d21123
12
bot.js
12
bot.js
|
|
@ -24,6 +24,7 @@ let defaultConfig = {
|
|||
};
|
||||
|
||||
let messageCounter = JSON.parse(fs.readFileSync('counter'));
|
||||
let pityTracker = {};
|
||||
|
||||
// Client
|
||||
client.on('message', onMessageHandler);
|
||||
|
|
@ -234,13 +235,13 @@ function onMessageHandler (channel, userstate, message, self) {
|
|||
}
|
||||
|
||||
counter.total++;
|
||||
|
||||
|
||||
// random chance
|
||||
// TODO: find a better alternative
|
||||
var number = Math.random() * 100;
|
||||
if (number <= config.chance || config.currentPity == config.pity) {
|
||||
if (number <= config.chance || (config.pity != 0 && pityTracker[channel] && pityTracker[channel] == config.pity)) {
|
||||
|
||||
config.currentPity = 0;
|
||||
pityTracker[channel] = 0;
|
||||
|
||||
counter.converted++;
|
||||
|
||||
|
|
@ -276,7 +277,10 @@ function onMessageHandler (channel, userstate, message, self) {
|
|||
|
||||
client.say(channel, newMessage.trim());
|
||||
} else {
|
||||
config.currentPity++;
|
||||
if (pityTracker[channel])
|
||||
pityTracker[channel]++;
|
||||
else
|
||||
pityTracker[channel] = 1;
|
||||
}
|
||||
|
||||
console.log(channel + ": " + JSON.stringify(counter));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user