Added pity system

This commit is contained in:
Marco Loewe 2021-09-03 19:43:17 +02:00
parent 0f65dcfdee
commit 39195e2445

18
bot.js
View File

@ -16,6 +16,8 @@ let configurations = JSON.parse(configFile);
let defaultConfig = {
word: "butt",
chance: 20,
pity: 0,
currentPity: 0,
limit: 10,
syllableCount: 2,
ignoredUsers: []
@ -117,6 +119,16 @@ function onMessageHandler (channel, userstate, message, self) {
client.say(channel, "Expected a number, got " + value);
}
break;
case "pity":
if (isNumeric(value)) {
config.pity = parseInt(value);
configurations[channel] = config;
fs.writeFileSync('buttsbot.config', JSON.stringify(configurations));
client.say(channel, "Pity set to " + value);
} else {
client.say(channel, "Expected a number, got " + value);
}
break;
case "ignore":
if (value && value !== "") {
console.log(`* ignore: value ok`);
@ -226,7 +238,9 @@ function onMessageHandler (channel, userstate, message, self) {
// random chance
// TODO: find a better alternative
var number = Math.random() * 100;
if (number <= config.chance) {
if (number <= config.chance || config.currentPity == config.pity) {
config.currentPity = 0;
counter.converted++;
@ -261,6 +275,8 @@ function onMessageHandler (channel, userstate, message, self) {
});
client.say(channel, newMessage.trim());
} else {
config.currentPity++;
}
console.log(channel + ": " + JSON.stringify(counter));