Apps Home
|
Create an App
sfasfafadf
Author:
eberk123
Description
Source Code
Launch App
Current Users
Created by:
Eberk123
/* ******************************************************* * Title: KarenGoal * Author: eberk123 * Version: 1.0 (11/6/2017) * ******************************************************* */ // vars var gTotalTipToday = 0; var gPrizeTipJar = 0; // NOTE: if user opt out from prizes, their tip doesnt get added into tip jar 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 gSetJackpotGoalCommand = '/setjackpotgoal'; var gSetMinLuckyNumberCommand = '/setminlucky'; var gSetMaxLuckyNumberCommand = '/setmaxlucky'; var gHashTag = '#karen #jackpot #cute #shy #sexy #hot #bigroundeye #beautiful #flash #pvt'; var gHashTagCommand = '/hashtag'; var gOptOutList = new Array(); var gSpecialUser = 'raccoonpig'; // KarenGoal specific stuff that are constant var gRarePrizeIncrementRate = 1.1; // 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 gMinRarePrizeBeforeLowChance = 4; // min rare prize in one tip before we dont increase probability of it occuring var gMaxRarePrizeBeforeLowChance = 7; // max rare prize in one tip before we dont increase probability of it occuring var gMaxCommonPrizeCount = 3; // max common prize per roll var gIsJackpotWon = false; // to ensure we only take one jackpot for each batch of tip // KarenGoal specific stuff that changes over time var gJackpot = new Array(); var gJackpotPrize = new Array(); var gCurrentRarePrizeChance = 0; var gCurrentGoalTarget = 0; var gCurrentGoalCount = 0; var gWinner = ''; // KarenLuckyNumberJackpot var gLuckyNumberPool = 0; var gMinLuckyNumber = 10; // min possible lucky number var gMaxLuckyNumber = 19; // max possible lucky number var gLuckyNumberOnBoard = new Array(); // all possible number on our lucky number board, sorted in ascending order var gUnluckyNumber = -1; // our current unlucky number for current game var gLuckyNumber = -1; // our current lucky number for current game var gSuccessfulLuckyGuess = 0; // number of successful guesses // control existing app var gEnableKarenGoal = true; var gEnableKarenLuckyNumber = false; // 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 gCommonPrizeList = new Array(); var gRarePrizeList = new Array(); var gPossibleCommonPrizeList = [ {text:"Smile", frequency:"35"}, {text:"Smile and look close into the camera", frequency:"35"}, {text:"Blow a kiss", frequency:"45"}, {text:"Say 'I love you'", frequency:"45"}, {text:"Show Belly", frequency:"45"}, {text:"Close up on my eye", frequency:"35"}, {text:"Short Dance", frequency:"15"}, {text:"Lick lips", frequency:"15"}, {text:"Tongue Tease", frequency:"18"}, {text:"Show tongue", frequency:"18"}, {text:"Play your song", frequency:"7"}, {text:"Mod for a day", frequency:"5"} ]; var gPossibleRarePrizeList = [ {text:"Name on arm", frequency:"2"}, {text:"Name on ass", frequency:"2"}, {text:"Name on boobs", frequency:"2"}, {text:"Flash ass", frequency:"10"}, {text:"Flash Right Boob", frequency:"10"}, {text:"Flash Left Boob", frequency:"10"}, {text:"Flash boobs", frequency:"10"}, {text:"Private for 30tk/min, max 10 min", frequency:"5"}, {text:"Pull nipples", frequency:"5"}, {text:"Tits Closeup", frequency:"5"}, {text:"Play boobs", frequency:"3"}, {text:"Pinch my nipples", frequency:"3"}, //{text:"Flash pussy", frequency:"3"}, {text:"Flash choice: boobs or ass", frequency:"3"}, {text:"Jump 5 times without bra", frequency:"3"}, {text:"Top off for 2 minutes", frequency:"2"}, {text:"Prize of choice", frequency:"2"}, ]; var gPossibleJackpot = [ {text:"Top off for 10 min", target:"1000"}, {text:"Top off for 10 min", target:"1000"}, {text:"Top off for 10 min", target:"1000"}, {text:"Top off for 10 min", target:"2000"}, {text:"Top off for 10 min", target:"2000"} ]; /* SETTINGS */ cb.settings_choices = new Array(); /* cb.settings_choices = [ { name: 'enableKarenGoal', label: 'Use Goal', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: gEnableKarenGoal }, { name: 'enableKarenLuckyNumber', label: 'Use Lucky Number', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: gEnableKarenLuckyNumber }, { name: 'minLuckyNumber', label: 'Minimum Lucky Number', type: 'int', defaultValue: gMinLuckyNumber }, { name: 'maxLuckyNumber', label: 'Maximum Lucky Number', type: 'int', defaultValue: gMaxLuckyNumber }, ]; */ /* KarenGoal */ for (i = 0; i < gPossibleJackpot.length; ++i) { goalIndex = i + 1; cb.settings_choices.push({ name: 'jackpotText' + goalIndex, label: 'Jackpot #' + goalIndex, type: 'str', minLength: 1, maxLength: 255, required: true, defaultValue: gPossibleJackpot[i].text }); cb.settings_choices.push({ name: 'jackpotTarget' + goalIndex, label: 'Jackpot #' + goalIndex + ' (Leave at 0 to turn off prize)', type: 'int', defaultValue: gPossibleJackpot[i].target, required: true }); } /* 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 { gPrizeTipJar += tip['amount']; gIsJackpotWon = false; for(var i = 0; i < gJackpot.length;) { if(gPrizeTipJar >= gJackpot[i].target) { gJackpotPrize.push(gJackpot[i].text); // add jackpot to jackpot prize list gJackpot.splice(i, 1); // remove it from array } // only increment 'i' if we not removing anything else { ++i; } } if(gEnableKarenGoal) { handleKarenGoal(tip['amount'], tip['from_user']); } if(gEnableKarenLuckyNumber) { handleKarenLuckyNumber(tip['amount'], tip['from_user']); } if(gEnableKarenGoal || gEnableKarenLuckyNumber) { // if jackpot is won if(gIsJackpotWon) { // always take the first jackpot prize then remove it notify(EMOTE_STARS + 'JACKPOT!!!!' + EMOTE_STARS + gJackpotPrize[0]); gJackpotPrize.shift(); } } } cb.drawPanel(); }); /* DRAW PANEL */ cb.onDrawPanel(function (user) { var luckyNumbers = ''; for(var i = 0; i < gLuckyNumberOnBoard.length; ++i) { luckyNumbers += gLuckyNumberOnBoard[i] + ' '; } if(gEnableKarenGoal && gEnableKarenLuckyNumber) { return { 'template': '3_rows_of_labels', 'row1_label': 'Token to Next Goal:', 'row1_value': (gGoalTarget - gCurrentGoalTarget), 'row2_label': 'Lucky Numbers:', 'row2_value': luckyNumbers, 'row3_label': 'Jackpot Prize:', 'row3_value': getNextJackpotPrize() } } else if(gEnableKarenGoal) { return { 'template': '3_rows_of_labels', 'row1_label': 'Token to Next Goal:', 'row1_value': (gGoalTarget - gCurrentGoalTarget), 'row2_label': 'Chance for Rare Prize:', 'row2_value': Math.ceil(gCurrentRarePrizeChance) + '%', 'row3_label': 'Jackpot Prize:', 'row3_value': getNextJackpotPrize() } } else if(gEnableKarenLuckyNumber) { return { 'template': '3_rows_of_labels', 'row1_label': 'Lucky Number:', 'row1_value': luckyNumbers, 'row2_label': 'Successful Guess:', 'row2_value': gSuccessfulLuckyGuess, 'row3_label': 'Jackpot Prize:', 'row3_value': getNextJackpotPrize() } } }); function getNextJackpotPrize() { return gJackpot.length == 0? 'None': gJackpot[0].text; } function IncrementAdvertMessagesCount() { // everytime we see a message, increment everyone's message count for (var key in gAdvertInformation) { if (gAdvertInformation.hasOwnProperty(key)) { ++gAdvertInformation[key].currentMsgCount; } } } function handleKarenGoal(tipAmount, user) { gCurrentGoalTarget += 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; // as long as we have left over, continue looping while(gCurrentGoalTarget >= gGoalTarget) { ++goalMetCount; // track how many times we met the goal var rolledChance = Math.random() * 100; //var debugText = 'rolled: ' + rolledChance + '% require ' + gCurrentRarePrizeChance + '%'; //notify(debugText); // first roll and see if we hit the rare chance if(rolledChance < gCurrentRarePrizeChance) { ++rarePrizeWonCount; // now pick something from rare prize pool GetRarePrize(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 -= gGoalTarget; ++gCurrentGoalCount; } for(var i = 0; i < goalMetCount && i < gMaxCommonPrizeCount; ++i) { // pick something from common prize pool and display it notify(EMOTE_STAR + user + EMOTE_STAR + ' - Prize won: ' + getPrizeFromPrizeList(gCommonPrizeList, gPossibleCommonPrizeList)); } } function handleKarenLuckyNumber(tipAmount, user) { // if it's on karen lucky number board, clear it // else we add to our pool if(!checkKarenLuckyNumber(tipAmount, user)) { // pool don't make a lot of sense if we have KarenGoal turned on /* // now add to pool gLuckyNumberPool += tipAmount; // keep clearing all existing safe number // NOTE: don't cache the max lucky number, it changes on each loop // and again if we ever clear the board so just keep grabbing it from function while(gLuckyNumberPool >= getMaxLuckyNumberOnBoard()) { gLuckyNumberPool -= getMaxLuckyNumberOnBoard(); checkKarenLuckyNumber(getMaxLuckyNumberOnBoard(), user); } */ } } function GetRarePrize(text, user) { // ensure only one jackpot is won each time round if(gJackpotPrize.length != 0 && !gIsJackpotWon) { gIsJackpotWon = true; } var currentPrize = getPrizeFromPrizeList(gRarePrizeList, gPossibleRarePrizeList); // track previous rare prize winner gWinner += currentPrize + ' - won by ' + user + '\x0A'; // display the prize that we won notify(text + currentPrize); } // return true if it clears a lucky number, else return false (meaning it needs to go to our pool) function checkKarenLuckyNumber(numberToCheckOff, user) { // if lucky number then roll for rare prize (and jackpot if we met the criteria) if(numberToCheckOff == gLuckyNumber) { // now pick something from rare prize pool GetRarePrize(EMOTE_STARS + user + EMOTE_STARS + ' Guessed the lucky number!!! ' + numberToCheckOff + '!!! - Rare Prize won: ', user); // track amount of lucky guesses ++gSuccessfulLuckyGuess; // reset our board for the next game initLuckyNumberBoard(); return true; } // if unlucky number we reset our board // NOTE: if lucky number is the minimum possible board value, unlucky number will be excluded from this game else if(gUnluckyNumber != -1 && numberToCheckOff == gUnluckyNumber) { // send notification we hit unlucky number notify(user + ' Guessed the unlucky number ' + numberToCheckOff + '! ((( Board will be resetting((('); // reset our board for the next game initLuckyNumberBoard(); return true; } // if not lucky/unlucky, ensure it's part of our existing number before we strike it off and roll for a common prize else { var index = isOnLuckyNumberBoard(numberToCheckOff); if(index != -1) { // remove it from the board gLuckyNumberOnBoard.splice(index, 1); // now roll for a common prize notify('Sorry ' + user + ', ' + numberToCheckOff + ' is not the lucky number(( Please try again!! :kisses4u '); return true; } else { return false; } } } function initLuckyNumberBoard() { // NOTE: cant reset lucky number pool, cause left over from previous guess needs to be kept, this ensure big tipper is rewarded notify('Resetting lucky number board', null, '#FFFFFF', '#FA8072', null); gLuckyNumberOnBoard = new Array(); // NOTE: if max > min, there will never be a valid number // populate our lucky number board for(var i = gMinLuckyNumber; i <= gMaxLuckyNumber; ++i) { gLuckyNumberOnBoard.push(i); } if(gLuckyNumberOnBoard.length != 0) { // now pick a lucky number gLuckyNumber = Math.floor(Math.random() * (gMaxLuckyNumber - gMinLuckyNumber)) + gMinLuckyNumber; // now if gLuckyNumber not our minimum number, we will pick a unlucky number (cause unlucky number has to be lower than lucky number) if(gLuckyNumber != gMinLuckyNumber) { gUnluckyNumber = Math.floor(Math.random() * (gLuckyNumber - gMinLuckyNumber)) + gMinLuckyNumber; } else { gUnluckyNumber = -1; // make it invalid for this game } } } function getMaxLuckyNumberOnBoard() { if(gLuckyNumberOnBoard.length == 0) { return -1; } else { return gLuckyNumberOnBoard[gLuckyNumberOnBoard.length - 1]; } } // return -1 if it's not found else it will index of it function isOnLuckyNumberBoard(tokenValue) { // early out if(tokenValue > getMaxLuckyNumberOnBoard()) { return -1; } for(var i = 0; i < gLuckyNumberOnBoard.length; ++i) { // if equal, then it is on board if(gLuckyNumberOnBoard[i] == tokenValue) { return i; } // else if it's lesser than existing number, it can never be on our board // this is an early exit else if(tokenValue < gLuckyNumberOnBoard[i]) { return -1; } } return -1; } 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; } /* ON MESSAGE */ cb.onMessage(function (msg) { var msgString = msg['m'].trim(); var isCommand = msgString.charAt(0) == '/'; 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; }); /* Initialization */ function init() { // this ensure app restart doesn't screw up gHighTipUsername = null; gHighTipAmount = 0; last_tip_username = null; gCurrentRarePrizeChance = gInitialRarePrizeChance; gCurrentGoalTarget = 0; gCurrentGoalCount = 0; gJackpot = new Array(); gJackpotPrize = new Array(); gWinner = ''; gLuckyNumberPool = 0; gSuccessfulLuckyGuess = 0; //gEnableKarenGoal = cb.settings.enableKarenGoal; //gEnableKarenLuckyNumber = cb.settings.enableKarenLuckyNumber; gMinLuckyNumber = cb.settings.minLuckyNumber; gMaxLuckyNumber = cb.settings.maxLuckyNumber; // you need to populate this gAdvertInformation = new Array(); gCommandInformation = new Array(); gCommonPrizeList = new Array(); gRarePrizeList = new Array(); playerStats = {}; gameStats = {firstplace: '',secondplace: '',thirdplace: '',firsttips: 0,secondtips: 0,thirdtips: 0}; initCommand(); if(gEnableKarenLuckyNumber) { initLuckyNumberBoard(); } // setup our jackpot prizes var currPool = 0; for(var i = 0; i < gPossibleJackpot.length; ++i) { var target = eval('cb.settings.jackpotTarget' + (i + 1)); if(target != 0) { gJackpot.push({ text: eval('cb.settings.jackpotText' + (i + 1)), target: target + currPool }); currPool += target; } } // 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: 20, maxNoFireCount: 4}; gAdvertInformation[advertLeaderboard] = { initialTimer: 0.5 * CONFIG_ADVERT_MINUTES, periodicTimer: CONFIG_ADVERT_MINUTES, minMsgCount: 10, maxNoFireCount: 7 }; // 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(advertLeaderboard, gAdvertInformation[advertLeaderboard].initialTimer); cb.setTimeout(advertGamerules, gAdvertInformation[advertGamerules].initialTimer); updateSubject(); cb.drawPanel(); } init(); /* 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' }; // 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: handleToggleJackpotCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Enable/Disable KarenGoal' }; //gCommandInformation['/toggleluckynumber'] = { callBackFcn: handleToggleLuckyNumberCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Enable/Disable KarenLuckyNumber' }; gCommandInformation[gHashTagCommand] = { callBackFcn: handleHashTagCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Set subject hash tag' }; if(gEnableKarenGoal) { gCommandInformation['/jackpot'] = { callBackFcn: handleJackpotGoalCommand, userGroupCallBackFcn: checkIsHost, helpText: 'Show jackpot token requirement' }; gCommandInformation[gSetJackpotGoalCommand] = { callBackFcn: handleGoalTargetCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetJackpotGoalCommand + ' <new_amount>\' will change our goal target to a new_amount of token' }; } if(gEnableKarenLuckyNumber) { gCommandInformation[gSetMinLuckyNumberCommand] = { callBackFcn: handleMinLuckyNumberCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetMinLuckyNumberCommand + ' <new_amount>\' will change our minimum lucky number for next game' }; gCommandInformation[gSetMaxLuckyNumberCommand] = { callBackFcn: handleMaxLuckyNumberCommand, userGroupCallBackFcn: checkIsHost, helpText: '\'' + gSetMaxLuckyNumberCommand + ' <new_amount>\' will change our maximum lucky number for next game' }; } } // recurring advertisement on how to play karen jackpot function advertGamerules() { var text = ''; if(gEnableKarenGoal) { text += 'Tip to hit the goal. Each time we hit a goal, a random prize (can be common/rare prize) will be chosen from the prize list with a chance for jackpot!\n'; text += 'On each goal if you failed to get a rare prize, the chance for rare prize will increase until we get a rare prize\n'; text += 'Type \'/opt\' to opt in/out from prizes\n\n'; } if(gEnableKarenLuckyNumber) { text += 'Guess the lucky number!\n'; text += 'Each time you guess the lucky number, a rare prize will be chosen from random with a chance of jackpot.\n'; text += 'There MIGHT be a unlucky number which cause the board to reset.\n\n'; } text += 'Type /prize to see the list of prizes and the possible jackpot prizes\n'; handleAdvertFiring(text, '', '', '', 'bold', advertGamerules); } // recurring advertisement on leaderboard function advertLeaderboard() { var text = getLeaderBoard(); handleAdvertFiring(text, null, '#FFFFFF', '#000000', '', advertLeaderboard); } // 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 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 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 handleJackpotGoalCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up var text = 'Jackpot Prizes (Only roomhost can see this):\n'; for(var i = 0; i < gJackpot.length; ++i) { text += gJackpot[i].text + ' - ' + gJackpot[i].target + 'token \n'; } notify(text, 'roomHost', '#FFFFFF', '#FF0000'); } 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; // everytime we update this we need to update subject and drawboard updateSubject(); cb.drawPanel(); } else { notify('Use only integer for goal', 'roomHost'); } } function handleMinLuckyNumberCommand(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 newVal = parseInt(text.substr(gSetMinLuckyNumberCommand.length)); if(newVal != 0) { gMinLuckyNumber = newVal; } else { notify('Use only integer for goal', 'roomHost'); } } function handleMaxLuckyNumberCommand(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 newVal = parseInt(text.substr(gSetMaxLuckyNumberCommand.length)); if(newVal != 0) { gMaxLuckyNumber = newVal; } else { notify('Use only integer for goal', 'roomHost'); } } function handleToggleJackpotCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gEnableKarenGoal = !gEnableKarenGoal; cb.drawPanel(); initCommand(); var text = 'Use KarenGoal: ' + (gEnableKarenGoal? 'Yes': 'No'); notify(text, 'roomHost', '#FFFFFF', '#FF0000', null); } function handleToggleLuckyNumberCommand(msg) { msg['X-Spam'] = true; // we want to hide this command from showing up gEnableKarenLuckyNumber = !gEnableKarenLuckyNumber; cb.drawPanel(); initCommand(); // if turning on lucky number we need to initialize our board if(gEnableKarenLuckyNumber) { initLuckyNumberBoard(); } var text = 'Use KarenLuckyNumber: ' + (gEnableKarenLuckyNumber? 'Yes': 'No'); notify(text, 'roomHost', '#FFFFFF', '#FF0000', null); } function handleHashTagCommand(msg) { var text = msg['m']; msg['X-Spam'] = true; // we want to hide this command from showing up // first strip out the command to obtain our hash tag string gHashTag = text.substr(gHashTagCommand.length); updateSubject(); } function handlePrizeCommandAll(msg) { msg['m'] = msg['m'] + " (prize sent to all)"; cb.sendNotice(getPrize()) } 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 notifyError(message, u) { notify(message, u, '#FFCCCC', '#BB2222'); } function notifyErrorBold(message, u) { notify(message, u, '#BB2222', '#FFF'); } function isBlank(cbsetting) { var s; if(cbsetting) { s = cbsetting.trim(); } if(s == null || s == '' || s.substr(0,8) == 'Optional') { return true; } else { return false; } } function updateSubject() { var newSubject = ''; if(gEnableKarenGoal) { newSubject += 'Goal at every ' + gGoalTarget + ' token. At each goal, roll for a prize with a chance for jackpot. \n'; newSubject += 'Current jackpot: ' + getNextJackpotPrize() + '. \n'; } else if(gEnableKarenLuckyNumber) { newSubject += 'Guess the lucky number and get a rare prize or a chance for jackpot!. \n'; } newSubject += gHashTag; cb.changeRoomSubject(newSubject) } 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 getPrize() { var out = ''; // show previous winner out += '\nRare Prizes won (oldest to newest):\n'; out += gWinner; out += '\n'; // show prize list out += '\nCommon Prizes:\n'; for(var i = 0; i < gPossibleCommonPrizeList.length; ++i) { out += gPossibleCommonPrizeList[i].text + '\n'; } // show rare prize list out += '\nRare Prizes:\n'; for(var i = 0; i < gPossibleRarePrizeList.length; ++i) { out += gPossibleRarePrizeList[i].text + '\n'; } // show possible jackpot out += '\nJackpot:\n'; for(var i = 0; i < gJackpot.length; ++i) { out += gJackpot[i].text + '\n'; } 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 } function getRandomArrayVal(arry) { return arry[Math.floor(Math.random() * (arry.length - 1))] }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.