Bots Home
|
Create an App
Lucky 7 Slots
Author:
badforcleanminds1
Description
Source Code
Launch Bot
Current Users
Created by:
Badforcleanminds1
// App: Lucky 7 Slots // Author: BadForCleanMinds // Version: 1.0.0 // Date: 2019-10-10 const winning_sets = Array( '3x dildos', '3x sevens', '3x fleshlights', '3x bottles of lube', '2x+ cherries', '2x+ combo of condom/dildo', '1x cherry' ); cb.settings_choices = [ { name: 'tokens', type: 'int', label: 'Cost per spin (tokens)', defaultValue: 7 }, { name: 'notice_wait_time', type: 'choice', label: 'Notification Time (in minutes)', choice1: 1, choice2: 2, choice3: 3, choice4: 4, choice5: 5, choice6: 10, choice7: 15, choice8: 20, choice9: 25, choice10: 30, choice11: 45, choice12: 60, defaultValue: 10 }, { name: 'tip_multiplier', type: 'choice', label: 'Spins for (See Full Description for details)', choice1: 'Exact', choice2: 'At least', choice3: 'Exact Multiple', choice4: 'Count', choice5: 'Count + At least', default: 'At least', }, { name: 'ignore_tip_values', type: 'str', label: 'Exact Tip values to ignore (separated by a comma, empty for none)', required: false, defaultValue: '' }, { name: 'jackpot_minimum', type: 'int', label: 'Minimum number of tokens before jackpot can be won (0 for no min)', minValue: 0, defaultValue: 1000 }, { name: 'prize_1', type: 'str', label: 'Jackpot prize (' + winning_sets[0] + ')' }, { name: 'prize_2', type: 'str', label: '2nd place prize (' + winning_sets[1] + ')', required: false, default: '', }, { name: 'prize_3', type: 'str', label: '3rd place prize (' + winning_sets[2] + ')', required: false, default: '', }, { name: 'prize_4', type: 'str', label: '4th place prize (' + winning_sets[3] + ')', required: false, default: '', }, { name: 'prize_5', type: 'str', label: '5th place prize (' + winning_sets[4] + ')', required: false, default: '', }, { name: 'prize_6', type: 'str', label: '6th place prize (' + winning_sets[5] + ')', required: false, default: '', }, { name: 'prize_7', type: 'str', label: '7th place prize (' + winning_sets[6] + ')', required: false, default: '', } ]; const glyph_dildo = ':sm_dildo'; const glyph_seven = ':sm_seven'; const glyph_cherry = ':sm_cherry'; const glyph_fleshlight = ':sm_fleshlight'; const glyph_lube = ':sm_lube'; const glyph_condom = ':sm_condom'; const glyph_jackpot = glyph_dildo; const slot_machine_pieces = Array(glyph_dildo, glyph_lube, glyph_seven, glyph_fleshlight, glyph_cherry, glyph_condom); const pluralize_token_str = (cb.settings.tokens > 1) ? 'tokens' : 'token'; const ignored_tip_values = String(cb.settings.ignore_tip_values).replace(/[,;\.\s]+/g, ",").split(',').map(Number); let prizes_won = Array(); let spin_counter = 0; let rolling_tip_counter = 0; let last_player = ''; let last_prize_won = ''; const lobby_chat = ''; const default_background_color = ''; const default_foreground_color = ''; const testing_background_color = '#000000'; const testing_foreground_color = '#00A000'; function get_random_glyph() { let random_array_index = Math.floor(Math.random() * slot_machine_pieces.length); // Respins Jackpot Glyph once on odd spins to decrease its probability if((slot_machine_pieces[random_array_index] === glyph_jackpot) && (spin_counter % 2 !== 0)) { random_array_index = Math.floor(Math.random() * slot_machine_pieces.length); } return slot_machine_pieces[random_array_index]; } function get_row_of_random_glyphs() { return Array(get_random_glyph(), get_random_glyph(), get_random_glyph()); } function get_row_of_random_glyphs_with_jackpot_limit() { let row = Array(get_random_glyph(), get_random_glyph(), get_random_glyph()); if (row.filter(x => x === glyph_jackpot).length === 3 && (parseInt(rolling_tip_counter) < parseInt(cb.settings.jackpot_minimum))) { // Spun a Jackpot but haven't reached the minimum yet -> Spin Again! row = get_row_of_random_glyphs_with_jackpot_limit(); } return row; } function is_winning_prize_row(row) { if (row.filter(x => x === glyph_jackpot).length === 3) { return 1; // Jackpot } if (row.filter(x => x === glyph_seven).length === 3) { return 2; // 2nd Prize } if (row.filter(x => x === glyph_fleshlight).length === 3) { return 3; // 3rd Prize } if (row.filter(x => x === glyph_lube).length === 3) { return 4; // 4th Prize } if (row.filter(x => x === glyph_cherry).length >= 2) { return 5; // 5th Prize } if ((row.filter(x => x === glyph_dildo).length + row.filter(x => x === glyph_condom).length) >= 2) { return 6; // 6th Prize } if (row.filter(x => x === glyph_cherry).length === 1) { return 7; // 7th Prize } return 8; // Not a winning prize } const win_notice_foreground_color = '#99FF99'; const lose_notice_foreground_color = '#996633'; function spin(user) { const top_row = get_row_of_random_glyphs_with_jackpot_limit(); const mid_row = get_row_of_random_glyphs_with_jackpot_limit(); const bot_row = get_row_of_random_glyphs_with_jackpot_limit(); const prize_number = is_winning_prize_row(mid_row); const prize = cb.settings['prize_' + prize_number]; spin_counter += 1; let notice = ''; notice += top_row.join(' ') + "\n"; notice += mid_row.join(' ') + " <-- Pay Line\n"; notice += bot_row.join(' '); cb.sendNotice( notice, lobby_chat ); if (prize_number >= 1 && prize_number <= 7 && prize !== '') { last_player = user; last_prize_won = prize; prizes_won.push(prize + ' - ' + user); notice = user + ' won a prize! Prize: ' + prize; cb.sendNotice( notice, lobby_chat, default_background_color, win_notice_foreground_color, 'bold' ); } else { notice = user + ' did not win anything. :cry'; cb.sendNotice( notice, lobby_chat, default_background_color, lose_notice_foreground_color, 'bold' ); } cb.drawPanel(); return prize; } function test_spins(user, num_of_spins) { // temporary stores the running 'spin_counter' so we can do our test(s) let old_spin_counter = spin_counter; spin_counter = 0; let spin_counters = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, }; for(let i = 1; i <= num_of_spins; i++) { spin_counters[is_winning_prize_row(get_row_of_random_glyphs())] += 1; spin_counter += 1 } // restore the running 'spin_counter' spin_counter = old_spin_counter; let sorted_spin_counters = {}; Object.keys(spin_counters).sort().forEach(function(key) { sorted_spin_counters[key] = spin_counters[key]; }); let notice = sorted_spin_counters; cb.sendNotice( notice, user, default_background_color, default_foreground_color ); return spin_counters } function calculate_spins(tip) { switch (cb.settings.tip_multiplier) { case 'Exact': return tip === cb.settings.tokens ? 1 : 0; break; case 'At least': return tip >= cb.settings.tokens ? 1 : 0; break; case 'Exact Multiple': return tip % cb.settings.tokens === 0 ? Math.floor(tip / cb.settings.tokens) : 0; break; case 'Count': re = new RegExp("^("+String(cb.settings.tokens)+")+$"); if (!String(tip).match(re)) { return 0 } re = new RegExp(String(cb.settings.tokens), 'g'); return (String(tip).match(re) || []).length; break; case 'Count + At least': if (tip < cb.settings.tokens) { return 0; } // Returns at least 1 spin re = new RegExp("^("+String(cb.settings.tokens)+")+$"); if (!String(tip).match(re)) { return 1 } re = new RegExp(String(cb.settings.tokens), 'g'); return (String(tip).match(re) || []).length; } } function handle_tips(tip) { const tipped_amount = parseInt(tip['amount']); if (tipped_amount !== cb.settings.tokens && ignored_tip_values.includes(tipped_amount)) { return; } rolling_tip_counter += tipped_amount; let number_of_spins = calculate_spins(tipped_amount); for(let i = 1; i <= number_of_spins; i++) { cb.setTimeout( function() { spin(tip['from_user']); }, 2000*i ); } } function test_tipping(user, test_tip) { const tip = { 'amount': parseInt(test_tip), 'from_user': user }; cb.sendNotice( 'Testing tip amount: ' + test_tip, user, testing_background_color, testing_foreground_color, 'bold' ); handle_tips(tip); } function draw_panel(user) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Last prize won:', 'row1_value': last_prize_won, 'row2_label': 'Last player:', 'row2_value': last_player, 'row3_value': rolling_tip_counter + ' ' + pluralize_token_str + ' received / spun ' + spin_counter + ' time(s)' }; } function handle_messages(msg) { const message = msg['m']; const user = msg['user']; if (message.match(/^\/w\b/i)) { msg['X-Spam'] = true; send_prizes_won_list_to_user(user); } else if (message.match(/^\/p\b/i)) { msg['X-Spam'] = true; send_prize_list_to_user(user); } else if (user === cb.room_slug && message.match(/^\/test_spin_odds/i)) { msg['X-Spam'] = true; test_spins(user, 100000); } else if (user === cb.room_slug && message.match(/^\/test_tipping/i)) { msg['X-Spam'] = true; test_tipping(user, parseInt(message.split(' ')[1])); } return msg; } const notice_background_color = '#D1F0FF'; function send_prize_list_to_user(user) { let notice = '**** Possible Prizes ****'; // CB does not support 'Object.entries' // notice += Object.values(Object.entries(nning_sets).map(([key, value]) => key + ') ' + value + ' = ' +cb.settings['prize_' + key])).join('\n'); for (let i = 0; i < winning_sets.length; i++) { notice += '\n' + (i+1) + ") " + winning_sets[i] + ' = ' + cb.settings['prize_' + (i+1)]; } cb.sendNotice( notice, user, notice_background_color, default_foreground_color, 'bold' ); } const empty_win_list_foreground_color = '#CC0000'; const win_list_background_color = '#EBFFEB'; function send_prizes_won_list_to_user(user) { if(prizes_won.length > 0) { const recent_prize_list = prizes_won.slice(-20); let notice = "**** Last 20 Winners ****"; for(let i = 0; i < recent_prize_list.length; i++) { notice += "\n" + (i + 1) + ") " + recent_prize_list[i]; } cb.sendNotice( notice, user, win_list_background_color, default_foreground_color, 'bold' ); } else { cb.sendNotice( 'No one has won anything yet. Play the slot machine to win a prize!', user, default_background_color, empty_win_list_foreground_color, 'bold' ); } } let advertisement_notice = ''; advertisement_notice += 'Tip ' + cb.settings.tokens + ' ' + pluralize_token_str + ' to spin the reels.\n'; advertisement_notice += 'Type "/p" to see the available prizes.\n'; advertisement_notice += 'Type "/w" to see a list of the last 20 winners.'; advertisement_background_color = default_background_color; advertisement_foreground_color = '#FF6600'; function user_enters_room(user_data) { const user = user_data['user']; let notices = "Welcome, " + user + ". We are playing the slot machine.\n" + advertisement_notice; cb.sendNotice( notices, user, advertisement_background_color, advertisement_foreground_color, 'bold' ); } function post_notice_advertisement() { let notices = "Luck 7 Slots\n" + advertisement_notice; cb.sendNotice( notices, lobby_chat, advertisement_background_color, advertisement_foreground_color, 'bold' ); cb.setTimeout(post_notice_advertisement, cb.settings.notice_wait_time * 60000); } function init() { post_notice_advertisement(); } //cb.onDrawPanel( // draw_panel //); cb.onEnter( user_enters_room ); cb.onMessage( handle_messages ); cb.onTip( handle_tips ); init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.