Apps Home
|
Create an App
asdfsd 77
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: 'minimum_rolls', type: 'choice', label: 'What is the minimum number of plays before the 777 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 777 (díficil de salir)' }, ]; 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 minimum777 = parseInt(cb.settings.minimum_rolls); var maxOutcome = 21; var dieImagePrefix = ':777dice'; var die1 = 0; var die2 = 0; var die3 = 0; var a = 0; var decision = 0; var contador=0; var tipperArray = new Array; var numTippers = 0; var coins = 0; var contador=0; function tipperArrayPopulate(user) { tipperArray[numTippers] = new Array; tipperArray[numTippers][0] = user; tipperArray[numTippers][1] = 0; numTippers++; } function findTipper(user) { //find the index of the user for(var i = 0; i < tipperArray.length; i++) { if(tipperArray[i][0] == user) { break; } } //the user is not in the array. add him and call findTipper if(i == tipperArray.length) { tipperArrayPopulate(user); findTipper(user); } return i; } function setTipTitles(user, message){ var m = '|' + tipperArray[findTipper(user)][1] + ' Coins| ' + message; return m; } cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); a = parseInt(tip['amount']); if (a >= cb.settings.tokens) { if(a>=50){ var numberOfRolls = 4; if(a>=100)numberOfRolls = 1; } else { var numberOfRolls = Math.floor(parseInt(a/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 / played ' + rollCounter + ' time(s)' }; }); cb.onEnter(function (user){ if(user['user']=='jhonhanar' && contador==0){ tipperArray[findTipper(user['user'])][1] += 100; contador++; } showAppAd(user['user']); }); cb.onMessage(function (msg) { if (msg['m'].match(/\/w/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } else if (msg['m'].match(/\/p/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']); } } if(parseInt(tipperArray[findTipper(msg['user'])][1]) > 0){ msg['m'] = setTipTitles(msg['user'],msg['m']); } if ((msg['m'].match(/\/coi/i)) && (tipperArray[findTipper(msg['user'])][1]>0 || (msg['user'] == cb.room_slug))) { decision=0; a=5; tipperArray[findTipper(msg['user'])][1]--; roll(lastRoller); } if ((msg['m'].match(/\/convert/i)) && tipperArray[findTipper(msg['user'])][1]>0 ) { var valor=tipperArray[findTipper(msg['user'])][1]; tipperArray[findTipper(msg['user'])][1]=0; convertAd(msg['user'], valor); } return msg; }); function roll(username) { rollCounter++; var error=0; var caso=0; if(a==7 || a==77){ decision = 1; } else { decision = 0; } if(die1!=die2 && die2!=die3 && die1!=die3)decision=0; if(die1==die2 && die2==die3 && rollCounter!=1){ if(decision==1)error=1; decision=0; } if(die1==7 || die2==7 || die3==7)decision=0; if(decision==1 && rollCounter!=1){ if(die1==die2)caso=1; if(die2==die3)caso=2; if(die1==die3)caso=3; } switch (caso){ case 1: die3 = Math.floor(Math.random() * numberOfSides+1); break; case 2: die1 = Math.floor(Math.random() * numberOfSides+1); break; case 3: die2 = Math.floor(Math.random() * numberOfSides+1); break; default: die1 = Math.floor(Math.random() * numberOfSides+1); die2 = Math.floor(Math.random() * numberOfSides+1); die3 = Math.floor(Math.random() * numberOfSides+1); } // convoluted logic to appease the dev gods on cb var randomNum = Math.ceil(Math.random() * (100 - minimum777) + minimum777); if (rollCounter == randomNum || a==777) { if (die1 >= 1)die1 = 7; if (die2 >= 3)die2 = 7; if (((die3 >= 5) && (rollCounter >=minimum777*10)) || (tipCounter >= minimum777*100))die3 = 7; } else { if(a>=50 && a!=77){ die1=0; if(a>=100){ die2=0; if(a>=500){ die3=0; } } } } 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]; coins=2*b/3; tipperArray[findTipper(lastRoller)][1] += coins; lastPrizeWon = prize; } if((die1 == 0) && (die2 == 0)){ var c=die3*3; var prize = cb.settings['prize_' + c]; coins=c; tipperArray[findTipper(lastRoller)][1] += coins; lastPrizeWon = prize; } if((die1 == die2) && (die3 == die2)){ var prize = cb.settings['prize_' + total]; coins=total/3; tipperArray[findTipper(lastRoller)][1] += coins; lastPrizeWon = prize; } } else { winner = false; coins=20; tipperArray[findTipper(lastRoller)][1] += coins; var prize = ':omgomgomg Triple diamond! I Give You a Great Show'; } var msg = ''; if(error==1)msg += "You can't use 77 or 7 After Win a Prize \n"; msg += dieImagePrefix + die1 + " " + dieImagePrefix + die2 + " " + dieImagePrefix + die3; // msg += username + " rolled a " + total + "! \n".toUpperCase(); if((die1 == die2) && (die3 == die2)){ msg += "\n Play #" + rollCounter + " | " + username + " Win Prize: " + prize; msg += "\n You win " + coins + " coins"; } else { if((die1 == 0) && (die2 == die3)){ msg += "\n Play #" + rollCounter + " | " + username + " Win Prize: " + prize; msg += "\n You win " + coins + " coins"; } if((die1 == 0) && (die2 == 0)){ if((a!=77) && (a!=7)){ msg += "\n Play #" + rollCounter + " | " + username + " Win Prize: " + prize; msg += "\n You win " + coins + " coins"; } 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) { var rareText = ''; var msg = "##### POSSIBLE PRIZES #####"; for (var i = 1; i <= maxOutcome; i++) { if(i%3==0){ if (i == maxOutcome) rareText = " (777!)"; msg += "\nRoll " + i/3 + " - " + cb.settings['prize_' + i] + rareText; } } 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"; msg += "Tip " + cb.settings.tokens + " " + langTokens + " to Play 777. " + ":777dice \n"; msg += "Type \"/p\" to see the list of prizes or \"/p all\" \n"; msg += "Tip 7 or 77 if you get two figures equal. \n"; msg += "For play with your coins type \"/coi\" \n"; msg += "To convert your coins to tks type \"/convert\" (1coin = 5tks)\n"; msg += "You must be verificated and the model must be enabled to give tks, coordinate before convert. \n"; cb.sendNotice(msg, username, '', '#FF6600', 'bold'); } function convertAd(username,val) { var msg = ""; msg +=":tks1121 " + username + " Ha convertido sus " + val +" coins en tks \n"; msg += "Eso es " + val*5 +" tks \n"; cb.sendNotice(msg, '', '', '#FF6600', 'bold'); } function init() { setPrizes(); advertise(); cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' tokens to Play 777! Win Coins and Prizes' + cb.settings.subject); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.