Bots Home
|
Create an App
Roll Dice + throttled free roll
Author:
mynamesnotbrian
Description
Source Code
Launch Bot
Current Users
Created by:
Mynamesnotbrian
cb.settings_choices = [ { name: 'disable_tip_rolls', type: 'choice', label: "Free rolls only mode? (i.e. _only_ let users roll with their free random rolls, ignore tips)", choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'tokens', type: 'int', minValue: 1, label: 'Tokens per roll?', defaultValue: 33 }, { name: 'throttle_min', type: 'int', minValue: 0, label: "Users will have to wait a random amount of time between free rolls -- what's the minumum number of minutes users should have to wait between free rolls?", defaultValue: 10 }, { name: 'throttle_max', type: 'int', minValue: 1, label: "What's the maximum number of minutes users should have to wait between free rolls?", defaultValue: 20 }, { name: 'notify_throttle', type: 'choice', label: "Notify users when they're able to use their free roll?", choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'one_free_only', type: 'choice', label: "Should each user only get one free roll per session?", choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'global_throttle', type: 'int', minValue: 0, label: "Allow a free roll by anyone once every _ minutes (if set to 5, every five minutes whoever gets in first will be able to use their free roll, and then all users will have to wait). 0 means anyone can use a free roll anytime they have one.", defaultValue: 10 }, { name: 'notice_wait_time', type: 'int', minValue: 1, label: 'In minutes, how often should the app advertise itself?', defaultValue: 10 }, { name: 'prize_2', type: 'str', label: 'Prize for rolling 2 (rarest)', defaultValue: 'dance (you choose song)' }, { name: 'prize_3', type: 'str', label: 'Prize for rolling 3', defaultValue: 'flash boobs' }, { name: 'prize_4', type: 'str', label: 'Prize for rolling 4', defaultValue: 'flash pussy' }, { name: 'prize_5', type: 'str', label: 'Prize for rolling 5', defaultValue: 'flash butt' }, { name: 'prize_6', type: 'str', label: 'Prize for rolling 6', defaultValue: 'flash (you choose what)' }, { name: 'prize_7', type: 'str', label: 'Prize for rolling 7 (most common)', defaultValue: 'suck nipples' }, { name: 'prize_8', type: 'str', label: 'Prize for rolling 8', defaultValue: 'pussy close up' }, { name: 'prize_9', type: 'str', label: 'Prize for rolling 9', defaultValue: 'camel toe' }, { name: 'prize_10', type: 'str', label: 'Prize for rolling 10', defaultValue: 'spank butt' }, { name: 'prize_11', type: 'str', label: 'Prize for rolling 11', defaultValue: 'spank butt both hands' }, { name: 'prize_12', type: 'str', label: 'Prize for rolling 12 (rarest)', defaultValue: 'spank pussy' }, ]; var price = cb.settings.tokens; var langTokens = (price > 1) ? 'tokens' : 'token'; var numberOfSides = 6; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var prizes = []; var maxOutcome = 12; var dieImagePrefix = (cb.settings.die_type == 'Traditional') ? ':reddie' : ':cdie'; var disable_tip_rolls = cb.settings.disable_tip_rolls; var lastFreeRoll = []; var minThrottleDuration = cb.settings.throttle_min * 60 * 1000; var maxThrottleDuration = cb.settings.throttle_max * 60 * 1000; var notify_free_roll_available = cb.settings.notify_throttle; var one_free_only = cb.settings.one_free_only === "Yes"; cb.log(':' + JSON.stringify(cb.settings.one_free_only)); var global_throttle = cb.settings.global_throttle * 60 * 1000; var last_roll = Date.now(); var rolled_users = {}; cb.onTip(function (tip) { if (disable_tip_rolls) return; var tipAmount = parseInt(tip['amount']); // check to see if tip was for a dice roll if (tipAmount === price) { roll(tip['from_user']); lastRoller = tip['from_user']; } else { // Tip was for something else, don't roll the dice var textColor = '#000000'; var bgColor = '#D9FAD7'; //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) { var randomDuration = Math.floor(Math.random() * maxThrottleDuration) + minThrottleDuration; lastFreeRoll[user.user] = Date.now() + randomDuration; cb.sendNotice("You'll be able to use your first free roll in about " + Math.ceil(randomDuration / 60 / 1000) + " minutes!", user.user) if (notify_free_roll_available) cb.setTimeout(function() { cb.sendNotice("You can use a free roll now!", user.user); }, randomDuration) showAppAd(user['user']); }); cb.onMessage(function (msg) { // sample message: // { // "c": "#494949", // "f": "default", // "gender": "m", // "has_tokens": true, // "in_fanclub": false, // "is_mod": false, // "m": "test", // "tipped_alot_recently": false, // "tipped_recently": false, // "tipped_tons_recently": false, // "user": "mynamesnotbrian" // } if (msg['m'].match(/!free-roll/i)) { msg['X-Spam'] = true; if (one_free_only && rolled_users[msg.user]) { cb.sendNotice("Sorry - only one roll per person per show!", msg.user); return msg; } cb.log(Math.abs(last_roll - Date.now())); cb.log(global_throttle); if (global_throttle && (Math.abs(last_roll - Date.now()) < global_throttle)) { cb.sendNotice("Someone rolled too recently, sorry!", msg.user); return msg; } if (lastFreeRoll[msg.user] && Date.now() - lastFreeRoll[msg.user] > 0) { // cb.sendNotice(':dices :dices ' + msg.user + " used a free roll! :dices :dices "); cb.sendNotice('' + msg.user + " used a free roll!"); roll(msg.user); var randomDuration = Math.floor(Math.random() * maxThrottleDuration) + minThrottleDuration; lastFreeRoll[msg.user] = Date.now() + randomDuration; if(one_free_only) { rolled_users[msg.user] = true; return msg; } cb.sendNotice("You'll be able to use your next free roll in about " + Math.ceil(randomDuration / 60 / 1000) + " minutes!", msg.user) if (notify_free_roll_available) cb.setTimeout(function() { cb.sendNotice("You can use a free roll again!", msg.user); }, randomDuration) return msg; } cb.sendNotice( "Too soon, you have to wait!", msg.user); return msg; } if (msg['m'].match(/!winners/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } else if (msg['m'].match(/!prizes/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 roll(username) { rollCounter++; last_roll = Date.now(); var die1 = Math.floor(Math.random() * numberOfSides) + 1; var die2 = Math.floor(Math.random() * numberOfSides) + 1; var total = die1 + die2; var winner = false; if (total >= 1) { winner = true; var prize = cb.settings['prize_' + total]; } else { winner = false; var prize = 'A Thank You!'; } // var msg = ":dices " + die1 + " :dices " + die2 + "\n"; var msg = "" + die1 + " " + die2 + "\n"; // msg += ":dices " + username + " rolled a " + total + "! \n".toUpperCase(); msg += "" + username + " rolled a " + total + "! \n".toUpperCase(); // msg += ":dices Roll #" + rollCounter + " | Prize: " + prize; msg += "Roll #" + rollCounter + " | Prize: " + prize; var textColor = '#000000'; var bgColor = '#D9FAD7'; if (winner) textColor = '#067D00'; if (total == maxOutcome) { bgColor = '#FFDBF3'; textColor = '#A805A6'; } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); lastPrizeWon = prize; winners.push("Roll #" + rollCounter + " (" + total + "): " + username + " - " + prize); cb.drawPanel(); } function setPrizes() { for (var i = 1; i <= maxOutcome; i++) { prizes.push(cb.settings['prize_' + i]); } } function showPrizes(username) { var rareText = ''; var msg = "***** POSSIBLE PRIZES *****"; for (var i = 2; i <= maxOutcome; i++) { if (prizes.indexOf(cb.settings['prize_' + i] + rareText) >= 0) msg += "\n Roll " + i + " - " + cb.settings['prize_' + i] + rareText; } cb.sendNotice(msg, username, '#FFFFFF', '#34113F', '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, '#ffff00', '#000000', 'bold'); } else { var recentWinners = winners.slice(-20); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#FFFFFF', '#34113F', 'bold'); } } function showappinformation(username) { var msg = "***** app information ***** "; msg += "\nRoll the Dice \n"; msg += "made by mynamesnotbrian \n"; msg += "old version - 10.1.1 \n"; msg += "new version - 10.2.1 \n"; msg += "release date - 2018-03-31 \n"; msg += "update date - 2018-11-24 \n"; msg += "(Tweaked from the original game and its modifications by zingknaat and mynamesnotbrian) \n"; msg += "for questions or suggestions you can mail to feedback.chaturbate@gmail.com \n"; msg += "you can leave a feedback via http://www.zencloud.site/feedback.php \n"; msg += "Type \"!log\" to see the changelog history \n"; msg += "Type \"!lol\" to see the list of prizes \n"; msg += "Type \"!lol all\" to send the list to all viewers if you're a mod or the broadcaster\n"; msg += "Type \"!winners\" to see a list of the last 20 winners "; cb.sendNotice(msg, username, '#FFFFFF', '#34113F', 'bold'); } function showchangelog(username) { var msg = "***** changelog information ***** "; msg += "\nchangelog (2018-11-23) \n"; msg += "I have made the text white and the layout black. then people who are color blind can read it well. \n"; msg += "bug fixed \n"; msg += "added a welcome message \n"; msg += "added Remove prize from list after each roll \n\n"; msg += "changelog (2018-11-24) \n"; msg += "remove welcome message \n"; msg += "added What shall happen if a user tips an amount that is a multiple of the roll price but would result in more rolls at once than allowed \n"; msg += "minor bugs fixed \n"; cb.sendNotice(msg, username, '#FFFFFF', '#34113F', 'bold'); } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; msg += "We are playing Roll the Dice - by mynamesnotbrian \n"; msg += "Each roll reveals a prize. There are " + prizes.length + " possible prizes.\n"; if (cb.settings.remove_winning_prize == 'Yes') { msg += "Each prize won will be removed from the list.\n"; } else { msg += "Each prize won will stay on the list.\n"; } msg += "Tip " + price + " " + langTokens + " to roll the dice. \n"; msg += "Type \"!prizes\" to see the list of prizes \n"; msg += "Type \"!prizes all\" to send the list to all viewers if you're a mod or the broadcaster \n"; msg += "Type \"!winners\" to see a list of the last 20 winners "; cb.sendNotice(msg, username, '#FFFFFF', '#34113F', 'bold'); } function init() { setPrizes(); advertise(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.