Apps Home
|
Create an App
Guess the Number for HOT Mess
Author:
gtojudge24
Description
Source Code
Launch App
Current Users
Created by:
Gtojudge24
// vars var total_tipped = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var subject_is_set_with_0 = false; var moving_target = Math.floor(Math.random()*66)+11; var dark_blue = null; var numberGuessedCorrectly = false; var possibles = new Array(); var close_guess = 0; var highnum = 0; var lownum = 0; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 1011}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255, default: 'Naked Table Top Dancing'} ]; // handlers cb.onMessage(function (msg) { if (msg['user'] == 'elle_sterling') { msg['background'] = "#FF69B4"; } if (msg['user'] == 'steedj') { msg['background'] = "#90EE90"; msg['c'] = "#000000"; } if (msg['user'] == 'ellelover') { msg['background'] = "#00BFFF"; } if (msg['user'] == 'snowpup_1011') { msg['background'] = "#A2E3E8" msg['c'] = "#0000FF"; } if (msg['user'] == 'muddywaters1') { msg['c'] = "#000000"; } if (msg['user'] == 'ellelover') {cb.chatNotice("Ellelover says "+msg['m'],cb.room_slug) } if(msg['tipped_recently'] == true && msg['in_fanclub'] == true) { dark_blue = msg['user']; } if(msg['m'] == "/list" && msg['user'] == "elle_sterling") { msg['X-Spam'] = true; cb.chatNotice(dark_blue + " is a dark blue fan club member", msg['user']); } if(msg['m'] == "/list" && msg['user'] == "snowpup_1011") { msg['X-Spam'] = true; cb.chatNotice(dark_blue + " is a dark blue fan club member", msg['user']); } if(msg['m'] == "/list" && msg['user'] == "muddywaters1") { msg['X-Spam'] = true; cb.chatNotice(dark_blue + " is a dark blue fan club member", msg['user']); } if(msg['m'] == "/close") { cb.chatNotice(close_guess) } if(msg['m'] == "/rules") { msg['X-Spam'] = true; cb.chatNotice("Goal is met when " + cb.settings.tokens + " tokens have been received OR when someone guesses the magic number, whichever happens first. The magic number will be from 11 to 77 BUT if you guess wrong, it will be recalculated. However, if you get within three of the number, it will not change so you might be able to hit it IF your next guess is on target or closer. GOOD LUCK!", msg.user); } if(msg['m'] == "/hilo" && moving_target<61) {msg['X-Spam'] = true; cb.chatNotice("The number is in the range 11 to 60")} else if(msg['m'] == "/hilo" && moving_target > 60) {msg['X-Spam'] = true; cb.chatNotice("The number is in the range 61 to 111") } if(msg['m'] == "/strategy") { msg['X-Spam'] = true; cb.chatNotice("Freeze the Number Strategy -- If you guess within three of the number, it will NOT change. One of six numbers will then be the correct number. The Kankolite Strategy: From the list of possible numbers, pick ONE of the two furthest away from your first guess. You have a 50% chance of losing BUT if you do not lose on that guess, you have a 100% chance of winning. It may take two more guesses to win, but you cannot lose. If you decide to move just in one direction, one number at a time, and your second guess does not lose nor win, but is still close, you will also have eliminated one other number as a possibility. Should you find that you have not lost after your third guess, you will have only two numbers left to chose from. Reversing direction at this point will not lose!", msg.user); } if (msg['user'] == cb.room_slug && msg['m'] == "/number") { msg['X-Spam'] = true; cb.chatNotice(moving_target, msg['user']); } if (msg['user'] == 'snowpup_1011' && msg['m'] == "/number") { msg['X-Spam'] = true; cb.chatNotice(moving_target, msg['user']); } if (msg['user'] == 'muddywaters1' && msg['m'] == "/number") { msg['X-Spam'] = true; cb.chatNotice(moving_target, msg['user']); } if(msg['m'] == "/possibles") { var newpossibles = possibles.join(" ") cb.chatNotice(newpossibles); } return msg; }); cb.onTip(function(tip) { total_tipped += tip['amount'] cb.chatNotice("Tip message: "+tip['message'],'snowpup_1011'); cb.chatNotice("Tip message: "+tip['message'],'muddywaters1'); lownum = tip['amount'] - 3; highnum = tip['amount'] + 3; if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } if (lownum < 11) {lownum = 11}; if (highnum > 77) {highnum = 77}; if (tip['amount'] < 11 || tip['amount'] > 77) {cb.chatNotice(tip['from_user'] + ", your tip is welcome but outside the range of possible numbers for this game. The number will be from 11 to 77")}; if (tip['amount'] == moving_target) { cb.chatNotice("Wow! We have a winner! Congratulations, " + tip['from_user'] +"!"); moving_target = Math.floor(Math.random()*66)+11; possibles.length = 0; close_guess = 0; } else if (Math.abs(tip['amount'] - moving_target) <= 3 && close_guess == 0) { close_guess = 1; possibles[tip['amount']-3] = tip['amount']-3; possibles[tip['amount']-2] = tip['amount']-2; possibles[tip['amount']-1] = tip['amount']-1; possibles[tip['amount']+1] = tip['amount']+1; possibles[tip['amount']+2] = tip['amount']+2; possibles[tip['amount']+3] = tip['amount']+3; for (var i = 0; i < possibles.length; i++) if (possibles[i]<11) {delete possibles[i]}; for (var i = 0; i < possibles.length; i++) if (possibles[i]>77) {delete possibles[i]}; cb.chatNotice("A close guess! The number will not change so long as the next guess is not more than three away from the number! The winning number will be from " + lownum + " to " + highnum + "."); } else if (Math.abs(tip['amount'] - moving_target) <= 3 && close_guess > 0) { close_guess += 1; delete (possibles[tip['amount']]) for (var i = 0; i < possibles.length; i++) {if (Math.abs(tip['amount'] - possibles[i])>3) {delete possibles[i]} }; var newpossibles = possibles.join(" "); cb.chatNotice("Another close guess! Remaining possible numbers are " + newpossibles); } else if(tip['amount'] > 10 && tip['amount']<112) { cb.chatNotice("Sorry, "+tip['from_user']+", that was not the lucky number. It was " +moving_target+ ". Better luck next time."); close_guess = 0; possibles.length = 0; moving_target = Math.floor(Math.random()*66)+11; if (moving_target - tip['amount'] < 4 && tip['amount'] < 15) { moving_target +=4 } } update_subject(); last_tip_amount = tip['amount'] last_tip_username = tip['from_user'] if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount'] high_tip_username = tip['from_user'] } cb.drawPanel(); }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); // helper functions function update_subject() { if (total_tipped >= cb.settings.tokens || numberGuessedCorrectly == true) { var new_subject = "GOAL MET! Thanks to all tippers!"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } else if (numberGuessedCorrectly == true) { cb.settings.tokens == total_tipped; var new_subject = "We have a winner!. " + last_tip_username + " has guessed the correct number!" cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } else {var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]" +" Type /rules for a quick explanation or /strategy for one way to win if you guess close enough to the number"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject) } } function tips_remaining() { var r = cb.settings.tokens - total_tipped; if (r < 0) { return 0; } else { return r; } } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function init() { update_subject(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.