Bots Home
|
Create an App
mikerr
Author:
underlinger
Description
Source Code
Launch Bot
Current Users
Created by:
Underlinger
/****************************** * TITLE: Competition Bot * AUTHOR: Sweetandreea * VERSION: 1.2 * DATE: 2014-04-16 * ORIGINAL CONCEPT: Sweetandreea * DESCRIPTION: * * Friendly Competition between broadcasters in the same room! * The first person to 0 wins and the other broadcasters must perform the goal! * *********** COMMANDS *********** * * /subtract <competitor> <amount> - Removes <amount> from <competitor> Example /subtract Angelique 10 * /restart - Restart the goals * /score - shows the scores ** * Updates v1.1 - Added Scores and Goals for Room Subject and DrawPanel * Fixed issue with reset * v1.2 - Removed Changing Room Subject. * - *******************************/ var bHaveWinner = false; var bAllScoresMet = true; var winner = ''; function MyUser(name, score, emote) { this.Name = name; this.Score = score; this.Emote = emote; this.IsWinner = 0; } MyUser.prototype.GetScore = function() { return this.Score; } MyUser.prototype.GetName = function() { return this.Name; } MyUser.prototype.GetEmote = function() { return this.Emote; } MyUser.prototype.IsWinner = function() { return this.IsWinner; } var competitors = []; /****************************** * Setup Bot Choices *******************************/ cb.settings_choices = [ { name: 'GameName', type:'str', minLength: 1, maxLength: 100, label:"Competition Name:", defaultValue:'Titis and Pussy Competition Bot'}, { name: 'UserNames', type:'str', minLength: 0, maxLength: 500, label:"Competitor Names: (comma separated)", defaultValue:'Titis,Pussy'}, { name: 'WinnersGoal', type:'str', minLength: 0, maxLength: 1000, label:"Winners Goal:", defaultValue:'Nude Titis'}, { name: 'LoserGoal', type:'str', minLength: 0, maxLength: 1000, label:"Losers Goal:", defaultValue:'Naked Pussy'}, { name: 'RoomSubject', type:'str', minLength: 0, maxLength: 1000, label:"Room Subject:", defaultValue:'All Scores must be 0. Winner Nude Titis. Loser Get Pussy Naked!'}, { name: 'StartValue', type:'int', minValue: 1, label:"Competition Start Value:", defaultValue: 15}, { name: 'TokenCost', type:'int', minValue: 1, label:"Token Costs:", defaultValue: 123}, { name: 'AllScoresZero', type:'int', minValue: 0, label:"All Scores Must Be Zero For Goal: (0 - No)", defaultValue: 0}, { name: 'UseEmotes', type:'int', minValue: 0, label:"Use Emotes for Competition: (0 - No)", defaultValue: 1}, { name: 'Comp1Emote', type:'str', minLength: 0, maxlength: 100, label:"Competitor 1 Emote:", defaultValue: ':comptitis'}, { name: 'Comp2Emote', type:'str', minLength: 0, maxlength: 100, label:"Competitor 2 Emote:", defaultValue: ':comppussy'} ]; cb.onTip( function (tip) { var aT = parseInt(tip['amount']); var newScore = 0; var idx = 0; var bFound = 0; // get current count and subtract one for(idx=0; idx < competitors.length; idx++) { // get what user was selected in Tip Message if (competitors[idx].GetName() == tip['message']) { cb.sendNotice(tip['from_user'] + ' selected ' + tip['message'], '', '#5919a3','#ffffff','bold'); bFound = 1; break; } } if (bFound == 0) return; while ((aT >= cb.settings.TokenCost) && (bHaveWinner == false)) { newScore = competitors[idx].GetScore() - 1; if (newScore < 0) newScore = 0; competitors[idx].Score = newScore; ShowScore(); if (newScore <= 0) { // save off first winner to 0 if (winner.length == 0) { competitors[idx].IsWinner = 1; winner = competitors[idx].GetName(); cb.sendNotice(winner + ' has won!!!', '', '#FF0000','#ffffff','bold'); } showwinner(); cb.drawPanel(); return; } aT -= cb.settings.TokenCost; } cb.drawPanel(); } ); cb.onDrawPanel( function (user) { if (bHaveWinner) { var w = winner.toUpperCase(); return { 'template': '3_rows_11_21_31', 'row1_value': '*** WINNER: *** ' + w, 'row2_value': 'THANK YOU TIPPERS', 'row3_value': 'FULL SCREEN SUGGESTED' }; } var c1 = ''; var t1 = 0; var c2 = ''; var t2 = 0; for(idx=0; idx < competitors.length; idx++) { if (idx == 0) { c1 = competitors[idx].GetName(); t1 = competitors[idx].GetScore(); } else if (idx == 1) { c2 = competitors[idx].GetName(); t2 = competitors[idx].GetScore(); } } return { 'template': '3_rows_of_labels', 'row1_label': 'CONTEST', 'row1_value': 'SCORE', 'row2_label': c1, 'row2_value': t1.toString(), 'row3_label': c2, 'row3_value': t2.toString() }; } ); cb.onMessage(function (msg) { var message = msg['m']; var user = msg['user']; var sub = []; var newScore = 0; if (cb.room_slug === user) { if (msg['m'] == '/restart' || msg['m'] == '/r') { for(var idx = 0; idx < competitors.length; idx++) { competitors[idx].Score = cb.settings.StartValue; competitors[idx].IsWinner = 0; } bHaveWinner = false; bAllScoresMet = true; winner = ''; ShowScore(); cb.drawPanel(); } if (msg['m'].indexOf('/subtract') >= 0 || msg['m'].indexOf('/sub') >= 0) { sub = msg['m'].split(" "); if (sub[1].length == 0 || sub[2].length == 0) return msg; for(idx=0; idx < competitors.length; idx++) { if (competitors[idx].GetName() == sub[1]) { newScore = competitors[idx].GetScore() - sub[2]; if (newScore < 0) newScore = 0; competitors[idx].Score = newScore; if (newScore <= 0) { // save off first winner to 0 if (winner.length == 0) { competitors[idx].IsWinner = 1; winner = competitors[idx].GetName(); cb.sendNotice(winner + ' has won!!!', '', '#FF0000','#ffffff','bold'); } showwinner(); cb.drawPanel(); } break; } } ShowScore(); cb.drawPanel(); } } if ((cb.room_slug === user || msg['is_mod'] == true || user == 'sweetandreea')) { if (msg['m'] == '/score') { ShowScore(); } } if (msg['m'][0] == '/') { msg['X-Spam'] = true; } return msg; }); function output(message) { cb.sendNotice(message); } cb.tipOptions(function(user) { // var opt = []; // for(var i=0; i < competitorNames.lenth; i++) // opt.push({label: competitorNames[i]}); // output(opt); // return {options:[opt], label:"Select Team"}; return {options:[{label: 'Titis'}, {label: 'Pussy'}], label: "Please Choose:"}; }); function showTextScore() { var s = ''; s = readList(); cb.sendNotice('***** SCORE: ' + s + ' *****','', '#5919a3','#ffffff','bold'); return; } function showEmoteScores() { var sOut = ''; var score = 0; var values = []; // loop through all competitors and get score for(var u=0; u < competitors.length; u++) { score = competitors[u].GetScore(); // convert score to image equal for(var x=0, a=''; a=score.toString().charAt(x); x++) { switch (a) { case '1': values.push(':comp1'); break; case '2': values.push(':comp2'); break; case '3': values.push(':comp3'); break; case '4': values.push(':comp4'); break; case '5': values.push(':comp5'); break; case '6': values.push(':comp6'); break; case '7': values.push(':comp7'); break; case '8': values.push(':comp8'); break; case '9': values.push(':comp9'); break; default: values.push(':comp0'); } } if (sOut.length > 0) sOut += '\n'; sOut += competitors[u].GetEmote() + ' ' + values.join(' '); values=[]; } // write notice output(sOut); return; } function showwinner() { if (cb.settings.AllScoresZero > 0) { bAllScoresMet = CheckScores(); if (bAllScoresMet == false) cb.sendNotice('All Scores must be Zero for the show to start!', '', '#FF0000','#ffffff','bold'); } if (bAllScoresMet) { bHaveWinner = true; cb.sendNotice('************\n CONGRATULATIONS: ' + winner + '\n************\nWinner Goal: ' + cb.settings.WinnersGoal +'\n************\nLoser Goal: ' + cb.settings.LoserGoal, '', '#FF0000','#ffffff','bold'); } return bAllScoresMet; } function CheckScores() { var bScoresMet = true; for (var i=0; i < competitors.length; i++) { if (competitors[i].GetScore() > 0) bScoresMet = false; } return bScoresMet; } function readList() { var s = ''; for(var i=0; i < competitors.length; i++) { if (s.length > 0) s += ' To '; s = s + competitors[i].GetName() + ': ' + competitors[i].GetScore(); } return s; } function LoadArrays(lst) { var temp; var emote = ''; temp = lst ? lst.split(',') : ''; // create the array for(var i=0; i < temp.length; i++) { emote = ''; if (temp[i] != null) { switch (i) { case 0: if (cb.settings.Comp1Emote != null) emote = cb.settings.Comp1Emote; break; case 1: if (cb.settings.Comp2Emote != null) emote = cb.settings.Comp2Emote; break; } competitors[i] = new MyUser(temp[i], cb.settings.StartValue, emote); } } } // Show the Score function ShowScore() { if (cb.settings.UseEmotes == 0) showTextScore(); else showEmoteScores(); } // Load all the settings function LoadSettings() { LoadArrays(cb.settings.UserNames); } // Initialize Application function init() { var title = "-----------------------------------------\n--- " + cb.settings.GameName + "\n--- Developed By: Sweetandreea\n--- Thanks Sweetandreea for the Concept!!\n-----------------------------------------"; output(title); LoadSettings(); ShowScore(); cb.changeRoomSubject(cb.settings.RoomSubject); cb.drawPanel(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.