Apps Home
|
Create an App
Hottest Random repeating goal
Author:
everlast_69
Description
Source Code
Launch App
Current Users
Created by:
Everlast_69
// original code from Reset_Goals by Pussyfucker_007 /********************************************************/ /* Random Prize Multi-goal app */ /* */ /* Original app Reset-Goals by PussyFucket_007 */ /* Modified by everlast_69 April 16, 2017 */ /* Modification: added Random Prize Selection at */ /* every goal. */ /* Modification designed for Hottest_Evil */ /* The app works similar to the */ /* Multi Goal apps except the prize at each goal is */ /* selected randomly from a list of up to 10 prizes */ /* entered by the model. There is a final prize when */ /* a specified number of goals is reached. */ /* */ /* Items that are selectable by the model: */ /* 1. tokens for goal */ /* 2. Number of goals to play */ /* 3. Prize when number of goals is reached */ /* 4. How often (in minutes) to display prize list */ /* 5. 1 to 10 prizes. */ /* 6. Info to be added to the subject line. */ /********************************************************/ // vars var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; var set_tokens_command = '!settok'; var set_reached_command = '!setreached'; var prizes = []; var subject_tags = null; var prizelist = null; var gameover = false; var number_of_entries = 15; var tip_menu = []; var tip_menu_included = false; var debug_command = '!debug'; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, defaultvalue: 100, label: "Tokens For Goal"}, {name: 'interval', type: 'int', minValue: 1, maxValue: 10, defaultvalue: 2, label: "Display Prize List every X minutes"}, {name: 'hashtab', type: 'str', minLength: 1, maxLength: 255, label: "Additional subject items", defaultValue: "#pussy, #cum,#tits"}, {name: 'tipmenuvalues', type: 'str', minLength: 1, maxLength: 255, label: "Tip Menu Values", defaultValue: "10,20,30,50"}, {name: 'goal', type: 'int' , minValue: 1, maxValue: 100, label: "Number Of Goals To Play", defaultValue: 10}, {name: 'goalprize', type: 'str', minLength: 1, maxLength: 255, label: "Prize for top goal"}, {name: 'prize1', type: 'str', minLength: 1, maxLength: 255, label: "Prize 1", defaultValue: "p1", required: true}, {name: 'prize2', type: 'str', minLength: 1, maxLength: 255, label: "Prize 2", defaultValue: "p2", required: false}, {name: 'prize3', type: 'str', minLength: 1, maxLength: 255, label: "Prize 3", defaultValue: "p3", required: false}, {name: 'prize4', type: 'str', minLength: 1, maxLength: 255, label: "Prize 4", defaultValue: "p4", required: false}, {name: 'prize5', type: 'str', minLength: 1, maxLength: 255, label: "Prize 5", defaultValue: "p5", required: false}, {name: 'prize6', type: 'str', minLength: 1, maxLength: 255, label: "Prize 6", defaultValue: "p6", required: false}, {name: 'prize7', type: 'str', minLength: 1, maxLength: 255, label: "Prize 7", defaultValue: "p7", required: false}, {name: 'prize8', type: 'str', minLength: 1, maxLength: 255, label: "Prize 8", defaultValue: "p8", required: false}, {name: 'prize9', type: 'str', minLength: 1, maxLength: 255, label: "Prize 9", defaultValue: "p9", required: false}, {name: 'prize10', type: 'str', minLength: 1, maxLength: 255, label: "Prize10!", defaultValue: "p10", required: false}, {name: 'prize11', type: 'str', minLength: 1, maxLength: 255, label: "Prize 11", defaultValue: "p11", required: false}, {name: 'prize12', type: 'str', minLength: 1, maxLength: 255, label: "Prize 12", defaultValue: "p12", required: false}, {name: 'prize13', type: 'str', minLength: 1, maxLength: 255, label: "Prize 13", defaultValue: "p13", required: false}, {name: 'prize14', type: 'str', minLength: 1, maxLength: 255, label: "Prize 14", defaultValue: "p14", required: false}, {name: 'prize15', type: 'str', minLength: 1, maxLength: 255, label: "Prize 15", defaultValue: "p15", required: false} ]; // handlers cb.onTip(function(tip) { if (!tip_menu_included) { if (cbjs.arrayContains(tip_menu, tip['amount'])) { return; } } if (!gameover) { current_goal_tipped += tip['amount'] if (current_goal_tipped >= cb.settings.tokens) { goalReached(tip['from_user']); } update_subject(); cb.drawPanel(); } }); cb.onDrawPanel(function(user) { if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': 'Never' }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': '' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago' }; } }); cb.onMessage(function (msg) { if (msg['m'][0] == '!') { if (msg['user'] == cb.room_slug || msg['is_mod'] == true) { if (startsWith(msg['m'], set_tokens_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_tokens_command.length); times_goal_reached = Math.floor(number / cb.settings.tokens); current_goal_tipped = number % cb.settings.tokens; last_time_goal_reached = new Date(); cb.drawPanel(); cb.sendNotice('The tokens received has been updated!', msg['user']); } else if (startsWith(msg['m'], set_reached_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_reached_command.length); times_goal_reached = number; last_time_goal_reached = new Date(); current_goal_tipped = 0; cb.drawPanel(); cb.sendNotice('The number of times reached has been updated!', msg['user']); } else if (startsWith(msg['m'], debug_command)) { msg['X-Spam'] = true; cb.sendNotice("Tip Meny Values Entered : " + cb.settings.tipmenuvalues,msg['user']); } } } }); // Functions function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 20000); cb.drawPanel(); } function update_subject() { var new_subject = "" if (gameover) { new_subject = getNumberString(cb.settings.goal) + " goal reached! " + cb.settings.goalprize + " time! Thanks all tippers." + " " + subject_tags; } else { new_subject = "Random Multi Goal [" + tips_remaining() + " tokens remaining] @" + getNumberString(cb.settings.goal) + " goal " + cb.settings.goalprize + " " + subject_tags; } cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function goalReached(userName) { last_time_goal_reached = new Date(); var curr_times_reached = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < curr_times_reached; i++) { times_goal_reached++; if (times_goal_reached == cb.settings.goal) { gameover = true; current_goal_tipped = 0; cb.sendNotice( getNumberString(cb.settings.goal) + " goal reached! " + cb.settings.goalprize + " time! Thanks all tippers.",'', "#FEF9CD", "#1A1AD7", "bold"); cb.sendNotice('The user ' + userName + ' has reached the goal.', cb.room_slug, "#FEF9CD", "#1A1AD7", "bold"); } else { current_goal_tipped -= cb.settings.tokens; cb.sendNotice("Goal was reached for the " + getNumberString(times_goal_reached) + " time!",'', "#FEF9CD", "#1A1AD7", "bold"); cb.sendNotice('The user ' + userName + ' has reached the goal.', cb.room_slug, "#FEF9CD", "#1A1AD7", "bold"); cb.sendNotice('The prize won is '+ getRandomPrize(),'', "#FEF9CD", "#1A1AD7", "bold"); } } } function getNumberString(number) { var numberString = null; var lastChar = String(number).charAt(String(number).length - 1); if ((lastChar == '1') && ((number % 100) != 11)) { numberString = number + "st"; } else if ((lastChar == '2') && ((number % 100) != 12)) { numberString = number + "nd"; } else if ((lastChar == '3') && ((number % 100) != 13)) { numberString = number + "rd"; } else { numberString = "" + number + "th"; } return (numberString); } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0; } else { return r; } } // Random Prize additions function startsWith(source, str) { return source.substring(0, str.length) === str; } function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } function getRandomPrize() { return prizes[getRandomIntInclusive(0, prizes.length - 1)]; } function build_prizes_array() { prizes = []; for (i = 1; i < number_of_entries + 1;i++) { if (eval("cb.settings.prize" + i) != "") { prizes.push(eval("cb.settings.prize" + i)); } } subject_tags = cb.settings.hashtab; prizelist = "Hottest_Evil Random Prize Multi-Goal Prize List\nOne of the following prizes will be selected\nat random when the next goal is reached\n" ; for (i=0; i < prizes.length; i++) { prizelist += prizes[i] + "\n"; } } function list_prizes() { //for (i=0; i < prizes.length; i++) { // prizelist += prizes[i] + "\n"; // } cb.sendNotice(prizelist,'', "#FEF9CD", "#1A1AD7", "bold"); } function display_prize_list() { if (!gameover) { list_prizes(); cb.setTimeout(display_prize_list, cb.settings.interval * 60000); } } function listToAray(fullString, separator) { var fullArray = []; if (fullString !== undefined) { if (fullString.indexOf(separator) == -1) { fullAray.push(fullString); } else { fullArray = fullString.split(separator); } } return fullArray; } function init() { if (cb.settings.tipmenuvalues != undefined){ if (cb.settings.tipmenuvalues.length > 0) { var temp = listToAray(cb.settings.tipmenuvalues, ','); tip_menu = temp.map(Number); tip_menu_included = false; } else { tip_menu_included = true; } } build_prizes_array(); update_subject(); display_prize_list(); } init(); cb.setTimeout(refresh, 20000);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.