Bots Home
|
Create an App
MonkeyDice fir Mae
Author:
chatturmate
Description
Source Code
Launch Bot
Current Users
Created by:
Chatturmate
/** * Monkeydice For Mae By: Chatturmate * Version: 1.2 * Author: chatturmate * Date: 2019-02-22 * Additional credit to: kingchris_, zingknaat, */ cb.settings_choices = [ {name: 'settings_section_label', type:'choice', label:'################# Basic Settings #################', required: false}, { name: 'tokens', type: 'int', minValue: 1, label: 'How much do you want to charge per roll?', defaultValue: 21 }, { 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: 'change_room_subject', type: 'choice', label: 'Change room subject when using this bot?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, {name: 'multirolls_subsection_label', type:'choice', label:'######### Multi Rolls #########', required: false}, { name: 'max_rolls_at_once', type: 'int', minValue: 1, label: 'Maximum number of rolls that can be tipped for in a single tip.', defaultValue: 1 }, { name: 'perfect_multi', type: 'choice', label: 'Require exact multiples of tip amount to roll the die? (if you charge 33 per roll, 66 will roll 2x but 69 won\'t)', choice1: 'yes', choice2: 'no', defaultValue: 'yes' }, {name: 'prizeodds_subsection_label', type:'choice', label:'######### Prize Odds #########', required: false}, { name: 'equal_odds', type: 'choice', label: 'Should all non-rare prizes have equal odds of being rolled? ("no" simulates rolling a pair of dice and "yes" rolls a single die)', choice1: 'yes', choice2: 'no', defaultValue: 'no' }, { name: 'last_prize_rare', type: 'choice', label: 'Should the last prize in the list be RARE? (RARE prizes will only show up after a minimum number of rolls have been rolled and should be significantly less likely than other prizes)', choice1: 'yes', choice2: 'no', defaultValue: 'yes' }, { name: 'minimum_rolls', type: 'int', minValue: 0, label: 'Minimum number of rolls that must be rolled before RARE prizes can be won.', defaultValue: 20 }, { name: 'rare_chance_mult', type: 'choice', //[TODO] Remove in favor of multiplier with precalced odds 1/2, 1, 2 etc 1x should be 1/2 odds for equal die? label: 'Multiplier for the chance of rolling rare prizes. Increase if rare prizes are too uncommon, Decrease if they\'re too common', choice1: '1/2x', choice2: '1x', choice3: '1.5x', choice4: '2x', choice5: '4x', choice6: '8x', defaultValue: '1x' }, {name: 'prize_section_label', type:'choice', label:'#################### Prizes ####################', required: false}, {name: 'prize_1', type: 'str', label: '(List possible prizes from most common to least.) Prize 1', defaultValue: ' Blow kisses'}, {name: 'prize_2', type: 'str', label: '(if equal odds option is \'yes\' order doesn\'t matter.) Prize 2', defaultValue: 'Tongue out'}, {name: 'prize_3', type: 'str', label: '(Fill prize spots in order from top to bottom.) Prize 3', defaultValue: ' Bra flash', required: false}, {name: 'prize_4', type: 'str', label: '(Leave the remaining fields blank to not use them.) Prize 4', defaultValue: 'Panty flash', required: false}, {name: 'prize_5', type: 'str', label: 'Prize 5', defaultValue: 'show feet/soles for 30 seconds', required: false}, {name: 'prize_6', type: 'str', label: 'Prize 6', defaultValue: '', required: false}, {name: 'prize_7', type: 'str', label: 'Prize 7', defaultValue: '', required: false}, {name: 'prize_8', type: 'str', label: 'Prize 8', defaultValue: 'Stand and turn', required: false}, {name: 'prize_9', type: 'str', label: 'Prize 9', defaultValue: '', required: false}, {name: 'prize_10', type: 'str', label: 'Prize 10', defaultValue: 'Legs', required: false}, {name: 'prize_11', type: 'str', label: 'Prize 11', defaultValue: '', required: false}, {name: 'prize_12', type: 'str', label: 'Prize 12', defaultValue: 'Say your name w/volume', required: false}, {name: 'prize_13', type: 'str', label: 'Prize 13', defaultValue: 'Show my lotus tattoo', required: false}, {name: 'prize_14', type: 'str', label: 'Prize 14', defaultValue: 'Pants off and turn around', required: false}, {name: 'prize_15', type: 'str', label: 'Prize 15', defaultValue: 'Sing you a song', required: false}, {name: 'prize_16', type: 'str', label: 'Prize 16', defaultValue: 'Wildcard! – Pick any prize on the public tip menu', required: false}, {name: 'prize_17', type: 'str', label: 'Prize 17', defaultValue: '', required: false}, {name: 'prize_18', type: 'str', label: 'Prize 18', defaultValue: '', required: false}, {name: 'prize_19', type: 'str', label: 'Prize 19', defaultValue: '', required: false}, {name: 'prize_20', type: 'str', label: 'Prize 20', defaultValue: '', required: false}, {name: 'prize_21', type: 'str', label: 'Prize 21', defaultValue: '', required: false}, {name: 'prize_22', type: 'str', label: 'Prize 22', defaultValue: '', required: false}, {name: 'prize_23', type: 'str', label: 'Prize 23', defaultValue: '', required: false}, {name: 'prize_24', type: 'str', label: 'Prize 24', defaultValue: '', required: false}, {name: 'prize_25', type: 'str', label: 'Prize 25', defaultValue: '', required: false}, {name: 'miscellaneous_section_label', type:'choice', label:'########## Advanced Settings (Safe to Ignore) ##########', required: false}, {name: 'cmd_prefix', type: 'str', minLength: 1, maxLength: 1, label: 'Prefix for bot commands. (Might want to change if you have other bots using the same commands.)', defaultValue: '/'}, {name: 'die_prefix', type: 'str', label: 'Prefix for die gifs ("prefix#" only change if you know what you\'re doing)', defaultValue: ':chaturmatedice_'} ]; var maxPrizes = 25; var rollprice = parseInt(cb.settings.tokens); var prizeCount = 13; var equalOdds = cb.settings.equal_odds == 'yes'; var numberOfDie = equalOdds?1:2; var die = [ { die: 1, label: "One", sides: Math.floor((equalOdds? ((cb.settings.last_prize_rare == 'yes')?prizeCount-1:prizeCount) : ((cb.settings.last_prize_rare == 'yes')?prizeCount:prizeCount+1)/2)) }, { die: 2, label: "Two", sides: Math.ceil((equalOdds? ((cb.settings.last_prize_rare == 'yes')?prizeCount-1:prizeCount) : ((cb.settings.last_prize_rare == 'yes')?prizeCount:prizeCount+1)/2)) } ]; var perfectMults = cb.settings.perfect_multi == 'yes'; var maxRollsPerTip = parseInt(cb.settings.max_rolls_at_once); var usingRares = cb.settings.last_prize_rare == 'yes'; var minRollsForRare = parseInt(cb.settings.minimum_rolls); var rareChance = (cb.settings.rare_chance_mult == '1x')?1:((cb.settings.rare_chance_mult == '1/2x')?0.5:((cb.settings.rare_chance_mult == '1.5x')?1.5:(cb.settings.rare_chance_mult == '2x')?2:(cb.settings.rare_chance_mult == '4x')?4:8)); var changeSubject = cb.settings.change_room_subject == 'Yes'; var cmdPrefix = cb.settings.cmd_prefix; var diePrefix = cb.settings.die_prefix; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; var prizes = []; cb.onTip(function(tip) { var tipAmount = parseInt(tip.amount); if(tipAmount >= rollprice && (!perfectMults || ((tipAmount <= (maxRollsPerTip*rollprice)) && (tipAmount % rollprice === 0)))) { var rolls = Math.floor(tipAmount/rollprice); for(var i = 0; i < rolls; i++) { roll(tip.from_user); lastRoller = tip.from_user; } } else { //not rolling the dice var textColor = '#000000'; var bgColor = '#D9FAD7'; 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 + ' ' + ((tipCounter > 1)?'tokens':'token') + ' received / rolled ' + rollCounter + ' time(s)' }; }); cb.onEnter(function (user) { adBlurb(user.user); }); cb.onMessage(function(msg) { var message = msg.m.split(" "); if (message[0].charAt(0) == cmdPrefix) { // Don't print command messages to chat. msg["X-Spam"] = true; msg.background = "#EEEEEE"; switch (message[0]) { case cmdPrefix+'help': adBlurb(msg.user); break; case cmdPrefix+'winners': if(message[1] == 'all' && ((msg.is_mod === true) || (msg.user == cb.room_slug)))winnersBlurb(); else winnersBlurb(msg.user); break; case cmdPrefix+'prizes': if(message[1] == 'all')prizesBlurb(); else prizesBlurb(msg.user); break; default: msg["X-Spam"] = false; msg.background = "#D9FAD7"; break; } } }); function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } function roll(username) { var prize = 'A Thank You!'; rollCounter++; var dieResults = []; var total = -numberOfDie; for(var i = 0; i < numberOfDie; i++) { dieResults[i] = getRandomIntInclusive(1, die[i].sides); total += dieResults[i]; } if(usingRares && (rollCounter > minRollsForRare) && (getRandomIntInclusive(0, 100) <= (rareChance/100))) { //RARE PRIZE WON!!! if(numberOfDie == 1) { dieResults[0] = die[0].sides+1; total = dieResults[0] - numberOfDie; } else { if(getRandomIntInclusive(0,1) === 0) { dieResults[0] = die[0].sides+1; dieResults[1] = die[1].sides; total = dieResults[0] + dieResults[1] - numberOfDie; } else { dieResults[0] = die[0].sides; dieResults[1] = die[1].sides+1; total = dieResults[0] + dieResults[1] - numberOfDie; } } } var winner = false; if (total >= 0 && total < prizeCount) { winner = true; prize = prizes[total]; } else { winner = false; } var msg = ((numberOfDie == 1)?diePrefix + dieResults[0]: diePrefix + dieResults[0] + " " + diePrefix + dieResults[1]) + "\n"; msg += username + " rolled " + (total+numberOfDie) + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; var textColor = '#000000'; var bgColor = '#D9FAD7'; if (winner) textColor = '#067D00'; if (total == prizeCount-1) { bgColor = '#FFDBF3'; textColor = '#A805A6'; } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); lastPrizeWon = prize; winners.push("Roll #" + rollCounter + " (" + (total+numberOfDie) + "): " + username + " - " + prize); if(winners.length > 20)winners = winners.slice(-21); cb.drawPanel(); } function initPrizes() { for (var i = 1; i <= maxPrizes; i++) { if(cb.settings['prize_' + i] === '' || cb.settings['prize_' + i] == '.' || cb.settings['prize_' + i] == ' ')continue; if(i%2 == 1)prizes.push(cb.settings['prize_' + i]); else prizes.unshift(cb.settings['prize_' + i]); } prizeCount = prizes.length; if(usingRares) { if(prizeCount%2 === 0)prizes.push(prizes.shift()); prizes[prizes.length-1] += " (RARE)"; } die[0].sides = Math.floor(((numberOfDie == 1)? ((cb.settings.last_prize_rare == 'yes')?prizeCount-1:prizeCount) : ((cb.settings.last_prize_rare == 'yes')?prizeCount:prizeCount+1)/2)); die[1].sides = Math.ceil(((numberOfDie == 1)? ((cb.settings.last_prize_rare == 'yes')?prizeCount-1:prizeCount) : ((cb.settings.last_prize_rare == 'yes')?prizeCount:prizeCount+1)/2)); rareChance *= equalOdds?100/prizeCount:100/((die[0].sides+1)*die[1].sides); cb.log(rareChance); } function prizesBlurb(username) { var msg = "No Prizes!! D:"; if (prizes.length) { msg = "##### POSSIBLE PRIZES #####"; for (var i = 0; i < prizeCount; i++) { msg += "\nRoll " + (i+numberOfDie) + " - " + prizes[i]; } } cb.sendNotice(msg, username, '#DBFBFF', '#008596', 'bold'); } function winnersBlurb(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, '', '', 'bold'); } else { var recentWinners = winners.slice(-21); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#FFF0DE', '#8A4900', 'bold'); } } function adBlurb(username) { var msg = ""; msg += "A Better Dice Roller for Mae by chatturmate.\n"; msg += "Tip " + rollprice + " " + ((rollprice>1)?'tokens':'token') + " to roll the dice.\n"; msg += "There are " + prizes.length + " possible prizes.\n "; msg += "Every roll is a winner.\n"; if(maxRollsPerTip>1) { msg += "You can roll up to " + maxRollsPerTip + " times with a single tip (" + (maxRollsPerTip*rollprice) + " tokens).\n"; if(perfectMults && rollprice>1) msg += "You must tip exact amounts to roll the dice.\n(1 roll for " + rollprice + " tokens, 2 for " + rollprice*2 + " tokens, but " + Math.ceil(rollprice*1.5) + " tokens won't roll the dice).\n"; } msg += "Type \""+cmdPrefix+"prizes\" to see the list of prizes. \n"; msg += "Type \""+cmdPrefix+"prizes all\" to send the list to all viewers if you're a mod or the broadcaster.\n"; msg += "Type \""+cmdPrefix+"winners\" to see a list of the last 20 winners."; cb.sendNotice(msg, username, '', '#15A6B0', 'bold'); } function advertise() { adBlurb(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function init() { initPrizes(); advertise(); if (changeSubject) { cb.changeRoomSubject('Tip ' + rollprice + ' ' + ((rollprice>1)?'tokens':'token') + ' to roll the dice and win a prize!'); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.