Bots Home
|
Create an App
Smurfettes Dice Bot
Author:
happyferret
Description
Source Code
Launch Bot
Current Users
Created by:
Happyferret
/** * Smurfettes Dice * Version: 1.1.12 * Author: HappyFerret * Date: 2021-04-012 */ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, label: 'Cena za grę / Price per game?', defaultValue: 29 }, { name: 'multirolls', type: 'int', minValue: 1, label: 'Liczba gier napiwek / What is the maximum number of rolls you want a user to be able to make in a single tip? (set to 1 to disable) Example: If you set this to 3 and you charge 33 tokens per roll, a user could tip 66 for 2 rolls or 99 for 3 rolls. Any other tip amounts will be ignored.', defaultValue: 1 }, { name: 'notice_wait_time', type: 'choice', label: 'Czas między reklamami / Time between advertisments?', choice1: 3, choice2: 5, choice3: 8, choice4: 13, choice5: 21, choice6: 34, choice7: 55, choice8: 89, defaultValue: 8 }, {name: 'prize_3', type: 'str', label: 'Prize for rolling 3 (~0.5%)', defaultValue: 'sorry, try again'}, {name: 'prize_4', type: 'str', label: 'Prize for rolling 4 (~1.5%)', defaultValue: 'blow a kiss'}, {name: 'prize_5', type: 'str', label: 'Prize for rolling 5 (~3%)', defaultValue: 'lick lips'}, {name: 'prize_6', type: 'str', label: 'Prize for rolling 6 (~4.5%)', defaultValue: 'close flash panties'}, {name: 'prize_7', type: 'str', label: 'Prize for rolling 7 (~7%)', defaultValue: 'body tour'}, {name: 'prize_8', type: 'str', label: 'Prize for rolling 8 (~9.5%)', defaultValue: 'hand bra'}, {name: 'prize_9', type: 'str', label: 'Prize for rolling 9 (~11.5%)', defaultValue: 'use lush for 5 minutes'}, {name: 'prize_10', type: 'str', label: 'Prize for rolling 10 (~12.5%)', defaultValue: 'spank ass 2 times'}, {name: 'prize_11', type: 'str', label: 'Prize for rolling 11 (~12.5%)', defaultValue: 'doggy pose in panties'}, {name: 'prize_12', type: 'str', label: 'Prize for rolling 12 (~11.5%)', defaultValue: 'spank ass 5 times'}, {name: 'prize_13', type: 'str', label: 'Prize for rolling 13 (~9.5%)', defaultValue: 'flash tits'}, {name: 'prize_14', type: 'str', label: 'Prize for rolling 14 (~7%)', defaultValue: 'play with tits'}, {name: 'prize_15', type: 'str', label: 'Prize for rolling 15 (~4.5%)', defaultValue: 'flash pussy'}, {name: 'prize_16', type: 'str', label: 'Prize for rolling 16 (~3%)', defaultValue: 'naked flash'}, {name: 'prize_17', type: 'str', label: 'Prize for rolling 17 (~1.5%)', defaultValue: 'panties off doggy pose'}, {name: 'prize_18', type: 'str', label: 'Prize for rolling 18 (~0.5%)', defaultValue: 'panties off masturbation'}, ]; var price = cb.settings.tokens; var langTokens = (price > 1) ? 'tokens' : 'token'; var numberOfSides = 6; var multiRolls = cb.settings.multirolls; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var prizes = []; var maxOutcome = 18; var dieImagePrefix = ':smurfdie'; cb.onTip(function (tip) { var maxTip = multiRolls * price; var tipAmount = parseInt(tip['amount']); // check to see if tip was for a dice roll if(tipAmount >= price && (tipAmount <= maxTip) && (tipAmount % price === 0)) { var numberOfRolls = Math.floor(tipAmount / price); for (var i = 0; i < numberOfRolls; i++) { roll(tip['from_user']); lastRoller = tip['from_user']; } } else { // Tip was for something else, don't roll the dice var textColor = '#FFFFFF'; var bgColor = '#0000D0'; //cb.sendNotice('Tip was not for dice roll.', '', bgColor, textColor, 'bold'); //tipCounter += parseInt(tip['amount']); cb.drawPanel(); } }); cb.onDrawPanel(function (user) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Last prize won:', 'row1_value': lastPrizeWon, 'row2_label': 'Last player:', 'row2_value': lastRoller, 'row3_value': tipCounter + ' ' + langTokens + ' received / rolled ' + rollCounter + ' time(s)' }; }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(function (msg) { if (msg['m'].match(/!sw/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } else if (msg['m'].match(/!sd/i)) { msg['X-Spam'] = true; if (msg['m'].match(/all/i) && ((msg['is_mod'] === true) || (msg['user'] == cb.room_slug))) { showPrizes(); } else { showPrizes(msg['user']); } } return msg; }); function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } function roll(username) { var prize = 'A Thank You!'; rollCounter++; var die1 = getRandomIntInclusive(1, 6); var die2 = getRandomIntInclusive(1, 6); var die3 = getRandomIntInclusive(1, 6); var total = die1 + die2 + die3; var winner = false; if (total >= 3) { winner = true; prize = cb.settings['prize_' + total]; } else { winner = false; } var prizeIndex = prizes.indexOf(prize); if (prizeIndex >= 0) { if (cb.settings.remove_winning_prize == 'Yes') prizes.splice(prizeIndex, 1); } else { prize = 'A Thank You!'; } var dicemsg = dieImagePrefix + die1 + " " + dieImagePrefix + die2 + " "+ dieImagePrefix + die3 + ""; msg = username + " rolled a " + total + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; var dicetextColor = '#0000D0'; var dicebgColor = '#FFFFFF'; var textColor = '#FFFFFF'; var bgColor = '#0000D0'; if (winner) textColor = '#FFFFFF'; if (total == maxOutcome) { bgColor = '#0000FF'; textColor = '#FFFFFF'; } cb.sendNotice(dicemsg, '', dicebgColor, dicetextColor, 'bold'); cb.sendNotice(msg, '', bgColor, textColor, 'bold'); lastPrizeWon = prize; winners.push("Roll #" + rollCounter + " (" + total + "): " + username + " - " + prize); cb.drawPanel(); } function setPrizes() { var rareText = ''; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (RARE)"; prizes.push(cb.settings['prize_' + i] + rareText); } } function showPrizes(username) { var msg = ""; for (var i = 3; i <= 18; i++) { msg += "Roll " + i + " - " + cb.settings['prize_' + i] + "\n"; } cb.sendNotice(msg, username, '#0000C0', '#FFFFFF', 'bold'); } function showPrizesWon(username) { var msg = "##### LAST 20 WINNERS #####"; msg += "\nList sorted in chronological order"; if (winners.length === 0) { cb.sendNotice('No one has won anything yet. Roll the dice to win a prize!', username, '', '', 'bold'); } else { var recentWinners = winners.slice(-20); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#0000D0', '#FFFFFF', 'bold'); } } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; msg += "We are playing Smurfettes Dice Game - by happyferret \n"; msg += "Each roll reveals a prize. There are 16 possible prizes.\n"; msg += "Tip " + price + " " + langTokens + " to roll the dice. \n"; if (multiRolls > 1) msg += "You can roll a maximum of " + multiRolls + " times in a single tip (" + (multiRolls*price) + " tokens). \n"; msg += "Type \"!sd\" to see the list of prizes. \n"; msg += "Type \"!sd all\" to send the list to all viewers if you're a mod or the broadcaster.\n"; msg += "Type \"!sw\" to see a list of the last 20 winners."; cb.sendNotice(msg, username, '#0000D0', '#FFFFFF', 'bold'); } function init() { setPrizes(); advertise(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.