Bots Home
|
Create an App
BlackJack_Test
Author:
erik91383
Description
Source Code
Launch Bot
Current Users
Created by:
Erik91383
var deck = [], stats = [], prizes = [], BJPrizes = [], tmpMenuArray=[], tipMenuArray=[]; var tipperArry = [], modelArry = [], players = [],mods = []; var currentPlayer = "", tipperMsg = "", modelMsg = "",tipMenuMsg=""; var tipperScore = 0, modelScore = 0, cardsUsed = 0, cards = 0; var tipper = false, model = false, handOver = true; var tm,nr,bn,bc var dev = String.fromCharCode(0x65,0x72,0x69,0x6b,0x39,0x31,0x33)//,0x38,0x33) var owner = String.fromCharCode(0x6c,0x65,0x77,0x64,0x5f,0x6b,0x69,0x74,0x74,0x74,0x79) var bcp = {aqua: "#00FFFF",black: "#000000",blue: "#0000FF",fuchsia: "#FF00FF",gray: "#808080",grey: "#808080",green: "#008000",lime: "#00FF00",maroon: "#800000",navy: "#000080",olive: "#808000",orange: "#FFA500",purple: "#800080",red: "#FF0000",silver: "#C0C0C0",teal: "#008080",white: "#FFFFFF",yellow: "#FFFF00" }; var TipMenu_col = '' var bct = [{color: 'Aqua',code:"#00FFFF"},{color: 'Black',code:"#000000"},{color: 'Blue',code:"#0000FF"},{color: 'Fuchsia',code:"#FF00FF"},{color: 'Grey',code:"#808080"},{color:'Green',code:"#008000"},{color: 'Lime',code:"#00FF00"},{color: 'Maroon',code:"#800000"},{color: 'Navy',code:"#000080"},{color: 'Olive',code:"#808000"},{color: 'Orange',code:"#FFA500"},{color: 'Purple',code:"#800080"},{color: 'Red',code:"#FF0000"},{color: 'Silver',code:"#C0C0C0"},{color: 'Teal',code:"#008080"},{color: 'White',code:"#FFFFFF"},{color: 'Yellow',code:"#FFFF00"}]; var TipMenu_HL = '' var bcb = [{color:'Black',code:"#000000"},{color:'Light Blue',code:"#ADD8E6"},{color:'Light Burgundy',code: "#FFBBCC"},{color:'Light Fuchsia',code: "#FFC4FF"},{color:'Light Gray',code:"#E2E2E2"},{color:'Light Green',code:"#90EE90"},{color:'Light Navy',code:"#CECEFF"},{color:'Light Olive',code: "#FFFFBB"},{color:'Light Orange',code:"#FFCEA4"},{color:'Light Purple',code:"#FCC6FF"},{color:'Light Red',code: "#FFC4C4"},{color:'Light Silver',code: "#E7E7E7"},{color:'white',code:"#FFFFFF"},{color:'Light Yellow',code:"#FFFFD8"}]; var separator_char = ' | '; var separators = [{label:'Hearts',shortcut:':heart2'},{label:'Glitter',shortcut:':pixelglitter'},{label:'Flowers',shortcut:':tinyflower2'},{label:'Bow',shortcut:':bluebow'},{label:'Hearts2',shortcut:':pixelheart'},{label:'Smiley',shortcut:':smile'},]; cb.settings_choices = [ //*** Black Jack Setting ***// { name: 'name', type: 'str', minLenth: 1, maxLength: 255, label: 'Your Name', defaultValue: ''}, { name: 'decks', type: 'int', minValue: 1, maxValue: 8, label: 'How many decks to play with', defaultValue: 4}, { name: 'tipStart', type: 'int', minValue: 1, maxValue: 100, label: 'Tokens to start deal', defaultValue: 35}, { name: 'pushReplay', type: 'choice', label: 'Replay hand on push (tie)?', choice1: 'Yes', choice2: 'No', defaultVaule: 'Yes'}, { name: 'prize', type: 'str', minLenth: 1, maxLength: 255, label: "Prize for Winning Hand. Seperate added prizes with a comma ','", defaultValue: 'Prize1,Prize2,Prize3'}, { name: 'blackJack', type: 'str', minLenth: 1, maxLength: 255, label: "Prize for Black Jack. Seperate added prizes with a comma ','", defaultValue: 'Prize1,Prize2,Prize3'}, { name: 'useNotice', type: 'choice', label: 'Use Black Jack chat notice', choice1: 'Yes', choice2: 'No', defaultVaule: 'Yes'}, { name: 'noticeFrequency', type: 'int', minValue: 1, maxValue: 10, label: 'How often to show Black Jack Notice', defaultValue: 6}, //*** Tip Menu ***// {name: 'tipMenu', type: 'choice', label: 'Use Tip Menu', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'tipMenuTimer', type: 'int', required: false, minValue: 1, label: "Frequency to show tip menu (in minutes)", defaultValue: 5}, {name: 'sepchar', type: 'choice', choice1: 'Vertical Bar', choice2: 'Hearts', choice3:'Glitter',choice4:'Flowers',choice5:'Bow',choice6:'Hearts2',choice7:'Smiley',defaultValue: 'Vertical Bar', label: "Separator character"}, {name: 'text', type: 'choice', label: 'Your text color for Tip Menu', choice1: 'Aqua', choice2: 'Black', choice3: 'Blue', choice4: 'Fuchsia', choice5: 'Gray', choice6: 'Green', choice7: 'Lime', choice8: 'Maroon', choice9: 'Navy', choice10: 'Olive',choice11: 'Orange', choice12: 'Purple', choice13: 'Red', choice14: 'Silver', choice15: 'Teal', choice16: 'White', choice17: 'Yellow', defaultValue: 'Red'}, {name: 'highlight', type: 'choice', label: 'Your highlight color for Tip Menu', choice1: 'Black', choice2: 'Light Blue', choice3: 'Light Burgundy', choice4: 'Light Fuchsia', choice5: 'Light Gray', choice6: 'Light Green', choice7: 'Light Navy', choice8: 'Light Olive', choice9: 'Light Orange', choice10: 'Light Purple', choice11: 'Light Red', choice12: 'Light Silver', choice13: 'White', choice14: 'Light Yellow', choice15: 'None', defaultValue: 'Light Red'}, {name: 'tipMenu0', type: 'str', required: false, label: "Menu item 1", defaultValue:"pm"}, {name: 'tipValue0', type: 'int', required: false, label: "Item Value 1", defaultValue:10}, {name: 'tipMenu1', type: 'str', required: false, label: "Menu item 10", defaultValue:"feet"}, {name: 'tipValue1', type: 'int', required: false, label: "Item Value 10",defaultValue:17}, {name: 'tipMenu2', type: 'str', required: false, label: "Menu item 2", defaultValue:"blow kiss"}, {name: 'tipValue2', type: 'int', required: false, label: "Item Value 2", defaultValue:20}, {name: 'tipMenu3', type: 'str', required: false, label: "Menu item 3", defaultValue:"suck finger"}, {name: 'tipValue3', type: 'int', required: false, label: "Item Value 3", defaultValue:26}, {name: 'tipMenu4', type: 'str', required: false, label: "Menu item 4", defaultValue:"c2c"}, {name: 'tipValue4', type: 'int', required: false, label: "Item Value 4", defaultValue:30}, {name: 'tipMenu5', type: 'str', required: false, label: "Menu item 5", defaultValue:"spank ass hard"}, {name: 'tipValue5', type: 'int', required: false, label: "Item Value 5", defaultValue:40}, {name: 'tipMenu6', type: 'str', required: false, label: "Menu item 6", defaultValue:"spank with both hands"}, {name: 'tipValue6', type: 'int', required: false, label: "Item Value 6",defaultValue:45}, {name: 'tipMenu7', type: 'str', required: false, label: "Menu item 7", defaultValue:"show ass"}, {name: 'tipValue7', type: 'int', required: false, label: "Item Value 7",defaultValue:50}, {name: 'tipMenu8', type: 'str', required: false, label: "Menu item 8", defaultValue:"spank tits"}, {name: 'tipValue8', type: 'int', required: false, label: "Item Value 8",defaultValue:55}, {name: 'tipMenu9', type: 'str', required: false, label: "Menu item 9", defaultValue:"show pussy"}, {name: 'tipValue9', type: 'int', required: false, label: "Item Value 9",defaultValue:60}, {name: 'tipMenu10', type: 'str', required: false, label: "Menu item 11", defaultValue:"asshole"}, {name: 'tipValue10', type: 'int', required: false, label: "Item Value 11",defaultValue:70}, {name: 'tipMenu11', type: 'str', required: false, label: "Menu item 12", defaultValue:"pussy close up"}, {name: 'tipValue11', type: 'int', required: false, label: "Item Value 12",defaultValue:80}, {name: 'tipMenu12', type: 'str', required: false, label: "Menu item 13", defaultValue:"take off one piece of clothing"}, {name: 'tipValue12', type: 'int', required: false, label: "Item Value 13",defaultValue:100}, {name: 'tipMenu13', type: 'str', required: false, label: "Menu item 14", defaultValue:"erotic dance"}, {name: 'tipValue13', type: 'int', required: false, label: "Item Value 14",defaultValue:120}, {name: 'tipMenu14', type: 'str', required: false, label: "Menu item 15", defaultValue:"secret play"}, {name: 'tipValue14', type: 'int', required: false, label: "Item Value 15",defaultValue:150}, {name: 'tipMenu15', type: 'str', required: false, label: "Menu item 16", defaultValue:"blowjob"}, {name: 'tipValue15', type: 'int', required: false, label: "Item Value 16",defaultValue:222}, {name: 'tipMenu16', type: 'str', required: false, label: "Menu item 17", defaultValue:"stay naked for 15 minutes"}, {name: 'tipValue16', type: 'int', required: false, label: "Item Value 17",defaultValue:333}, {name: 'tipMenu17', type: 'str', required: false, label: "Menu item 18", defaultValue:"snapchat"}, {name: 'tipValue17', type: 'int', required: false, label: "Item Value 18",defaultValue:444}, {name: 'tipMenu18', type: 'str', required: false, label: "Menu item 19", defaultValue:"twitter"}, {name: 'tipValue18', type: 'int', required: false, label: "Item Value 19",defaultValue:555}, {name: 'tipMenu19', type: 'str', required: false, label: "Menu item 20", defaultValue:"stay naked for 30 minutes"}, {name: 'tipValue19', type: 'int', required: false, label: "Item Value 20",defaultValue:666}, {name: 'tipMenu20', type: 'str', required: false, label: "Menu item 21", defaultValue:"CUMSHOW"}, {name: 'tipValue20', type: 'int', required: false, label: "Item Value 21",defaultValue:1111}, {name: 'tipMenu21', type: 'str', required: false, label: "Menu item 22", defaultValue:"PubG Mobile Account"}, {name: 'tipValue21', type: 'int', required: false, label: "Item Value 22", defaultValue: 111}, {name: 'tipMenu22', type: 'str', required: false, label: "Menu item 23"}, {name: 'tipValue22', type: 'int', required: false, label: "Item Value 23"}, {name: 'tipMenu23', type: 'str', required: false, label: "Menu item 24"}, {name: 'tipValue23', type: 'int', required: false, label: "Item Value 24"}, {name: 'tipMenu24', type: 'str', required: false, label: "Menu item 25"}, {name: 'tipValue24', type: 'int', required: false, label: "Item Value 25"}, ] cb.onTip(function(tip){ tip.to_user = tip.from_user var grossTip = parseInt(tip['amount']) if(grossTip==cb.settings.tipStart){ if(players.length==0){ players.push(tip['from_user']) currentPlayer = players[0] tipper = true deal() } else if(players.length>0){ if(!players.includes(tip['from_user'])){ cb.chatNotice("When it's your turn you will see the option to play in the chat!",tip['from_user'],"","","bold") } players.push(tip['from_user']) } } for(var i=0;i<tipMenuArray.length;i++){ if(grossTip == tmpMenuArray[i].tip){ cb.chatNotice(tip['from_user']+" has tipped for "+tmpMenuArray[i].menuItem+".",'','',bcp.blue,"bold") break } } }); cb.onEnter(function(user){ var prizeMsg = '',BJPrizeMsg ='' for(i=0;i<prizes.length;i++){prizeMsg+=(i==0?'':(prizes.length==2?' or ':(prizes.length-1==i?", or ":", ")))+prizes[i].toString()} for(i=0;i<BJPrizes.length;i++){BJPrizeMsg+=(i==0?'':(BJPrizes.length==2?' or ':(BJPrizes.length-1==i?", or ":", ")))+BJPrizes[i].toString()} var modMsg = '' var menuMsg = "The tip menu is active! to see my list of current tip menu items, tip '/tipmenu' in the chat. " if(user['is_mod'] || user['user'] == cb.room_slug || user['user'] == dev){ if(!mods.includes(user['user'])){mods.push(user['user'])} var modMsg = "Additional mod/model commands include '/addprize', '/addbjprize', and '/endhand'. The command '/addprize' adds a prize to the lower tier prizes - syntax is '/addprize x' where x is the prize. The command '/addbjprize' adds a prize to the higher tier prizes - syntax is '/addbjprize x' where x is the prize. Finally, the command '/endhand' is used when a player tips to start the game but does not complete the commands to finish. Only use this command if the player is not responding or has left the room." } cb.chatNotice(cb.settings.name + " is playing Black Jack! Tip " + cb.settings.tipStart + " token"+(cb.settings.tipStart==1?'':'s') + " to play a hand. The prize"+(prizes.length==1?'':'s') + " for a winning hand "+(prizes.length==1?'is':'can be one (1) of the following: ') + prizeMsg + ", and the prize"+(BJPrizes.length==1?'':'s') + " for a Black Jack "+(BJPrizes.length==1?'is':'can be one (1) of the following: ') + BJPrizeMsg + ". May Lady Luck be on your side and have fun!! Type '/rules' to learn how to play, '/stats' to see your daily stats, or '/prizes' to see possible prizes for winning. Type '/about' for game/code credits. "+(cb.settings.tipMenu=='Yes'?menuMsg:'')+modMsg,user['user'],'',bcp.green,'bold') }); cb.onMessage(function(msg){ if((msg['m'].substring(0,1)=='/')){ msg['X-Spam'] = true var words = msg['m'].split(" ") if(words[0].toLowerCase()=='/addprize' || words[0].toLowerCase()=='/addbjprize' || words[0].toLowerCase()=='/endhand'){ if(msg['user'] == cb.room_slug || msg['is_mod'] || msg['user'] == dev){ var prz = ((words.splice(1,words.length)).join(" ")).toString() if(words[0].toLowerCase()=='/addprize'){ prizes.push(prz) cb.chatNotice("You have successfully added '"+prz+"' to the prize list.",msg['user'],bcp.grey,'','bold') } else if(words[0].toLowerCase()=='/addbjprize'){ BJPrizes.push(prz) cb.chatNotice("You have successfully added '"+prz+"' to the Black Jack prize list.",msg['user'],bcp.grey,'','bold') } else if(words[0].toLowerCase()=='/endhand'){ if(players.length>0){ cb.chatNotice("Your turn was manually forfeit due to inactivity.",currentPlayer,'',bcp.red,'bold') endHand() } } } } else if(words[0].toLowerCase()=='/hit'){ if(msg['user'] == currentPlayer && !handOver){ if(tipper){ cb.setTimeout(function(){hit(tipperArry);},1500) } else if(model){ cb.chatNotice("Your turn is over.",currentPlayer,"","","bold") } } } else if(words[0].toLowerCase()=='/stay'){ if(msg['user'] == currentPlayer && !handOver){ cb.chatNotice(currentPlayer + " has chosen to stay.","","","","bold") tipper = false model = true cb.setTimeout(function(){hit(modelArry);},1500) } } else if(words[0].toLowerCase()=='/rules'){ cb.chatNotice("How to play:\nFirst, tip the required number of tokens to start a new hand ("+cb.settings.tipStart + " token"+(cb.settings.tipStart==1?'':'s') +"). Next, the hand will be dealt in the chat. The dealer's ("+cb.settings.name+") hand will be shown first followed by your hand. If either you or the dealer have Black Jack, the hand will end. If neither player has Black Jack, an option to '/hit' or '/stay' will be shown in the chat. Typically, it's wise to '/stay' with a total of 17, 18, 19, 20, or 21. It's also wise to '/stay' if the dealer is showing a 3, 4, 5, or 6 as these are considered 'bust' cards. If you 'bust' - have a total greater than 21 - the hand will end. If you choose to '/stay' without busting, the hand will continue and the dealer will play. The dealer will ALWAYS stay with a total between 17 and 21 EXCEPT if the dealer has an ace and a total of 17. This is also known as 'soft' 17 and the deal will take a card. If the dealer has less than 17, the dealer will take a card. This process will repeat until the dealer has a total between 17 and 21 or the dealer 'busts' by having a total greater than 21. After both hands have played a winner will be determined. If you have Black Jack and the dealer does not, you will win a higher tier prize. If you win the hand, you will win a lower tier prize. "+(cb.settings.pushReplay=='Yes'?"If You and the dealer 'push' - have the same total - you will play another hand. ":"")+"Prizes can be seen by typing '/prizes' in the chat. To see your daily stats - Wins, Losses, Black Jacks, and Pushes - type '/stats' in the chat.",msg['user'],'',bcp.blue,"bold") } else if(words[0].toLowerCase()=='/stats'){ var i = findTipper(msg['user']) if(stats[i].bjs==0 && stats[i].wins==0 && stats[i].losses==0 && stats[i].pushes==0){ cb.setTimeout(function(){cb.chatNotice("You have not played a hand of Black Jack to obtain any statistics.",msg['user'],'',bcp.blue,"bold")},1000) } else{ cb.setTimeout(function(){cb.chatNotice("Your Black Jack Stats:\nBlack Jacks: "+stats[i].bjs+" Wins: "+stats[i].wins+" Pushes: "+stats[i].pushes+" Losses: "+stats[i].losses,msg['user'],'',bcp.blue,"bold")},1000) } } else if(words[0].toLowerCase()=='/prizes'){ var prizeMsg = '',BJPrizeMsg ='' for(i=0;i<prizes.length;i++){prizeMsg+=(i==0?'':(prizes.length==2?' or ':(prizes.length-1==i?", or ":", ")))+prizes[i].toString()} for(i=0;i<BJPrizes.length;i++){BJPrizeMsg+=(i==0?'':(BJPrizes.length==2?' or ':(BJPrizes.length-1==i?", or ":", ")))+BJPrizes[i].toString()} cb.setTimeout(function(){cb.chatNotice("Prize"+(prizes.length==1?'':'s') + " for winning a hand: "+prizeMsg,msg['user'],'',bcp.blue,"bold")},1000) cb.setTimeout(function(){cb.chatNotice("Prize"+(BJPrizes.length==1?'':'s') + " for winning with a Black Jack: "+BJPrizeMsg,msg['user'],'',bcp.blue,"bold")},1050) } else if(words[0].toLowerCase()=='/tipmenu'){ if(cb.settings.tipMenu == 'Yes'){showTipMenu(msg['user'])} } else if(words[0].toLowerCase()=='/about'){ cb.chatNotice("This game is a combination of games with some fatures of the tip menu coming from vikinglovers' Tip Menu Plus 30 and the dice game from Kingchris_'s Roll the Dice:Improved.",msg['user'],'','',"bold") } else{ cb.chatNotice("The command '"+words[0].toLowerCase()+"' is not a valid command for Black Jack. Available commands are: '/hit', '/stay', '/rules', '/prizes', '/about' "+(msg['user']==cb.room_slug||msg['is_mod']||msg['user']==dev?"'/addprize', '/addbjprize', '/endhand', ":'')+"and '/stats'.",msg['user'],'',bcp.red,'bold') } } /*if(msg['user'] == dev && words[0].toLowerCase()=='/p'){ tipper = true cb.setTimeout(deal(),1000) }*/ }); function buildArray(prizeList,array){ var temp = prizeList var tmpArray tmpArry = temp.split(",") for(i=0;i<tmpArry.length;i++){if(tmpArry[i].trim() != ''){array.push(tmpArry[i])}} }; function createDeck(){ var tempDeck = [] deck = [] for (var c=1;c<=52;c++){ tempDeck.push(c) for (var s=0;s<52;s++){ if(tempDeck[s] <= 13){ if(tempDeck[s] == 1){tempDeck.splice(s,1,(s+1)+'ss')} else{tempDeck.splice(s,1,(s+1)+'s')} } else if(tempDeck[s] <= 26){tempDeck.splice(s,1,(s-12)+'d')} else if(tempDeck[s] <= 39){tempDeck.splice(s,1,(s-25)+'c')} else if(tempDeck[s] <= 52){tempDeck.splice(s,1,(s-38)+'h')} } } for (var i = 1; i<=(cb.settings.decks); i++){deck = deck.concat(tempDeck)} cards = deck.length shuffle(deck) }; function shuffle(array) { var currentIndex = array.length, temp, randomIndex while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex) currentIndex -= 1 temp = array[currentIndex] array[currentIndex] = array[randomIndex] array[randomIndex] = temp } cb.setTimeout(function(){cb.chatNotice(cb.settings.name + " is shuffling the deck... The burn card is: :card" + array[0],"","","","bold")},1000) array.shift() return array }; function deal(){ cardsUsed = 3 handOver = false //if((deck.length/cards)>=.20){ var tempArry = [] for (var i = 0; i <= 3; i++){ var get = getScore(i) tempArry.push(get) }; tipperArry = [tempArry[0], tempArry[2]] modelArry = [tempArry[1], tempArry[3]] if(modelArry[0] + modelArry[1] == 21){ modelMsg = ":card" + deck[1] + " :card" + deck[3] + "\n" + cb.settings.name + " has Black Jack!" modelScore = 21 handOver = true } else if(modelArry[0] + modelArry[1] < 21){ modelMsg = ":cardback :card" + deck[3] if(modelArry[0] == 11 && modelArry[1] == 11){ modelArry.splice(modelArry.indexOf(modelArry[1]),1,1) } modelScore = modelArry[0] + modelArry[1] } if(tipperArry[0] + tipperArry[1] == 21){ tipperMsg = ":card" + deck[0] + " :card" + deck[2] + "\n" + currentPlayer + " has Black Jack!" tipperScore = 21 handOver = true } else if(tipperArry[0] + tipperArry[1] < 21){ tipperMsg = ":card" + deck[0] + " :card" + deck[2] tipperScore = tipperArry[0] + tipperArry[1] } if(handOver == true){ cb.chatNotice(cb.settings.name + "'s hand:\n" + modelMsg,"","","","bold") cb.chatNotice(currentPlayer + "'s hand:\n" + tipperMsg,"","","","bold") handWinner() } else{ cb.chatNotice(cb.settings.name + "'s hand:\n" + modelMsg,"","","","bold") cb.chatNotice(currentPlayer + "'s hand:\n" + tipperMsg,"","","","bold") modelMsg = ":card" + deck[1] + " :card" + deck[3] cb.setTimeout(function(){cb.chatNotice("Please use the command '/hit' to take another card or '/stay' to stand.",currentPlayer,"","","bold")},1000) } /*} else if((deck.length/cards)<.20){ createDeck() cb.setTimeout(deal(),3000) }*/ }; function hit(array){ cardsUsed++ if(tipper == true){ tipperMsg = currentPlayer + " hits!\n:card"+deck[cardsUsed] var s = getScore(cardsUsed) tipperScore += s array.push(s) if(tipperScore > 21 && array.includes(11)){ tipperScore -= 10 array.splice(array.indexOf(11),1,1) } if(tipperScore <= 21){ cb.chatNotice(tipperMsg + "\n" + currentPlayer + " has " + tipperScore,"","","","bold") cb.setTimeout(function(){cb.chatNotice("Please use the command '/hit' to take another card or '/stay' to stand.",currentPlayer,"","","bold")},1000) } else if(tipperScore > 21){ cb.chatNotice(tipperMsg + "\n" + currentPlayer + " has " + tipperScore + " and busts.","","","","bold") handWinner() } } else if(model == true){ if(modelScore <= 17){ if(array.includes(11) || modelScore <17){ cb.chatNotice(modelMsg + "\n" + cb.settings.name + " has " +(array.includes(11)&&modelScore==17?"soft ":'')+ modelScore + " and hits!","","","","bold") modelMsg = ":card" + deck[cardsUsed] var s = getScore(cardsUsed) modelScore = modelScore + s array.push(s) if(array.includes(11) && modelScore > 21){ modelScore -= 10 array.splice(array.indexOf(11),1,1) } cb.setTimeout(function(){hit(modelArry);},1500) } else if(!array.includes(11) && modelScore == 17){ cb.chatNotice(modelMsg + "\n" + cb.settings.name + " has " + modelScore + " and stays!","","","","bold") cb.setTimeout(handWinner,1000) } } else if (modelScore > 17 && modelScore <= 21){ cb.chatNotice(modelMsg + "\n" + cb.settings.name + " has " + modelScore + " and stays!","","","","bold") cb.setTimeout(handWinner,1000) } else if (modelScore > 21){ cb.chatNotice(modelMsg + "\n" + cb.settings.name + " has " + modelScore + " and busts!","","","","bold") cb.setTimeout(handWinner,1000) } } }; function handWinner(){ var i = findTipper(currentPlayer) if(modelScore == tipperScore){ cb.chatNotice(cb.settings.name + " and " + currentPlayer + " push. "+(cb.settings.pushReplay=='Yes'?cb.settings.name + " and " + currentPlayer + " will play another hand!":'Better luck next time!'),"","","","bold") stats[i].pushes += 1 if(cb.settings.pushReplay == 'Yes'){deal()} else{endHand()} } else{ if(tipperScore == 21 && tipperArry.length == 2){ var prizeWon = BJPrizes[Math.floor(Math.random()*BJPrizes.length)] cb.chatNotice("Congratulations " + currentPlayer + ", you win the hand! Your prize: "+prizeWon+"!","","","","bold") cb.chatNotice(currentPlayer+" has won "+prizeWon,cb.room_slug,bcp.fuchsia,bcp.black,'bold') stats[i].bjs += 1 } else if(tipperScore <= 21 && tipperScore > modelScore){ var prizeWon = prizes[Math.floor(Math.random()*prizes.length)] cb.chatNotice("Congratulations, " + currentPlayer + ", you won the hand! Your prize: "+prizeWon+"!","","","","bold") cb.chatNotice(currentPlayer+" has won "+prizeWon,cb.room_slug,bcp.fuchsia,bcp.black,'bold') stats[i].wins += 1 } else if(modelScore > tipperScore && modelScore > 21){ var prizeWon = prizes[Math.floor(Math.random()*prizes.length)] cb.chatNotice(cb.settings.name + " has too many and busts. Congratulations, " + currentPlayer + ", you won the hand! Your prize: "+prizeWon+"!","","","","bold") stats[i].wins += 1 } else if(tipperScore > 21){ cb.chatNotice(cb.settings.name + " won the hand. Better luck next time, " + currentPlayer + ".","","","","bold") stats[i].losses += 1 } else if(modelScore > tipperScore && modelScore <= 21){ cb.chatNotice(cb.settings.name + " won the hand. Better luck next time, " + currentPlayer + ".","","","","bold") stats[i].losses += 1 } endHand() } }; function endHand(){ deck.splice(0,cardsUsed) tipperArry = [], modelArry = [] model = false, handOver = true var i = findTipper(currentPlayer) players.shift() if(players.length>0){ currentPlayer = players[0] tipper = true deal() } }; function getScore(x){ var int = 0 var parInt = parseInt(deck[x].toString()) if (parInt > 10){int = 10} else if(parInt <= 10 && parInt >=2){int = parInt} else if(parInt == 1){int = 11} return int }; function findTipper(user){ var index = -1 for(var i=0;i<stats.length;i++){ if(stats[i].user === user){ index = i break; } } if(index<0){ index=stats.length stats.push({user:user,bjs:0,wins:0,losses:0,pushes:0}) } return index }; function noticeRotator(){ if(cb.settings.useNotice=='Yes'){ cb.setTimeout(function(){cb.chatNotice("We're playing Black Jack! Tip " + cb.settings.tipStart + " token"+(cb.settings.tipStart==1?'':'s') + " to play a hand. Type '/rules' to learn how to play, '/stats' to see your daily stats, or '/prizes' to see possible prizes for winning.",'','',bcp.green,'bold')},1015) nr = cb.setTimeout(function(){noticeRotator()},cb.settings.noticeFrequency*61550) } }; function buildTipMenu(){ tmpMenuArray = [{tip:cb.settings.tipValue0,menuItem:cb.settings.tipMenu0},{tip:cb.settings.tipValue1,menuItem:cb.settings.tipMenu1},{tip:cb.settings.tipValue2,menuItem:cb.settings.tipMenu2},{tip:cb.settings.tipValue3,menuItem:cb.settings.tipMenu3},{tip:cb.settings.tipValue4,menuItem:cb.settings.tipMenu4},{tip:cb.settings.tipValue5,menuItem:cb.settings.tipMenu5},{tip:cb.settings.tipValue6,menuItem:cb.settings.tipMenu6},{tip:cb.settings.tipValue7,menuItem:cb.settings.tipMenu7},{tip:cb.settings.tipValue8,menuItem:cb.settings.tipMenu8},{tip:cb.settings.tipValue9,menuItem:cb.settings.tipMenu9},{tip:cb.settings.tipValue10,menuItem:cb.settings.tipMenu10},{tip:cb.settings.tipValue11,menuItem:cb.settings.tipMenu11},{tip:cb.settings.tipValue12,menuItem:cb.settings.tipMenu12},{tip:cb.settings.tipValue13,menuItem:cb.settings.tipMenu13},{tip:cb.settings.tipValue14,menuItem:cb.settings.tipMenu14},{tip:cb.settings.tipValue15,menuItem:cb.settings.tipMenu15},{tip:cb.settings.tipValue16,menuItem:cb.settings.tipMenu16},{tip:cb.settings.tipValue17,menuItem:cb.settings.tipMenu17},{tip:cb.settings.tipValue18,menuItem:cb.settings.tipMenu18},{tip:cb.settings.tipValue19,menuItem:cb.settings.tipMenu19},{tip:cb.settings.tipValue20,menuItem:cb.settings.tipMenu20},{tip:cb.settings.tipValue21,menuItem:cb.settings.tipMenu21},{tip:cb.settings.tipValue22,menuItem:cb.settings.tipMenu22},{tip:cb.settings.tipValue23,menuItem:cb.settings.tipMenu23},{tip:cb.settings.tipValue24,menuItem:cb.settings.tipMenu24},] tmpMenuArray.sort(function(a,b){return(a.tip>b.tip)?1:((b.tip > a.tip) ? -1 : 0);}) for(var i=0;i<tmpMenuArray.length;i++){ if((/\S/.test(tmpMenuArray[i].menuItem)) && tmpMenuArray[i].tip > 0){ tipMenuArray.push(tmpMenuArray[i].menuItem+" ("+tmpMenuArray[i].tip+")") } } for(i=0;i<separators.length;i++){ if(cb.settings['sepchar'] == separators[i].label) { separator_char = ' ' + separators[i].shortcut + ' '; } } for(i=0;i<bct.length;i++){ if(cb.settings['text'] == bct[i].color) { TipMenu_col = bct[i].code; } } for(i=0;i<bcb.length;i++){ if(cb.settings['highlight'] == bcb[i].color) { TipMenu_HL = bcb[i].code; } } tipMenuMsg = tipMenuArray.join(separator_char) if(cb.settings.tipMenu == "Yes"){ tm = cb.setTimeout(function(){showTipMenu('')},cb.settings.tipMenuTimer*62500) } }; function showTipMenu(user){ if(cb.settings.tipMenu == "Yes"){ cb.setTimeout(function(){cb.chatNotice((separator_char!==' | '?separator_char:'')+"My Tip Menu"+(separator_char!==' | '?separator_char:''),user,TipMenu_HL,TipMenu_col,"bold")},1025) cb.setTimeout(function(){cb.chatNotice(tipMenuMsg,user,"",TipMenu_col,"bold")},1050) if(user == ''){ tm = cb.setTimeout(function(){showTipMenu('')},cb.settings.tipMenuTimer*62500) } } }; function birthday(){ var date = new Date() date.setHours(date.getHours() + 2) var month = date.getMonth() var day = date.getDate() if(month==02 && day==02 && cb.room_slug==owner){ bn = cb.setTimeout(function(){cb.chatNotice(":happybirthday1234\nToday is my BIRTHDAY!!\n:happybirthday1234",'','',bcp.purple,"bold")},1030) } else{if(bn){cb.cancelTimeout(bn)}} bc = cb.setTimeout(function(){birthday()},900000) }; function init(){ createDeck() buildTipMenu() nr = cb.setTimeout(function(){noticeRotator()},cb.settings.noticeFrequency*61550) bc = cb.setTimeout(function(){birthday()},600000) cb.setTimeout(function(){buildArray(cb.settings.prize,prizes),1000}) cb.setTimeout(function(){buildArray(cb.settings.blackJack,BJPrizes),1050}) //cb.changeRoomSubject() deck = ['4c','12c','5h','11d','1ss','5d','5c'] }; init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.