Bots Home
|
Create an App
DiceRollTest
Author:
alicetryx
Description
Source Code
Launch Bot
Current Users
Created by:
Alicetryx
/** * Roll the Dice * Version: 1.1.1 * Author: jeffreyvels1994 * Modified: Alice Tryx * Date: 2018-05-28 */ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, label: 'How much do you want to charge per roll?', defaultValue: 25 }, { name: 'minimum_rolls', type: 'choice', label: 'What is the minimum number of rolls before the rare dice can appear? (Keep this a secret!)', choice1: 5, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 35, choice8: 40, choice9: 45, choice10: 50, choice11: 55, choice12: 60, defaultValue: 20 }, { name: 'notice_wait_time', type: 'choice', label: 'In minutes, how often should the app advertise itself?', choice1: 5, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 45, choice8: 60, defaultValue: 15 }, { name: 'prize_1', type: 'str', label: 'Prize for rolling 1', defaultValue: 'dance' }, { name: 'prize_2', type: 'str', label: 'Prize for rolling 2', 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', 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', defaultValue: 'spank pussy' }, { name: 'prize_13', type: 'str', label: 'Prize for rolling 13 (RARE if using traditional dice)', defaultValue: 'finger pussy 10 mins' }, ]; var price = cb.settings.tokens; var langTokens = (price > 1) ? 'tokens' : 'token'; var numberOfSides = ('Traditional' == 'Traditional') ? 6 : 10; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var prizes = []; var minimumRollsToGetRareDice = parseInt(cb.settings.minimum_rolls); var maxOutcome = ('Traditional' == 'Traditional') ? 13 : 21; var rareChance = 10; // percent chance of rolling a RARE (minimum rolls must also be met) cb.onTip(function (tip) { var maxTip = price; 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 { var textColor = '#de7158'; var bgColor = '#E6E6FA'; } }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(function (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(/list/i) && ((msg['is_mod'] == true) || (msg['user'] == cb.room_slug))) { showPrizes(); } else { showPrizes(msg['user']); } } return msg; }); function roll(username) { rollCounter++; var die1 = Math.floor(Math.random() * numberOfSides) + 1; var die2 = Math.floor(Math.random() * numberOfSides) + 1; // see if there's a chance we can roll a rare die if (rollCounter > minimumRollsToGetRareDice) { if (Math.random() <= 1 / (rareChance / 100)) { die1 = 7; } } 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 prizeIndex = prizes.indexOf(prize); if (prizeIndex >= 0) { if (cb.settings.remove_winning_prize == 'Yes') prizes.splice(prizeIndex, 1); } else { prize = 'A Thank You!'; } var msg = username + " rolled a " + total + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; var textColor = '#de7158'; var bgColor = '#E6E6FA'; if (winner) textColor = '#de7158'; if (total == maxOutcome) { bgColor = '#E6E6FA'; textColor = '#de7158'; } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); lastPrizeWon = prize; winners.push("Roll #" + rollCounter + " (" + total + "): " + username + " - " + prize); } 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) { if (prizes.length) { var rareText = ''; var msg = "Dice Tryx - Prize List"; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (RARE)"; if (prizes.indexOf(cb.settings['prize_' + i] + rareText) >= 0) msg += "\nRoll " + i + " - " + cb.settings['prize_' + i] + rareText; } } else { var msg = "SORRY! There are no prizes left in the list, but thank you for the tip. :thumbsup"; } cb.sendNotice(msg, username, '#E6E6FA', '#de7158', 'bold'); } function showPrizesWon(username) { var msg = "Dice Tryx - Last 20 Rolls"; 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, '#E6E6FA', '#de7158', 'bold'); } else { var recentWinners = winners.slice(-20); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#E6E6FA', '#de7158', '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. Each roll reveals a prize. There are " + prizes.length + "prizes availiable.\n"; msg += "Tip a minimum of" + price + " " + langTokens + " to roll the dice. \n"; msg += "Type \"/prizes\" to see the list of prizes \n"; msg += "Type \"/winners\" to see a list of the last 20 wins"; cb.sendNotice(msg, username, '#E6E6FA', '#de7158', 'bold'); } function init() { setPrizes(); advertise(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.