Apps Home
|
Create an App
Multi Goal Sequential Tipping
Author:
polymath614
Description
Source Code
Launch App
Current Users
Created by:
Polymath614
// vars var max_tip_level = null; var next_level_amount = 1; var support_level_amount = 0; var goal_reached = false; var imena = []; //new Array(); var tipovi = []; //new Array(); var displaySubject = 0; var tip_for_next_level = support_level_amount; var total_for_all_goals = 0; var total_tiped = 0; var msgAdmin = false; var multiTipGoal = ''; //var tipammountLeftAfterGoal = 0; var amountTipOver = 0; var highTipAmmountForNextGoal = 0; var tipammountLeftAfterGoal = 0; var goalCount; var hashTags = ''; var mGoal = []; var mIndex = 0; var mDoneFlag = 0; var tipUser = ''; var counter = 0; var admins = []; var adminChoice = ''; // var version = 1 // Limit goal description as we add some text cb.settings_choices = [ { name: 'AdminControl', label: 'There are parts of this app that control adding a missed tip, changing goals, goal Ammounts, Goal Subjets would you like all Mods to be able to make these changes or only the broadcaster?', type: 'choice', choice1: 'Only Brodcaster', choice2: 'All mods', choice3: 'Only Mods Listed Below:', default: 'Only Brodcaster', required: true }, { name: 'AdminMods', label: 'If you want Admin Mods add them here with a space seperating the names (you can only add people during setup)', type: 'str', minLength: 0, required: false }, { name: 'display_goals', type: 'choice', label: 'Display detail goal status notice messages to', choice1: 'Everyone', choice2: '-', default: '-' }, { name: 'hashTagsChoice', type: 'str', minLength: 0, maxLength: 255, label: 'Enter Hash Tags here to be add to the subject', default: '#SEXY' }, { name: 'active1', type: 'choice', label: '=== (1) Set Goal ======', choice1: 'active', choice2: '-', default: 'active' }, { name: 'goal_description1', required: false, type: 'str', minLength: 1, maxLength: 190, label:"Goal Description" }, { name: 'goal_value1', required: false, type: 'int', minValue: 1, maxValue: 100000, default: 1000, label:"Token Goal" }, { name: 'order1', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active2', type: 'choice', label: '=== (2) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description2', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value2', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order2', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active3', type: 'choice', label: '=== (3) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description3', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value3', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order3', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active4', type: 'choice', label: '=== (4) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description4', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value4', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order4', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active5', type: 'choice', label: '=== (5) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description5', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value5', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order5', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active6', type: 'choice', label: '=== (6) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description6', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value6', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order6', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active7', type: 'choice', label: '=== (7) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description7', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value7', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order7', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'tipGoalNotice', required: false, type: 'choice', label: 'send notice after every tip', choice1: 'No', choice2: 'Yes', default: 'No'}, { name: 'multiTipGoal', type: 'choice', label: 'Allow large tips to go towards more than one of the goals?', choice1: 'Yes', choice2: 'No', default: 'No'}, { name: 'tipHasToBeThisHigh', type: 'int', label: 'How much should the tip be to go to more than one goal?', minValue: 0, maxValue: 100000, default: 100}, { name: 'tipLeftAfterGoal', type: 'int', label: 'How much should be left of the tip for it to go towards next goal? (example left for current goal is 50 tokens someone tips 101 so it is over the inital amount to go towards the next goal but will fail here because it only over by 51 tokens)', minValue: 0, maxValue: 1000, default: 10} ]; cb.onTip( function (tip) { var tipAmount = parseInt(tip['amount']); tipUser = tip['from_user']; amountTipOver; if (mGoal.length === 0) { return; } total_tiped += tipAmount; total_for_all_goals = (total_for_all_goals - tipAmount); if (tipAmount > totalUntilNextGoal) { amountTipOver = (tipAmount - totalUntilNextGoal); //the if statement below is for if you also want the amount going towards the next goal if ((tipAmount > highTipAmmountForNextGoal) && (multiTipGoal === 'Yes') && (amountTipOver >= tipammountLeftAfterGoal)) { //if (multiTipGoal === 'Yes') { najvisi(tip['from_user'], tip['amount']); var diff = tip['amount']; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoalWExtraFunds(amountTipOver, tipAmount, tipUser); displayGoals(); } } } else { /* this is where the tips that are over goal but not over the amount to go towards other goals*/ najvisi(tip['from_user'], tip['amount']); var tipToGoalOnly = (tip['amount'] - amountTipOver); totalUntilNextGoal = (totalUntilNextGoal - tipToGoalOnly); var diff = tipToGoalOnly; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } } } else { totalUntilNextGoal = (totalUntilNextGoal - tip['amount']); najvisi(tip['from_user'], tip['amount']); var diff = tip['amount']; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } } // najvisi(tip['from_user'], tip['amount']); // var diff = tip['amount']; // diff += support_level_amount; // support_level_amount = diff; // while ((diff > 0) && (!checkGoalReached())) { // diff -= next_level_amount; // if (diff >= 0) { // support_level_amount = diff; // setNextLevelNeeded(); // } // } // if (checkGoalReached()) { // if ((mIndex + 1) > (mGoal.length - 1)) { // if (mDoneFlag === 0) { // mDoneFlag = 1; // mGoal[mIndex]["goal_status"] = "COMPLETED"; // displayGoals(); // } // return; // } // else { // mGoal[mIndex]["goal_status"] = "COMPLETED"; // mIndex += 1; // startGoal(); // } // } tip_for_next_level = next_level_amount - support_level_amount; update_subject(); cb.drawPanel(); } ); cb.onDrawPanel( function (user) { if (mGoal.length === 0) return; if (checkGoalReached()) { var result = { 'template': '3_rows_11_21_31', 'row1_value': '*** Goal ' + (mIndex + 1) + ' / ' + mGoal.length + ' reached! ***', 'row2_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")", 'row3_value': 'Thanks to all tippers' }; displaySubject = 0; return result; } else { if (isAscendingOrder()) { return { 'template': '3_rows_of_labels', 'row1_label': 'Current Level:', 'row1_value': next_level_amount-1 + ' (of 1 to ' + max_tip_level + ")", 'row2_label': 'Left at this Level:', 'row2_value': tip_for_next_level, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")" }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Current Level:', 'row1_value': next_level_amount+1 + ' (of ' + max_tip_level + ' to 1)', 'row2_label': 'Left at This Level:', 'row2_value': tip_for_next_level, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")" }; } } } ); cb.onMessage(function (msg) { if (adminChoice === 'Only Broadcaster') { msgAdmin = cb.room_slug; } else if (adminChoice === 'All mods') { msgAdmin = msg['is_mod']; } else if (adminChoice === 'Only Mods Listed Below:') { msgAdmin = admins.includes(msg['user']); } else { msgAdmin = false; } msgUser = msg['user']; msgMsg = msg['m']; msgMod = (cb.room_slug === msg['user'] || msg['is_mod']); var msgParam = ""; var msgArray = []; var msgDQote = []; var firstDQuote = 0; if(msgMsg.startsWith('/')) { msg['X-Spam'] = true; msgArray = msgMsg.split(' '); var msgSplitIndex = msgMsg.indexOf(' '); firstDQuote = msgMsg.indexOf("\""); if (msgSplitIndex > -1) { var msgCommand = msgMsg.substring(0, msgSplitIndex); } else { var msgCommand = msgMsg; } if (msgMsg.length >= msgSplitIndex) { msgParam = msgMsg.substring(msgSplitIndex).trim(); } if (msgArray.length >= 3){ msgDQote = msgMsg.split("\""); } if (msgMod) { switch (msgCommand) { case '/subject': changeSubject(msgParam, msgUser); break; //case '/goal': would like this to work at somepoint //showGoals(msgUser); //break; case '/gall': msgUser = ''; showGoals(msgUser); break; case '/ltt': goalTip(); break; case '/totalleft': totalTip(); break; case '/addtip': //need to think how i am going to do this one because everything that is entered is a string //with this command you have to enter /addTip, amount, who tipped it, Mod that changed it. if (msgAdmin) { var tipToNumber = msgArray[1]; msgTipAmount = parseInt(tipToNumber); msgTipper = msgArray[2]; cb.sendNotice("addTip(" + msgTipAmount + ", " + msgTipper + ", " + msgUser + ") ",cb.room_slug,'','','',''); cb.sendNotice("addTip(" + msgTipAmount + ", " + msgTipper + ", " + msgUser + ") ",msgUser,'','','',''); addTip(msgTipAmount, msgTipper, msgUser); break; } else { cb.sendNotice(msgUser + ' tried to use the addTip',cb.room_slug,'','','','red'); } break; case '/totaltipped': if (msgAdmin) { totalTipped(msgUser); } else { cb.sendNotice("sorry that did not work " + msgUser,msgUser,'','','','red'); } break; case '/changeGoal': // /changeGoalAmount what number for goal then ammount changed to use " to seperate the subject var order = (msgArray[msgArray.length - 1]) ? 'ascending' : 'descending'; if (msgAdmin) { var goalNum = parseInt(msgArray[1] - 1); var goalAmount = parseInt(msgArray[2]); var goalSubject = msgDQote[1]; if (mGoal[goalNum].goal_status === 'Not Started') { if ((typeof goalNum === 'number') && (goalNum <= 7 ) && (goalNum >= 0)) { if (goalAmount > 0) { if (goalSubject.length > 1 ) { cb.sendNotice('The first number was correct and was in the correct range',msgUser,'','','',''); cb.sendNotice('This should be the goal subject \"' + goalSubject + '\"',msgUser,'','','',''); changeGoalComplete(goalNum,goalAmount,goalSubject,order); } else { cb.sendNotice('The Subject is not valid ' + goalSubject,'','','','',''); } } else { cb.sendNotice('Goal Amount was Wrong goal amount entered is ' + goalAmount,'','','','',''); } // probably a good idea to print the old goal } else { //this means that the second argument was not a number or that it was too big or small cb.sendNotice('There was a problem with change goal' + msgMsg,msgUser,'','','',''); } //cb.sendNotice('this is in the change goal amount command\n ' + msgComma,'','','','',''); //cb.sendNotice('this should be the goal number ' + msgComma[1],'','','','',''); } } else { cb.sendNotice('You do not have rights to change goals',msgUser,'','','',''); } break; case '/changeGoalAmount': if (msgAdmin) { var goalNum = parseInt((msgArray[1]) - 1); var goalAmount = parseInt(msgArray[2]); if (goalNum >= 0 && goalNum <= mGoal.length) { if (mGoal[numGoal].goal_status === 'Not Started') { if (goalAmount >= 0) { cb.sendNotice('So i am just testing to see if these will even work line 452', '', '', '', '', ''); changeGoalAmmount(parseInt(goalNum), parseInt(goalAmount)); } else { cb.sendNotice('Your goal ammount is not valid ' + goalAmount, '', '', '', '', ''); } } else { cb.sendNotice('You can only make changes to future goals this goal status is ' + mGoal[numGoal].goal_status, '') } } else { cb.sendNotice('Your goal number is not valid goal num ' + goalNum + ' or lenght is wrong ' + mGoal.length, '', '', '', '', ''); } } else { cb.sendNotice('Sorry you do not have permisions to use this comaand', '','','','',''); } break; case '/changeGoalSubject': if (msgAdmin) { var goalNum = parseInt((msgArray[1]) - 1); var goalSubject = msgDQote[1]; if (mGoal[goalNum].goal_status === 'Not Started') { cb.sendNotice('The description has been changed for goal ' + goalNum + ' was \"' + mGoal[goalNum].goal_description + '\"',msgUser,'','','',''); changeGoalSubject(goalNum, goalSubject); cb.sendNotice('The description has been changed for goal ' + goalNum + ' to \"' + mGoal[goalNum].goal_description + '\"',msgUser,'','','',''); } else { cb.sendNotice('You Can\'t change the value of goal that are started or completed ' + mGoal[numGoal].goal_status, '', '', '', '', ''); } } else { cb.sendNotice('Sorry you do not have permisions to use this comaand', '','','','',''); } // cb.sendNotice('so i am just testing to see if these will even work line 454','','','','',''); // cb.sendNotice('This is the double quote array' + msgDQote,'','','','',''); break; case '/changeOrder': if (msgAdmin) { var numGoal = parseInt((msgArray[1]) - 1); var changeOrder = msgArray[2] ? 'ascending' : 'descending'; if (mGoal[numGoal].goal_status === 'Not Started') { changeGoalOrder(numGoal, changeOrder); } else { cb.sendNotice('Error you can only make changes to goals that have not been started ' + mGoal[numGoal].goal_status, '', '', '', '', ''); } } else { cb.sendNotice('Sorry you do not have permisions to use this comaand', '','','','',''); } break; case '/addtag': if (msgArray[1].startsWith('#')) { addHashTags(msgParam,msgUser); cb.sendNotice('New Tags were added ' + msgParam,msgUser,'','','',''); } else { cb.sendNotice('Sorry there was no # in the message',msgUser,'','','',''); } break; case '/replacetag': //would like to make this so that you could replace individual tags if (msgArray[1].startsWith('#')) { cb.sendNotice('Hash Tags were ' + hashTags,msgUser,'','','',''); replaceHashTags(msgParam,msgUser); //hashTags = msgParam; cb.sendNotice('Hash Tags were replaced with ' + msgParam,msgUser,'','','',''); } else { cb.sendNotice('Sorry there was no # in the message',msgUser,'','','',''); } break; case '/help': cb.sendNotice("***** help *****", msgUser, '#ff0000', '', 'bold', ''); cb.sendNotice("Help with this app their are a few commands that can help \n" + " /subject will let you change the room subject so a mod can make changes \n" + " /subject anything after subject will be in the subject. \n" + " /goal will show you the goals that are left and completed. \n" + " /ltt will post to everyone how many tokens are left for this goal \n" + " /totalleft will show you how much is left to clear all goals \n" + " /addtip will let you add tips that may have not been counted or to get back to the right spot if you need to restart the app \n" + " /totaltipped will show you what is the total amount that have been tipped (only admin can do this command).\n" + "/changeGoal allows the Admins to make changes to future goals. \n" + "the formate for these commands has to be done in a certain way \n" + "/changeGoal goalNumber goalAmount \"subject\" order(optional) \n" + "/changeGoalAmount allows the Admins to make changes to future goals value \n" + "the formate for these commands has to be done in a certain way \n" + "/changeGoalAmount goalNumber goalAmount \n" + "/changeGoalSubject allows the Admins to make changes to future goals description. \n" + "the formate for these commands has to be done in a certain way \n" + "/changeGoalSubject goalNumber \"subject\" \n" + "/changeOrder allows the Admins to make changes to future goals description. \n" + "the formate for these commands has to be done in a certain way \n" + "/changeOrder goalNumber Order \n" + "/addtag adds the next word on to the hash tag list. \n" + "/replacetag replaces all the words in the hash tag list. \n" + "******* HELP ********" ,msgUser,'#ffffe0','#000000','bold',''); // cb.sendNotice("/changeGoal allows the Admins to make changes to future goals.", msgUser, '', '', '', ''); // cb.sendNotice("the formate for these commands has to be done in a certain way", msgUser, '', '', '', ''); // cb.sendNotice("/changeGoal goalNumber goalAmount \"subject\" order(optional)", msgUser, '', '', '', ''); // cb.sendNotice("/changeGoalAmount allows the Admins to make changes to future goals value", msgUser, '', '', '', ''); // cb.sendNotice("the formate for these commands has to be done in a certain way", msgUser, '', '', '', ''); // cb.sendNotice("/changeGoalAmount goalNumber goalAmount", msgUser, '', '', '', ''); // cb.sendNotice("/changeGoalSubject allows the Admins to make changes to future goals description.", msgUser, '', '', '', ''); // cb.sendNotice("the formate for these commands has to be done in a certain way", msgUser, '', '', '', ''); // cb.sendNotice("/changeGoalSubject goalNumber \"subject\"", msgUser, '', '', '', ''); // cb.sendNotice("/changeOrder allows the Admins to make changes to future goals description.", msgUser, '', '', '', ''); // cb.sendNotice("the formate for these commands has to be done in a certain way", msgUser, '', '', '', ''); // cb.sendNotice("/changeOrder goalNumber Order", msgUser, '', '', '', ''); // cb.sendNotice("/addtag adds the next word on to the hash tag list.", msgUser, '', '', '', ''); // cb.sendNotice("/replacetag replaces all the words in the hash tag list.", msgUser, '', '', '', ''); // cb.sendNotice("******* HELP ********", msgUser, '', '', '', ''); break; default: // IF you want to be able to see failed commands you can uncomment below just specify who it should go to. //cb.sendNotice("***** "+ msgCommand +" *****", "", "", "", "", ""); return msg; } } else { switch (msgCommand) { case '/help': cb.sendNotice('For the Multi Goal app Users can only see what the current goals is. do that by doing /goal',msgUser,'','','',''); break; case '/goal': currentGoal(msgUser); break; default: return msg; } } } if (mGoal.length === 0) { return; } //if (msg['user'] === mGoal[mIndex].high_tip_username) { // msg['background'] = '#9F9'; //} return msg; }); //functions for changing goals durring show function changeGoalSubject(goalNum,newGoalSubject) { if (mGoal[goalNum].goal_status !== 'COMPLETED') { cb.sendNotice('Current Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order,'','','','',''); mGoal[goalNum].goal_description = newGoalSubject; cb.sendNotice('Current Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order,'','','','',''); } else { GoalNumber = goalNum + 1; cb.sendNotice('the Goal ' + GoalNumber + ' is listed as ' + mGoal[goalNum].goal_status + ' and can\'t be changed','','','','',''); } } function changeGoalAmmount(goalNum,newGoalAmount) { cb.sendNotice('Current Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order,'','','','',''); var max_tip_level_goal = mGoal[goalNum].max_tip_level; var real_total = (((1 + max_tip_level_goal)/2) * max_tip_level_goal); total_for_all_goals = total_for_all_goals - real_total; var newMax = howManyNumbers(newGoalAmount); var real_total2 = (((1 + newMax) / 2) * newMax); total_for_all_goals = total_for_all_goals + real_total2; mGoal[goalNum].max_tip_level = newMax; mGoal[goalNum].goal_value = newGoalAmount; cb.sendNotice('New Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order,'','','','',''); } function changeGoalComplete(goalNum,newGoalAmount,newGoalSubject,tipOrder) { var goalOrder = tipOrder; var max_tip_level_goal = mGoal[goalNum].max_tip_level; var real_total = (((1 + max_tip_level_goal)/2) * max_tip_level_goal); total_for_all_goals = total_for_all_goals - real_total; cb.sendNotice('Current Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order + ' Goal max tip level ' + mGoal[goalNum].max_tip_level,'','','','',''); mGoal[goalNum].goal_value = newGoalAmount; mGoal[goalNum].goal_description = newGoalSubject; mGoal[goalNum].order = goalOrder; var MaxTipLevel = howManyNumbers(newGoalAmount); if (MaxTipLevel > 0) { mGoal[goalNum].max_tip_level = MaxTipLevel; } var real_total2 = (((MaxTipLevel + 1) / 2) * MaxTipLevel); total_for_all_goals = total_for_all_goals + real_total2; cb.sendNotice('New Goal value ' + mGoal[goalNum].goal_value + ' Goal description ' + mGoal[goalNum].goal_description + ' Goal order ' + mGoal[goalNum].order + ' Goal max tip level ' + mGoal[goalNum].max_tip_level,'','','','',''); } function changeGoalOrder(goalNum,GoalOrder) { mGoal[numGoal].order = changeOrder; cb.sendNotice('The order has changed for ' + mGoal.numGoal + ' to ' + mGoal[numGoal].order + '.','','','','',''); } function howManyNumbers(amount) { var highNumber = 0; var realNumber = 0; var largeNumber = amount; highNumber = Math.floor(Math.sqrt(largeNumber * 2)) + 1; realNumber = (Math.floor(Math.sqrt((largeNumber * 2) - highNumber)) + 1); return realNumber; } //end of the goal changes //Change to hashtags function addHashTags(hashTagsAdd,msgUser) { cb.sendNotice('Hash tags Were changed ' + hashTags + ' following was added ' + hashTagsAdd ,msgUser,'','','',''); hashTags = hashTags + hashTagsAdd; return true; } function replaceHashTags(hashTagsNew,msgUser) { cb.sendNotice('Hash tags were replaced old hash tags were \'' + hashTags + '\' new hash tags \'' + hashTagsNew + '\'',msgUser,'','','',''); hashTags = hashTagsNew; if (hashTags.length > 0) { return true; } else { return false; } } //end of hashtags function totalTipped(adminUser) { cb.sendNotice('how much has been tipped = ' + total_tiped, adminUser, '','','','red'); } function totalTip() { var backgroundColor = "#fffd14"; var weight = 'bold'; cb.sendNotice("Total for all goals is " + total_for_all_goals + ".",msgUser,backgroundColor,"",weight,'red'); } function goalTip(userAsk) { var backgroundColor = "#fffd14"; var weight = 'bold'; cb.sendNotice("Total left to tip for this goal " + totalUntilNextGoal + "",'',backgroundColor,'',weight,''); } // helper functions function changeSubject(newSubject,modName) { cb.changeRoomSubject(newSubject + ' ' + hashTags); cb.sendNotice(modName + ' has changed the subjest', cb.room_slug,'','','',''); } function addTip(msgAmount, msgTipper, modName) { var msgAmount2 = msgAmount; var msgTipper = msgTipper; var msgMod = modName; //the tip function var tipAmount = msgAmount2; tipUser = msgTipper; amountTipOver; if (mGoal.length === 0) { return; } total_tiped += msgAmount2; total_for_all_goals = (total_for_all_goals - msgAmount2); if (tipAmount >= totalUntilNextGoal) { amountTipOver = (tipAmount - totalUntilNextGoal); if ((tipAmount > tipammountLeftAfterGoal) && (multiTipGoal === 'Yes')) { //if ((tipAmount > tipammountLeftAfterGoal) && (multiTipGoal === 'Yes') && (amountTipOver >= highTipAmmountForNextGoal)) { najvisi(msgTipper, msgAmount2); var diff = msgAmount2; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoalWExtraFunds(amountTipOver, tipAmount, tipUser); displayGoals(); } } } else { /* this is where the tips that are over goal but not over the amount to go towards other goals*/ najvisi(msgTipper, msgAmount2); var tipToGoalOnly = (msgAmount2 - amountTipOver); totalUntilNextGoal = (totalUntilNextGoal - tipToGoalOnly); var diff = tipToGoalOnly; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } } } else { totalUntilNextGoal = (totalUntilNextGoal - msgAmount2); najvisi(msgTipper, msgAmount2); var diff = msgAmount2; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } } tip_for_next_level = next_level_amount - support_level_amount; update_subject(); cb.drawPanel(); } function update_subject() { if (goal_reached) { return; } var new_subject = ""; tip_for_next_level = next_level_amount - support_level_amount; if (checkGoalReached()) { new_subject = mGoal[mIndex].goal_description + " [Goal " + (mIndex + 1) + " / " + mGoal.length + " reached! Thanks to all tippers.]"; goal_reached = true; } else { if (isAscendingOrder()) { new_subject = mGoal[mIndex].goal_description //+ " [Tip to ascend levels from 1 to " + max_tip_level + ". Tip for next level: " + tip_for_next_level + "]" ; } else { new_subject = mGoal[mIndex].goal_description //+ " [Tip to descend levels from " + max_tip_level + " to 1. Tip for next level: " + tip_for_next_level + "]" ; } } if (cb.settings.tipGoalNotice === 'Yes') { cb.changeRoomSubject(new_subject + ' ' + hashTags); } else { if (displaySubject === 0) { new_subject = mGoal[mIndex].goal_description; displaySubject ++; counter ++; cb.changeRoomSubject(new_subject + ' ' + hashTags); } else { //new_subject = mGoal[mIndex].goal_description; //displaySubject ++; //cb.changeRoomSubject(new_subject) } } } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function najvisi(ime, tip) { var index = imena.indexOf(ime); if (index == -1) { imena[imena.length] = ime; tipovi[tipovi.length] = tip; if (mGoal[mIndex].high_tip_amount == 0 || mGoal[mIndex].high_tip_amount < tip) { mGoal[mIndex].high_tip_amount = tip; mGoal[mIndex].high_tip_username = ime; } } else { tipovi[index] += tip; if (tipovi[index] > mGoal[mIndex].high_tip_amount) { mGoal[mIndex].high_tip_amount = tipovi[index]; mGoal[mIndex].high_tip_username = imena[index]; } } } function isAscendingOrder() { return (mGoal[mIndex].order == 'ascending'); } function setNextLevelNeeded() { if (isAscendingOrder()) { next_level_amount++; } else { next_level_amount--; } } function checkGoalReached() { if (isAscendingOrder()) { return (next_level_amount > max_tip_level); } else { return (next_level_amount <= 0); } } function startGoalWExtraFunds(moreMoney, originalTipAmmount, tipUser) { var originalTipAmmount2 = originalTipAmmount; var tipUser2 = tipUser; max_tip_level = null; next_level_amount = 1; support_level_amount = 0; goal_reached = false; imena = []; //new Array(); tipovi = []; //new Array(); max_tip_level = howManyNumbers(mGoal[mIndex].goal_value); totalUntilNextGoal = (max_tip_level * ((1 + max_tip_level)/2)); if (max_tip_level > 0) { // totalUntilNextGoal = (max_tip_level * (1 + max_tip_level))/2; totalUntilNextGoal = (((max_tip_level + 1)/2) * max_tip_level); } else { totalUntilNextGoal = mGoal[mIndex].goal_value; } mGoal[mIndex].goal_status = 'Current Goal'; if (isAscendingOrder()) { next_level_amount = 1; } else { next_level_amount = max_tip_level; } if ((moreMoney > totalUntilNextGoal) && (moreMoney >= highTipAmmountForNextGoal)) { //this is for when the tip amount has cleared more than one goal najvisi(tipUser2, originalTipAmmount2); var pleaseShootMe = 0; pleaseShootMe = (moreMoney - totalUntilNextGoal); var diff = moreMoney; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } startGoalWExtraFunds(pleaseShootMe, originalTipAmmount2,tipUser2); } else if (moreMoney > highTipAmmountForNextGoal){ //this is if the amount tipped is larger then the tip ammount to be add to next goal but not enough to clear this goal as well. totalUntilNextGoal = (totalUntilNextGoal - moreMoney); najvisi(tipUser2, originalTipAmmount2); var diff = moreMoney; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } } else { totalUntilNextGoal = (totalUntilNextGoal - moreMoney); najvisi(tipUser2, originalTipAmmount2); var diff = moreMoney; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag === 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED"; displayGoals(); cb.drawPanel(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } // displayGoals(); cb.drawPanel(); //startGoal() } // update_subject(); // // displayGoals(); } function startGoal() { //totalUntilNextGoal = null; max_tip_level = null; next_level_amount = 1; support_level_amount = 0; goal_reached = false; imena = []; //new Array(); tipovi = []; //new Array(); max_tip_level = howManyNumbers(mGoal[mIndex].goal_value); totalUntilNextGoal = (max_tip_level * ((1 + max_tip_level)/2)); mGoal[mIndex].goal_status = 'Current Goal'; if (isAscendingOrder()) { next_level_amount = 1; } else { next_level_amount = max_tip_level; } update_subject(); displayGoals(); } function currentGoal(msgUser) { var theUser = msgUser; cb.sendNotice('************ ' + mGoal[mIndex].goal_status + '***********',theUser,'#ffffff','#4169E1','bold',''); cb.sendNotice('When Goal is done were going to do ' + mGoal[mIndex].goal_description + ' \nTotal tokens left for this goal ' + totalUntilNextGoal + ' \n the goal is ' + mGoal[mIndex].order + '',theUser,'#ffffff','#4169E1','bold',''); } function displayGoals() { var displayOption = cb.settings.display_goals; var user = ""; if (displayOption == "-") { return; } if (displayOption == "Me") { user = cb.room_slug; } var fgColor1 = "#87CEEB"; var bgColor1 = "#ffffff"; var fontw1 = "bold"; var fgColor2 = "#4169E1"; var fgColor; cb.chatNotice("***********************************************", user, bgColor1, fgColor1, fontw1); var numGoal = mGoal.length; for (var i=0;i<numGoal;i++) { if ( mGoal[i]["goal_status"] == "COMPLETED") fgColor = fgColor1; else fgColor = fgColor2; var status = mGoal[i]["goal_status"]; if (i === mIndex && mDoneFlag === 0) { status = "Current Goal"; } cb.chatNotice("\n==== Goal " + (i + 1) + " / " + numGoal + " - " + status, user, bgColor1, fgColor, fontw1); cb.chatNotice(mGoal[i]["goal_description"], user, bgColor1, fgColor, fontw1); if (mGoal[i]["order"] == "descending") cb.chatNotice("Level: " + mGoal[i]["max_tip_level"] + " to 1", user, bgColor1, fgColor, fontw1); else cb.chatNotice("Level: 1 to " + mGoal[i]["max_tip_level"], user, bgColor1, fgColor, fontw1); if (mGoal[i]["high_tip_username"]) { cb.chatNotice("High Tipper: " + mGoal[i]["high_tip_username"] + " (" + mGoal[i]["high_tip_amount"] + ")", user, bgColor1, fgColor, fontw1); } } new_subject = mGoal[mIndex].goal_description; cb.changeRoomSubject(new_subject + ' ' + hashTags); cb.chatNotice("\n***********************************************", user, bgColor1, fgColor1, fontw1); } function showGoals(msgUserParam) { var user = msgUserParam; var fgColor1 = "#87CEEB"; var bgColor1 = "#ffffff"; var fontw1 = "bold"; var fgColor2 = "#4169E1"; var fgColor; cb.sendNotice("***********************************************", user, bgColor1, fgColor1, fontw1,''); var numGoal = mGoal.length; for (var i=0;i<numGoal;i++) { if ( mGoal[i]["goal_status"] == "COMPLETED") fgColor = fgColor1; else fgColor = fgColor2; var status = mGoal[i]["goal_status"]; if (i == mIndex && mDoneFlag == 0) { status = "Current Goal"; } cb.sendNotice("\n==== Goal " + (i + 1) + " / " + numGoal + " - " + status, user, bgColor1, fgColor, fontw1,''); cb.sendNotice(mGoal[i]["goal_description"], user, bgColor1, fgColor, fontw1,''); if (mGoal[i]["order"] == "descending") cb.sendNotice("Level: " + mGoal[i]["max_tip_level"] + " to 1", user, bgColor1, fgColor, fontw1,''); else cb.sendNotice("Level: 1 to " + mGoal[i]["max_tip_level"], user, bgColor1, fgColor, fontw1,''); if (mGoal[i]["high_tip_username"]) { cb.sendNotice("High Tipper: " + mGoal[i]["high_tip_username"] + " (" + mGoal[i]["high_tip_amount"] + ")", user, bgColor1, fgColor, fontw1,''); } } cb.sendNotice("\nend***********************************************", user, bgColor1, fgColor1, fontw1,''); } function createGoal(gdesc, gvalue, gorder) { var tmp1 = { "goal_description": gdesc, "goal_value" : gvalue, "order" : gorder, "high_tip_amount" : 0, "high_tip_username" : null, "max_tip_level" : 0, "goal_status" : "Not Started" }; var maxTipLevel = howManyNumbers(gvalue); total_for_all_goals += (maxTipLevel * ((maxTipLevel + 1)/2)); tmp1["max_tip_level"] = howManyNumbers(gvalue); return tmp1; } function init() { /** cb.chatNotice("***********************************************", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("Token Climber Multi-Goal - Version 1.0", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("Developer: SKYEnet ", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("***********************************************", "", "#ffffff", "#00BFFF", "bold"); */ var tempadmins = []; tempadmins = cb.settings.AdminMods; adminChoice = cb.settings.AdminControl; admins = typeof tempadmins !== 'string' ? tempadmins = false : tempadmins.split(" "); mIndex = 0; goalCount = 0; highTipAmmountForNextGoal = cb.settings.tipHasToBeThisHigh; tipammountLeftAfterGoal = cb.settings.tipLeftAfterGoal; multiTipGoal = cb.settings.multiTipGoal; hashTags = cb.settings.hashTagsChoice; if (cb.settings.active1 == "active" && cb.settings.goal_description1 && cb.settings.goal_value1 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description1, cb.settings.goal_value1, cb.settings.order1)); } if (cb.settings.active2 == "active" && cb.settings.goal_description2 && cb.settings.goal_value2 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description2, cb.settings.goal_value2, cb.settings.order2)); } if (cb.settings.active3 == "active" && cb.settings.goal_description3 && cb.settings.goal_value3 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description3, cb.settings.goal_value3, cb.settings.order3)); } if (cb.settings.active4 == "active" && cb.settings.goal_description4 && cb.settings.goal_value4 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description4, cb.settings.goal_value4, cb.settings.order4)); } if (cb.settings.active5 == "active" && cb.settings.goal_description5 && cb.settings.goal_value5 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description5, cb.settings.goal_value5, cb.settings.order5)); } if (cb.settings.active6 == "active" && cb.settings.goal_description6 && cb.settings.goal_value6 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description6, cb.settings.goal_value6, cb.settings.order6)); } if (cb.settings.active7 == "active" && cb.settings.goal_description7 && cb.settings.goal_value7 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description7, cb.settings.goal_value7, cb.settings.order7)); } if (goalCount > 0) { startGoal(); } else { cb.chatNotice("** No Goals Set **", "", "#ffffff", "#FF0000", "bold"); } cb.sendNotice('Poly\'s Multi-Goal Token Climber please email me with issues or additions \n polymath614@gmail.com',cb.room_slug,'') } init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.