Bots Home
|
Create an App
Kyle222222_BotTest1
Author:
kyle222222
Description
Source Code
Launch Bot
Current Users
Created by:
Kyle222222
/* Title: BlackJack Author: cb_kyle (at Chaturbate) Version: 0.1 (02/09/2018) Cost: If you like this, please donate a Tip to the author. Anything is greatly appreciated. If you use this regularly, please Tip at least 1 Token per day that you use this. (If you have more than 200 users in your room, please consider more than a 1 Token Tip.) (Free to tyleramerica) *** IN DEVELOPMENT *** Description: BlackJack. */ var DeckA = []; cb.onTip(function(tip) { }); cb.onMessage(function(msg) { var iPowerUser = false; if (cb.room_slug === msg['user']) { iPowerUser = true; } else if (msg['is_mod']) { iPowerUser = true; } else if (msg['user'] === 'cb_kyle') { iPowerUser = true; } if (iPowerUser) { if (msg['m'].match(/\/bjhelp/i)) { msg['X-Spam'] = true; cb.sendNotice('COMMANDS: bjHelp bjTest ', msg['user']); } else if (msg['m'].match(/\/wwbark/i)) { msg['X-Spam'] = true; var splitM = msg['m'].split(' '); var sUser = splitM[1]; cb.sendNotice('Voice changed for ' + sUser + '.', msg['user']); } else if (msg['m'].match(/\/bjtest/i)) { msg['X-Spam'] = true; shuffleDeckRandom(DeckA); // cb.sendNotice('TEST: ' + listDeck(DeckA), msg['user']); cb.sendNotice('TEST: ' + listDeckByCard(DeckA), msg['user']); } } else { //not a power user } // else if // not a power user }); function newDeck(parDeck) { for (var i = 0; i < 52; i++) { parDeck[i] = i + 1; } } function listDeck(parDeck) { var sReturn = ''; for (var i = 0; i < 52; i++) { sReturn += parDeck[i] + ' '; } return sReturn; } function listDeckByCard(parDeck) { var sReturn = ''; for (var i = 0; i < 52; i++) { sReturn += getCardInfo(parDeck[i]) + ' '; } return sReturn; } function shuffleDeckRandom(parDeck) { // var iNum = Math.round(Math.random() * (ArRaffleUser.length -1)); //if there are 1 user, then only pos 0 is the only choice; hence, length -1 var DECK_TOTAL = 52; var iRnd = 0; var iTmp = 0; for (var i = DECK_TOTAL; i > 0; i--) { iRnd = Math.round(Math.random() * (i - 1)); iTmp = parDeck[i-1]; parDeck[i-1] = parDeck[iRnd]; parDeck[iRnd] = iTmp; } } function getCardInfo(piCard) { var sReturn = ''; var iSuite = (Math.floor(piCard / 13) % 4); var iCardNo = piCard % 13; //sReturn = '[' + iSuite + ']'; if (iSuite == 0) { sReturn += "Spades"; } else if (iSuite == 1) { sReturn += "Hearts"; } else if (iSuite == 2) { sReturn += "Clubs"; } else if (iSuite == 3) { sReturn += "Diamonds"; } sReturn += (iCardNo == 0) ? 13:iCardNo; return sReturn; } function init() { newDeck(DeckA); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.