Apps Home
|
Create an App
777
Author:
papapa
Description
Source Code
Launch App
Current Users
Created by:
Papapa
cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'How much do you want to charge per roll? (Un cantidad pequena)', defaultValue: 5 }, { name: 'subject', label: 'Room Subject (tags)', type: 'str', required: false }, { name: 'remove_winning_prize', type: 'choice', label: 'Remove prize from list after each roll?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'minimum_rolls', type: 'choice', label: 'What is the minimum number of rolls before the rare dice 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_3', type: 'str', label: 'Prize fresita (del premio mas pequeño)'}, {name: 'prize_6', type: 'str', label: 'Prize manzanita'}, {name: 'prize_9', type: 'str', label: 'Prize naranjita'}, {name: 'prize_12', type: 'str', label: 'Prize sandia'}, {name: 'prize_15', type: 'str', label: 'Prize campanita '}, {name: 'prize_18', type: 'str', label: 'Prize bar (al premio mas grande)'}, { name: 'prize_21', type: 'str', default: 'Cum Show', label: 'Prize for rolling 13 (RARE if using traditional dice)' }, ]; 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 = 21; var dieImagePrefix = ':777die'; var die1 = 0; var die2 = 0; var die3 = 0; var a = 0; var b = 0; cb.tipOptions(function(user) { if(a==7 || a==77){ return { options:[{label: '1 and 2'}, {label: '2 and 3'}, {label: '1 and 3'}], label:"Select what figures you want keep"}; } }); cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); a = parseInt(tip['amount']); // if(cb.tipOptions()== '1 and 2')b=1; // if(cb.tipOptions()== '1 and 2')b=2; // if(cb.tipOptions()== '1 and 2')b=3; if (parseInt(tip['amount']) >= cb.settings.tokens) { if(a>=100){ var numberOfRolls = 1; } else { 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++; if(b != 0){ if(b==1){ if ((a == 7 || a == 77) && rollCounter ==1){ die1 = Math.floor(Math.random() * numberOfSides+1); die2 = Math.floor(Math.random() * numberOfSides+1); } if (a != 7 && a!=77){ die1 = Math.floor(Math.random() * numberOfSides+1); die2 = Math.floor(Math.random() * numberOfSides+1); } die3 = Math.floor(Math.random() * numberOfSides+1); } if(b==2){ if ((a == 7 || a == 77) && rollCounter ==1){ die2 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } if (a != 7 && a!=77){ die2 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } die1 = Math.floor(Math.random() * numberOfSides+1); } if(b==3){ if ((a == 7 || a == 77) && rollCounter ==1){ die1 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } if (a != 7 && a!=77){ die1 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } die2 = Math.floor(Math.random() * numberOfSides+1); }} if(b==0) { die1 = Math.floor(Math.random() * numberOfSides+1); die2 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } if(a>=100 || a == 777){ die1=0; if(a>=200){ die2=0; if(a>=500){ die3=0; } } } // convoluted logic to appease the dev gods on cb var randomNum = Math.ceil(Math.random() * (100 - minimumRollsToGetRareDice) + minimumRollsToGetRareDice); if (rollCounter == randomNum) { if (die1 >= 1)die1 = 7; if (die2 >= 3)die2= 7; if ((die3 >= 5) && (rollCounter >=200))die3 = 7; } var total = die1 + die2 + die3; var winner = false; if (total >= 1) { winner = true; if((die1 == 0) && (die2 == die3)){ var b=die2*3; var prize = cb.settings['prize_' + b]; lastPrizeWon = prize; } if((die1 == 0) && (die2 == 0)){ var c=die3*3; var prize = cb.settings['prize_' + c]; lastPrizeWon = prize; } if((die1 == die2) && (die3 == die2)){ var prize = cb.settings['prize_' + total]; lastPrizeWon = prize; } } else { winner = false; var prize = ':omgomgomg Triple diamond! I Give You a Great Show'; } var prizeIndex = prizes.indexOf(prize); if (prizeIndex >= 0) { if (cb.settings.remove_winning_prize == 'Yes') prizes.splice(prizeIndex, 1); } else { var prizeb = 'A Thank You!'; } var msg = dieImagePrefix + die1 + " " + dieImagePrefix + die2 + " " + dieImagePrefix + die3; // msg += username + " rolled a " + total + "! \n".toUpperCase(); if((die1 == die2) && (die3 == die2)){ msg += "\n Roll #" + rollCounter + " | Prize: " + prize; } else { if((die1 == 0) && (die2 == die3)){ msg += "\n Roll #" + rollCounter + " | Prize: " + prize; } if((die1 == 0) && (die2 == 0)){ if((a!=77) && (a!=7)){ msg += "\n Roll #" + rollCounter + " | Prize: " + prize; } else { msg += "\n You can't use 77 or 7 now"; } } } var textColor = '#000000'; var bgColor = '#D9FAD7'; if (winner){ textColor = '#067D00' } else { textColor = '#0836A9' }; if (total == maxOutcome) { bgColor = '#FFDBF3'; textColor = '#A805A6'; msg += "\n :omgomgomgomgomgomg Awesome Congratulations"; } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); winners.push("Roll #" + rollCounter + " (" + total + "): " + username + " - " + prize); cb.drawPanel(); } function setPrizes() { var rareText = ''; for (var i = 1; 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 PRIZES #####"; for (var i = 1; i <= maxOutcome; i++) { if(i%3==0){ if (i == maxOutcome) rareText = " (VERY RARE)"; if (prizes.indexOf(cb.settings['prize_' + i] + rareText) >= 0) msg += "\nRoll " + i/3 + " - " + 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, '#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. 777 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 777. \n"; } else { msg += "777 \n"; } msg += "Get Three Equal Figures and Win a Prize. There are 7 possible prizes. \n"; if (cb.settings.remove_winning_prize == 'Yes') { msg += "Each prize won will be removed from the list.\n"; } else { msg += "Each prize won will stay on the list.\n"; } msg += "Tip " + cb.settings.tokens + " " + langTokens + " to Play 777. " + ":777die \n"; msg += "Type \"/prizes\" to see the list of prizes. \n"; msg += "Special commands \"/prizes all\" and \"/winners\".\n"; msg += "Tip 7 or 77 to keep the first two figures equal to the previous game."; cb.sendNotice(msg, username, '', '#15A6B0', 'bold'); } function init() { setPrizes(); advertise(); cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' tokens to Play 777!' + cb.settings.subject); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.