Apps Home
|
Create an App
Find The G-spot
Author:
sexentettentest
Description
Source Code
Launch App
Current Users
Created by:
Sexentettentest
cb.settings_choices = function () { var ins_index = 0; var output = [ {name: 'fg_color', label: '[GENERAL SETTINGS] ---------------------- Text color', type: 'str', defaultValue: '#800000', required: false}, {name: 'bg_color', label: 'Highlight color', type: 'str', required: false}, {name: 'hashtags', label: 'Room subject', type: 'str', defaultValue: 'find the #gspot on the board and the goal will be reached!', required: false}, {name: 'commanders', label: 'Users who can use admin commands', type: 'str', required: false, defaultValue: 'sexentetten'}, {name: 'row_size', label: '[GSPOT BOARD SETTINGS] ---------------------- squares per row', type: 'int', minValue: 5, maxValue: 12, defaultValue: 10}, {name: 'custom_header', label: 'Custom header for the G-Spot Board', type: 'str', defaultValue: 'The G-Spot Board', required: false}, {name: 'min_tip', label: 'Minimum tip', type: 'int', minValue: 1, defaultValue: 10}, {name: 'interval', label: 'Seconds between auto-displays (0 = off)', type: 'int', minValue: 0, defaultValue: 180}, {name: 'distance_threshold', label: 'Notify the user when his chosen tile is within X tiles from the G-Spot (incl diagonal tiles)', type: 'int', minValue: 0, defaultValue: 3}, {name: 'found_goal', label: 'G-Spot found goal', type: 'str', defaultValue: 'cum show', required: true}, {name: 'mvp_prize', label: 'Special prize for MVP', type: 'str', required: false} ]; return output; }(); var cbs = JSON.parse(JSON.stringify(cb.settings)); for (var key in cbs) { if (typeof cbs[key] === 'string') cbs[key] = cbs[key].trim(); } var gspot_header = cbs.custom_header || '[G-SPOT BOARD]'; var goal = cbs.found_goal; var mvp_prize = cbs.mvp_prize; var min_tip = cbs.min_tip; var game_end = false; var row_size = cbs.row_size; var discovered_squares = []; var gspot_location = generateNewGSpotLocation(); var tipLedger = {}; var mvp = {}; var distance_threshold = cbs.distance_threshold; var bg_color_win = '#62dbcf'; cb.onEnter((user) => displayBoard(user.user)); var commanders = cbs.commanders ? cbs.commanders.split(/\s*,\s*/) : []; /********** ------------ PANEL ------------ **********/ cb.onDrawPanel(function () { return { 'template': '3_rows_of_labels', 'row1_label': 'When G-Spot found ::', 'row1_value': goal, 'row2_label': '---', 'row2_value': '---' , 'row3_label': 'MVP :: ' + (mvp.user || '???'), 'row3_value': mvp.amt ? mvp.amt + ' tks' : '???' }; }); /********** ------------ MESSAGES ------------ **********/ cb.onMessage(function (msg) { if (msg.m.charAt(0) === '/' || msg.m.charAt(0) === '!') { msg['X-Spam'] = true; var str = msg.m.substring(1).trim(); var params = str.split(/\s+/); var cmd = params[0].toLowerCase().trim(); if (isCommander(msg.user)) command(cmd, params.slice(1), msg.user); switch (cmd) { case 'b': displayBoard(msg.user); break; /*case 'p': displayPrizes(msg.user); break;*/ }; } return msg; }); function isCommander(user) { return user === cb.room_slug || commanders.includes(user); } function generateNewGSpotLocation() { var gspotLocation = Math.floor(Math.random() * row_size * row_size); game_end = false; discovered_squares = []; mvp = {}; cb.changeRoomSubject(cbs.hashtags); return gspotLocation; } function command(cmd, params, user) { try { switch(cmd) { case 'h': case 'help': var sep = '\n\u2007\u2007'; roomNotice(['\u25CF ----- [COMMANDS] ----- \u25CF', '/h or /help ' + sep + ' Show the help menu.', '/bx ' + sep + ' Show the board to everyone', '/px ' + sep + ' Show the goal to everyone.', '/timer [X (number)] ' + sep + ' Sets a countdown timer for X minutes.', '/restart ' + sep + 'Restarts the game.', '/newgoal ' + sep + 'Set a new goal, the current game continues.', '/newmvpprize ' + sep + 'Set (or clear) the MVP prize, the current game continues.', '/rowSize [X (number)] ' + sep + ' Sets the number of board slots per row to X.', '/tipamount ' + sep + 'Set the minimum tip amount to play the game.', // '/count [X (number)] ' + sep + ' Sets the number of tokens received to X.', // '/kxt [X (number)] ' + sep + ' Simulates a tip of X tokens from ModelBot.', '/kx# [JavaScript] ' + sep + ' Execute JavaScript. Only use in emergencies.', ].join('\n'), user); break; /*case 'count': if (!Number(command[1])) break; tipCount = Number(command[1]); break;*/ /*case 'kxt': if (!params || !Number(params[0])) break; doTip({from_user: 'ModelBot', amount: Number(params[0])}) break;*/ case 'bx': displayBoard(); break; case 'px': roomNotice('The goal is ' + goal); if(mvp_prize !== '') { roomNotice('The MVP prize is ' + mvp_prize); } else { roomNotice('No MVP prize set'); } break; case 'restart': gspot_location = generateNewGSpotLocation(); displayBoard(); break; case 'newgoal': if (params && params[0]) { var val = params.join(' '); goal = val; roomNotice('There is a new goal: ' + goal); } break; case 'newmvpprize': if (params && params[0]) { var val = params.join(' '); mvp_prize = val; roomNotice('There is a new MVP prize: ' + mvp_prize); } else { mvp_prize = ''; roomNotice('There is no prize for the MVP anymore.'); } break; case 'tipamount': if (params && params[0]) { var num = Number(params[0]); if (num && num > 1) { min_tip = num; roomNotice('The minimum amount you need to tip in order to play the game has been changed to ' + min_tip); } } break; case 'timer': if (params && params[0]) { var num = Number(params[0]); if (num) { cbs.interval = num; modMessage('Timer set to ' + num + '.', user); } } break; case 'rowsize': if (params && params[0]) { var num = Number(params[0]); if (num) { if (num < 5) {num = 5;} else if (num > 12) {num = 12;} row_size = num; gspot_location = generateNewGSpotLocation(); //Notify the modMessage('Row size set to ' + num + '.', user); displayBoard(); } } break; case 'kx#': try { var str = params.join(' '); var result = eval(str); var notice = 'TYPE: ' + typeof result + '\nVALUE: '; result !== void 0 ? notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007') : notice += 'undefined'; cb.setTimeout(() => cb.sendNotice(newLines(notice), user, '', '#00CC00', '', ''), 100); } catch (e) { cb.setTimeout(() => cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', ''), 100); } break; }; } catch (e) { cb.sendNotice(e.message, '') } cb.drawPanel(); } function displayBoard(user) { var vals = []; var rows = []; var output = '\u2007 Tip minimum ' + min_tip + ' and put the tile number you want to check in the tip message to play! \n'; output += '\u2007 Values between bracets indicate the distance from the G-Spot (incl. diagonal!).\n'; output += '\u2007 ' + gspot_header + '\n'; for(var i = 0; i < row_size; i = i + 1) { for(var j = 0; j < row_size; j = j +1) { var locationNumber = (i * row_size) + (j + 1); //this one starts from 1 instead of 0 var squareNumber = locationNumber - 1; var tileContent = ''; if(game_end && squareNumber === gspot_location) { tileContent = '\u2007' + 'G'; } else { if(discovered_squares.indexOf(squareNumber) != -1) { var distance = calculateDistance(squareNumber, gspot_location); if(distance <= distance_threshold) { tileContent = '(' + distance + ')'; } else { tileContent = '\u2007\u2007'; } } else { tileContent = locationNumber; } } if(!isNaN(tileContent) && tileContent.toString().length === 1) { output += '\u2007\u2007' + tileContent + '\u2007 |'; } else { //output += '\u2007' + tileContent + '\u2007 |'; if(tileContent.toString().length === 2 || isNaN(tileContent)) { output += '\u2007' + tileContent + '\u2007 |'; } else { output += tileContent + '\u2007 |'; } } } if(i != row_size - 1) { output += '\n'; } } //for (var i = 0; i < vals.length; i = i + row_size) rows.push(vals.slice(i, i + row_size).join(' \u25E6 ')); //while (rows[rows.length - 1].length < rows[0].length) rows[rows.length - 1] += ' \u25E6 ' + blankSpot; //var output = '\u2007 ' + gspot_header + '\n' + rows.join('\u2007 |>\n') + '\u2007 |>\n' + infoStr + '\n'; roomNotice(output, user, 'bold'); } /********** ------------ TIPS ------------ **********/ cb.onTip((tip) => doTip(tip)); function doTip(tip) { var amt = tip.amount; if(!game_end && amt < min_tip) { cb.sendNotice('The tip amount has to be ' + min_tip + ' or more to play the game'); return; } var user = tip.from_user; var squareNumber = parseInt(tip.message.trim()); if(isNaN(squareNumber) || squareNumber < 1 || squareNumber > 100) { if(!game_end) { cb.sendNotice('Note tip message is not a number between 1 and 100'); } return; } if(game_end) { cb.sendNotice('The game is over, please wait before a new game is started.'); return; } squareNumber = squareNumber - 1; game_end = checkTip(squareNumber, user); checkMVP(amt, user); displayBoard(); cb.drawPanel(); } function checkTip(squareNumber, user) { // CHECK IF THE squareNumber IS THE SAME AS THE GSPOT LOCATION, OTHERWISE MAYBE SEND A NOTIFICATION if(discovered_squares.indexOf(squareNumber) < 0) { discovered_squares.push(squareNumber); } if(squareNumber === gspot_location) { cb.sendNotice('User ' + user + ' has found the G-Spot!', null, bg_color_win, cbs.fg_color, 'bold'); cb.sendNotice('You won: ' + goal, null, bg_color_win, cbs.fg_color, 'bold'); if(mvp && mvp.user) { if(mvp_prize !== '') { cb.sendNotice('The MVP: ' + mvp.user + ' (' + mvp.amt + ') won a ' + mvp_prize + '!', null, bg_color_win, cbs.fg_color, 'bold'); } else { cb.sendNotice('The MVP: ' + mvp.user + ' (' + mvp.amt + ')', null, bg_color_win, cbs.fg_color, 'bold'); } } cb.changeRoomSubject('The G-Spot has been found by ' + user + ' prize: ' + goal); return true; } else { var distance = calculateDistance(squareNumber, gspot_location); if(distance <= 3) { if(distance === 1) { cb.sendNotice('Tile ' + (squareNumber + 1) + ' is only 1 tile away from the G-Spot', null, '#ffffff', '#47c93e', 'bold'); } else { cb.sendNotice('Tile ' + (squareNumber + 1) + ' is only ' + distance + ' tiles away from the G-Spot', null, '#ffffff', '#47c93e', 'bold'); } } else { cb.sendNotice('Tile ' + (squareNumber + 1) + ' is nowhere near the G-Spot!', null, '#ffffff', '#47c93e', 'bold'); } } return false; } function calculateDistance(locationToCheck, gspotLocation) { var row = findRowOfLocationNumber(locationToCheck); var column = findColumnOfLoctionNumber(locationToCheck); var gspotRow = findRowOfLocationNumber(gspotLocation); var gspotColumn = findColumnOfLoctionNumber(gspotLocation); var x = [column, row]; var y = [gspotColumn, gspotRow]; return chebyshev(x, y); //return Math.abs(row - gspotRow) + Math.abs(column - gspotColumn) //OLD VERSION WITHOUT DIAGONALS } function chebyshev( x, y, clbk ) { var len, d, v, i; /*if ( !isArray( x ) ) { throw new TypeError( 'chebyshev()::invalid input argument. First argument must be an array. Value: `' + x + '`.' ); } if ( !isArray( y ) ) { throw new TypeError( 'chebyshev()::invalid input argument. Second argument must be an array. Value: `' + y + '`.' ); } if ( arguments.length > 2 ) { if ( !isFunction( clbk ) ) { throw new TypeError( 'chebyshev()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' ); } }*/ len = x.length; if ( len !== y.length ) { throw new Error( 'chebyshev()::invalid input arguments. Input arrays must have the same length.' ); } if ( !len ) { return null; } if ( clbk ) { v = clbk( x[0], 0, 0 ) - clbk( y[0], 0, 1 ); d = ( v < 0 ) ? -v : v; for ( i = 1; i < len; i++ ) { v = clbk( x[i], i, 0 ) - clbk( y[i], i, 1 ); if ( v < 0 ) { v = -v; } if ( v > d ) { d = v; } } } else { v = x[ 0 ] - y[ 0 ]; d = ( v < 0 ) ? -v : v; for ( i = 1; i < len; i++ ) { v = x[ i ] - y[ i ]; if ( v < 0 ) { v = -v; } if ( v > d ) { d = v; } } } return d; } function findRowOfLocationNumber(locationNumber) { return Math.floor(locationNumber / row_size); } function findColumnOfLoctionNumber(locationNumber) { var row = findRowOfLocationNumber(locationNumber); return locationNumber - (row * row_size); } function checkMVP(amt, user) { tipLedger[user] ? tipLedger[user] += amt : tipLedger[user] = amt; if (!mvp.user || tipLedger[user] > mvp.amt) mvp = {user: user, amt: tipLedger[user]}; } function numString(num) { return num < 10 ? '0' + num : '' + num; } /********** ------------ COMMUNICATION ------------ **********/ function roomNotice(text, user, weight) { cb.sendNotice(newLines(text), user, cbs.bg_color, cbs.fg_color, weight || 'bold', ''); } function modMessage (str, user) { roomNotice('MOD MESSAGE: ' + str, user); if (user !== cb.room_slug) roomNotice('MOD MESSAGE: ' + str, cb.room_slug); } function newLines(input) { return '|\u2007 ' + input.replace(/\n/g, '\n|\u2007 '); } /********** ------------ INIT ------------ **********/ if (cbs.interval) { (function rotator() { displayBoard(); cb.setTimeout(rotator, cbs.interval * 1000); })(); } cb.changeRoomSubject(cbs.hashtags); cb.drawPanel(); displayBoard();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.