Bots Home
|
Create an App
test-drg
Author:
greyq
Description
Source Code
Launch Bot
Current Users
Created by:
Greyq
/* * Title: FREE and Tokens Dice Roll Game * Author: Naturist_be * Version: 1.4 (04/08/13) * Summary: Dice roll Game. Roll a dice for tokens or for free (Broadcaster roll it) * * Description: Options: - Set the number of Dice to roll (1 to 3) - Set if you want to play for tokens or not (you still can roll the dice for free) - Set the tip rate for rolling Dice - Set the delay for displaying commands (4 to 10 minutes) - Set if mods can roll the Dice too- Set the prizes for each dice number: 1 dice: prizes 1 to 6 2 Dice: prizes 7 to 12 3 Dice: prizes 13 to 18 It's better to fill all the prizes so you can change the number of Dice during game. List of commands: !r username = roll the dice for username !d1 XX to play with one dice (XX = new tokens rate, optionnal) !d2 XX to play with two Dice (XX = new tokens rate, optionnal) !d3 XX to play with three Dice (XX = new tokens rate, optionnal) !z to reset rolls list !s to pause/resume the game !p to see the prizes !w to display the list of rolls !h to display the commands Have fun! Naturist_be * */ var pause = 'No'; var last_player = null; var last_winner = null; var prize_won = ""; var player = ""; var score = 0; var scores = ""; var addon = ""; var lines = '━━━━━━━━━━━━━━━━━━━━'; Winners = new Array(); cb.settings_choices = [{ name: 'nbDice', label: "Number of Dice to play", type: 'choice', choice1: '1', choice2: '2', choice3: '3', default: '1' }, { name: 'notfree', label: "Play for Tokens? (if Yes you still can roll it for free)", type: 'choice', choice1: 'Yes', choice2: 'No', default: 'Yes' }, { name: 'tokens', type: 'int', minValue: 1, default: 50, label: 'Tokens to roll the dice' }, { name: 'ADVERT_TIME', type: 'int', minValue: 4, maxValue: 10, defaultValue: 5, label: 'Delay for commands display (4 to 10 min) ' }, { name: 'mod_as_king', label: "Allow mods to roll the Dice?", type: 'choice', choice1: 'Yes', choice2: 'No', default: 'Yes' }, { name: 'prize1', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 1', default: 'Private dance (you choose music)' }, { name: 'prize2', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 2', default: 'Dressed picture just for you' }, { name: 'prize3', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 3', default: 'Blank, sorry :(' }, { name: 'prize4', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 4', default: 'Your name on my body for one public show' }, { name: 'prize5', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 5', default: '10 min private show, you choose what i do' }, { name: 'prize6', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 6', default: 'Blank, sorry :(' }, { name: 'prize7', type: 'str', minLength: 1, maxLength: 255, label: 'If u selected 2 Dice : Prize for 7', required: false }, { name: 'prize8', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 8', required: false }, { name: 'prize9', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 9', required: false }, { name: 'prize10', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 10', required: false }, { name: 'prize11', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 11', required: false }, { name: 'prize12', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 12', required: false }, { name: 'prize13', type: 'str', minLength: 1, maxLength: 255, label: 'If u selected 3 Dice : Prize for 13', required: false }, { name: 'prize14', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 14', required: false }, { name: 'prize15', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 15', required: false }, { name: 'prize16', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 16', required: false }, { name: 'prize17', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 17', required: false }, { name: 'prize18', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for 18', required: false }, { name: 'act_triple', label: "Enable prizes for triple same Dice?", type: 'choice', choice1: 'Yes', choice2: 'No', default: 'Yes' }, { name: 'triple1', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 1', required: false }, { name: 'triple2', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 2', required: false }, { name: 'triple3', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 3', required: false }, { name: 'triple4', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 4', required: false }, { name: 'triple5', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 5', required: false }, { name: 'triple6', type: 'str', minLength: 1, maxLength: 255, label: 'Prize for triple 6', required: false } ]; function rollDice(player) { last_player = player; var triple = 0; switch (cb.settings.nbDice) { case '1': var dice1 = Math.floor(Math.random() * 6 + 1); score = dice1; break; case '2': var dice1 = Math.floor(Math.random() * 6 + 1); var dice2 = Math.floor(Math.random() * 6 + 1); score = dice1 + dice2; break; case '3': var dice1 = Math.floor(Math.random() * 6 + 1); var dice2 = Math.floor(Math.random() * 6 + 1); var dice3 = Math.floor(Math.random() * 6 + 1); score = dice1 + dice2 + dice3; break; } drawDice(dice1, dice2, dice3); if (cb.settings.nbDice == '3' && cb.settings.act_triple == 'Yes') { if (dice1 == dice2 && dice2 == dice3) { prize_won = cb.settings["triple" + dice1]; triple = 1; } else { prize_won = cb.settings["prize" + score]; } } else { prize_won = cb.settings["prize" + score]; } stateChange(player, prize_won, triple); } function stateChange(player, prize_won, triple) { setTimeout(function() { if (player) { if (triple == 0) cb.chatNotice(' ★ ' + player + ', you win: ' + prize_won + ' ★', '', '#666699', '#FFFFFF'); else cb.chatNotice(' ★ TRIPLE WIN!! ' + player + ', you win: ' + prize_won + ' ★', '', '#B00000', '#FFFFFF', 'bold'); last_winner = player; updateUser(player, score); cb.drawPanel(); } }, 3500); } cb.onMessage(function(msg) { if (msg['user'] == cb.room_slug && msg['m'].indexOf('!roll') === 0) { msg['X-Spam'] = true; cb.chatNotice('New command!! use !r username', msg['user'], '', '', 'bold'); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!r ') === 0) { msg['X-Spam'] = true; player = msg['m'].replace("!r ", ""); cb.chatNotice('Rolling Dice for ' + player, '', '', '', 'bold'); rollDice(player); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!s') === 0) { msg['X-Spam'] = true; if (pause == 'Yes') { pause = 'No'; cb.chatNotice('Game is resumed! You can play again!', '', '', '', 'bold'); } else { pause = 'Yes'; cb.chatNotice('Game is paused! Wait for tipping!', '', '', '', 'bold'); cb.chatNotice('Type !s again to resume game.', cb.room_slug, '', '', 'bold'); } } if (msg['m'].indexOf('!p') === 0) { drawprizes(msg['user']); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!z') === 0) { msg['X-Spam'] = true; Winners = new Array(); cb.chatNotice('The winners list has been reset.', '', '', '', 'bold'); } if (msg['m'].indexOf('!h') === 0) { help(msg['user']); } if (msg['m'].indexOf('!w') === 0) { drawWinners(msg['user']); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!d1') === 0) { msg['X-Spam'] = true; var tks = msg['m'].replace("!d1 ", ""); if (tks > 0) { cb.settings.tokens = tks; addon = 'Tip ' + tks + ' tokens to roll Dice.'; } cb.chatNotice(' Now, we are playing with 1 dice ! ' + addon, '', '#B00000', '#FFFFFF', 'bold'); cb.settings.nbDice = '1'; updateSubject(); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!d2') === 0) { msg['X-Spam'] = true; var tks = msg['m'].replace("!d2 ", ""); if (tks > 0) { cb.settings.tokens = tks; addon = 'New token rate for playing: ' + tks + ' tokens.'; } cb.chatNotice(' Now, we are playing with 2 Dice ! ' + addon, '', '#B00000', '#FFFFFF', 'bold'); cb.settings.nbDice = '2'; updateSubject(); } if (msg['is_mod'] == true && cb.settings.mod_as_king === "Yes" && msg['m'].indexOf("!r") === 0) { msg['X-Spam'] = true; player = msg['m'].replace("!r ", ""); cb.chatNotice('Rolling Dice for ' + player, '', '', '', 'bold'); rollDice(player); } if (msg['user'] == cb.room_slug && msg['m'].indexOf('!d3') === 0) { msg['X-Spam'] = true; var tks = msg['m'].replace("!d3 ", ""); if (tks > 0) { cb.settings.tokens = tks; addon = 'New token rate for playing: ' + tks + ' tokens.'; } cb.chatNotice(' Now, we are playing with 3 Dice ! ' + addon, '', '#B00000', '#FFFFFF', 'bold'); cb.settings.nbDice = '3'; updateSubject(); } return msg; }); function drawprizes(user) { var out = ''; var j = cb.settings.nbDice; for (i = j; i < cb.settings.nbDice * 6 + 1; i++) { out += i + ': ' + cb.settings["prize" + i] + '\n'; } out += lines; cb.chatNotice(' Prizes: ', user, '#B00000', '#FFFFFF', 'bold'); cb.chatNotice(out, user); } cb.onTip(function(tip) { player = tip.from_user; var amount = tip.amount; if (amount == cb.settings.tokens) { if (pause == 'Yes') { cb.chatNotice('Thanks for the tips! Game is paused. Broadcaster will roll Dice for you when resumed.', '', '', '', 'bold'); } else { if (cb.settings.notfree == 'Yes') { rollDice(player); } } } cb.drawPanel(); }); cb.onDrawPanel(function(user) { if (last_winner == null) last_winner = "What will you win?" + '★ '; if (prize_won == "") var tit3 = ""; else tit3 = "Win: "; if (score == 0) scores = ''; else scores = ' | ' + score + ' points ★'; return { 'template': '3_rows_11_21_31', 'row1_value': 'Dice ROLL GAME! by Naturist_be', 'row2_value': '★ ' + last_winner + scores, 'row3_value': tit3 + prize_won, } }); function updateUser(user, score) { Winners.push({ user: user, pz: cb.settings["prize" + score] }); } function drawWinners(user) { var out = ""; for (var i = 0; i < Winners.length; i++) { out += '★ ' + Winners[i].user + ' won ' + Winners[i].pz + '\n'; } out += lines; cb.chatNotice(' Winners: ', user, '#B00000', '#FFFFFF', 'bold'); cb.chatNotice(out, user); } function init() { updateSubject(); cb.drawPanel(); drawprizes(); advert(); } function advert() { if (pause == 'Yes') { cb.chatNotice('Game is paused. Please wait before tipping. Broadcaster will type !s to resume game.', '', '', '', 'bold'); } else { if (cb.settings.notfree == 'Yes') cb.chatNotice('Tip ' + cb.settings.tokens + ' tokens to roll the ' + cb.settings.nbDice + ' Dice!! Type !p to see the prizes! Type !w to see the played rolls. Type !h to display commands.'); else cb.chatNotice('Play with Broadcaster to roll the ' + cb.settings.nbDice + ' Dice and win a prize! Type !p to see the prizes! Type !w to see the played rolls. Type !h to display commands.'); cb.chatNotice('Type !r username to roll the Dice\nType !z to reset the winners list.\nType !d1 XX (or !d2 or !d3) to change number of Dice\n(XX \= new TK rate, optional): !d2 25.\nType !s to pause or resume game.', cb.room_slug); } cb.setTimeout(advert, (cb.settings.ADVERT_TIME * 60000)); } function help(user) { if (pause == 'Yes') cb.chatNotice('Game is paused. Please wait before tipping. Broadcaster type !s to resume game.', '', '', '', 'bold'); if (cb.settings.notfree == 'Yes') cb.chatNotice('Tip ' + cb.settings.tokens + ' tokens to roll the ' + cb.settings.nbDice + ' Dice!! Type !p to see the prizes! Type !w to see the played rolls. Type !h to display commands.', user); else cb.chatNotice('Play with Broadcaster to roll the ' + cb.settings.nbDice + ' Dice and win a prize! Type !p to see the prizes! Type !w to see the played rolls. Type !h to display commands.', user); if (user == cb.room_slug) cb.chatNotice('Type !r username to roll the Dice\nType !z to reset the winners list.\nType !d1 XX (or !d2 or !d3) to change number of Dice\n(XX \= new TK rate, optional): !d2 25.\nType !s to pause or resume game.', user); } function updateSubject() { if (cb.settings.notfree == 'Yes') var newSubject = 'Dice roll game! Tip ' + cb.settings.tokens + ' tokens to roll the ' + cb.settings.nbDice + ' Dice!! Type !p to see the prizes! Type !w to see the played rolls.\nType !h to display commands.'; else var newSubject = 'Dice roll game (' + cb.settings.nbDice + ' Dice)!! Type !p to see the prizes! Type !w to see the played rolls.\nType !h to display commands.'; cb.log("Changing subject to: " + newSubject); cb.changeRoomSubject(newSubject); } drawings = { 1: ":tdr1", 2: ":tdr2", 3: ":tdr3", 4: ":tdr4", 5: ":tdr5", 6: ":tdr6" }; function drawDice(dice1, dice2, dice3) { switch (cb.settings.nbDice) { case '1': cb.chatNotice(drawings[dice1]); break; case '2': cb.chatNotice(drawings[dice1] + ' ' + drawings[dice2]); break; case '3': cb.chatNotice(drawings[dice1] + ' ' + drawings[dice2] + ' ' + drawings[dice3]); break; } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.