Bots Home
|
Create an App
jest game
Author:
jestnotest420
Description
Source Code
Launch Bot
Current Users
Created by:
Jestnotest420
/* Hi-Lo by remmbermytitans */ // vars var total_tipped = 0; var last_tip_username = null; var deckOfCards = new Array(); var tipperCard = -1; var camCard = -1; var countdown = 3; var numOfCardsLeft = 54; var numOfJokersLeft = 2; var cardIsBeingDealt = false; var lastResult = ""; cb.settings_choices = [ {name: 'Minimum_tip_required_to_play', type: 'int', minValue: 10, maxValue: 100}, {name: 'Small_Joker_Prize', type: 'str', minLength: 1, maxLength: 511, default: "5 minute private show"}, {name: 'Large_Joker_Prize', type: 'str', minLength: 1, maxLength: 511, default: "15 minute private show"} ]; // handlers cb.onTip(function(tip) { total_tipped += tip['amount'] last_tip_user = tip['from_user'] last_tip_username = tip['from_user'] if (tip['amount'] >= cb.settings.Minimum_tip_required_to_play) { if (!cardIsBeingDealt) selectTipperCard(); else cb.chatNotice("Oh no! Please don't tip while the dealer is handing out cards."); cb.drawPanel(); } }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Cards Remaining:', 'row1_value': numOfCardsLeft, 'row2_label': 'Jokers Remaining:', 'row2_value': numOfJokersLeft, 'row3_label': 'Last result:', 'row3_value': lastResult }; }); // helper functions function update_App() { var new_subject = "Hi-Lo! with Jokers. Number of cards left: " + (numOfCardsLeft - numOfJokersLeft) + ". Number of Jokers left: " + numOfJokersLeft + ". Minimum tip needed to play: " + cb.settings.Minimum_tip_required_to_play + "."; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject) } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function init() { setDeck(); update_App(); } function setDeck() { for (var i = 0; i < 4; i++) { deckOfCards[0+i] = "2"; deckOfCards[4+i] = "3"; deckOfCards[8+i] = "4"; deckOfCards[12+i] = "5"; deckOfCards[16+i] = "6"; deckOfCards[20+i] = "7"; deckOfCards[24+i] = "8"; deckOfCards[28+i] = "9"; deckOfCards[32+i] = "10"; deckOfCards[36+i] = "Jack"; deckOfCards[40+i] = "Queen"; deckOfCards[44+i] = "King"; deckOfCards[48+i] = "Ace"; } deckOfCards[52] = "Small Joker"; deckOfCards[53] = "Large Joker"; cb.chatNotice('# of cards: ' + deckOfCards.length); } function selectTipperCard() { tipperCard = Math.floor((Math.random()*53)+1); while (deckOfCards[tipperCard] == "-1") tipperCard = Math.floor((Math.random()*53)+1); cb.chatNotice(last_tip_username + '\'s card: ' + deckOfCards[tipperCard]); countdown = 3; if (tipperCard == 52 || tipperCard == 53) BigWin(); else selectCamCard(); } function selectCamCard() { cardIsBeingDealt = true; if (countdown > 0) { setTimeout(function(){selectCamCard()},1000); cb.chatNotice('Selecting my card in ' + countdown + '...'); countdown--; } else { camCard = Math.floor((Math.random()*51)+1); while (deckOfCards[camCard] == "-1") camCard = Math.floor((Math.random()*51)+1); cb.chatNotice('My card: ' + deckOfCards[camCard]); CheckIfWinner(); } } function CheckIfWinner() { var tipperValue = tipperCard / 4; var camValue = camCard / 4; deckOfCards[tipperCard] = "-1"; deckOfCards[camCard] = "-1"; if (tipperValue > camValue) // maybe include bonus, if they double the minimum they get an extra point? Win(); else LoseOrTie(); cardIsBeingDealt = false; } function BigWin() { cb.chatNotice('WE HAVE A BIG WINNER'); deckOfCards[tipperCard] = "-1"; lastResult = "Joker found!"; if (tipperCard == 52) cb.chatNotice(last_tip_username + ' wins (a) ' + cb.settings.Small_Joker_Prize); if (tipperCard == 53) cb.chatNotice(last_tip_username + ' wins (a) ' + cb.settings.Large_Joker_Prize); CountNumberOfCardsLeft(); } function Win() { lastResult = "Win!"; cb.chatNotice('Congrats! ' + last_tip_username + ' beat me!'); CountNumberOfCardsLeft(); } function LoseOrTie() { lastResult = "Loss!"; cb.chatNotice('Sorry, ' + last_tip_username + ' lost or tied.'); CountNumberOfCardsLeft(); } function CountNumberOfCardsLeft() { numOfCardsLeft = 0; for (var i = 0; i < 52; i++) { if (deckOfCards[i] != "-1") numOfCardsLeft++; } numOfJokersLeft = 0; if (deckOfCards[52] != "-1") numOfJokersLeft++; if (deckOfCards[53] != "-1") numOfJokersLeft++; if (numOfCardsLeft <= 0) cb.chatNotice('Not enough cards to continue, please reset app to start over.'); update_App(); update_App(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.