Bots Home
|
Create an App
Sexy Dices
Author:
antoniopalotes
Description
Source Code
Launch Bot
Current Users
Created by:
Antoniopalotes
/** * App: Sexy Dices * Version: 0.1.2 * Author: Trouner * Date: 2016-02-07 */ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'How much do you want to charge per roll?', defaultValue: 25 }, { 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: 'player1', type: 'str', label: 'Player 1 name'}, {name: 'player2', type: 'str', label: 'Player 2 name'}, {name: 'side_d1_1', type: 'str', label: 'Action 1'}, {name: 'side_d1_2', type: 'str', label: 'Action 2'}, {name: 'side_d1_3', type: 'str', label: 'Action 3'}, {name: 'side_d1_4', type: 'str', label: 'Action 4'}, {name: 'side_d1_5', type: 'str', label: 'Action 5'}, {name: 'side_d1_6', type: 'str', label: 'Action 6'}, {name: 'side_d2_1', type: 'str', label: 'Part of the Body 1'}, {name: 'side_d2_2', type: 'str', label: 'Part of the Body 2'}, {name: 'side_d2_3', type: 'str', label: 'Part of the Body 3'}, {name: 'side_d2_4', type: 'str', label: 'Part of the Body 4'}, {name: 'side_d2_5', type: 'str', label: 'Part of the Body 5'}, {name: 'side_d2_6', type: 'str', label: 'Part of the Body 6'}, ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var numberOfSides = 6; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var maxOutcome = 6; 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); var player = Math.floor(Math.random() * 2+1); var action = cb.settings['side_d1_' + die1]; var body = cb.settings['side_d2_' + die2]; var playername = cb.settings['player'+player]; var msg = username + ' rolls the Sexy Dices \n' msg += 'Now '+ playername + ' has to '+ action + ' ' + body; var textColor = '#000000'; var bgColor = '#D9FAD7'; cb.sendNotice(msg, '', bgColor, textColor, 'bold'); winners.push("Roll #" + rollCounter + " " + username); cb.drawPanel(); } function showPrizes(username) { var msg = "##### POSSIBLE PRIZES #####"; for (var i = 1; i <= maxOutcome; i++) { msg += "\n Actions " + i + " - " + cb.settings['side_d1_' + i]; } for (var i = 1; i <= maxOutcome; i++) { msg += "\n Part of the body " + i + " - " + cb.settings['side_d2_' + i]; } cb.sendNotice(msg, username, '#DBFBFF', '#008596', '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 dice 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, '#FFF0DE', '#8A4900', '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 Sexy Dices. \n"; } else { msg += "Sexy Dices by Trouner \n"; } msg += "Each roll match an action and body part \n"; msg += "Tip " + cb.settings.tokens + " " + 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, '', '#15A6B0', 'bold'); } function init() { advertise(); cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' tokens to roll the sexy dices!'); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.