Bots Home
|
Create an App
CB Plays BlackJack
Author:
qwertyyy1122
Description
Source Code
Launch Bot
Current Users
Created by:
Qwertyyy1122
cb.settings_choices = [ {name:'top3', type:'choice', choice1: "Hoodie", choice2: "Tshirt", choice3: "Bra", choice4: "N/A", label: "Most outer layer of clothing for Tops"}, {name:'top2', type:'choice', choice1: "Hoodie", choice2: "Tshirt", choice3: "Bra", choice4: "N/A", label: "Next layer of clothing for Tops"}, {name:'top1', type:'choice', choice1: "Hoodie", choice2: "Tshirt", choice3: "Bra", choice4: "N/A", label: "Next layer of clothing for Tops"}, {name:'bot2', type:'choice', choice1: "Shorts", choice2: "Panties", choice3: "N/A", label: "Most outer layer of clothing for Bottoms"}, {name:'bot1', type:'choice', choice1: "Shorts", choice2: "Panties", choice3: "N/A", label: "Next layer of clothing for Bottoms"}, ]; var topCurrent = []; if(cb.settings.top1 != "N/A"){ topCurrent.push(cb.settings.top1);} if(cb.settings.top2 != "N/A"){ topCurrent.push(cb.settings.top2);} if(cb.settings.top3 != "N/A"){ topCurrent.push(cb.settings.top3);} var botCurrent = []; if(cb.settings.bot1 != "N/A"){ botCurrent.push(cb.settings.bot1);} if(cb.settings.bot2 != "N/A"){ botCurrent.push(cb.settings.bot2);} //var topCurrent = cb.settings.topCurrent.split(","); //var botCurrent = cb.settings.botCurrent.split(","); //var topCurrent = ["bra", "tshirt"]; //var botCurrent = ["panties", "shorts"]; var topOpposite = []; var botOpposite = []; var special = ["lush 1 min"]; var prizes = [topCurrent , botCurrent , special]; var hitVote = 0; var standVote = 0; var patt = /!start \d+/; var flag = false; var timer; cb.onMessage(function (msg){ if(patt.test(msg['m']) && msg['user'] == cb.room_slug){ msg['X-Spam'] = true; var array = msg['m'].split(' '); var str = "Broadcaster has set timer for " + array[1] + " seconds. Tip 1 to vote hit. Tip 2 to vote stand." cb.sendNotice(str, '', '#C8F9AC'); timer = parseInt(array[1]); recur(); } else{ var weight = [0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]; var index = weight[Math.floor(Math.random() * weight.length)]; switch(msg['m']){ case '!bust': msg['X-Spam'] = true; chatLose(index); break; case '!chatWin': msg['X-Spam'] = true; chatWin(index); break; case '!chatLose': msg['X-Spam'] = true; chatLose(index); break; case '!printall': cb.sendNotice(topCurrent); cb.sendNotice(botCurrent); cb.sendNotice(topOpposite); cb.sendNotice(botOpposite); break; case '!help': msg['X-Spam'] = true; cb.sendNotice("The following commands are available:", msg['user']); cb.sendNotice("!start 10 starts poll timer for 10 seconds. Number 10 can be changed to be any number of seconds.", msg['user'], '#C8F9AC'); cb.sendNotice("!chatLose chooses a piece of clothing to put on.", msg['user'], '#C8F9AC'); cb.sendNotice("!chatWin chooses a piece of clothing to take off.", msg['user'], '#C8F9AC'); break; } } }); function chatWin(prizeIndex){ switch(prizeIndex){ case 0: if(topCurrent.length > 0){ var popped = topCurrent.pop(); cb.sendNotice("Chat wins! Prize is " + popped + " off", '', '#C8F9AC'); topOpposite.push(popped); } else{ chatWin(1); } break; case 1: if(botCurrent.length > 0){ var popped = botCurrent.pop(); cb.sendNotice("Chat wins! Prize is " + popped + " off", '', '#C8F9AC'); botOpposite.push(popped); } else{ chatWin(2); } break; case 2: //base case, if there is nothing in topcurrent or botcurrent, choose something from special var index = Math.floor(Math.random()* special.length); cb.sendNotice("Chat wins! Prize is " + special[index], '', '#C8F9AC'); } } function chatLose(prizeIndex){ switch(prizeIndex){ case 0: //case for topcurrent //cb.sendNotice("case0"); if(topOpposite.length > 0){ var popped = topOpposite.pop(); cb.sendNotice("Chat loses! Punishment is " + popped + " on", '', '#C8F9AC'); topCurrent.push(popped); } else{ //so if there are no more tops to take off, check the bots chatLose(1); } break; case 1: //cb.sendNotice("case1"); if(botOpposite.length > 0){ var popped = botOpposite.pop(); cb.sendNotice("Chat loses! Punishment is " + popped + " on", '', '#C8F9AC'); botCurrent.push(popped); } else{ //"base case" needs to stop recursion if nothing is in any array cb.sendNotice("Nothing to put on!"); } break; case 2: //case for topcurrent //cb.sendNotice("case2"); if(topOpposite.length > 0){ var popped = topOpposite.pop(); cb.sendNotice("Chat loses! Punishment is " + popped + " on", '', '#C8F9AC'); topCurrent.push(popped); } else{ //so if there are no more tops to take off, check the bots chatLose(1); } break; } cb.sendNotice() } function recur(){ if(timer == 0){ cb.sendNotice("Voting closed.", '', '#C8F9AC'); flag = false; if(hitVote > standVote){ cb.sendNotice("Hit wins with " + hitVote);} else{ cb.sendNotice("Stand wins with " + standVote, '', '#C8F9AC');} hitVote = 0; standVote = 0; //if(hitVote > standVote) return "hit"; //return "stand"; return; } timer = timer -1; flag = true; // cb.onTip(function(tip){ // if(parseInt(tip['amount']) == 1){ // hitVote += 1; // standVote += 1; // } // }); cb.setTimeout(recur, 1000); } cb.onTip(function(tip){ if(flag){ if(parseInt(tip['amount']) == 1){ hitVote += 1; } if(parseInt(tip['amount']) == 2){standVote += 1; } } });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.