Apps Home
|
Create an App
Roll the Bones
Author:
darkcultisttest
Description
Source Code
Launch App
Current Users
Created by:
Darkcultisttest
/** * App: Roll the Bones * Version: 1.0.0 * Author: Darkcultist * Date: * Based off and thanks to: * App: Roll The Dice * Version: 2.0.5 * Author: zingknaat * Date: 2014-12-22 */ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, 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 bones can appear? (Keep this a secret!)', choice1: 10, choice2: 15, choice3: 20, choice4: 25, choice5: 30, choice6: 35, choice7: 40, choice8: 45, choice9: 50, defaultValue: 10 }, { 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: 10 }, {name: 'prize_2', type: 'str', default:'Pussy flash', label: 'Prize for rolling 2 (3% chance)'}, {name: 'prize_3', type: 'str', default:'Tits flash', label: 'Prize for rolling 3 (6% chance)'}, {name: 'prize_4', type: 'str', default:'Tits flash', label: 'Prize for rolling 4 (8% chance)'}, {name: 'prize_5', type: 'str', default:'Twerk', label: 'Prize for rolling 5 (11% chance)'}, {name: 'prize_6', type: 'str', default:'Twerk', label: 'Prize for rolling 6 (14% chance)'}, {name: 'prize_7', type: 'str', default:'Twerk', label: 'Prize for rolling 7 (17% chance)'}, {name: 'prize_8', type: 'str', default:'Spank', label: 'Prize for rolling 8 (14% chance)'}, {name: 'prize_9', type: 'str', default:'Spank', label: 'Prize for rolling 9 (11% chance)'}, {name: 'prize_10', type: 'str', default:'Tits flash', label: 'Prize for rolling 10 (8% chance)'}, {name: 'prize_11', type: 'str', default:'Tits flash', label: 'Prize for rolling 11 (6% chance)'}, {name: 'prize_12', type: 'str', default:'Pussy flash', label: 'Prize for rolling 12 (3% chance)'}, { name: 'prize_13', type: 'str', default: 'A smile', label: 'Prize for rolling 13 (RAREST)' } ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var numberOfSides = 6; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var prizes = []; var minimumRollsToGetRareDice = parseInt(cb.settings.minimum_rolls); var maxOutcome = 13; cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); if (parseInt(tip['amount']) >= cb.settings.tokens) { var numberOfRolls = Math.floor(parseInt(tip['amount']) / cb.settings.tokens); for (var i = 0; i < numberOfRolls; i++) { roll(tip['from_user']); lastRoller = tip['from_user']; } } else { 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(/\/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++; var die1 = Math.floor(Math.random() * numberOfSides+1); var die2 = Math.floor(Math.random() * numberOfSides+1); // convoluted logic to appease the dev gods on cb var randomNum = Math.ceil(Math.random() * (100 - minimumRollsToGetRareDice) + minimumRollsToGetRareDice); if (rollCounter == randomNum) { if ((die1 == 1) && (die2 != 1)) die1 = 7; if ((die2 == 1) && (die1 != 1)) die2 = 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); var msg = "What did the future see for you?\n"; msg += username + " rolled a " + total + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; var textColor = '#000000'; var bgColor = '#f5ccff'; if (winner) textColor = '#7000a0'; 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() { var rareText = ''; for (var i = 2; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (VERY RARE)"; prizes.push(cb.settings['prize_' + i] + rareText); } } function showPrizes(username) { if (prizes.length) { var rareText = ''; var msg = "##### POSSIBLE FUTURES #####"; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (VERY 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, '#f5ccff', '##8100a0', 'bold'); } function showPrizesWon(username) { var msg = "##### LAST 40 WINNERS #####"; msg += "\nList sorted in chronological order"; if (winners.length == 0) { cb.sendNotice('No one has won anything yet. Roll the bones to win a prize!', username, '', '', 'bold'); } else { var recentWinners = winners.slice(-40); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#b3ffb3', '#006600', 'bold'); } } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; if (username != undefined) { msg += "Welcome, " + username + "! We are playing Roll The Bones. \n"; } else { msg += "Roll The Bones by Darkcultist\n"; } msg += "Each roll reveals a future. There are " + prizes.length + " possible futures. \n"; msg += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the bones. \n"; msg += "Type \"/prizes\" to see the list of futures. \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."; msg += "Will you roll the bones and see what is in your future?"; cb.sendNotice(msg, username, '', '#7000a0', 'bold'); } function init() { setPrizes(); advertise(); cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' tokens to roll the bones if you dare!'); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.