Bots Home
|
Create an App
cb_api
Author:
airapsi
Description
Source Code
Launch Bot
Current Users
Created by:
Airapsi
cb.settings_choices = [ {name:'draw_tip_amount', type:'int', minValue:10, maxValue:666, defaultValue:123, label: "Tokens per Draw"}, {name:'new_deck_amount', type:'int', minValue:246, maxValue:1312, defaultValue:246, label: "Tokens for a new Deck"}, {name:'keep_losers', type:'choice', choice1:'YES', choice2:'NO', defaultValue: 'NO', label: "Keep Losers in Deck, puts the losers back after a Draw"}, {name:'keep_winners', type:'choice', choice1:'YES', choice2:'NO', defaultValue: 'NO', label: "Keep Winners in Deck, puts the winners back after a Draw"}, {name:'minimum_tip_amount_to_draw', type:'int', minValue:333, maxValue:666, defaultValue:666, label: "How much people who dont quallify, no club members ect, have to tip before able to draw a card"}, ]; const fulldeck = [ {Name: "Joker"},{Name: "Joker"}, {Name: "Ace of Spades"}, {Name: "King of Spades"}, {Name: "Queen of Spades"}, {Name: "Jack of Spades"}, {Name: "10 of Spades"}, {Name: "9 of Spades"}, {Name: "8 of Spades"}, {Name: "7 of Spades"}, {Name: "6 of Spades"}, {Name: "5 of Spades"}, {Name: "4 of Spades"}, {Name: "3 of Spades"}, {Name: "2 of Spades"}, {Name: "Ace of Hearts"}, {Name: "King of Hearts"}, {Name: "Queen of Hearts"}, {Name: "Jack of Hearts"}, {Name: "10 of Hearts"}, {Name: "9 of Hearts"}, {Name: "8 of Hearts"}, {Name: "7 of Hearts"}, {Name: "6 of Hearts"}, {Name: "5 of Hearts"}, {Name: "4 of Hearts"}, {Name: "3 of Hearts"}, {Name: "2 of Hearts"}, {Name: "Ace of Diamonds"}, {Name: "King of Diamonds"}, {Name: "Queen of Diamonds"}, {Name: "Jack of Diamonds"}, {Name: "10 of Diamonds"}, {Name: "9 of Diamonds"}, {Name: "8 of Diamonds"}, {Name: "7 of Diamonds"}, {Name: "6 of Diamonds"}, {Name: "5 of Diamonds"}, {Name: "4 of Diamonds"}, {Name: "3 of Diamonds"}, {Name: "2 of Diamonds"}, {Name: "Ace of Clubs"}, {Name: "King of Clubs"}, {Name: "Queen of Clubs"}, {Name: "Jack of Clubs"}, {Name: "10 of Clubs"}, {Name: "9 of Clubs"}, {Name: "8 of Clubs"}, {Name: "7 of Clubs"}, {Name: "6 of Clubs"}, {Name: "5 of Clubs"}, {Name: "4 of Clubs"}, {Name: "3 of Clubs"}, {Name: "2 of Clubs"}, ]; const deck = fulldeck; const valueCards = new Array(); const members = new Array(); const tippers = new Array(); const players = ["airapsi"]; const banks = new Array(); const activeCards = new Array(); const allCards = new Array(); const drawCardAmount = 123; const minTippedToDraw = 666; const keepDrawsInDeck = false; cb.onMessage(function(msg){ var content = msg['m']; var user = msg['user']; if( players.indexOf(user) > -1 || members.indexOf(user) > -1){ if(content.indexOf('/showbank') > -1 && banks[user] !== undefined){ let message = ""; for(var i = 0; i < banks[user].length; i++){ message += banks[user][i]; message += "\n"; } if(message.length === 0){ message = "I'm sorry but your bank seems empty"; } else { message = "You have the following items in Your Bank:\n" + message + "to use them type /use <card-name> for example \"/use 7\" to use one of your banked sevens"; } cb.sendNotice(message, user); } if(content.indexOf('/use') === 0 && banks[user] !== undefined){ let item = content.replace('/use', '').trim(); if(item.length > 0){ if( allCards.indexOf(item) > -1){ if( banks[user].indexOf(item) > -1){ banks[user][ banks[user].indexOf(item)] = null; activeCards.push({user: user, card: item}); cb.sendNotice(user + " activated his " +item, ''); }else{ //TODO: ADD TOKEN AMOUNT cb.sendNotice("you dont have such a card banked, try to draw it right now for just", user); } } else{ cb.sendNotice("the given name doesnt seem right, maybe you missspelled it", user); } }else{ cb.sendNotice("it seems you forgot to name your card, which you wanne play", user); } } } if( activeCards[user] !== undefined){ } }); cb.onTip(function(msg){ var amount = parseInt(msg['amount']); var user = msg['from_user']; let tippedEnough = true; if( tippers[user] === undefined){ tippers[user] = 0; } if( tippers[user] < minTippedToDraw){ tippedEnough = false; } if(amount === drawCardAmount && ( tippers[user] > minTippedToDraw || members.indexOf(user) > -1)){ shuffelCards(); var card = drawCard(); if( hasValue(card)){ if( banks[user] === undefined){ banks[user] = []; } banks[user].push(card); cb.sendNotice((user + "did draw a " + card.Name ), ""); cb.sendNotice((card.Name + " was added to your bank, to use it just type /use "+card.Name), user); }else{ cb.sendNotice((user + "did draw a " + card.Name + "but we all know thats worth nothing... More luck next time ;)"), ""); } }else{ tippers[user]+= amount; if( tippers[user] > minTippedToDraw && !tippedEnough){ cb.sendNotice("Hello "+user+", i have a special offer for you, since you tipped quite a sum already i let you participate in our exclusive game for today!", user); cb.sendNotice("If you tip me with "+ drawCardAmount+" Tokens, you will get the chance to draw a card. Which might give you the ultimate power over my show, for more information type /tellmemore in the chat", user); } } }); function hasValue(card){ return valueCards.findIndex(x => x.Name === card.Name) > -1; } function shuffelCards(){ let counter = deck.length; while(counter > 0){ let index = Math.floor(Math.random() * counter); counter--; let temp = deck[counter]; deck[counter] = deck[index]; deck[index] = temp; } } function drawCard(){ let index = Math.floor(Math.random() * deck.length); console.log(index); var card = deck[index]; return card; } function shuffelAndDraw(){ console.log( deck); shuffelCards(); shuffelCards(); shuffelCards(); console.log( drawCard()); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.