Apps Home
|
Create an App
Slave-App
Author:
justme0815
Description
Source Code
Launch App
Current Users
Created by:
Justme0815
function getSettingsArray(setting, max) { var i; var result = []; for (i = 0; i < max; i++) { var opt = cb.settings[setting + i]; if (opt !== undefined && opt !== '') { result.push(opt); } } return result; } cb.settings_choices = [ {name: 'slave', type: 'str', required: true, label: 'Enter the account name of the slave'}, {name: 'delay', type: 'int', required: true, label: 'Enter the delay between the spanking actions (between 5 and 120 minutes)', minValue: 5, maxValue: 120}, {name: 'multiplier', type: 'int', required: true, label: 'Enter the multiplier for the spanking, i.e. \'multiplier * user = spanks\' (between 1 and 10)', minValue: 1, maxValue: 10}, {name: 'tip', type: 'int', required: true, label: 'Enter the amount of tokens for an additional spank', minValue: 1}, {name: 'seeking', type: 'choice', required: true, label: 'Enter the gender you are looking for', choice1: 'female', choice2: 'male', choice3: 'couple', choice4: 'shemale', choice5: 'no limitations', defaultValue: 'female'}, {name: 'tool0', type: 'str', required: true, label: 'Enter the 1st tool for spanking'}, {name: 'tool1', type: 'str', required: false, label: 'Enter a 2nd tool (optional)'}, {name: 'tool2', type: 'str', required: false, label: 'Enter a 3th tool (optional)'}, {name: 'tool3', type: 'str', required: false, label: 'Enter a 4th tool (optional)'}, {name: 'tool4', type: 'str', required: false, label: 'Enter a 5th tool (optional)'}, {name: 'bodypart0', type: 'str', required: true, label: 'Enter the 1st part of the body on which the spanking will be executed'}, {name: 'bodypart1', type: 'str', required: false, label: 'Enter a 2nd part of the body (optional)'}, {name: 'bodypart2', type: 'str', required: false, label: 'Enter a 3th part of the body (optional)'}, {name: 'bodypart3', type: 'str', required: false, label: 'Enter a 4th part of the body (optional)'}, {name: 'bodypart4', type: 'str', required: false, label: 'Enter a 5th part of the body (optional)'}, {name: 'position0', type: 'str', required: true, label: 'Enter the 1st position of the slave during spanking'}, {name: 'position1', type: 'str', required: false, label: 'Enter a 2nd position (optional)'}, {name: 'position2', type: 'str', required: false, label: 'Enter a 3th position (optional)'}, {name: 'position3', type: 'str', required: false, label: 'Enter a 4th position (optional)'}, {name: 'position4', type: 'str', required: false, label: 'Enter a 5th position (optional)'}, {name: 'action0', type: 'str', required: true, label: 'Enter the 1st action of the slave between spanking'}, {name: 'action1', type: 'str', required: false, label: 'Enter a 2nd action (optional)'}, {name: 'action2', type: 'str', required: false, label: 'Enter a 3th action (optional)'}, {name: 'action3', type: 'str', required: false, label: 'Enter a 4th action (optional)'}, {name: 'action4', type: 'str', required: false, label: 'Enter a 5th action (optional)'}, {name: 'action5', type: 'str', required: false, label: 'Enter a 6th action (optional)'}, {name: 'action6', type: 'str', required: false, label: 'Enter a 7th action (optional)'}, {name: 'action7', type: 'str', required: false, label: 'Enter a 8th action (optional)'}, {name: 'action8', type: 'str', required: false, label: 'Enter the 9th action (optional)'}, {name: 'action9', type: 'str', required: false, label: 'Enter the 10th action (optional)'} ]; var viewers = 0; var genders = {}; var roles = {}; var votings = {}; var delay = parseInt(cb.settings.delay); var tip_spanks = 0; var cur_spanks = 0; var tools = getSettingsArray('tool', 5); var cur_tool = cb.settings.tool0; var bodyparts = getSettingsArray('bodypart', 5); var cur_bodypart = cb.settings.bodypart0; var positions = getSettingsArray('position', 5); var cur_position = cb.settings.position0; var actions = getSettingsArray('action', 10); var cur_action = cb.settings.action0; var dictionary = { spank: {1: 'spank', 2: 'spanks'}, tool: {1: 'tool', 2: 'tools'}, action: {1: 'action', 2: 'actions'}, bodypart: {1: 'body part', 2: 'body parts'}, token: {1: 'token', 2: 'tokens'}, minute: {1: 'minute', 2: 'minutes'}, user: {1: 'user', 2: 'users'} }; // Handles the grammatical number of the given word if it is in the dictionary. function getFromDictionary(key, count) { var count = (count > 1) ? 2 : 1; return dictionary[key][count]; } // Reset additional spanks by tipping. function resetSpanks() { tip_spanks = 0; } // Add additional spanks by tipping. function addSpanks(number) { tip_spanks = tip_spanks + number; } // Returns the delay between SPANKING TIME in msec. function getDelay() { return 1000 * 60 * delay; } // Returns a random tool. function getRandomTool() { return tools[Math.floor(Math.random() * tools.length)]; } // Returns a random body part. function getRandomBodyPart() { return bodyparts[Math.floor(Math.random() * bodyparts.length)]; } // Returns a random position. function getRandomPosition() { return positions[Math.floor(Math.random() * positions.length)]; } // Increases the number of viewers by one. function increaseViewer() { viewers = viewers + 1; } // Decreases the number of viewers by one, minimal value is zero. function decreaseViewer() { viewers = (viewers > 0) ? viewers - 1 : 0; } // Returns the gender avatar for the given gender string. function getAvatar(gender) { if (gender === 'm') { return ':genderM'; } else if (gender === 'f') { return ':genderF'; } else if (gender === 'c') { return ':genderC'; } else if (gender === 't') { return ':genderS'; } return ':genderG'; } // Stores the specified gender of the user name. function setGender(name, gender) { genders[name] = gender; } // Deletes the stored gender of the user name. function deleteGender(name) { if (genders.hasOwnProperty(name)) { delete genders[name]; } } // Returns all voting commands for the actions. function allVotingCommandsAction() { var cmds = []; for (var i = 0; i < actions.length; i++) { cmds.push("!" + i); } return cmds; } // Sets the voting of the specified user to the given vote. function setVote(name, vote) { votings[name] = vote; } // Deletes the stored voting of the specified user. function deleteVote(name) { if (votings.hasOwnProperty(name)) { delete votings[name]; } } // Returns the vote action number, i.e. the action with the most votes. function getVoting(count) { var current_voting = {}; for (var i = 0; i < count; i++) { current_voting[i] = 0; } for (var name in votings) { var prop = votings[name]; if (current_voting.hasOwnProperty(prop)) { current_voting[prop]++; } } var max = 0; for (var action in current_voting) { if (current_voting[action] > max) { max = current_voting[action]; } } var possible_votes = []; for (var action in current_voting) { if (current_voting[action] === max) { possible_votes.push(parseInt(action)); } } return possible_votes[Math.floor(Math.random() * possible_votes.length)]; } // Returns the role string for the specified user name. function getRole(name) { if (roles.hasOwnProperty(name)) { return '[' + roles[name] + ']'; } return ''; } // Deletes the stored role of the specified user name. function deleteRole(name) { if (roles.hasOwnProperty(name)) { delete roles[name]; } } // Returns the string with the additional information of the specified user. function getAdditionalInfo(name, gender) { var avatar = getAvatar(gender); var role = getRole(name); return role !== '' ? avatar + ' ' + role : avatar; } // Sets the role of the specified user to devot. function setDevot(name) { roles[name] = 'devot'; } // Sets the role of the specified user to dominat. function setDominant(name) { roles[name] = 'dominat'; } // Sets the role of the specified user to switch. function setSwitch(name) { roles[name] = 'switch'; } // Returns whether the slave seeks the specified gender. function isSlaveSeeking(gender) { var seeking = 'all'; if (cb.settings.seeking === 'male') { seeking = 'm'; } else if (cb.settings.seeking === 'female') { seeking = 'f'; } else if (cb.settings.seeking === 'couple') { seeking = 'c'; } else if (cb.settings.seeking === 't') { seeking = 't'; } return (seeking === 'all') ? true : seeking === gender; } // Function which handles the SPANKING TIME. function spankingTime() { cur_spanks = (parseInt(cb.settings.multiplier) * viewers) + tip_spanks; cur_tool = getRandomTool(); cur_position = getRandomPosition(); cur_bodypart = getRandomBodyPart(); cur_action = actions[getVoting(actions.length)]; printInformation(getActionMessage(), ''); resetSpanks(); cb.drawPanel(); cb.setTimeout(spankingTime, getDelay()); } // Prints the help message to the specified user. function printHelp(user) { var hr = '****** SLAVE-APP is running ******'; var commands = getCommandDescription(user); var minute = getFromDictionary('minute', delay); var token = getFromDictionary('token', cb.settings.tip); var tool = getFromDictionary('tool', tools.length); var random = ''; if (tools.length > 1 && bodyparts.length > 1) { random = 'The tools as well as the body parts on which the slave receives the spanks are choosen randomly every SPANKING TIME. '; } else if (tools.length > 1) { random = 'The tools are choosen randomly every SPANKING TIME. '; } else if (bodyparts.length > 1) { random = 'The body parts on which the slave receives the spanks are choosen randomly every SPANKING TIME. '; } var msg = hr + '\nThe slave ' + cb.settings.slave + ' has to be punished. Therefore the slave has to execute every ' + delay + ' ' + minute + ' the SPANKING TIME. The amount of spanks depends on the current number of registrated user ' + 'in the room multiplied by ' + cb.settings.multiplier + '. By tipping you can also add additional spanks for the slave. ' + 'For every additional spank send ' + cb.settings.tip + ' ' + token +'. For spanking, the slave has to use the following ' + tool +': ' + tools.join(', ') + '. ' + random + 'You can vote for the action which the slave has to do after the next ' + 'SPANKING TIME. ' + 'Following commands are available:\n' + commands.join('\n') + '\n' + hr; printInformation(msg, user); } // Prints an information to the specified user. function printInformation(msg, user) { cb.sendNotice(msg, user, '#D8D8D8', '#000000'); } // Returns an array of all user function getUserList() { var users = []; for (var name in genders) { var gender = genders[name]; var info = getAdditionalInfo(name, gender); var vote = ''; if (votings.hasOwnProperty(name)) { vote = actions[votings[name]]; } users.push(name + ' ' + info + ' - ' + vote); } return users; } // Prints a status information to the slave. function printStatus(msg) { cb.sendNotice(msg, cb.settings.slave, '#FFFF99', '#E00000'); } // Returns the 'Spanking time message' function getActionMessage() { var hr = '****** SPANKING TIME ******'; var spank = getFromDictionary('spank', cur_spanks); return hr + '\nThe slave ' + cb.settings.slave + ' has to execute ' + cur_spanks + ' ' + spank + '. ' + 'This amount results from the following equation:\n (no. registrated users * multiplier) + additional spanks = (' + viewers + ' * ' + cb.settings.multiplier + ') + ' + tip_spanks + ').\n' + 'Therefore the slave has to use the ' + cur_tool + ' for spanking the ' + cur_bodypart + '.\n' + 'The position of slave has to be: ' + cur_position + '.\n' + 'After spanking the slave has to do the following: ' + cur_action + '\n' + hr; } // Returns an array of strings which describe all available commands. function getCommandDescription(user) { var descriptions = []; var commands = allVotingCommandsAction(); for (var i = 0; i < commands.length; i++) { descriptions.push(commands[i] + ': Voting for the action "' + actions[i] + '".'); } descriptions.push('!dev: Specifies your role as devot.'); descriptions.push('!swi: Specifies your role as switcher.'); descriptions.push('!dom: Specifies your role as dominant.'); if (user === cb.settings.slave) { descriptions.push('!stat: Show a list of all registrated users in the room.'); } descriptions.push('!help: Prints the help message.'); return descriptions; } // Returns the 'Tip message' for specified user, tokens and spanks. function getTipMessage(user, tokens, spanks) { var token = getFromDictionary('token', tokens); var spank = getFromDictionary('spank', spanks); return user + ' tipped ' + tokens + ' ' + token + '. Therefore the slave has to execute ' + spanks + ' additional ' + spank + ' during the next SPANKING TIME.'; } cb.onEnter(function(user) { var name = user.user; var gender = user.gender; increaseViewer(); setGender(name, gender); printHelp(name); if (isSlaveSeeking(gender)) { printStatus('User ' + name + ' has entered the room.'); } }); cb.onLeave(function(user) { var name = user.user; deleteRole(name); deleteVote(name); deleteGender(name); decreaseViewer(); }); cb.onMessage(function(message) { var user = message.user; var msg = message.m; var gender = message.gender; if (msg.lastIndexOf('!', 0) === 0) { message['X-Spam'] = true; var voting_commands = allVotingCommandsAction(); if (msg === '!dev') { setDevot(user); printInformation(user + ', your role is: devot.', user); } else if (msg === '!dom') { setDominant(user); printInformation(user + ', your role is: dominat.', user); } else if (msg === '!swi') { setSwitch(user); printInformation(user + ', your role is: switch.', user); } else if (msg === '!help') { printHelp(user); } else if (voting_commands.indexOf(msg) >= 0) { setVote(user, voting_commands.indexOf(msg)); var act = actions[voting_commands.indexOf(msg)]; printInformation(user + ', you want that the slave has to do the following after the next SPANKING TIME: ' + act, user); printStatus(user + ' voted for ' + act); } else if (user === cb.settings.slave && msg === "!stat") { printStatus(getUserList().join('\n')); } else { printInformation('Invalid command. Send !help for a complete command list.', user); } } else { message.m = getAdditionalInfo(user, gender) + ' ' + msg; if (getRole(user) === '') { printInformation(user + ', please specify your role by sending !dev if your are devot,' + ' !dom if you are dominat or !swi if you are a switcher.', user); } } return message; }); cb.onTip(function(tip) { switch (tip.message) { case 'spanking': var add = (parseInt(tip.amount) / parseInt(cb.settings.tip) >> 0); addSpanks(add); printInformation(getTipMessage(tip.from_user, tip.amount, add), ''); cb.drawPanel(); break; default: break; } printInformation('Thanks for tipping!', tip.from_user); }); cb.tipOptions(function(user) { return {options: [{label: 'spanking'}, {label: 'normal'}], label: "Decide whether it is a normal or a spanking tip:"}; }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Current action', 'row1_value': cur_action, 'row2_label': 'Spanks', 'row2_value': cur_spanks, 'row3_label': 'Additional spanks', 'row3_value': tip_spanks }; }); function init() { cb.setTimeout(spankingTime, getDelay()); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.