Apps Home
|
Create an App
r3rwefwead
Author:
eberk123
Description
Source Code
Launch App
Current Users
Created by:
Eberk123
/* ******************************************************* * Title: KarenJackpot * Author: Ryan * ******************************************************* */ // vars var gTotalTipToday = 0; var gHighTipUsername = null; var gHighTipAmount = 0; var last_tip_username = null; var TIME_ONE_SEC = 1000; var TIME_ONE_MINUTE = 60 * TIME_ONE_SEC; var CONFIG_ADVERT_MINUTES = 1 * TIME_ONE_MINUTE; var EMOTE_STAR = ' :star_olivia_dellvine '; var EMOTE_STARS = EMOTE_STAR + EMOTE_STAR + EMOTE_STAR; var gHashTag = ' #karen #dice #cute #shy #sexy #hot #bigroundeye #beautiful #flash #pvt'; var gSetJackpotGoalCommand = '/setgoal'; var gOptOutList = new Array(); var gIsSale = false; var gMenuTipping = true; var gSpecialUser = 'crazytipper123'; // KarenGoal specific stuff that are constant var gRarePrizeIncrementRate = 1.28; // rate at which rare prize chance increases var gInitialRarePrizeChance = 1; // initial chance in % at which rare prize occurs var gGoalTarget = 9; // how much token for goal var gCasinoGoalMinRequirement = 150; // indicate how much token before a goal is even possible var gMinRarePrizeBeforeLowChance = 1; // min rare prize in one tip before we dont increase probability of it occurring var gMaxRarePrizeBeforeLowChance = 1; // max rare prize in one tip before we dont increase probability of it occurring var gIsJackpotWon = false; // to ensure we only take one jackpot for each batch of tip var gJackpotEnabled = false; // whether it is even possible to win jackpot var gJackpotUsingSelectedWinner = false; // whether only selected people can win jackpot var gPrizePoolMultiplier = 0.5; // commands var gJackpotAddNameCommand = '/jackpotadd'; var gCasinoBuyCommand = '/buy'; var gCasinoMinPrizeCommand = '/setprizemin'; var gCasinoPrizeMultiplierCommand = '/setmultiplier'; // how much price win rate increases each time we fail var gCasinoPoolMultiplierCommand = '/setpoolmultiplier'; // how much relative to tip should we increase our pool var gRouletteCommand = '/roulette'; // used to join roulette game (or leave) var gRouletteHelpCommand = '/roulettehelp'; // display help command for roulette var gRouletteSetTimerCommand = '/setroulettetimer'; // set roulette round time var gCasinoBetCommand = '/bet'; // set our bets var gCasinoAddChipCommand = '/addchip'; // add chip to user var gCasinoRemoveChipCommand = '/removechip'; // remove chip to user var gCasinoGiveChipCommand = '/givechip'; // give chip to user (affects our winning) // KarenGoal specific stuff that changes over time var gCurrentRarePrizeChance = 0; var gCurrentGoalTarget = 0; var gGoalPoolSinceRare = 0; // indicate the amount of token since the last rare prize var gJackpotPossibleWinner = new Array(); // the list of people who can possibly win var gJackpotPool = 0; // NOTE: if user opt out from prizes, their tip doesnt get added into tip jar // requires resetting too var playerStats = {}; var gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; var gCurrentCommandArg = new Array(); // i'm abusing global variable here, this is used to store current command argument (only valid during command parsing) // you need to populate this, refer to init() for more information var gAdvertInformation = new Array(); var gCommandInformation = new Array(); var gRarePrizeList = new Array(); // indicate the cost to purchase chip var gCasinoChipCost = [ 15, 150 ]; var gCasinoPlayerBets = new Array(); // indicate the bets for the player var gCasinoMinBet = 1; // the default bet value for all players var gCasinoEarning = 0; // track our total earning, also ensure house edge var gCasinoTrueEarning = 0; // track our true casino earning var gCasinoWallets = new Array(); // contain information of chips held by all casino player // roulette related var gRoulettePlayers = new Array(); // track the players in roulette game (roulette announcement is only made to them) var gRoulettePayouts = new Array(); // numbered from 0 to 36, indicates the payout for each roulette roll and the payout for each user var gRouletteStraightCommand = '/straight'; var gRouletteTimerCurrent = 0; var gRouletteTimerInitial = 30; var gRouletteRedNumbers = [ 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36 ]; var gRouletteBlackNumbers = [ 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35 ]; var gViewerRouletteCommands = [ { command: '/odd', helpText: 'bet on odd numbers (1, 3, 5.... 35), payout 1:1', func: handleRouletteOddCommand }, { command: '/even', helpText: 'bet on even numbers (2, 4, 6.... 36), payout 1:1 NOTE: 0 is not considered for this bet', func: handleRouletteEvenCommand }, { command: '/low', helpText: 'bet on lower half numbers (1 to 18), payout 1:1', func: handleRouletteLowCommand }, { command: '/high', helpText: 'bet on upper half numbers (19 to 36), payout 1:1', func: handleRouletteHighCommand }, { command: '/doz1', helpText: 'bet on 1 to 12, payout 2:1', func: handleRouletteDozen1Command }, { command: '/doz2', helpText: 'bet on 13 to 24, payout 2:1', func: handleRouletteDozen2Command }, { command: '/doz3', helpText: 'bet on 25 to 36, payout 2:1', func: handleRouletteDozen3Command }, { command: '/col1', helpText: 'bet on (1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34), payout 2:1', func: handleRouletteColumn1Command }, { command: '/col2', helpText: 'bet on (2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35), payout 2:1', func: handleRouletteColumn2Command }, { command: '/col3', helpText: 'bet on (3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36), payout 2:1', func: handleRouletteColumn3Command }, { command: '/red', helpText: 'bet on red numbers (refer to roulette image for exact number), payout 1:1', func: handleRouletteRedCommand }, { command: '/black', helpText: 'bet on black numbers (refer to roulette image for exact number), payout 1:1', func: handleRouletteBlackCommand }, { command: gRouletteStraightCommand, helpText: 'bet on a single number (0 to 36), payout 35:1', func: handleRouletteStraightCommand } ]; function InitRoulettePayouts() { for(var i = 0; i < 37; ++i) { gRoulettePayouts.push( { totalPayouts: 0, individualPayouts: new Array() } ); } } var gPossibleRarePrizeList = [ {text:"Top off for 5 minutes", frequency:"0"}, {text:"Bottom off for 5 minutes", frequency:"0"}, {text:"Flash ass", frequency:"5"}, {text:"Play Right Boob", frequency:"3"}, {text:"Play Left Boob", frequency:"3"}, {text:"Play Boobs", frequency:"1"}, {text:"Pull Nipples", frequency:"1"}, {text:"Closeup on Boobs", frequency:"1"}, {text:"Play Boobs", frequency:"1"}, {text:"Spank Ass", frequency:"1"}, {text:"Twerk Ass", frequency:"1"}, {text:"Flash Pussy", frequency:"1"}, {text:"Jump 5 times without bra", frequency:"1"}, {text:"Triple Flash", frequency:"1"} ]; var gGiftMenuContainer = [ {text:"Send Karen :rose888", cost:5, sale:5}, {text:"Send Karen :bouquetredroses", cost:25, sale:25} ]; var gFlashMenuContainer = [ {text:"Triple Flash", cost:299, sale:299}, {text:"Flash Pussy", cost:199, sale:199}, {text:"Spank Ass", cost:139, sale:139}, {text:"Boob Close Up", cost:125, sale:125}, {text:"Play Boob", cost:100, sale:100}, {text:"Twerk Ass", cost:89, sale:89}, {text:"Play Left Boob", cost:70, sale:70}, {text:"Play Right Boob", cost:69, sale:69}, {text:"Flash Ass", cost:50, sale:50} ]; var gKarenMenuContainer = [ {text:"15 casino chips", cost:15, sale:15}, {text:"Stay Nude 10 min", cost:999, sale:999}, {text:"Panties off for 10 min", cost:799, sale:799}, {text:"Bra off for 10 min", cost:599, sale:599} ]; var gRequestMenuContainer = [ {text:"Smile", cost:10, sale:10}, {text:"PM", cost:11, sale:11}, {text:"Song Request", cost:29, sale:29}, {text:"c2c 5 min", cost:35, sale:35}, {text:"Short Dance", cost:135, sale:135}, {text:"Allow Private Recording", cost:500, sale:500}, {text:"Kik/Email", cost:1000, sale:1000}, {text:"20 min Password Show", cost:2999, sale:2999} ]; var gMenuContainer = [ {menu:gKarenMenuContainer, text:"Special"}, {menu:gFlashMenuContainer, text:"Flash"}, {menu:gRequestMenuContainer, text:"Request"}, {menu:gGiftMenuContainer, text:"Gifts"} ]; var gLovenseLevelContainer = [ {text:"Tiny Vibration", cost:1}, {text:"Small Vibration", cost:15}, {text:"Strong Vibration", cost:100}, {text:"Pleasure!!!", cost:500}, {text:"Ultimate Pleasure!!!", cost:1000}, {text:":pulsepattern Pattern", cost:101}, {text:":wavepattern Pattern", cost:201} ]; /* SETTINGS */ cb.settings_choices = new Array(); /* ON TIP */ cb.onTip(function (tip) { last_tip_username = tip['from_user']; gTotalTipToday += tip['amount']; if(tip['amount'] > gHighTipAmount) { gHighTipAmount = tip['amount']; gHighTipUsername = tip['from_user']; } //IncrementAdvertMessagesCount(); if (last_tip_username in playerStats) { playerStats[last_tip_username].totaltips += tip['amount'] } else { playerStats[last_tip_username] = { totaltips: tip['amount'] } } // update tip statistic trackTips(last_tip_username, tip['amount']); if(inArray(last_tip_username, gOptOutList)) { notify(last_tip_username + ' opt out from prizes, tips will be ignored, type \'/opt\' to opt in/out from prizes'); } else { gIsJackpotWon = false; handleGoalTipping(tip['amount'], last_tip_username); // if jackpot is won if(gIsJackpotWon) { if(!(tip['from_user'] in gCasinoWallets)) { gCasinoWallets[tip['from_user']] = { chips: 0 // amount held in wallet } } gCasinoWallets[tip['from_user']].chips += gJackpotPool; notify(EMOTE_STARS + 'JACKPOT!!!!' + EMOTE_STARS + tip['from_user'] + ' won ' + gJackpotPool + ' chips'); gJackpotPool = 0; // reset our pool each time jackpot is won } } if(gMenuTipping) { handleTipMenu(tip['amount'], last_tip_username, false); } handleChipPurchase(tip['amount'], last_tip_username); cb.drawPanel(); }); // add chip to user account function CasinoChipAdd(chipAmount, user) { if(!(user in gCasinoWallets)) { gCasinoWallets[user] = { chips: 0 } } gCasinoWallets[user].chips += chipAmount; notify(chipAmount + ' chips was added to your account. Current balance: ' + gCasinoWallets[user].chips, user, '#FFFFFF', '#A569BD'); notify(chipAmount + ' chips was added to ' + user + ' account. Current balance: ' + gCasinoWallets[user].chips, gSpecialUser, '#FFFFFF', '#A569BD'); } // used to subtract chip from user account // also ensure we don't go below 0 and meet the minimum amount // NOTE: if we don't meet the minimum amount, -1 will be returned, as the amount that was subtracted will be returned function CasinoChipRemove(chipAmount, user, minBet) { var hasEnough = false; // ensure user has top up before if(user in gCasinoWallets) { // ensure we meet the minimum bet amount if(gCasinoWallets[user].chips >= minBet) { hasEnough = true; // ensure if user bet say 10, but only has 8, we only use 8 as the bet if(gCasinoWallets[user].chips < chipAmount) { chipAmount = gCasinoWallets[user].chips; } gCasinoWallets[user].chips -= chipAmount; notify(chipAmount + ' chips was removed from your account. Current balance: ' + gCasinoWallets[user].chips + ' chips', user, '#FFFFFF', '#A569BD'); notify(chipAmount + ' chips was removed from ' + user + ' account. Current balance: ' + gCasinoWallets[user].chips + ' chips', gSpecialUser, '#FFFFFF', '#A569BD'); } } return hasEnough? chipAmount: -1; } function handleChipPurchase(tip, user) { for(var i = 0; i < gCasinoChipCost.length; ++i) { if(tip == gCasinoChipCost[i]) { CasinoChipAdd(tip, user); // add chips to player wallet break; } } } function getTipMenuText() { // tip menu! var finalMessage = ""; var saleMessage = "Sale Menu: "; if(gMenuTipping) { for(var i = 0; i < gMenuContainer.length; ++i) { finalMessage += gMenuContainer[i].text + ': '; for(var j = 0; j < gMenuContainer[i].menu.length; ++j) { if(gIsSale && gMenuContainer[i].menu[j].sale != gMenuContainer[i].menu[j].cost) { saleMessage += gMenuContainer[i].menu[j].text + ' (' + gMenuContainer[i].menu[j].sale + ' Token, original price ' + gMenuContainer[i].menu[j].cost + ') ' + ':pixelheart '; } else { finalMessage += gMenuContainer[i].menu[j].text + ' (' + gMenuContainer[i].menu[j].cost + ' Token) ' + ':pixelheart '; } } finalMessage += '\n'; } } return gIsSale? saleMessage + '\n' + finalMessage: finalMessage; } // note: only usable for array of pair with text and cost and sale function getTextFromCostWithSale(cost, arrayPair) { if(arrayPair) { for(var i = 0; i < arrayPair.length; ++i) { if((gIsSale && arrayPair[i].sale == cost) || arrayPair[i].cost == cost) { return arrayPair[i].text; } } } return ''; } function getTipPrize(currentTip) { var prize = ''; for(var i = 0; i < gMenuContainer.length; ++i) { prize = getTextFromCostWithSale(currentTip, gMenuContainer[i].menu); if(prize != '') { return prize; } } return prize; } function handleTipMenu(currentTip, user, isCasino) { // first check if it's inside our menu list var text = getTipPrize(currentTip); // only display notification if there's a valid tip menu if(text != null && text != '') { if(isCasino) { // if it's part of the menu, display the appropriate text cb.sendNotice(user + ' exchanged casino winning for ' + text, '', '#FFFFFF', '#FF0000', 'bold'); } else { // if it's part of the menu, display the appropriate text cb.sendNotice(user + ' tipped for ' + text, '', '#FFFFFF', '#FF0000', 'bold'); } } else if(isCasino) { cb.sendNotice(user + ' gift Karen ' + text + ' chips', '#FFFFFF', '#FF0000', 'bold'); } } /* DRAW PANEL */ cb.onDrawPanel(function (user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Token to Goal:', 'row1_value': (gGoalTarget - gCurrentGoalTarget), 'row2_label': 'Chance for Rare Prize:', 'row2_value': gCurrentRarePrizeChance.toFixed(2) + '%', 'row3_label': 'Jackpot Pool:', 'row3_value': gJackpotPool + ' Chips' } }); /* START OF GAME SPECIFIC FUNCTION */ function updateSubject() { var newSubject = ''; newSubject += (gGoalTarget - gCurrentGoalTarget) + ' Token to roll for a rare prize or chance for jackpot!'; newSubject += gHashTag; cb.changeRoomSubject(newSubject) } function handleGoalTipping(tipAmount, user) { gCurrentGoalTarget += tipAmount; gGoalPoolSinceRare += tipAmount; var rarePrizeWonCount = 0; var goalMetCount = 0; // first we randomize the max number of rare prize we can have in this roll so it doesnt look so 'fixed' that its always a max of 5 prize var maxRarePrizeForThisTip = Math.floor(Math.random() * (gMaxRarePrizeBeforeLowChance - gMinRarePrizeBeforeLowChance)) + gMinRarePrizeBeforeLowChance; // looping disabled now if(gCurrentGoalTarget >= gGoalTarget) { ++goalMetCount; // track how many times we met the goal var rolledChance = Math.random() * 100; //var debugText = 'rolled: ' + rolledChance + '% require ' + gCurrentRarePrizeChance + '%'; //notify(debugText); // test for rare // ensure we meet a min amount before rare prize is even possible if(gGoalPoolSinceRare >= gCasinoGoalMinRequirement && rolledChance < gCurrentRarePrizeChance) { ++rarePrizeWonCount; gGoalPoolSinceRare = 0; // reset // now pick something from rare prize pool GetRarePrize('Polka_Jackpot: ' + EMOTE_STARS + user + EMOTE_STARS + ' - Rare Prize won: ', user); gCurrentRarePrizeChance = gInitialRarePrizeChance; // we want to reset it each time we get a rare prize } // since we didn't get a rare prize, we increment the chance for it instead // NOTE: if we already won enough rare prize on this tip, we dont bother incrementing the chance of success else if(rarePrizeWonCount < maxRarePrizeForThisTip) { gCurrentRarePrizeChance *= gRarePrizeIncrementRate; } gCurrentGoalTarget = 0;//-= gGoalTarget; gJackpotPool += gGoalTarget; } if(rarePrizeWonCount == 0 && goalMetCount != 0) { notify('Polka_Jackpot: Sorry ' + user + ' no prize won, try again!'); } updateSubject(); cb.drawPanel(); } function GetRarePrize(text, user) { // ensure jackpot is enabled first and that it is possible to win jackpot if(gJackpotEnabled) { var found = false; // if using only selected winner, ensure user is inside the list before we accept it for jackpot if(gJackpotUsingSelectedWinner) { for(var i = 0; i < gJackpotPossibleWinner.length; ++i) { if(gJackpotPossibleWinner[i] == user) { found = true; break; } } } else { found = true; } if(found) { gIsJackpotWon = true; gJackpotEnabled = false; // automatically turns it off again } } var currentPrize = getPrizeFromPrizeList(gRarePrizeList, gPossibleRarePrizeList); // display the prize that we won notify(text + currentPrize); } function getPrizeFromPrizeList(prizeList, possiblePrizeList) { // if empty, we repopulate the list first if(prizeList.length == 0) { for(var i = 0; i < possiblePrizeList.length; ++i) { for(var j = 0; j < possiblePrizeList[i].frequency; ++j) { prizeList.push(possiblePrizeList[i].text); } } } // fetch from the prize list (guaranteed to have something so don't bother checking) var randIndex = Math.floor(Math.random() * (prizeList.length - 1)); var currentPrize = prizeList[randIndex]; // remove it from the prize list prizeList.splice(randIndex, 1); return currentPrize; } /* Initialization */ function init() { // don't initialize if it's invalid user if(!( cb.room_slug == 'polka_lv' || cb.room_slug == 'raccoon_pig' || cb.room_slug == 'raccoonpig' || cb.room_slug == 'eberk123' || cb.room_slug == 'crazytipper123' || cb.room_slug == 'eberk321')) { return; } // this ensure app restart doesn't screw up gHighTipUsername = null; gHighTipAmount = 0; last_tip_username = null; gCurrentRarePrizeChance = gInitialRarePrizeChance; gCurrentGoalTarget = 0; // you need to populate this gAdvertInformation = new Array(); gCommandInformation = new Array(); gRarePrizeList = new Array(); playerStats = {}; gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; initCommand(); InitRoulettePayouts(); // initialize our required information for notification // it's given in a key value pair where key refers to the function to trigger the notification // intialTimer refers to the initial timer before it's fired // periodicTimer refers to the periodic timer after the first firing // minMsgCount refers to the minimum number of messages before the message can fire (this prevent us from spamming the room when no one is typing) // maxNoFireCount refers to the max number of time we can avoid firing the notification before we will force it to fire gAdvertInformation[advertGamerules] = { initialTimer: 0.1 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 0, maxNoFireCount: 11}; gAdvertInformation[advertTipMenu] = { initialTimer: CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 5, maxNoFireCount: 6 }; gAdvertInformation[advertLeaderboard] = { initialTimer: 0.5 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 0, maxNoFireCount: 23 }; gAdvertInformation[advertRouletteUpdate] = { initialTimer: TIME_ONE_SEC, periodicTimer: TIME_ONE_SEC, minMsgCount: 0, maxNoFireCount: 0 }; // start our periodic timer // automatically initialize those required variable, this is basically constructor in c++ class for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { gAdvertInformation[key].currentMsgCount = 0; // number of msg we have seen since we last fire it gAdvertInformation[key].missedFireCount = gAdvertInformation[key].maxNoFireCount; // number of time we skipped firing the messages (set to max to ensure it's fired) } } cb.setTimeout(advertRouletteUpdate, gAdvertInformation[advertRouletteUpdate].initialTimer); cb.setTimeout(advertLeaderboard, gAdvertInformation[advertLeaderboard].initialTimer); cb.setTimeout(advertGamerules, gAdvertInformation[advertGamerules].initialTimer); cb.setTimeout(advertTipMenu, gAdvertInformation[advertTipMenu].initialTimer); cb.drawPanel(); } init(); var gRouletteSetTimerCommand = '/setroulettetimer'; // set roulette round time /* Helper function */ function initCommand() { gCommandInformation = new Array(); // initialize our command information // public command gCommandInformation['/help'] = { callBackFcn: handleHelpCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display all available command in KarenKeno' }; gCommandInformation['/prize'] = { callBackFcn: handlePrizeCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display all possible karen jackpot possible prize list' }; gCommandInformation['/leaderboard'] = { callBackFcn: handleLeaderBoardCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'display KarenKeno Leaderboard' }; gCommandInformation['/opt'] = { callBackFcn: handleOptCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Opt in or out of prize' }; gCommandInformation['/chips'] = { callBackFcn: handleChipCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Display chips and what you can do with it' }; gCommandInformation['/chip'] = { callBackFcn: handleChipCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Display chips and what you can do with it' }; gCommandInformation[gCasinoBuyCommand] = { callBackFcn: handleBuyCommand, userGroupCallBackFcn: checkIsViewer, helpText: gCasinoBuyCommand + ' <amount> is the same as tipping <amount> of token for menu item' }; gCommandInformation[gRouletteCommand] = { callBackFcn: handleRouletteCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Join or leave roulette table' }; gCommandInformation[gCasinoBetCommand] = { callBackFcn: handleBetCommand, userGroupCallBackFcn: checkIsViewer, helpText: gCasinoBetCommand + ' <amount> is the amount to set for future bets' }; gCommandInformation[gRouletteHelpCommand] = { callBackFcn: handleRouletteHelpCommand, userGroupCallBackFcn: checkIsViewer, helpText: 'Display command related to roulette' }; // add all public roulette command for(var i = 0; i < gViewerRouletteCommands.length; ++i) { gCommandInformation[gViewerRouletteCommands[i].command] = { callBackFcn: gViewerRouletteCommands[i].func, userGroupCallBackFcn: checkIsViewer, helpText:gViewerRouletteCommands[i].helpText }; } // privilege user command gCommandInformation['/helpall'] = { callBackFcn: handleHelpCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /help to everyone' }; gCommandInformation['/prizeall'] = { callBackFcn: handlePrizeCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /prize to everyone' }; gCommandInformation['/leaderboardall'] = { callBackFcn: handleLeaderBoardCommandAll, userGroupCallBackFcn: checkHasPrivileges, helpText: 'send /leaderboard to everyone' }; // host command gCommandInformation['/totaltoken'] = { callBackFcn: handleTotalTokenCommand, userGroupCallBackFcn: checkIsHost, helpText: 'show total token gained so far' }; gCommandInformation['/togglejackpot'] = { callBackFcn: handleJackpotCommand, userGroupCallBackFcn: checkIsHost, helpText: 'toggle whether to use jackpot'}; gCommandInformation['/togglejackpotlist'] = { callBackFcn: handleJackpotListCommand, userGroupCallBackFcn: checkIsHost, helpText: 'toggle whether to allow jackpot for special user' }; gCommandInformation['/casinowallets'] = { callBackFcn: handleCasinoWalletCommand, userGroupCallBackFcn: checkIsHost, helpText: 'show wallet of all user' }; gCommandInformation[gJackpotAddNameCommand] = { callBackFcn: handleAddNameCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Add name to jackpot list' }; gCommandInformation[gCasinoMinPrizeCommand] = { callBackFcn: handleMinPrizeCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Change the minimum pool before prize is possible' }; gCommandInformation[gCasinoPrizeMultiplierCommand] = { callBackFcn: handlePrizeMultiplierCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Change prize chance multiplier' }; gCommandInformation[gCasinoPoolMultiplierCommand] = { callBackFcn: handlePoolMultiplierCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Change percentage of tip that is added to pool' }; gCommandInformation[gRouletteSetTimerCommand] = { callBackFcn: handleSetRouletteTimerCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Set timer' }; gCommandInformation['/casinoearning'] = { callBackFcn: handleShowCasinoEarning, userGroupCallBackFcn: checkIsHost, helpText: 'Show casino earning' }; gCommandInformation['/resetcasinoearning'] = { callBackFcn: handleResetCasinoEarning, userGroupCallBackFcn: checkIsHost, helpText: 'Reset casino earning' }; gCommandInformation['/savecasinowallet'] = { callBackFcn: handleSaveCasinoWallet, userGroupCallBackFcn: checkIsHost, helpText: 'Save our casino wallet' }; gCommandInformation[gCasinoAddChipCommand] = { callBackFcn: handleAddChipCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Add chip to user account' }; gCommandInformation[gCasinoRemoveChipCommand] = { callBackFcn: handleRemoveChipCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Remove chip from user account' }; gCommandInformation[gCasinoGiveChipCommand] = { callBackFcn: handleGiveChipCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Give chip to user account (affect earning)' }; gCommandInformation['/tipmenu'] = { callBackFcn: handleBroadcastTipMenuCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Broadcast tip menu' }; getTipMenuText gCommandInformation[gSetJackpotGoalCommand] = { callBackFcn: handleGoalTargetCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetJackpotGoalCommand + ' <new_amount>\' will change our goal target to a new_amount of token' }; } // recurring advertisement on how to play karen jackpot function advertGamerules() { var text = ':alexcasino3'; text += 'Tip to hit the goal. Each time we hit a goal we will roll for a prize (with chance for jackpot!!!).\n'; text += 'Winner of jackpot will be awarded in chips (which can be used for casino games/purchase tip menu)\n'; text += 'Roulette game is enabled. To join/leave the table, type \'' + gRouletteCommand + '\'\n'; text += 'To purchase more chips, tip ' + gCasinoChipCost[0] + ' or ' + gCasinoChipCost[1] + 'tokens\n'; text += 'Type \'/opt\' to opt in/out from prizes\n\n'; text += 'Type /prize to see the list of prizes\n'; text += 'Type /chips to see how much chip you have\n'; handleAdvertFiring(text, '', '', '', 'bold', advertGamerules); } // recurring advertisement on our current tip menu function advertTipMenu() { handleAdvertFiring(getTipMenuText(), null, '#FFFFFF', '#FF0000', 'bold', advertTipMenu); } function getPrize() { var out = ''; // show rare prize list out += '\nRare Prizes:\n'; for(var i = 0; i < gPossibleRarePrizeList.length; ++i) { out += gPossibleRarePrizeList[i].text + '\n'; } return out; } function handlePrizeCommandAll(msg) { msg['m'] = msg['m'] + " (prize sent to all)"; cb.sendNotice(getPrize()) } function handleGoalTargetCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gSetJackpotGoalCommand.length)); if(newGoalVal != 0) { gGoalTarget = newGoalVal; if(gCurrentGoalTarget > gGoalTarget) { gCurrentGoalTarget = gGoalTarget - 1; } // everytime we update this we need to update subject and drawboard cb.drawPanel(); updateSubject(); } else { notify('Use only integer for goal', 'roomHost'); } } function RoulettePlaceBet(user) { // start from min bet var bets = -1; if(user in gCasinoWallets) { // obtain user bet if there is any else use default if(user in gCasinoPlayerBets) { bets = gCasinoPlayerBets[user]; } else { bets = gCasinoMinBet; } bets = CasinoChipRemove(bets, user, gCasinoMinBet); // update player wallet if(bets != -1) { gCasinoTrueEarning += bets; // never ever resetted gCasinoEarning += bets; // update the amount we earn from casino (used to ensure house edge) } } if(bets == -1) { notify('You need a minimum of ' + gCasinoMinBet + ' chips to make any bets on Roulette, purchase more chips to place your bet. Type \'/chips\' to view current balance'); } return bets; } // when we reach this point, we assume the bet is valid and we just update the payout // use RoulettePlaceBet to ensure we have enough to place our bets function RoulettePayoutUpdate(num, user, betMultiplier, bets) { var currentPayout = betMultiplier * bets;; gRoulettePayouts[num].totalPayouts += currentPayout; if(!(user in gRoulettePayouts[num].individualPayouts)) { gRoulettePayouts[num].individualPayouts[user] = { payout: 0 } } notify('Adding ' + currentPayout + ' chips as payout for roulette number ' + num, 'roomHost'); gRoulettePayouts[num].individualPayouts[user].payout += currentPayout; } function SendMessageToRoulettePlayers(msg) { SendMessageToGroup(gRoulettePlayers, '[Roulette]: ' + msg); } function SendMessageToGroup(group, msg) { for(var i = 0; i < group.length; ++i) { notify(msg, group[i], '#FFFFFF', '#58D68D'); } } function handleRouletteStraightCommand(msg) { var text = msg['m']; // first strip out the command then parse it as a integer var num = parseInt(text.substr(gRouletteStraightCommand.length)); if(num > 36) { notify('You can only bet on numbers 0 to 36', msg['user']); } else { var bets = RoulettePlaceBet(user); RoulettePayoutUpdate(num, msg['user'], 36, bets); if(bets > 0) { SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on single number ' + num); } } } function handleRouletteOddCommand(msg) { var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 1; i < 37; ++i) { if(i % 2) { RoulettePayoutUpdate(i, msg['user'], 2, bets); } } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on odd numbers from 1 to 35'); } } function handleRouletteEvenCommand(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 1; i < 37; ++i) { if(!(i % 2)) { RoulettePayoutUpdate(i, msg['user'], 2, bets); } } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on even number from 2 to 36'); } } function handleRouletteLowCommand(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 1; i < 19; ++i) { RoulettePayoutUpdate(i, msg['user'], 2, bets); } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on lower half number (1 to 18)'); } } function handleRouletteHighCommand(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 19; i < 37; ++i) { RoulettePayoutUpdate(i, msg['user'], 2, bets); } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on upper half number (19 to 36)'); } } function handleRouletteDozenCommand(msg, start, end) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = start; i <= end; ++i) { RoulettePayoutUpdate(i, msg['user'], 3, bets); } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on a dozen number (' + start + ' to ' + end + ')'); } } function handleRouletteDozen1Command(msg) { handleRouletteDozenCommand(msg, 1, 12); } function handleRouletteDozen2Command(msg) { handleRouletteDozenCommand(msg, 13, 24); } function handleRouletteDozen3Command(msg) { handleRouletteDozenCommand(msg, 25, 36); } function handleRouletteColumn1Command(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 1; i < 37; i += 3) { RoulettePayoutUpdate(i, msg['user'], 3, bets); } } } function handleRouletteColumn2Command(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 2; i < 37; i += 3) { RoulettePayoutUpdate(i, msg['user'], 3, bets); } } } function handleRouletteColumn3Command(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 3; i < 37; i += 3) { RoulettePayoutUpdate(i, msg['user'], 3, bets); } } } function handleMinPrizeCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gCasinoMinPrizeCommand.length)); if(newGoalVal != 0) { gCasinoGoalMinRequirement = newGoalVal; notify('Casino min pool for prize changed to: ' + gCasinoGoalMinRequirement, 'roomHost', '#FFFFFF', '#FF0000'); } else { notify('Use only integer', 'roomHost'); } } function handleRouletteRedCommand(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 0; i < gRouletteRedNumbers.length; ++i) { RoulettePayoutUpdate(gRouletteRedNumbers[i], msg['user'], 2, bets); } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on a dozen number (' + start + ' to ' + end + ')'); } } function handleRouletteBlackCommand(msg) { var text = msg['m']; var bets = RoulettePlaceBet(msg['user']); if(bets > 0) { for(var i = 0; i < gRouletteBlackNumbers.length; ++i) { RoulettePayoutUpdate(gRouletteBlackNumbers[i], msg['user'], 2, bets); } SendMessageToRoulettePlayers(msg['user'] + ' bet ' + bets + ' chips on a dozen number (' + start + ' to ' + end + ')'); } } function handlePrizeMultiplierCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gCasinoPrizeMultiplierCommand.length)); if(newGoalVal != 0) { gRarePrizeIncrementRate = newGoalVal; notify('Rare prize multiplier changed to: ' + gRarePrizeIncrementRate, 'roomHost', '#FFFFFF', '#FF0000'); } else { notify('Use only integer', 'roomHost'); } } function handlePoolMultiplierCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gCasinoPoolMultiplierCommand.length)); if(newGoalVal != 0) { gPrizePoolMultiplier = newGoalVal; notify('Prize pool multipler changed to: ' + gPrizePoolMultiplier, 'roomHost', '#FFFFFF', '#FF0000'); } else { notify('Use only integer', 'roomHost'); } } function handleSetRouletteTimerCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var newGoalVal = parseInt(text.substr(gRouletteSetTimerCommand.length)); if(newGoalVal != 0) { gRouletteTimerInitial = newGoalVal; notify('Roulette round timer changed to: ' + gRouletteTimerInitial + ' secs', 'roomHost', '#FFFFFF', '#FF0000'); } else { notify('Use only integer', 'roomHost'); } } function handleAddChipCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var inputs = text.substr(gCasinoAddChipCommand.length)['split'](' '); if(inputs.length == 2) { CasinoChipAdd(parseInt(inputs[1]), inputs[0]); } else { notify('Use only integer', 'roomHost'); } } function handleRemoveChipCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var inputs = text.substr(gCasinoRemoveChipCommand.length)['split'](' '); if(inputs.length == 2) { CasinoChipRemove(parseInt(inputs[1]), inputs[0], 1); } else { notify('Use only integer', 'roomHost'); } } // used to randomly reward people in the room function handleGiveChipCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var inputs = text.substr(gCasinoGiveChipCommand.length)['split'](' '); if(inputs.length == 2) { var chipsToGive = parseInt(inputs[1]); if(chipsToGive < gCasinoEarning) { // update our earning since we are giving chips directly gCasinoEarning -= chipsToGive; gCasinoTrueEarning -= chipsToGive; notify('You have won Karen\'s random lucky draw!!!', inputs[0]); CasinoChipAdd(chipsToGive, inputs[0]); } else { notify('Insufficient balance in account to give out tokens', gSpecialUser); } } else { notify('Use only integer', 'roomHost', '#FFFFFF', '#FF0000'); } } function handleShowCasinoEarning(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up notify('Casino earning so far: ' + gCasinoEarning + ' (True earning: ' + gCasinoTrueEarning + ')', 'roomHost', '#FFFFFF', '#FF0000'); } function handleResetCasinoEarning(msg) { gCasinoEarning = 0; notify('Resetting casino earning', 'roomHost', '#FFFFFF', '#FF0000'); } function handleSaveCasinoWallet(msg) { for(var key in gCasinoWallets) { if (gCasinoWallets.hasOwnProperty(key)) { notify('CasinoChipAdd(' + gCasinoWallets[key].chips + ',' + key + ')', msg['user']); } } } function handleJackpotCommand(msg) { gJackpotEnabled = !gJackpotEnabled; notify('JackpotEnabled: ' + gJackpotEnabled, 'roomHost', '#FFFFFF', '#FF0000'); } function handleJackpotListCommand(msg) { gJackpotUsingSelectedWinner = !gJackpotUsingSelectedWinner; notify('JackpotUseSelectedWinner: ' + gJackpotUsingSelectedWinner, 'roomHost', '#FFFFFF', '#FF0000'); } function handleCasinoWalletCommand(msg) { notify('Casino Wallet:', msg['user']); for(var key in gCasinoWallets) { if (gCasinoWallets.hasOwnProperty(key)) { notify(key + ': ' + gCasinoWallets[key].chips + ' chips', msg['user']); } } } function handleAddNameCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var name = text.substr(gJackpotAddNameCommand.length + 1); notify('Adding ' + name + ' to jackpot winner', gSpecialUser); gJackpotPossibleWinner.push(name); } function handleBuyCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var tipAmount = parseInt(text.substr(gCasinoBuyCommand.length)); if(tipAmount != 0) { if(msg['user'] in gCasinoWallets) { if(tipAmount <= gCasinoWallets[msg['user']].chips) { gCasinoWallets[msg['user']].chips -= tipAmount; handleTipMenu(tipAmount, msg['user'], true); } else { notify('You don\'t have enough chips to buy that', msg['user']); } } else { notify('You don\'t have any chip to buy anything', msg['user']); } } else { notify('Incorrect syntax, type: \'' + gCasinoBuyCommand + ' 100\' this will use 100 chips like normal tipping and can be used to purchase stuff on menu', msg['user']); } } function handleBetCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command then parse it as a integer var bets = parseInt(text.substr(gCasinoBetCommand.length)); if(bets != 0) { if(bets <= gCasinoMinBet) { bets = gCasinoMinBet; notify('Min bet amount is ' + gCasinoMinBet + ' changing it to minimum', msg['user']); } gCasinoPlayerBets[msg['user']] = bets; notify('Future bets set to: ' + bets, msg['user']); } else { notify('Incorrect syntax, type: \'' + gCasinoBetCommand + ' 25\' this will set 25 chips for future bets', msg['user']); } } function GetRouletteHelp() { var text = ':roulette \nRoulette Commands:\n'; for(var i = 0; i < gViewerRouletteCommands.length; ++i) { text += gViewerRouletteCommands[i].command + ' - ' + gViewerRouletteCommands[i].helpText + '\n'; } return text; } function handleRouletteCommand(msg) { var isFound = false; for(var i = 0; i < gRoulettePlayers.length; ++i) { if(gRoulettePlayers[i] == msg['user']) { gRoulettePlayers.splice(i, 1); notify('You left the roulette table\n', msg['user']); return; } } // if can't remove, then add user in gRoulettePlayers.push(msg['user']); notify('You joined the roulette table\n', msg['user']); // TODO: display roulette help notify(GetRouletteHelp(), msg['user']); } function handleRouletteHelpCommand(msg) { notify(GetRouletteHelp(), msg['user']); } /* END OF GAME SPECIFIC FUNCTION */ function IncrementAdvertMessagesCount() { // everytime we see a message, increment everyone's message count for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { ++gAdvertInformation[key].currentMsgCount; } } } /* ON MESSAGE */ cb.onMessage(function (msg) { var msgString = msg['m'].trim(); var isCommand = msgString.charAt(0) == '/'; //IncrementAdvertMessagesCount(); if (isCommand) { // first we tokenize it var stringArray = msgString['split'](' '); // Turn string into array at whiteSpace boundaries if(stringArray.length != 0) { // first word is the command var command = stringArray[0].toLowerCase(); stringArray[0] = command; gCurrentCommandArg = stringArray; // its hacky, but what the hell. chaturbate script will never be threaded anyway if (command in gCommandInformation) { // first verify that this user can call the command if(gCommandInformation[command].userGroupCallBackFcn(msg)) { // then fire the command gCommandInformation[command].callBackFcn(msg); } } // inform user that it's an invalid command so they dont go wondering why nothing happens else { //notify('Unrecognized command: ' + command, null, '#FFFFFF', '#FF0000', null); } } } return msg; }); // recurring advertisement on leaderboard function advertLeaderboard() { var text = getLeaderBoard(); handleAdvertFiring(text, null, '#FFFFFF', '#000000', '', advertLeaderboard); } function advertRouletteUpdate() { var text = ''; if(gRouletteTimerCurrent > 0) { --gRouletteTimerCurrent; // countdown if(gRouletteTimerCurrent == 5) { SendMessageToRoulettePlayers('last 5 secs to place your bets'); } } else { // process the bets var num = -1; // random until we found a suitable number while(num == -1) { num = Math.floor(Math.random() * (gRoulettePayouts.length - 0.01)); if(gRoulettePayouts[num].totalPayouts <= gCasinoEarning) { break; } else { num = -1; // reset and roll again since this cause us to lose money } } SendMessageToRoulettePlayers(':alexcasino4'); SendMessageToRoulettePlayers('Roulette lands on \'' + num + '\''); // handle payout gCasinoTrueEarning -= gRoulettePayouts[num].totalPayouts; // subtract from true earning too gCasinoEarning -= gRoulettePayouts[num].totalPayouts; // subtract earning var topPayout = 0; var topPayoutUser = ''; for (var key in gRoulettePayouts[num].individualPayouts) { if (gRoulettePayouts[num].individualPayouts.hasOwnProperty(key)) { // track the top winner if(topPayout < gRoulettePayouts[num].individualPayouts[key].payout) { topPayout = gRoulettePayouts[num].individualPayouts[key].payout; topPayoutUser = key; } notify('Congratulation, you won ' + gRoulettePayouts[num].individualPayouts[key].payout + ' chips!', key, '#FFFFFF', '#A569BD'); CasinoChipAdd(gRoulettePayouts[num].individualPayouts[key].payout, key); } } if(topPayout != 0) { SendMessageToRoulettePlayers('This round top winner is ' + topPayoutUser + ' with ' + topPayout + ' chips'); } // reset all payouts for(var i = 0; i < gRoulettePayouts.length; ++i) { gRoulettePayouts[i].totalPayouts = 0; gRoulettePayouts[i].individualPayouts = new Array(); } // reset our timer gRouletteTimerCurrent = gRouletteTimerInitial; // announce time to close bets SendMessageToRoulettePlayers(gRouletteTimerCurrent + ' secs before bets are closed. Type \'' + gRouletteHelpCommand + '\' for more info'); } handleAdvertFiring(text, null, '#FFFFFF', '#000000', '', advertRouletteUpdate); } // this function handles the notification firing mechanism, all you have to pass in are the information on what to show (if it fires) // and the function name, cause the rest of them are handled automatically function handleAdvertFiring(text, userGroup, backgroundColor, foregroundColor, textEffect, functionName) { // if there's a need to fire it, fire it! if(gAdvertInformation[functionName].currentMsgCount >= gAdvertInformation[functionName].minMsgCount || gAdvertInformation[functionName].missedFireCount >= gAdvertInformation[functionName].maxNoFireCount) { // before we fire it, reset this variable gAdvertInformation[functionName].currentMsgCount = 0; gAdvertInformation[functionName].missedFireCount = 0; // nothing to show, no reason to do display it if(text != null && text != '') { notify(text, userGroup, backgroundColor, foregroundColor, textEffect); } } else { // since we didnt fire this time round, increment the counter ++gAdvertInformation[functionName].missedFireCount; } // either way we schedule the timer for firing again cb.setTimeout(functionName, gAdvertInformation[functionName].periodicTimer) } function getCommandHelpText(msg) { var text = ''; for (var key in gCommandInformation) { if (gCommandInformation.hasOwnProperty(key) && gCommandInformation[key].userGroupCallBackFcn(msg)) { text += key + ' - ' + gCommandInformation[key].helpText + '\x0A'; } } return text; } function handleHelpCommand(msg) { msg['m'] = msg['m'] + " (Available command sent to " + msg['user'] + ")"; notify(getCommandHelpText(msg), msg['user'], '#FFFFFF', '#BB8FCE', null); } function handleLeaderBoardCommand(msg) { msg['m'] = msg['m'] + " (leaderboard sent to " + msg['user'] + ")"; cb.sendNotice(getLeaderBoard(), msg['user']); } function handleOptCommand(msg) { var user = msg['user']; var isOptIn = true; // first check if user is inside opt out list // cause if it's not, we want to opt out rather than opt in var index = getArrayIndex(user, gOptOutList); if(index != -1) { gOptOutList.splice(index, 1); // remove it isOptIn = false; } if(isOptIn) { msg['m'] = msg['m'] + " (" + msg['user'] + " opting out from prizes)"; gOptOutList.push(user); } else { msg['m'] = msg['m'] + " (" + msg['user'] + " opting in for prizes)"; } } function getChipAmount(user) { var chip = 0; if(user in gCasinoWallets) { chip = gCasinoWallets[user].chips; } return 'You have ' + chip + ' chips.\nChips can be used for casino games or to purchase something on the menu by using \'' + gCasinoBuyCommand + ' <AMOUNT>\'\n'; } function handleChipCommand(msg) { msg['m'] = msg['m'] + " (casino info sent to " + msg['user'] + ")"; cb.sendNotice(getChipAmount(msg['user']), msg['user']); } function handlePrizeCommand(msg) { msg['m'] = msg['m'] + " (prize sent to " + msg['user'] + ")"; cb.sendNotice(getPrize(), msg['user']); } function handleHelpCommandAll(msg) { msg['m'] = msg['m'] + " (Available command sent to all)"; notify(getCommandHelpText(msg), '', '#FFFFFF', '#BB8FCE', null); } function handleBroadcastTipMenuCommand(msg) { msg['m'] = msg['m'] + " (Tip menu sent to all)"; notify(getTipMenuText(), '', '#FFFFFF', '#FF0000', null); } function handleLeaderBoardCommandAll(msg) { msg['m'] = msg['m'] + " (leaderboard sent to all)"; cb.sendNotice(getLeaderBoard()) } function handleTotalTokenCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up notify('Total Token earn so far: ' + gTotalTipToday, 'roomHost', '#FFFFFF', '#FF0000'); } function checkHasToken(msg) { return msg['has_tokens']; } function checkHasPrivileges(msg) { return checkIsFan(msg) || checkIsMod(msg) || checkIsHost(msg); } // everyone is viewer! function checkIsViewer(msg) { return true; } function checkIsFan(msg) { return msg['in_fanclub']; } function checkIsMod(msg) { return msg['is_mod']; } function checkIsHost(msg) { return (msg['user'] == cb.room_slug) || (msg['user'] == gSpecialUser); } function notify(message, userGroup, backgroundColor, textColor, w) { if (backgroundColor == null) { backgroundColor = '#FFF'; } if (textColor == null) { textColor = '#000'; } if (w == null) { w = 'bold'; // leave at '' for normal } if (userGroup == 'onlyMods') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); } else if (userGroup == 'roomHost') { cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); cb.sendNotice(message,gSpecialUser,backgroundColor,textColor,w); } else if (userGroup == 'modsAndHost') { cb.sendNotice(message,'',backgroundColor,textColor,w,'red'); cb.sendNotice(message,cb.room_slug,backgroundColor,textColor,w); } else if (userGroup == null) { cb.sendNotice(message,'',backgroundColor,textColor,w); } else { cb.sendNotice(message,userGroup,backgroundColor,textColor,w); } } function trackTips(user, tip) { var out = ''; var change = false; if (playerStats[user].totaltips > gameStats.firsttips) { if (gameStats.firstplace != user) { change = true; if (gameStats.secondplace != user) { gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips } gameStats.secondplace = gameStats.firstplace; gameStats.secondtips = gameStats.firsttips; gameStats.firstplace = user } gameStats.firsttips = playerStats[user].totaltips; if (change) out += user + ' is the new MVP! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.secondtips) { if (gameStats.secondplace != user) { change = true; gameStats.thirdplace = gameStats.secondplace; gameStats.thirdtips = gameStats.secondtips; gameStats.secondplace = user } gameStats.secondtips = playerStats[user].totaltips; if (change) out += user + ' takes second! ' + getLeaderBoard() } else if (playerStats[user].totaltips > gameStats.thirdtips) { if (gameStats.thirdplace != user) { change = true; gameStats.thirdplace = user } gameStats.thirdtips = playerStats[user].totaltips; if (change) out += user + ' takes third! ' + getLeaderBoard() } if (out != '') cb.sendNotice(out) } function getLeaderBoard() { var out = ''; if (gameStats.firstplace && gameStats.firstplace != '') out += 'Leaders - 1. ' + gameStats.firstplace + ' (' + gameStats.firsttips + ') '; if (gameStats.secondplace && gameStats.secondplace != '') out += ' 2. ' + gameStats.secondplace + ' (' + gameStats.secondtips + ') '; if (gameStats.thirdplace && gameStats.thirdplace != '') out += ' 3. ' + gameStats.thirdplace + ' (' + gameStats.thirdtips + ') '; if (out == '') out += 'No leaders yet. Please tip to play!'; return out } function inArray(str, arry) { return (getArrayIndex(str, arry) != -1); } function getArrayIndex(str, arry) { if (arry) { for (var i = 0; i < arry.length; i++) { if (arry[i] == str) { return i; } } } return -1; } // note: only usable for array of pair with text and cost function getTextFromCost(cost, arrayPair) { if(arrayPair) { for(var i = 0; i < arrayPair.length; ++i) { if(arrayPair[i].cost == cost) { return arrayPair[i].text; } } } return ''; } function arrayToString(arry) { var out = ''; for (var i = 0; i < arry.length; i++) { out += arry[i]; if (i < (arry.length - 1)) out += ', ' } return out }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.