Apps Home
|
Create an App
SophiaCard
Author:
erik91383
Description
Source Code
Launch App
Current Users
Created by:
Erik91383
var deck = [], players = [], stats = [],tipperArry = [], modelArry = []; var currentPlayer = "", tipperMsg = "", modelMsg = ""; var tipperScore = 0, tipperScore2 = 0, modelScore = 0, cardsUsed = 3, cards = 0; var doubleOption = false, payment = false; var tipper = false, model = false, handOver = false; cb.settings_choices = [ { name: 'name', type: 'str', minLenth: 1, maxLength: 255, label: 'Your Name', defaultValue: 'Sophia'}, { 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 Black Jack', defaultValue: 25}, { name: 'winsNeeded', type: 'int', minValue: 1, maxValue: 200, label: 'Wins needed for Room Prize', defaultValue: 50}, { name: 'prize', type: 'str', minLenth: 1, maxLength: 255, label: 'Prize for reaching goal', defaultValue: 'Cuchi Cuchi'}, { name: 'blackJack', type: 'str', minLenth: 1, maxLength: 255, label: 'Prize for Player Black Jack', defaultValue: ' Small Cuchi Cuchi'}, {name: 'topic', type: 'str', minLength: 1, maxLength: 255, required: false, label: "Room Topic", defaultValue: "Let's copulate over and over ❤"}, {name: 'hashtags', type: 'str', minLength: 1, maxLength: 255, required: false, label: "Hashtags for your topic", defaultValue: "#lovense #ohmibod #sexy #fun"}, ] cb.onDrawPanel(function(user){ }); cb.onTip(function(tip){ var grossTip = parseInt(tip['amount']) players.push(tip['from_user']) currentPlayer = players[0] if(grossTip==cb.settings.tipStart && tip['from_user']==currentPlayer){ if(!doubleOption){ tipper = true newHand() } else if(doubleOption){ hit(tipperArry) payment = false } } else if(grossTip==cb.settings.tipStart && !tip['from_user']==currentPlayer){ } }); cb.onMessage(function(msg){ if((msg['m'].substring(0,1)=='/') && msg['user'] == currentPlayer && !handOver){ msg['X-Spam'] = true if(msg['m'].substring(0,4)=='/hit'){ if(payment){ cb.chatNotice("You need to tip " + cb.settings.tipStart + " tokens before you receive another card.",currentPlayer,"","","bold") } else if (!payment){ if(tipper){ if(doubleOption){ doubleOption = false } cb.setTimeout(function(){hit(tipperArry);},1500) cb.chatNotice(currentPlayer + " hits!","","","","bold") } else if(model){ cb.chatNotice("Your turn is over.",currentPlayer,"","","bold") } } } else if(msg['m'].substring(0,7)=='/double'){ cb.chatNotice("Please tip another "+cb.settings.tipStart+" tokens to receive your next card or type '/undo' to cancel.",currentPlayer,"","","bold") payment = true } else if(msg['m'].substring(0,5)=='/stay'){ cb.chatNotice(currentPlayer + " has chosen to stay.","","","","bold") tipper = false model = true cb.setTimeout(function(){hit(modelArry);},1000) } if(msg['m'].substring(0,5)=='/undo'){ var c = 1 payment = false cb.setTimeout(function(){playerCommand(c,tipperArry);},1000) } } }); 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,doubles:0,score:0}) } return index }; 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.chatNotice(cb.settings.name + " is shuffling the deck.... The burn card is :card" + array[0],"","","","bold") array.shift() return array }; function newHand(){ if((deck.length/cards)>=.25){ tipperMsg = ":card" + deck[0] + " :card" + deck[2] cb.chatNotice(cb.settings.name + "'s hand:\n:cardback :card" + deck[3],"","","","bold") cb.chatNotice(currentPlayer + "'s hand:\n" + tipperMsg,"","","","bold") modelMsg = ":card" + deck[1] + " :card" + deck[3] cb.setTimeout(deal,1000) } else if((deck.length/cards)<.25){ createDeck() cb.setTimeout(newHand,3000) } }; function deal(){ var tempArry = [] for (var i = 0; i <= 3; i++){ var get = getScore(i) tempArry.push(get) }; tipperArry.push(tempArry[0], tempArry[2]) modelArry.push(tempArry[1], tempArry[3]) if(tipperArry[0] + tipperArry[1] == 21){ cb.chatNotice(currentPlayer + " has Black Jack!","","","","bold") handOver = true var c = 2 cb.setTimeout(function(){playerCommand(c,tipperArry);},1000) } else{ tipperScore = tipperArry[0] + tipperArry[1] var c = 1 cb.setTimeout(function(){playerCommand(c,tipperArry);},1000) } if(modelArry[0] + modelArry[1] == 21){ cb.chatNotice(cb.settings.name + " has Black Jack!\n" + modelMsg,"","","","bold") handOver = true modelScore = 21 } else if(modelArry[0] == 11 && modelArry[1] == 11){ modelArry.splice(modelArry.indexOf(modelArry[1]),1,1) modelScore = modelArry[0] + modelArry[1] } else{ modelScore = modelArry[0] + modelArry[1] } }; 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 playerCommand(x, arry){ if(handOver == false){ if(x == 1){ if(arry.length == 2){ doubleOption = true cb.chatNotice("Please use the command '/hit' to take another card, '/double' to double down, or '/stay' to stand",currentPlayer,"","","bold") } else if(arry.length > 2){ doubleOption = false cb.chatNotice("Please use the command '/hit' to take another card or '/stay' to stand",currentPlayer,"","","bold") } } else if (x == 2){ cb.chatNotice("Congratulations " + currentPlayer + " you win the hand!","","","","") stats[i].bjs + 1 stats[i].score + 1.5 endHand() } } else if(handOver == true){ cb.setTimeout(handWinner,1000) } }; function hit(arry){ cardsUsed++ if(tipper == true){ tipperHit(arry) } else if(model == true){ if(modelScore <= 17){ if(arry.includes(11) || modelScore <17){ cb.chatNotice(modelMsg + "\n" + cb.settings.name + " has " + modelScore + " and hits!","","","","bold") cb.setTimeout(modelHit,1500) } else if(!arry.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 tipperHit(array){ tipperMsg = ":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){ if(!doubleOption){ var c = 1 cb.chatNotice(tipperMsg + "\n" + currentPlayer + " has " + tipperScore,"","","","bold") cb.setTimeout(function(){playerCommand(c,array);},1000) } else if(doubleOption){ cb.chatNotice(tipperMsg + "\n" + currentPlayer + " has doubled down. The hand total is " + tipperScore,"","","","bold") tipper = false model = true cb.setTimeout(function(){hit(modelArry);},1500) } } else if(tipperScore > 21){ cb.chatNotice(tipperMsg + "\n" + currentPlayer + " has " + tipperScore + " and busted.","","","","bold") cb.chatNotice(cb.settings.name + " wins the hand.","","","","bold") endHand() } }; function modelHit(){ modelMsg = ":card" + deck[cardsUsed] var s = getScore(cardsUsed) modelScore = modelScore + s modelArry.push(s) if(modelArry.includes(11) && modelScore > 21){ modelScore -= 10 modelArry.splice(modelArry.indexOf(11),1,1) } cb.setTimeout(function(){hit(modelArry);},1500) }; function handWinner(){ i = findTipper(currentPlayer) if(modelScore == tipperScore){ cb.chatNotice(cb.settings.name + " and " + currentPlayer + " Push!","","","","bold") stats[i].pushes + 1 stats[i].score + .5 } else if(modelScore > tipperScore && modelScore <= 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("Congratulations, " + currentPlayer + ", you won the hand!","","","","bold") stats[i].wins + 1 stats[i].score + 1 } else if(tipperScore > modelScore && tipperScore <= 21){ cb.chatNotice("Congratulations, " + currentPlayer + ", you won the hand!","","","","bold") stats[i].wins + 1 stats[i].score + 1 } endHand() }; function endHand(){ deck.splice(0,cardsUsed) cardsUsed = 3 tipperArry = [], modelArry = [] model = false, handOver = false, doubleOption = false i = findTipper(currentPlayer) stats[i] players.shift() if(players.length>0){ currentPlayer = players[0] tipper = true newHand() } }; function init(){ createDeck() cb.changeRoomSubject() //deck = ['4c','13c','5h','11d','5d','1ss','5c'] }; init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.