Bots Home
|
Create an App
Ms_Jojos Charades
Author:
ozzyzeppelin
Description
Source Code
Launch Bot
Current Users
Created by:
Ozzyzeppelin
/** Name: Dorothy's Charades and Pictionary Author: chelsea2950 **/ {cb.settings_choices = [ {name: 'dummyIntro', label: ' ******************* Introduction ********************* Latest Updt: 3/27/2020 (version 1.1) ', type: 'choice',required: false}, {name: 'dummyCharades', label: 'Welcome! To play Charades or Pictionary, the viewers can tip to have the broadcaster(s) act out (Charades) or draw (Pictionary) a word or phrase, and then the tipper or the audience attempts to guess what they are acting out or drawing. There are three modes - Broadcaster against Broadcaster (usually for couples/multiple performer shows), and two levels of viewer against room (usually for solo shows) - single games and a goal race.', type: 'choice',required: false}, {name: 'charadesMode', label: 'Game Format -- Based on the mode selected here, set up ONE of the sections below for that mode. For Broadcaster against Broadcaster, the broadcasters take turns, and accumulate points when the room guesses correctly on their turn. This can one round or multiple rounds until one broadcaster reaches the specified point total, up to 5 broadcasters can play. This mode can either be run with or without a tip requirement. For viewer against the room, the person who tips is trying to guess correctly before anyone else in the room to win a prize, and this goes 1 round for each tip.',required: false, type: 'choice', choice1: 'Mode 1 - Broadcaster against Broadcaster', choice2: 'Mode 2 - Viewer against Room (One Game)', choice3: 'Mode 3 - Viewer against Room (Goal Race)', choice4: 'Mode 4 - Viewer against Room (Goal Race Single Tip)', defaultValue: 'Mode 4 - Viewer against Room (Goal Race Single Tip)'}, {name: 'charadesType', label: 'Charades or Pictionary? -- The game behaves the same way for both, this just updates the text notices displayed during the game', type: 'choice', choice1: 'Charades', choice2: 'Pictionary', defaultValue: 'Charades'}, {name: 'charadesSource', label: 'Source of Word List',required: false, type: 'choice', choice1: 'Bot Default List', choice2: 'Broadcaster Defined List', choice3: 'Added During Game', defaultValue: 'Bot Default List'}, {name: 'charadesList', label: 'Word List -- If selecting "Broadcaster Defined List" above, list the words and phrases you want to use below. Use a ":" to separate the words and phrases from each other, in a format such as "Superman:Airplane Pilot:Reading a book". The actual word or phrase for each game will be randomly chosen from this list. The matching to the viewer guesses is not case sensitive, so it does not matter if they are capitalized or not',required: false,type: 'str',minLength: 1, maxLength: 2000}, {name: 'charadesTimerLength', label: 'Timer Length -- If the time for guessing will be limited, set the timer length to be used. Set to "no timer" to not use a timer, or set a length from the list.',type: 'choice', choice1: 'No timer', choice2: '30 sec',choice3: '1 min', choice4: '1 min 30 sec', choice5: '2 min', choice6: '3 min', choice7: '4 min',choice8: '5 min',defaultValue: '1 min 30 sec'}, {name: 'charadesRandom', label: 'Randomize Words? -- Should the next charades word or phrase be drawn at random from the list, or go in order of the entries in the list?', type: 'choice', choice1: 'Random', choice2: 'In Order', defaultValue: 'Random'}, {name: 'freePlayStarts', label: 'Free Play Immediate start -- When using the "/chfree" command to simulate a tip to start a game, immediately start the game, or wait until "/chplay" initiates the timer?', type: 'choice', choice1: 'Immediate Start', choice2: 'Require Command', defaultValue: 'Require Command'}, {name: 'allowModsAuthority', label: 'Moderator Authority -- Allow moderators to have authority to broadcaster commands?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'charadesModsKnowWord', label: 'Moderators Play? -- Do the moderators have visiblity to the Charades Word or Phrase (they don\'t play the game), and are able to add words to the list?',required: false, type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'silenceLevel', label: 'Allow silenced users -- If you have silenced certain user groups and do not want gray users or light blue users to guess, make the appropriate selection here',required: false, type: 'choice', choice1: 'All Users Can Guess', choice2: 'Gray Users Cannot Guess', choice3: 'Gray & Light Blue Users Cannot Guess', defaultValue: 'All Users Can Guess'}, {name: 'charadesNoticeInterval', label: 'Notice Interval -- Decimals like "3.2" are ok as long as they are greater than 1, setting is in minutes.',required: false,type: 'str',defaultValue: 2.6}, {name: 'charadesNoticeTextColor', label: 'Notice Text Color',type: 'choice',choice1: 'White/No Color',choice2: 'Black',choice3: 'Dark Grey',choice4: 'Dark Red',choice5: 'Dark Orange',choice6: 'Dark Green',choice7: 'Dark Aqua',choice8: 'Dark Blue',choice9: 'Dark Purple',choice10: 'Dark Pink',choice11: 'Dark Gold',choice12: 'Dark Teal',choice13: 'Dark Brown',choice14: 'Dark Bronze',choice15: 'Dark Periwinkle',choice16: 'Dark Fuschia',choice17: 'Dark Lime',choice18: 'Dark Plum',choice19: 'Custom',defaultValue: 'Dark Plum'}, {name: 'charadesNoticeBgColor', label: 'Notice Background/Highlight Color',required: false,type: 'choice', choice1: 'White/No Color',choice2: 'Light Yellow',choice3: 'Light Blue',choice4: 'Light Pink',choice5: 'Light Red',choice6: 'Light Green',choice7: 'Light Purple',choice8: 'Light Orange',choice9: 'Light Grey',choice10: 'Light Aqua',choice11: 'Light Teal',choice12: 'Cream',choice13: 'Light Bronze',choice14: 'Light Periwinkle',choice15: 'Light Fuschia',choice16: 'Light Lime',choice17: 'Light Plum',choice18: 'Custom',defaultValue: 'Light Pink'}, {name: 'dummyCharades1', label: ' ************** Charades Mode 1 Setup *************', type: 'choice',required: false}, {name: 'charadesBABPlayer1', label: 'Mode 1 - Player 1 Name',type: 'str',minLength: 1, maxLength: 25,defaultValue: 'Player 1 Name'}, {name: 'charadesBABPlayer2', label: 'Mode 1 - Player 2 Name',type: 'str',minLength: 1, maxLength: 25,defaultValue: 'Player 2 Name'}, {name: 'charadesBABPlayer3', label: 'Mode 1 - Player 3 Name (leave blank if not used)',required: false,type: 'str',minLength: 1, maxLength: 25}, {name: 'charadesBABPlayer4', label: 'Mode 1 - Player 4 Name (leave blank if not used)',required: false,type: 'str',minLength: 1, maxLength: 25}, {name: 'charadesBABPlayer5', label: 'Mode 1 - Player 5 Name (leave blank if not used)',required: false,type: 'str',minLength: 1, maxLength: 25}, {name: 'charadesBABPrice', label: 'Mode 1 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /chfree command.',type: 'int',minValue: 0,maxValue: 1000, defaultValue: 0}, {name: 'charadesBABGoal', label: 'Mode 1 - Point Goal -- Winning Broadcaster is the first one to this many correct guesses by the room',type: 'int',minValue: 1,maxValue: 100, defaultValue: 5}, {name: 'charadesBABPrize', label: 'Mode 1 - Prize for winning broadcaster -- Any text value can be entered, such as "Winner Receives oral from Loser" or "Winner Spanks Loser"',required: false,type: 'str'}, {name: 'dummyCharades2', label: ' ************** Charades Mode 2 Setup **************', type: 'choice',required: false}, {name: 'charadesVARPrice', label: 'Mode 2 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /chfree command.',type: 'int',minValue: 1,maxValue: 1000, defaultValue: 39}, {name: 'charadesVARPrize', label: 'Mode 2 - Prize - Any text value can be entered',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'dummyCharades3', label: ' ************** Charades Mode 3 Setup ***************', type: 'choice',required: false}, {name: 'charadesVAR2Goal', label: 'Mode 3 - Set the total point goal at which the winner gets the prize. Tippers who win their own game get 3 points, correct guesses from the rest of the room win 1 point.',type: 'int',minValue: 1,maxValue: 100, defaultValue: 8}, {name: 'charadesVAR2Price', label: 'Mode 3 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /chfree command.',type: 'int',minValue: 1,maxValue: 1000, defaultValue: 59}, {name: 'charadesVAR2Prize', label: 'Mode 3 - Prize - Any text value can be entered',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'dummyCharades4', label: ' ************** Charades Mode 4 Setup ***************', type: 'choice',required: false}, {name: 'charadesVAR3Goal', label: 'Mode 4 - Set the total point goal at which the winner gets the prize. Tippers who win their own game get 3 points, correct guesses from the rest of the room win 1 point.',type: 'int',minValue: 1,maxValue: 100, defaultValue: 8}, {name: 'charadesVAR3Price', label: 'Mode 4 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /chfree command.',type: 'int',minValue: 1,maxValue: 1000, defaultValue: 59}, {name: 'charadesVAR3Prize', label: 'Mode 4 - Prize - Any text value can be entered',required: false,type: 'str',minLength: 1, maxLength: 50} ]; } // *********************************** Variables and Arrays ************************************** { var initialize = 0; var dashLine60 = new Array(60).join('-'); var dashLine70 = new Array(70).join('-'); var dashLine80 = new Array(80).join('-'); var dashLine90 = new Array(90).join('-'); var appNoticeColor = '#4dd2ff'; // blue for general chat notices var appWarningColor = '#f4d599'; // yellow for general chat warnings (invalid prizes, invalid timer, etc) var appWarningTextColor = '#ff0000'; // red for general chat warnings (invalid prizes, etc) var yellow = '#f4d599'; // Used for clock countdown var red = '#f4c1bc'; // Used for last 2 minutes of clock countdown // ************ Variables for Charades Game var charadesToggle = 0; var charadesPrize = ''; var charadesVARPlayer = ''; var charadesGuessing = false; var charadesWaiting = false; var charadesEndWarning = false; var charadesActive = false; var charadesRound = 0; var charadesPrice = 0; var charadesGamesThisRound = 0; var charadesTimerLength = parseInt(cb.settings.charadesTimerLength); var charadesSource = cb.settings.charadesSource; var charadesMinsRemain = 0; var charadesSecsRemain = 0; var charadesType = cb.settings.charadesType; var charadesMode = cb.settings.charadesMode; // ************ Arrays var VIPListArray = []; var extFanListArray = []; var charadesList = []; var charadesWinners = []; var charadesDefaultList = ['star wars','elephant','lord of the rings','harry potter','madonna','little drummer boy','halloween','mermaid','titanic','full moon','volcano','kangaroo','lovense lush','babe ruth','goat','google','road trip','orange juice','spaghetti','Pacific Ocean', 'sex on the beach','bounce','alice in wonderland','koala','pyramid','south pole','queen','tarzan','captain america','flossy','dolphin','surfboard','farmer','tanlines','batman','superman','spiderman','jumper cables','sombrero','blue balls','bukkake','gangbang','orgy','threesome', 'butt plug','jeep','convertible','vacation','pineapple','cruise','short bus','winnie the pooh','puzzle','nutsack','mr bill','deep throat','polar bear','picasso','big ben','amazon','high school','leopard','edible panties','eiffel tower','gag reflex','dominatrix','peter pan', 'tinkerbelle','my precious','playboy bunny','jungle','gymnast','sailing','fuck buddy','telescope','saturn','thermometer','cucumber','balls deep','chef','great white shark','cello','jello','mexican jumping beans','bumblebee','rice crispies','igloo','carpet muncher','oreos', 'tarantula','iron man','jester','top gun','pac man','space invaders','asteroid','comet','black hole','dust bunny','tumbleweed','cartwheel','brown starfish','cornhole','alexa','casino','bartender','parallel','lumberjack','lawyer','scientist','chia pet','chemistry','siren', 'fireman','witch','mummy','frozen','snowman','queen of hearts','sudden death','homework','island','contract','hole in one','strip poker','nun','lucky charms','ping pong','pinball wizard','earthquake','seesaw','skateboard','snowball','pajamas','seashell','rhinoceros','saddle', 'hippopotamus','banana peel','frankenstein','cheerleader','captain','shopping cart','dentist','hair dryer','pizza','owl','gingerbread man','mouse trap','windmill','tuba','knot','quicksand','python','spider web','eraser','swordfish','flamingo','huddle','cumberbund', 'horse','door','song','trip','backbone','bomb','round','treasure','garbage','park','pirate','ski','state','whistle','palace','baseball','coal','queen','dominoes','photograph','computer','hockey','aircraft','hot dog','salt and pepper','key','iPad','whisk','frog','lawnmower', 'mattress','pinwheel','cake','circus','battery','mailman','cowboy','password','bicycle','skate','electricity','lightsaber','thief','teapot','deep','spring','nature','shallow','toast','outside','roller blading','gingerbread man','bowtie','half','spare','wax','light bulb','platypus', 'music','bobsled','cast','sculpture','early bird special','granola bar','prick','bbc','cavity search','mug shot','monopoly','pearl necklace','nipple ring','circle jerk','quickie','sex doll','viking','Will Smith','defect','standing ovation','flag','retaliate','mascot','shipwreck', 'jet lag','comfort zone','application','college','lifestyle','level','invitation','applesauce','crumb','loyalty','corduroy','fizz','shrink','ray','game plan','déjà vu','Olympic Games','oil','procrastinate','criticize','ergonomic','teenager','organize','baby monitor','Beethoven', 'streamline','satellite','gratitude','journal','a cappella','beanstalk','explore','mineshaft','dismantle','weed killer','tachometer','unemployed','port','peck','windmill','party theme','dentist','softball','wig','stain','cuff','sunburn','funniest','sheet','hair dryer','nightmare', 'shadow','fog','sip','bathroom scale','taxi','pizza','sand','cowboy','ticket','doghouse','stiff','president','wrench','wench','story','whisk','quicksand','spine','chess','artist','invest','spider web','bobsled','lung','washing machine','boar','torch','eraser','mini blinds', 'mouse trap','jar','cramp','cast','honk','mirror','business trip','chalk','gym','volcano','folio','evolution','apathy','advertise','roundabout','sandbox','conversation','conservation','negotiate','silhouette','aisle','pendulum','sorcerer','wizard']; var charadesPlayers = []; var charadesScores = [0]; var charadesLevelPrizes = []; var charadesNextPlayer = []; var charadesResults = []; var charadesVAR2Scores = {user: [], score: [0]}; var charadesVAR3Scores = {user: [], score: [0]}; var charadesBABScores = {user: [], score: [0]}; } // *********************************** Functions ************************************** { // Generic functions to set the color or separator characters function checkTextColor(color) { switch (color) { case 'White/No Color': return '#FFFFFF'; case 'Black': return '#000000'; case 'Dark Blue': return '#0629AC'; case 'Dark Pink': return '#FF6680'; case 'Dark Green': return '#006600'; case 'Dark Red': return '#cc0000'; case 'Dark Purple': return '#3d003d'; case 'Dark Grey': return '#737373'; case 'Dark Orange': return '#e77400'; case 'Dark Aqua': return '#006767'; case 'Dark Gold': return '#998100'; case 'Dark Teal': return '#003f1f'; case 'Dark Brown': return '#582c00'; case 'Dark Bronze': return '#a56728'; case 'Dark Periwinkle': return '#155bd7'; case 'Dark Fuschia': return '#d6155c'; case 'Dark Lime': return '#6b790c'; case 'Dark Plum': return '#7f13bf'; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ('default'); } } } function checkBgColor(color) { switch (color) { case 'White/No Color': return '#FFFFFF'; case 'Light Aqua': return '#adeaea'; case 'Light Pink': return '#FFE6EA'; case 'Light Green': return '#94e594'; case 'Light Red': return '#ff9a9a'; case 'Light Purple': return '#f2cdff'; case 'Light Orange': return '#ffd9b3'; case 'Light Grey': return '#e6e6e6'; case 'Light Blue': return '#d1eaee'; case 'Light Yellow': return '#ffff94'; case 'Cream': return '#f9f6ed'; case 'Light Bronze': return '#ebccad'; case 'Light Periwinkle': return '#d7e4fb'; case 'Light Teal': return '#d7fbee'; case 'Light Fuschia': return '#fbd7e4'; case 'Light Lime': return '#ecf6a7'; case 'Light Plum': return '#e3c0f9'; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ('default'); } } } // ************** User List Functions ************ function findTipper(user) { for (var i = 0; i < kenoTipCountArray.name.length; i++) { if (kenoTipCountArray.name[i] == user) { break; } } return i; } // *********************************** Charades Functions ************************************** function charadesSetToggle(option, mod) { if (option == 'on') { if (charadesToggle == 1) { cb.sendNotice('The ' + charadesType + ' Game is already enabled.', mod, appNoticeColor); } else { charadesInit(); if (validCharades == true) { charadesToggle = 1; charadesInitNoticeTimer(); cb.sendNotice('You have enabled the ' + charadesType + ' Game.', mod, appNoticeColor); } else { cb.sendNotice('Invalid setting, the ' + charadesType + ' Game could not be started.', mod, appWarningColor, appWarningTextColor, 'bold'); } } } else if (option == 'off') { if (charadesToggle == 0) { cb.sendNotice('The ' + charadesType + ' Game is already disabled.', mod, appNoticeColor); } else { charadesToggle = 0; cb.sendNotice('You have disabled the ' + charadesType + ' Game.', mod, appNoticeColor); cb.sendNotice('The ' + charadesType + ' game has been disabled, tips will no longer start a ' + charadesType + ' game.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); if (charadesList.length > 0) { cb.sendNotice('Unused charades words listed below. \nYou can paste this list into the Broadcaster Managed word list when next starting the bot so you don\'t reuse words from the current session: \n' + cbjs.arrayJoin(charadesList,':'), u, appNoticeColor); } else { cb.sendNotice('There are no words or phrases left in the current word list.', u, appNoticeColor); } } } } function charadesInit() { charadesNoticeTextColor = checkTextColor(cb.settings.charadesNoticeTextColor); charadesNoticeBgColor = checkBgColor(cb.settings.charadesNoticeBgColor); charadesNumberofPlayers = 1; charadesActive = false; validCharades = true; charadesWordSelected = false; charadesSetTimerLength(); charadesLoadList(); if (validCharades = true) { if (charadesMode == 'M1') { charadesLoadBABPlayers(); } else { charadesTipper = ''; } } if (validCharades = true) { charadesLoadPrizes(); } charadesRound = 1; charadesGamesThisRound = 0; charadesGamesPerRound = charadesNumberofPlayers; charadesCurrentPlayerIndex = 0; charadesCurrentPlayer = charadesPlayers[charadesCurrentPlayerIndex]; charadesGamesGoalRace = 0; charadesWaiting = false; setCharadesWaitingTimer(); } function charadesLoadList() { if (charadesList.length > 0) { cb.sendNotice(charadesType + ' Game Setup Notice - Existing word list kept on restart. \nYou can use the command /chclearlist to clear the existing wordlist.', cb.room_slug, appWarningColor, '', 'bold'); } else { if (charadesSource == 'Bot Default List') { charadesList = charadesDefaultList; if (charadesList.length == 0 || charadesList[0] == ' ' || charadesList[0] == '' || charadesList[0] == null) { validCharades = false; cb.sendNotice(charadesType + ' Game Setup Error - ' + charadesType + ' Default Word/Phrase list not populated.', cb.room_slug, appWarningColor, '', 'bold'); return; } } else if (charadesSource == 'Broadcaster Defined List') { var n = cb.settings.charadesList; charadesList = n.split(':'); if (charadesList.length == 0 || charadesList[0] == ' ' || charadesList[0] == '' || charadesList[0] == null) { validCharades = false; charadesList.length = 0; cb.sendNotice(charadesType + ' Game Setup Notice - Word/Phrase list configured for "Broadcaster Defined List" but no list entered on launch page. \nPlease use the command "/chword xxxxx" to add words and phrases to the word list for the game, where "xxxxx" is the word or phrase you would like to add. \nWords must be spelled exactly the same for a match, but are not case sensitive.', cb.room_slug, appNoticeColor, '', 'bold'); return; } } } } function charadesSetTimerLength() { switch (cb.settings.charadesTimerLength) { case 'No timer': charadesTimerLength = 0; return; case '30 sec': charadesTimerLength = 0.5; return; case '1 min': charadesTimerLength = 1; return; case '1 min 30 sec': charadesTimerLength = 1.5; return; case '2 min': charadesTimerLength = 2; return; case '3 min': charadesTimerLength = 3; return; case '4 min': charadesTimerLength = 4; return; case '5 min': charadesTimerLength = 5; return; default: charadesTimerLength = 2; return; } } function charadesLoadBABPlayers() { if (cb.settings.charadesBABPlayer1) { charadesPlayers[0] = cb.settings.charadesBABPlayer1; charadesScores[0] = 0; } else { validCharades = false; cb.sendNotice(charadesType + ' Game Setup Error - Configured for "Mode 1 - Broadcaster against Broadcaster" but Player 1 is not defined.', cb.room_slug, appWarningColor, '', 'bold'); return; } if (cb.settings.charadesBABPlayer2) { charadesPlayers[1] = cb.settings.charadesBABPlayer2; charadesScores[1] = 0; } else { validCharades = false; cb.sendNotice(charadesType + ' Game Setup Error - Configured for "Mode 1 - Broadcaster against Broadcaster" but Player 2 is not defined.', cb.room_slug, appWarningColor, '', 'bold'); return; } if (cb.settings.charadesBABPlayer3) { charadesPlayers[2] = cb.settings.charadesBABPlayer3; charadesScores[2] = 0; } if (cb.settings.charadesBABPlayer4) { charadesPlayers[3] = cb.settings.charadesBABPlayer4; charadesScores[3] = 0; } if (cb.settings.charadesBABPlayer5) { charadesPlayers[4] = cb.settings.charadesBABPlayer5; charadesScores[4] = 0; } charadesNumberofPlayers = charadesPlayers.length; } function charadesLoadPrizes() { if (charadesMode == 'M1') { if (cb.settings.charadesBABPrize) { charadesPrize = cb.settings.charadesBABPrize; cb.sendNotice(charadesType + ' Game Setup Notice - Mode 1, Prize: ' + charadesPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice(charadesType + ' Game Setup Error - Mode 1, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validCharades = false; return; } } else if (charadesMode == 'M2') { if (cb.settings.charadesVARPrize) { charadesPrize = cb.settings.charadesVARPrize; cb.sendNotice(charadesType + ' Game Setup Notice - Mode 2, Prize: ' + charadesPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice(charadesType + ' Game Setup Error - Mode 2, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validCharades = false; return; } } else if (charadesMode == 'M3') { if (cb.settings.charadesVAR2Prize) { charadesPrize = cb.settings.charadesVAR2Prize; cb.sendNotice(charadesType + ' Game Setup Notice - Mode 3, Prize: ' + charadesPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice(charadesType + ' Game Setup Error - Mode 3, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validCharades = false; return; } } else if (charadesMode == 'M4') { if (cb.settings.charadesVAR3Prize) { charadesPrize = cb.settings.charadesVAR3Prize; cb.sendNotice(charadesType + ' Game Setup Notice - Mode 4, Prize: ' + charadesPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice(charadesType + ' Game Setup Error - Mode 4, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validCharades = false; return; } } } function charadesInitNoticeTimer() { if (cb.settings.charadesNoticeInterval == '' || cb.settings.charadesNoticeInterval == null) { cb.sendNotice(charadesType + ' Game Warning - Chat Notice Interval was not set. Using default value of 2.6 minutes.', cb.room_slug, appWarningColor, '', 'bold'); charadesInt = 2.6; } else { charadesInt = parseFloat(cb.settings.charadesNoticeInterval); } if (charadesInt < 1) { cb.sendNotice(charadesType + ' Game Warning - Chat Notice Interval setting is too short, must be at least 1 minute. Using default value of 2.6 minutes.', cb.room_slug, appWarningColor, '', 'bold'); charadesInt = 2.6; } charadesInt *= 60000; charadesInt = parseInt(charadesInt); charadesNoticeTimer(); } function charadesSetNoticeTimeout() { cb.setTimeout(charadesNoticeTimer, charadesInt); } function charadesNoticeTimer() { if (charadesToggle == 1) { charadesShowNotice(''); charadesSetNoticeTimeout(); } } function charadesShowNotice(sendto) { var msg = 'The "' + charadesType + '" Game is active and set to ' + cb.settings.charadesMode + '. '; if (charadesMode == 'M1') { if (charadesPrice > 0) { msg += '\nTip ' + charadesPrice + ' tokens to play to next game/round.'; } else { msg += '\nNo tips required, guess the ' + charadesType + ' word/phrase to win the current performer/drawer a point'; } msg += '\nFirst performer/drawer to the goal score of ' + cb.settings.charadesBABGoal + ' points wins the prize: ' + charadesPrize + '.'; } else if (charadesMode == 'M2') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to win!'; msg += '\nThe single game prize is: ' + charadesPrize + '.'; } else if (charadesMode == 'M3') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.charadesVAR2Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + charadesPrize + '.'; } else if (charadesMode == 'M4') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.charadesVAR3Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + charadesPrize + '.'; } msg += '\nUse the command "/chi" to see more info on the game modes, game format, commands and possible prizes.'; cb.sendNotice(msg, sendto, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } function charadesInfo(sendto,usertype) { var msg = 'The "' + charadesType + '" Game is active and set to ' + cb.settings.charadesMode + '. '; if (charadesMode == 'M1') { if (charadesPrice > 0) { msg += '\nYou can tip ' + charadesPrice + ' tokens to have the broadcaster play the next game/round.'; } else { msg += '\nNo tips are required, the broadcaster will start each round.'; } msg += '\nOnce started, guess the ' + charadesType + ' word/phrase to win the current performer a point'; msg += '\nFirst performer to the score of ' + cb.settings.charadesBABGoal + ' points wins the prize: ' + charadesPrize + '.'; } else if (charadesMode == 'M2') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to win!'; msg += '\nThe single game prize is: ' + charadesPrize + '.'; } else if (charadesMode == 'M3') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.charadesVAR2Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + charadesPrize + '.'; } else if (charadesMode == 'M4') { msg += '\nTip ' + charadesPrice + ' tokens to play and try to guess the ' + charadesType + ' word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.charadesVAR3Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + charadesPrize + '.'; } msg += '\nWhen tipping to start a game, if a game is already started, your name will go into the queue.'; msg += '\nAs each game is finished, the next player in the queue automatically starts the next game.'; msg += '\nOnce the broadcaster starts a game, all viewers in the room can attempt to guess the word/phrase.'; msg += '\nThe bot will monitor for the correct answer and announce the winner and stop the timer when a correct guess is made.'; msg += '\nNote that the answer must be spelled correctly, but case does not matter.'; if (charadesTimerLength > 0) { msg += '\nIf the timer is used, everyone will have ' + charadesTimerLength + ' minute' + (charadesMinsRemain > 1 ? 's' : '') + ' to guess the correct word/phrase.'; } msg += '\nUse the command "/chh" to see the history of the ' + charadesType + ' games that have been played so far this session.'; msg += '\nUse the command "/chq" to see the list of people who have tipped to play ' + charadesType + ' and are currently in line waiting to play.'; msg += '\nUse the command "/chsb" to display the ' + charadesType + ' scoreboard for modes 1, 3 and 4.'; msg += '\nYou can find some ideas on signals you can do to tell the audience what kind of word or phrase you are doing here: http://www.outsetmedia.com/charadessignals '; if (usertype == 'BC') { msg += '\nFor Broadcasters (and moderators with authority):'; msg += '\nThe ' + charadesType + ' game can be turned on or off with the command "/charades on" or "/charades off". '; msg += '\nUse the command "/chprice xx" to update the price for playing ' + charadesType + ' to the new value of xx.'; msg += '\nUse the command "/chwin username" to manually assign a correct guess to someone who may have come close but misspelled the word. The game will behave as if they had guessed correctly'; msg += '\nUse the command "/chfree" to initiate a free game to play the next turn or round, or to override the tip requirement and play a round for free as if someone had tipped'; msg += '\nUse the command "/chplay" once a word is selected to show the word to the broadcaster and start the timer.'; msg += '\nUse the command "/chword xxxxx" to add words and phrases to the word list used for the game, where "xxxxx" is the word or phrase to be added. You can add multiple words separated by a colon ":".'; msg += '\nUse the command "/chrmv xxxxx" to remove words or phrases from the word list used for the game, where "xxxxx" is the word or phrase to be removed (must exactly match spelling and case).'; msg += '\nThis can be done in any play mode at any time, and will only add to the existing list.'; msg += '\nIf the word list source is configured as "Added During Game", the list will be empty to start and must be added before a game can be played.'; msg += '\nOtherwise, it will be populated from the default list or the broadcaster defined list on the launch page (and you can still add to the list in either case).'; msg += '\nNOTE: Try not to use words that are hard to spell or long phrases, the spelling must match exactly (but is not case sensitive)'; msg += '\nUse the command "/chsave" to display the current remaining word list in a form that can be copied and pasted into the Broadcaster Managed word list upon restart of the bot to save your remaining words.'; msg += '\nUse the command "/chskip" to skip a word/phrase if you do not know what it is. Skipping a word will reset the timer, and you must use /chplay to start again after word selection.'; msg += '\nUse the command "/chend" to end the current game if you decide not to finish it. Does not end the ' + charadesType + ' feature, just the current game/word being guessed, and will be ready for the next game. If a game has been tipped for in the queue it will be started.'; msg += '\nUse the command "/chstoptimer" to stop the countdown timer. Viewers will still be allowed to guess, but the game will not end from the timer.'; msg += '\nUse the command "/chclearlist" to clear the wordlist. The wordlist is kept intact if the game is ended and restarted without restarting the bot.'; msg += '\nUse the command "/chlength" to update the length of the timer for each game. Valid values are .5, 1, 1.5, 2, 3, 4, 5.'; } cb.sendNotice(msg, sendto, charadesNoticeBgColor, charadesNoticeTextColor); } function charadesNewGame() { if (charadesMode != 'M4') { charadesActive = false; } if (charadesNextPlayer.length > 0 && charadesActive == false) { charadesActive = true; nextCharadesPlayer = charadesNextPlayer[0]; charadesNextPlayer.splice(0, 1); cb.sendNotice(nextCharadesPlayer + ' is next in line and is about to Play ' + charadesType + '. Ready to play...', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesPlay('tip',nextCharadesPlayer,true); } } function charadesPlay(mode,tippedby,charadesfromnext) { if (charadesActive == false) { charadesTipper = tippedby; } if (charadesMode == 'M4' && charadesfromnext == true) { charadesTipper = tippedby; } if (charadesActive == true && charadesfromnext != true) { charadesNextPlayer.push(tippedby); cb.sendNotice(tippedby + ' has tipped to play ' + charadesType + ' and been added to the player queue since a game is already being played. Their game will start once it reaches their place in line (current number of players in line : ' + charadesNextPlayer.length + '). \n You can use the command "/chq" to see the queue of players waiting to play.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { charadesActive = true; playmessage = ''; if (charadesMode == 'M1') { playmessage += 'Current Player: \n \u21D2 ' + charadesCurrentPlayer + ' \u21D0 \n'; } if (mode == 'tip') { if (charadesfromnext == false || charadesMode == 'M4') { playmessage += tippedby + ' has tipped to play the ' + charadesType + ' Game! Selecting word or phrase...'; } else { playmessage += 'Selecting word or phrase...'; } } else if (mode == 'bc') { playmessage += 'The broadcaster is starting the next game of ' + charadesType + '! Selecting word or phrase...'; } else if (mode == 'free') { playmessage += 'A free game of ' + charadesType + ' has been started by ' + tippedby + '! Selecting word or phrase...'; } cb.sendNotice(playmessage, '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); selectWord(); } } function selectWord() { charadesWaiting = true; charadesWordSelected = false; if (charadesList.length == 0) { cb.sendNotice('WORD LIST IS EMPTY! Waiting on word or phrase to be added using the command "/chword xxxxx", where "xxxxx" is the word or phrase that should be added to the list and used next.', cb.room_slug, appNoticeColor); if (cb.settings.charadesModsKnowWord == 'Yes') { cb.sendNotice('WORD LIST IS EMPTY! Waiting on word or phrase to be added using the command "/chword xxxxx", where "xxxxx" is the word or phrase that should be added to the list and used next.', '', appNoticeColor, '', '', 'red'); } } else { if (charadesList.length == 1 || cb.settings.charadesRandom == 'In Order') { charadesWord = charadesList[0].toLowerCase(); charadesList.splice(0,1); } else { numberOfEntries = charadesList.length; indexOfEntry = Math.floor(Math.random() * numberOfEntries); charadesWord = charadesList[indexOfEntry].toLowerCase(); charadesList.splice(indexOfEntry,1); } charadesWordSelected = true; if (cb.settings.freePlayStarts == 'Immediate Start') { charadesStartPlay(); } else { cb.sendNotice('Word selected, ready to start. \nYou can start the game with the /chplay command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.charadesModsKnowWord == 'Yes') { cb.sendNotice('Word selected, ready to start. \nModerators can start the game with the /chplay command.', '', appNoticeColor, '', '', 'red'); } cb.sendNotice('Word is selected, ' + charadesType + ' will start on command.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } } function setCharadesWaitingTimer() { cb.setTimeout(charadesWaitingNotice, 60000); } function charadesWaitingNotice() { if (charadesWaiting == true) { cb.sendNotice('Word selected, ready to start. \nYou can start the game with the /chplay command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.charadesModsKnowWord == 'Yes') { cb.sendNotice('Word selected, ready to start. \nModerators can start the game with the /chplay command.', '', appNoticeColor, '', '', 'red'); } } } function charadesStartPlay() { cb.sendNotice('The word/phrase for this game is: \n \u21D2 ' + charadesWord + ' \u21D0 \nA word can be skipped with the /chskip command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.charadesModsKnowWord == 'Yes') { cb.sendNotice('The word/phrase for this game is: \n \u21D2 ' + charadesWord + ' \u21D0 \nA word can be skipped with the /chskip command.', '', appNoticeColor, '', '', 'red'); } charadesWaiting = false; charadesGuessing = true; if (charadesTimerLength > 0) { charadesStartTime = new Date(); charadesStopTime = new Date(charadesStartTime.getTime() + charadesTimerLength * 60000); charadesMinsRemain = Math.floor(charadesTimerLength); charadesStopping = false; if (charadesTimerLength == 0.5 || charadesTimerLength == 1.5) { charadesSecsRemain = 30; if (charadesTimerLength == 0.5) { cb.sendNotice(charadesType + ' has started a timer for 30 seconds.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else if (charadesTimerLength == 1.5) { cb.sendNotice(charadesType + ' has started a timer for 1 minute and 30 seconds.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } if (charadesMinsRemain > 0) { charadesDisplaySeconds = false; } else { charadesDisplaySeconds = true; } charadesTimerSec(); } else { cb.sendNotice(charadesType + ' has started a timer for ' + charadesMinsRemain + ' minute' + (charadesMinsRemain > 1 ? 's' : ''), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesTimerMin(); } } else { cb.sendNotice('A timer is not used for this game of ' + charadesType + ', the game will be ended manually by the broadcaster or moderators.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); cb.sendNotice('Since no timer is used, you can use the command /chend when you are ready to end the current game.', cb.room_slug, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); if (cb.settings.allowModsAuthority == 'Yes') { cb.sendNotice('Since no timer is used, you can use the command /chend when the broadcaster is ready to end the current game.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold', 'red'); } } } function charadesTimerMin() { if (!charadesStopping) { switch (charadesMinsRemain) { case 10: case 9: case 8: case 7: case 6: case 5: case 4: case 3: case 2: cb.sendNotice('\u23f1 \u23f1 \u23f1 There are ' + charadesMinsRemain + ' minutes left on the ' + charadesType + ' timer \u23f1 \u23f1 \u23f1', '', yellow, '', 'bold'); break; case 1: cb.sendNotice('\u23f1 \u23f1 \u23f1 There is 1 minute left on the ' + charadesType + ' timer !! \u23f1 \u23f1 \u23f1', '', red, '', 'bold'); break; } charadesMinsRemain--; if (charadesMinsRemain > 0) { charadesDisplaySeconds = false; } else { charadesDisplaySeconds = true; } charadesSecsRemain = 60; charadesTimerSec(); } } function charadesTimerSec() { if (!charadesStopping) { if (charadesDisplaySeconds) { switch (charadesSecsRemain) { case 30: case 10: case 5: case 4: case 3: case 2: cb.sendNotice('\u23f1 \u23f1 \u23f1 There are ' + charadesSecsRemain + ' seconds left on the ' + charadesType + ' timer \u23f1 \u23f1 \u23f1', '', red, '', 'bold'); break; case 1: cb.sendNotice('\u23f1 \u23f1 \u23f1 There is 1 second left on the ' + charadesType + ' timer \u23f1 \u23f1 \u23f1', '', red, '', 'bold'); break; } } if (charadesSecsRemain < 1) { if (charadesMinsRemain >= 1) { charadesTimerMin(); } else { cb.sendNotice('\u23f0 \u23f0 \u23f0 Time is up! There were no correct guesses \u23f0 \u23f0 \u23f0 \n *** The correct word or phrase was "' + charadesWord + '".', '', yellow, '', 'bold'); charadesGuessing = false; charadesGameComplete('none',false); charadesNewGame(); } } else { charadesSecsRemain--; cb.setTimeout(charadesTimerSec, 1000); } } } function charadesStopTimer(mod) { charadesStopTime = new Date(); charadesStopping = true; charadesMinsRemain = 0; charadesSecsRemain = 0; if(mod != null) { cb.sendNotice(mod + ' has stopped the game timer.','',yellow,'', 'bold'); } } function charadesCorrectAnswer(guessedby) { cb.sendNotice(guessedby + ' guessed the correct answer of "' + charadesWord + '"!', '', red, '', 'bold'); charadesGuessing = false; if (charadesMinsRemain > 0 || charadesSecsRemain > 0) { charadesStopTimer(charadesType); } if (charadesMode == 'M1') { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! ' + charadesCurrentPlayer + ' wins a point!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' has guessed correctly, ' + charadesCurrentPlayer + ' wins a point!'); charadesScores[charadesCurrentPlayerIndex] ++; if (!cbjs.arrayContains(charadesBABScores.user,guessedby)) { charadesBABScores.user.push(guessedby); userIndex = charadesBABScores.user.indexOf(guessedby); charadesBABScores.score[userIndex] = 0; charadesBABScores.score[userIndex] += 1; } else { userIndex = charadesBABScores.user.indexOf(guessedby); charadesBABScores.score[userIndex] += 1; } } else if (charadesMode == 'M2') { if (guessedby == charadesTipper || charadesTipper == cb.room_slug) { cb.sendNotice('Congratulations ' + guessedby + ', you win! :smallpresent Prize is: ' + charadesPrize + ' :smallpresent ', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' has guessed correctly and has won the prize of : ' + charadesPrize); } else { cb.sendNotice('Sorry ' + charadesTipper + ', ' + guessedby + ' guessed the correct answer first!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(charadesTipper + ' did not win, ' + guessedby + ' guessed the correct answer first'); } } else if (charadesMode == 'M3') { var winPoints = 0; if (guessedby == charadesTipper) { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 3 points for guessing correctly in the game you tipped for!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' guessed correctly, and wins 3 points!'); winPoints = 3; } else { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 1 point!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' guessed correctly, and wins 1 point!'); winPoints = 1; } if (!cbjs.arrayContains(charadesVAR2Scores.user,guessedby)) { charadesVAR2Scores.user.push(guessedby); userIndex = charadesVAR2Scores.user.indexOf(guessedby); charadesVAR2Scores.score[userIndex] = 0; charadesVAR2Scores.score[userIndex] += winPoints; } else { userIndex = charadesVAR2Scores.user.indexOf(guessedby); charadesVAR2Scores.score[userIndex] += winPoints; } } else if (charadesMode == 'M4') { var winPoints = 0; if (guessedby == charadesTipper) { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 2 points for guessing correctly in the game you tipped for!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' guessed correctly, and wins 2 points!'); winPoints = 2; } else { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 1 point!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(guessedby + ' guessed correctly, and wins 1 point!'); winPoints = 1; } if (!cbjs.arrayContains(charadesVAR3Scores.user,guessedby)) { charadesVAR3Scores.user.push(guessedby); userIndex = charadesVAR3Scores.user.indexOf(guessedby); charadesVAR3Scores.score[userIndex] = 0; charadesVAR3Scores.score[userIndex] += winPoints; } else { userIndex = charadesVAR3Scores.user.indexOf(guessedby); charadesVAR3Scores.score[userIndex] += winPoints; } } charadesGameComplete(guessedby,false); charadesNewGame(); } function charadesGameComplete(guessedby,fixscore) { if (charadesMode == 'M1') { if (!fixscore) { charadesGamesThisRound++; } highScore = 0; secondScore = 0; for (var i = 0; i < charadesPlayers.length; i++) { if (charadesScores[i] > highScore) { secondScore = highScore; highScore = charadesScores[i]; } else if (charadesScores[i] > secondScore) { secondScore = charadesScores[i]; } } if (highScore >= cb.settings.charadesBABGoal) { if (charadesGamesThisRound >= charadesNumberofPlayers || charadesGamesThisRound == 0 || (highScore - secondScore) > 1) { winnercount = 0; for (var i = 0; i < charadesPlayers.length; i++) { if (charadesScores[i] == highScore) { winnercount++; winningindex = i; } } if (winnercount > 1) { charadesNextRound(); cb.sendNotice('There is a tie, we\'ll play another round of ' + charadesType + ' until there is a winner! \n' + charadesCurrentPlayer + ' will play next. \nCurrent Broadcaster Score - ' + charadesBABScore() + '\nCurrent Viewer Score - ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { cb.sendNotice('Final Broadcaster Score - ' + charadesBABScore() + '\nFinal Viewer Score ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); cb.sendNotice(charadesPlayers[winningindex] + ' has won ' + charadesType + '! :smallpresent The prize is ' + charadesPrize + '! :smallpresent ', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(charadesPlayers[winningindex] + ' has won ' + charadesType + '! The prize is ' + charadesPrize); charadesRestart(); cb.sendNotice('' + charadesType + ' Game has been reset.', cb.room_slug, appNoticeColor); } } else if (!fixscore) { if (charadesGamesThisRound >= charadesNumberofPlayers) { charadesNextRound(); cb.sendNotice((charadesRound-1) + ' round' + ((charadesRound-1) == 1 ? '' : 's') + ' played. \n' + charadesCurrentPlayer + ' will play next. \nCurrent Score - ' + charadesBABScore(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { charadesCurrentPlayerIndex ++; charadesCurrentPlayer = charadesPlayers[charadesCurrentPlayerIndex]; cb.sendNotice(charadesCurrentPlayer + ' will perform the next word/phrase. \nCurrent Broadcaster Score - ' + charadesBABScore() + '\nCurrent Viewer Score - ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } } else if (!fixscore) { if (charadesGamesThisRound >= charadesNumberofPlayers) { charadesNextRound(); cb.sendNotice((charadesRound-1) + ' round' + ((charadesRound-1) == 1 ? '' : 's') + ' played. \n' + charadesCurrentPlayer + ' will play next. \nCurrent Broadcaster Score - ' + charadesBABScore() + '\nCurrent Viewer Score - ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { charadesCurrentPlayerIndex ++; charadesCurrentPlayer = charadesPlayers[charadesCurrentPlayerIndex]; cb.sendNotice(charadesCurrentPlayer + ' will perform the next word/phrase. \nCurrent Broadcaster Score - ' + charadesBABScore() + '\nCurrent Viewer Score - ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } } else if (charadesMode == 'M2') { if (guessedby == 'none') { if (charadesTipper == cb.room_slug) { cb.sendNotice('The free play started by the broadcaster ended without a correct guess.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('Free Play game started by the broadcaster ended with no winner, time ran out.'); } else { cb.sendNotice('Sorry ' + charadesTipper + ', time ran out so you did not win a prize - Please play again!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('The ' + charadesType + ' game started by ' + charadesTipper + ' ended with no winner, time ran out.'); } } else { cb.sendNotice('The current ' + charadesType + ' game started by ' + charadesTipper + ' has been completed.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } else if (charadesMode == 'M3') { if (!fixscore) { charadesGamesGoalRace++; } highScore = 0; for (var i = 0; i < charadesVAR2Scores.user.length; i++) { if (charadesVAR2Scores.score[i] > highScore) { highScore = charadesVAR2Scores.score[i]; winningindex = i; } } if (highScore > 0 && highScore >= cb.settings.charadesVAR2Goal) { cb.sendNotice(charadesVAR2Scores.user[winningindex] + ' has won the ' + charadesType + ' Goal Race! :smallpresent The prize is ' + charadesPrize + '! :smallpresent ', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(charadesVAR2Scores.user[winningindex] + ' has won ' + charadesType + '! The prize is ' + charadesPrize); cb.sendNotice('Resetting the ' + charadesType + ' game and scores... Let\'s play again!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesRestart(); cb.sendNotice(charadesType + ' Game has been reset.', cb.room_slug, appNoticeColor); } else if (!fixscore) { cb.sendNotice(charadesGamesGoalRace + ' game' + (charadesGamesGoalRace == 1 ? '' : 's') + ' played in the goal race. \nCurrent Scoreboard - ' + charadesMode3Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesNextRound(); } } else if (charadesMode == 'M4') { if (!fixscore) { charadesGamesGoalRace++; } highScore = 0; for (var i = 0; i < charadesVAR3Scores.user.length; i++) { if (charadesVAR3Scores.score[i] > highScore) { highScore = charadesVAR3Scores.score[i]; winningindex = i; } } if (highScore > 0 && highScore >= cb.settings.charadesVAR3Goal) { cb.sendNotice(charadesVAR3Scores.user[winningindex] + ' has won the ' + charadesType + ' Goal Race! :smallpresent The prize is ' + charadesPrize + '! :smallpresent ', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push(charadesVAR3Scores.user[winningindex] + ' has won ' + charadesType + '! The prize is ' + charadesPrize); cb.sendNotice('Resetting the ' + charadesType + ' game and scores... Let\'s play again!', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesRestart(); cb.sendNotice(charadesType + ' Game has been reset.', cb.room_slug, appNoticeColor); } else if (!fixscore) { cb.sendNotice(charadesGamesGoalRace + ' game' + (charadesGamesGoalRace == 1 ? '' : 's') + ' played in the goal race. \nCurrent Scoreboard - ' + charadesMode4Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesNextRound(); } } } function charadesRestart() { charadesActive = false; charadesWordSelected = false; charadesRound = 1; charadesGamesThisRound = 0; charadesCurrentPlayerIndex = 0; charadesCurrentPlayer = charadesPlayers[charadesCurrentPlayerIndex]; charadesGamesGoalRace = 0; if (charadesMode == 'M1') { charadesLoadBABPlayers(); } else if (charadesMode == 'M3') { charadesVAR2Scores.user = []; charadesVAR2Scores.score = [0]; } else if (charadesMode == 'M4') { charadesVAR3Scores.user = []; charadesVAR3Scores.score = [0]; } charadesResults.push(charadesType + ' game has been restarted.'); } function sortMode3Scores() { var swapped, temp1, temp2; do { swapped = false; for (var i = 0; i < charadesVAR2Scores.user.length ; i++) { if (charadesVAR2Scores.score[i] < charadesVAR2Scores.score[i + 1]) { temp1 = charadesVAR2Scores.score[i]; temp2 = charadesVAR2Scores.user[i]; charadesVAR2Scores.score[i] = charadesVAR2Scores.score[i + 1]; charadesVAR2Scores.score[i + 1] = temp1; charadesVAR2Scores.user[i] = charadesVAR2Scores.user[i + 1]; charadesVAR2Scores.user[i + 1] = temp2; swapped = true; } } } while (swapped); } function sortMode4Scores() { var swapped, temp1, temp2; do { swapped = false; for (var i = 0; i < charadesVAR3Scores.user.length ; i++) { if (charadesVAR3Scores.score[i] < charadesVAR3Scores.score[i + 1]) { temp1 = charadesVAR3Scores.score[i]; temp2 = charadesVAR3Scores.user[i]; charadesVAR3Scores.score[i] = charadesVAR3Scores.score[i + 1]; charadesVAR3Scores.score[i + 1] = temp1; charadesVAR3Scores.user[i] = charadesVAR3Scores.user[i + 1]; charadesVAR3Scores.user[i + 1] = temp2; swapped = true; } } } while (swapped); } function sortMode1Scores() { var swapped, temp1, temp2; do { swapped = false; for (var i = 0; i < charadesBABScores.user.length ; i++) { if (charadesBABScores.score[i] < charadesBABScores.score[i + 1]) { temp1 = charadesBABScores.score[i]; temp2 = charadesBABScores.user[i]; charadesBABScores.score[i] = charadesBABScores.score[i + 1]; charadesBABScores.score[i + 1] = temp1; charadesBABScores.user[i] = charadesBABScores.user[i + 1]; charadesBABScores.user[i + 1] = temp2; swapped = true; } } } while (swapped); } function charadesBABScore() { charadesScoreList = '\n'; for (var i = 0; i < charadesPlayers.length; i++) { charadesScoreList += (i > 0 ? ' / ' : '') + charadesPlayers[i] + ': ' + charadesScores[i]; } return charadesScoreList; } function charadesMode3Score() { if (charadesVAR2Scores.user.length > 0) { sortMode3Scores(); charadesScoreboard = ''; for (var i = 0; i < charadesVAR2Scores.user.length; i++) { charadesScoreboard += '\n' + (i+1) + '. ' + charadesVAR2Scores.user[i] + ' (' + charadesVAR2Scores.score[i] + ')'; } } else { charadesScoreboard = '\nNo Scores Yet'; } return charadesScoreboard; } function charadesMode4Score() { if (charadesVAR3Scores.user.length > 0) { sortMode4Scores(); charadesScoreboard = ''; for (var i = 0; i < charadesVAR3Scores.user.length; i++) { charadesScoreboard += '\n' + (i+1) + '. ' + charadesVAR3Scores.user[i] + ' (' + charadesVAR3Scores.score[i] + ')'; } } else { charadesScoreboard = '\nNo Scores Yet'; } return charadesScoreboard; } function charadesMode1Score() { if (charadesBABScores.user.length > 0) { sortMode1Scores(); charadesScoreboard = ''; for (var i = 0; i < charadesBABScores.user.length; i++) { charadesScoreboard += '\n' + (i+1) + '. ' + charadesBABScores.user[i] + ' (' + charadesBABScores.score[i] + ')'; } } else { charadesScoreboard = '\nNo Scores Yet'; } return charadesScoreboard; } function charadesNextRound() { charadesRound++; if (charadesMode == 'M4') { charadesPlay('tip',charadesTipper,true); } else { charadesCurrentPlayerIndex = 0; charadesCurrentPlayer = charadesPlayers[charadesCurrentPlayerIndex]; charadesGamesThisRound = 0; } } function charadesEndGame(endedby) { charadesGuessing = false; charadesWaiting = false; charadesActive = false; charadesStopTimer(endedby); if (charadesMode == 'M1') { cb.sendNotice('The current ' + charadesType + ' game started by ' + charadesTipper + ' has been ended by ' + endedby + ', but the overall point race is still active.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('The ' + charadesType + ' game was ended by ' + endedby); charadesGameComplete('none',false); charadesNewGame(); } else if (charadesMode == 'M2') { cb.sendNotice('The current ' + charadesType + ' game started by ' + charadesTipper + ' has been ended by ' + endedby, '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('The current ' + charadesType + ' game started by ' + charadesTipper + ' was ended by ' + endedby); charadesNewGame(); } else if (charadesMode == 'M3') { cb.sendNotice('The current ' + charadesType + ' game started by ' + charadesTipper + ' has been ended by ' + endedby, ', but the overall point race is still active.', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('The current ' + charadesType + ' game started by ' + charadesTipper + ' was ended by ' + endedby); charadesNewGame(); } else if (charadesMode == 'M4') { cb.sendNotice('The current ' + charadesType + ' game started by ' + charadesTipper + ' has been ended by ' + endedby, ', but the overall point race is still active.', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesResults.push('The current ' + charadesType + ' game started by ' + charadesTipper + ' was ended by ' + endedby); charadesNewGame(); } } function charadesPlayerQueue(sendto) { if (charadesNextPlayer.length === 0) { cb.sendNotice('No players waiting.', sendto, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { var msg = 'Players waiting to play ' + charadesType + ':'; for (var i = 0; i < charadesNextPlayer.length; i++) { msg += '\n' + (i+1) + '. ' + charadesNextPlayer[i]; } cb.sendNotice(msg, sendto, charadesNoticeBgColor, charadesNoticeTextColor); } } function charadesShowResults(sendto,showall) { if (showall == 'all') { var msg = '\u22A1 \u22A1 \u22A1 \u22A1 ' + charadesType + ' Results \u22A1 \u22A1 \u22A1 \u22A1'; } else { var msg = '\u22A1 \u22A1 \u22A1 \u22A1 Last 20 ' + charadesType + ' Results \u22A1 \u22A1 \u22A1 \u22A1'; } if (charadesResults.length === 0) { cb.sendNotice('\nNo Selections have been made.', sendto, charadesNoticeBgColor, charadesNoticeTextColor); } else { if (showall == 'all') { for (var i = 0; i < charadesResults.length; i++) { msg += '\n' + (i+1) + '. ' + charadesResults[i]; } } else { var charadesRecentResults = charadesResults.slice(-20); for (var i = 0; i < charadesRecentResults.length; i++) { msg += '\n' + charadesRecentResults[i]; } } } cb.sendNotice(msg, sendto, charadesNoticeBgColor, charadesNoticeTextColor); } } // ******************************* Upon user entry of a Message ************************************** { cb.onMessage(function (msg) { var message = msg['m'].split(' '); var cmd = 0; var listRegExp = /[,\s]+/; var m = msg.m; var u = msg.user; var isMod = msg.is_mod; var isBC = (u === cb.room_slug); var BC = cb.room_slug; var isDarkBlue = false; var isLightBlue = false; var isLightPurple = false; var isDarkPurple = false; var isGray = false; var command = message[0] var commandVar1 = parseInt(message[1]); var commandVar2 = parseInt(message[2]); if (msg.tipped_tons_recently) { isDarkPurple = true; } else if (msg.tipped_alot_recently) { isLightPurple = true; } else if (msg.tipped_recently) { isDarkBlue = true; } else if (msg.has_tokens) { isLightBlue = true; } else if (!msg.has_tokens) { isGray = true; } if (cb.settings.silenceLevel == 'All Users Can Guess' || (cb.settings.silenceLevel == 'Gray Users Cannot Guess' && !isGray) || (cb.settings.silenceLevel == 'Gray & Light Blue Users Cannot Guess' && !isLightBlue && !isGray)) { if (message[0].charAt(0) != '/' && charadesToggle == 1 && charadesGuessing == true) { charadesguess = msg['m']; if (message[0].charAt(0) == '[' || message[0].charAt(0) == '|' || message[0].charAt(0) == ':') { for (var msgindex = 0; msgindex < 4; msgindex++) { if (message[0]) { if (message[0].charAt(0) == ':') { message.splice(0, 1); } } if (message[0]) { if (message[0].charAt(0) == '|') { message.splice(0, 1); } } if (message[0]) { if (message[0].charAt(0) == '[') { message.splice(0, 1); } } } charadesguess = cbjs.arrayJoin(message, ' '); } charadesguess = charadesguess.toLowerCase().trim(); charadesguess = charadesguess.replace(/[^a-z0-9]/g, ''); charadeswordtoguess = charadesWord.replace(/[^a-z0-9]/g, ''); if (charadesguess == charadeswordtoguess) { if (isMod && cb.settings.charadesModsKnowWord == 'Yes') { cb.sendNotice('Moderators are not allowed to guess when they know the word.', u, appNoticeColor); msg['X-Spam'] = true; } else if (isBC) { cb.sendNotice('Broadcasters are not allowed to guess.\n If you need to force a win for someone who guessed close enough, you can use the command "/chwin username" before time runs out and it will give them credit for the answer.\n After time runs out, you can correct the score if necessary with the "/chfixscore X username" command, where X is the new score for the given user.', u, appNoticeColor); msg['X-Spam'] = true; } else { charadesCorrectAnswer(u); } } } } if (message[0]) { if (message[0].charAt(0) == '/') { msg['X-Spam'] = true; var ntc = null; for (var i = 1; i < message.length; i++) { if (i == 1) ntc = message[i]; else ntc += " " + message[i]; } var cmdval = null; for (var i = 1; i < message.length; i++) { if (i == 1) cmdval = message[i]; else cmdval += " " + message[i]; } switch(command) { case '/chi': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { charadesInfo(u,'BC'); } else { charadesInfo(u,'common'); } } else { cb.sendNotice('The ' + charadesType + ' Game is not enabled.', u, appNoticeColor); } break; } case '/chlist': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { cb.sendNotice(charadesType + ' Word List (' + charadesList.length + (charadesList.length == 1 ? ' entry' : ' entries') + '): \n' + (charadesList.length > 0 ? cbjs.arrayJoin(charadesList, ', ') : 'No entries.') + '\nEnd of List', u, appNoticeColor); } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chq': { cmd = 1; if (charadesToggle == 1) { charadesPlayerQueue(u); } else { cb.sendNotice('The ' + charadesType + ' Game is not enabled.', u, appNoticeColor); } break; } case '/chh': { cmd = 1; showall = ''; if (message[1] == 'all' || message[1] == '' || message[1] == null) { showall = message[1]; } else { cb.sendNotice('Invalid parameter for the "/chh" command, valid values are "all" and blanks (blanks defaults to last 20 plays).', u, appNoticeColor); } if (isMod) { charadesShowResults(cb.room_slug,showall); } charadesShowResults(u,showall); break; } case '/chplay': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesToggle) { if (charadesWaiting == true) { if (charadesMinsRemain >= 1 || charadesSecsRemain >= 1) { cb.sendNotice('A ' + charadesType + ' timer is already running, likely from the previous game, please stop the current timer using the command /chstoptimer if it is no longer needed.', u, appNoticeColor); } else { if (charadesWordSelected == true) { charadesStartPlay(); } else { cb.sendNotice('A word has not yet been selected for the current game, please add a word to the wordlist using the /chword command.', u, appNoticeColor); } } } else { cb.sendNotice('The ' + charadesType + ' Game is not awaiting a start (word may not be selected, or already started and taking guesses).', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game is not enabled.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chword': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (isBC || (isMod && cb.settings.charadesModsKnowWord == 'Yes')) { if (cmdval != null) { var addlistarray = cmdval.split(':'); if (addlistarray.length > 1) { addnotice = ''; for (var i = 0; i < addlistarray.length; i++) { if (addlistarray[i] != '') { newCharadesWord = addlistarray[i].toLowerCase().trim(); if (!cbjs.arrayContains(charadesList, newCharadesWord)) { charadesList.push(newCharadesWord); addnotice += '\nAdded "' + newCharadesWord + '" to the ' + charadesType + ' Word List.' } else { addnotice += '\n' + newCharadesWord + ' is already on the ' + charadesType + ' Word List. Skipping.'; } } } addnotice += '\nAll words and phrases were added.'; cb.sendNotice(addnotice, u, appNoticeColor); } else { newCharadesWord = msg['m'].substring(8).trim(); if (cbjs.arrayContains(charadesList,newCharadesWord)) { cb.sendNotice(newCharadesWord + ' is already in the ' + charadesType + ' Word list.', u, appNoticeColor); } else { charadesList.push(newCharadesWord); cb.sendNotice('You have added "' + newCharadesWord + '" to the ' + charadesType + ' Word List.', u, appNoticeColor); } } if (charadesWaiting == true && charadesWordSelected == false) { selectWord(); } } else { cb.sendNotice('A parameter is required for the /chword command and should be the word or phrase you would like to add. Multiple words and phrases can be added to the list if they are separated with a colon ":".', u, appNoticeColor); } } else { cb.sendNotice('A moderator can only add words if they are configured to know the word list.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chsave': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (isBC || (isMod && cb.settings.charadesModsKnowWord == 'Yes')) { if (charadesList.length > 0) { cb.sendNotice('Unused charades words listed below. \nYou can paste this list into the Broadcaster Managed word list when next starting the bot so you don\'t reuse words from the current session: \n' + cbjs.arrayJoin(charadesList,':'), u, appNoticeColor); } else { cb.sendNotice('There are no words or phrases left in the current word list.', u, appNoticeColor); } } else { cb.sendNotice('A moderator can only use this command if they are configured to know the word list.', u, appNoticeColor); } } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.', u, appNoticeColor); } break; } case '/chrmv': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { wordtormv = msg['m'].substring(7).trim(); if (wordtormv != null && wordtormv != '' && wordtormv != ' ') { if (cbjs.arrayContains(charadesList,wordtormv)) { cbjs.arrayRemove(charadesList,wordtormv); cb.sendNotice('You have removed "' + wordtormv + '" from the ' + charadesType + ' Word List.', u, appNoticeColor); } else { cb.sendNotice('The word/phrase "' + wordtormv + '" is not in the ' + charadesType + ' Word List. Please check your spelling to ensure it is an exact match with what you are trying to remove, including upper and lower case. You can use the command /chlist to view the list, and then copy and paste the word or phrase from the list.', u, appNoticeColor); } } else { cb.sendNotice('A parameter is required for the /chrmv command and should be an exact match for the word or phrase you would like to remove.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chlength': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesToggle == 1) { numlength = parseFloat(message[1]); if(isNaN(numlength)) { cb.sendNotice('The value entered for the new ' + charadesType + ' timer length is not numeric, please try again.', u, appNoticeColor); } else if (numlength != .5 && numlength != 1 && numlength != 1.5 && numlength != 2 && numlength != 3 && numlength != 4 && numlength != 5) { cb.sendNotice('The value entered for the new ' + charadesType + ' timer length is not one of the allowable values of .5, 1, 1.5, 2, 3, 4, or 5 (min), please try again.', u, appNoticeColor); } else { charadesTimerLength = numlength; cb.sendNotice(u + ' has updated the ' + charadesType + ' timer length to ' + charadesTimerLength + (charadesTimerLength == 1 ? ' minute.' : ' minutes.'), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } else { cb.sendNotice('The ' + charadesType + ' Game is not enabled, you can use the command "/charades on" to enable it.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chprice': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesToggle == 1) { numprice = parseInt(message[1]); if(isNaN(numprice)) { cb.sendNotice('The value entered for the new ' + charadesType + ' price is not numeric, please try again.', u, appNoticeColor); } else if(numprice < 1 || numprice > 1000) { cb.sendNotice('The value entered for the new ' + charadesType + ' price is outside allowable values from 1 to 1000, please try again.', u, appNoticeColor); } else { charadesPrice = numprice; cb.sendNotice(u + ' has updated the ' + charadesType + ' price to ' + charadesPrice + ' tokens.', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } } else { cb.sendNotice('The ' + charadesType + ' Game is not enabled, you can use the command "/charades on" to enable it.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chfree': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesActive == false) { charadesPlay('free',u,false); } else { cb.sendNotice('A ' + charadesType + ' game has already started. Once the current game is finished, a new one can be started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chstoptimer': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesMinsRemain >= 1 || charadesSecsRemain >= 1) { if (charadesGuessing) { cb.sendNotice('The timer has been ended, but guessing can continue. To end the game, use the /chend command.', u, appNoticeColor); } charadesStopTimer(); } else { cb.sendNotice('A ' + charadesType + ' timer is not currently running.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chend': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesActive) { charadesEndGame(u); } else { cb.sendNotice('A ' + charadesType + ' game has not been started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chwin': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesGuessing) { if (message[1]) { charadesCorrectAnswer(message[1]); } else { cb.sendNotice('A user ID is required as a parameter for this command to identify the winner. Command should be used in the format "/chwin username".', u, appNoticeColor); } } else { cb.sendNotice('A ' + charadesType + ' game has not been started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chskip': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (charadesGuessing) { cb.sendNotice('Current word is being skipped, ' + charadesType + ' will start again on broadcaster\'s command', '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesStopTimer(u); selectWord(); } else { cb.sendNotice('The /chskip command can only be used once the game starts after the word has been shown.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chclearlist': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { charadesList = []; cb.sendNotice('The ' + charadesType + ' Word List has been cleared. You can add words to the list with the /chword command.', u, appNoticeColor); } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/chsb': case '/chscoreboard': { cmd = 1; if (charadesToggle == 1) { if (isMod || isBC) { sendto = ''; } else { sendto = u; } if (charadesMode == 'M1') { cb.sendNotice((sendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\n' + charadesType + ' Current Broadcaster Score - ' + charadesBABScore() + '\n' + charadesType + ' Current Viewer Score - ' + charadesMode1Score(), sendto, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else if (charadesMode == 'M3') { cb.sendNotice((sendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\n' + charadesType + ' Current Score ' + + charadesMode3Score(), sendto, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else if (charadesMode == 'M4') { cb.sendNotice((sendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\n' + charadesType + ' Current Score ' + + charadesMode4Score(), sendto, charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); } else { cb.sendNotice('The /chsb (or /chscoreboard) command is only valid for ' + charadesType + ' Modes 1, 3 and 4.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } case '/chfixscore': { cmd = 1; if (charadesToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { newscore = parseInt(message[1]); updateuser = message[2]; if (isNaN(newscore)) { cb.sendNotice('The value entered for the new user score is not numeric, please try again.\n The format of the command should be "/chfixscore X username" to update username\'s score to a new value X.', u, appNoticeColor); } else if (!message[2]) { cb.sendNotice('A value was not entered for the username of the score to update, please try again.\n The format of the command should be "/chfixscore X username" to update username\'s score to a new value X.', u, appNoticeColor); } else { if (charadesMode == 'M1') { if (cbjs.arrayContains(charadesPlayers,updateuser)) { index = charadesPlayers.indexOf(updateuser); charadesScores[index] = newscore; cb.sendNotice('You have updated ' + updateuser + '\'s score to ' + newscore + '.', u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has updated ' + updateuser + '\'s score to ' + newscore + '.', BC, appNoticeColor); } cb.sendNotice(charadesType + ' Current Broadcaster Score - ' + charadesBABScore() + '\n' + charadesType + ' Current Viewer Score - ' + charadesMode1Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesGameComplete(updateuser,true); charadesResults.push(u + ' has updated ' + updateuser + '\'s score to ' + newscore); } else { cb.sendNotice('The value entered for the username of the score to update does not match any of the current players, please try again.\n The format of the command should be "/chfixscore X username" to update username\'s score to a new value X.\n The entry is case sensitive, current player list: ' + cbjs.arrayJoin(charadesPlayers, ', '), u, appNoticeColor); } } else if (charadesMode == 'M3') { if (cbjs.arrayContains(charadesVAR2Scores.user,updateuser)) { index = charadesVAR2Scores.user.indexOf(updateuser); charadesVAR2Scores.score[index] = newscore; cb.sendNotice('You have updated ' + updateuser + '\'s score to ' + newscore + '.', u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has updated ' + updateuser + '\'s score to ' + newscore + '.', BC, appNoticeColor); } } else { cb.sendNotice('The value entered for the username of the score to update does not match any of the current players, an entry is being added for ' + updateuser, u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has added ' + updateuser + ' to the scoreboard with a score of ' + newscore + '.', BC, appNoticeColor); } charadesVAR2Scores.user.push(updateuser); userIndex = charadesVAR2Scores.user.indexOf(updateuser); charadesVAR2Scores.score[userIndex] = newscore; } cb.sendNotice(charadesType + ' Current Score - ' + charadesMode3Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesGameComplete(updateuser,true); charadesResults.push(u + ' has updated ' + updateuser + '\'s score to ' + newscore); } else if (charadesMode == 'M4') { if (cbjs.arrayContains(charadesVAR2Scores.user,updateuser)) { index = charadesVAR3Scores.user.indexOf(updateuser); charadesVAR3Scores.score[index] = newscore; cb.sendNotice('You have updated ' + updateuser + '\'s score to ' + newscore + '.', u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has updated ' + updateuser + '\'s score to ' + newscore + '.', BC, appNoticeColor); } } else { cb.sendNotice('The value entered for the username of the score to update does not match any of the current players, an entry is being added for ' + updateuser, u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has added ' + updateuser + ' to the scoreboard with a score of ' + newscore + '.', BC, appNoticeColor); } charadesVAR3Scores.user.push(updateuser); userIndex = charadesVAR3Scores.user.indexOf(updateuser); charadesVAR3Scores.score[userIndex] = newscore; } cb.sendNotice(charadesType + ' Current Score - ' + charadesMode4Score(), '', charadesNoticeBgColor, charadesNoticeTextColor, 'bold'); charadesGameComplete(updateuser,true); charadesResults.push(u + ' has updated ' + updateuser + '\'s score to ' + newscore); } else { cb.sendNotice('The /chfixscore command is only valid for ' + charadesType + ' Modes 1 and 3.', u, appNoticeColor); } } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The ' + charadesType + ' Game has not been enabled.', u, appNoticeColor); } break; } } } } return msg; }); } // *********************************** Actions on user entering ************************************** { cb.onEnter(function(user) { // Variables var onEnterUser = user.user; var onEnterIsMod = user.is_mod; // **** Charades Message if(charadesToggle == 1) { charadesShowNotice(onEnterUser); } }); } // *********************************** Actions upon leaving ************************************** { cb.onLeave(function(user) { var onLeaveUser = user.user; }); } // *********************************** Actions upon tipping ************************************** { cb.onTip(function (tip) { var tipAmount = Number.parseInt(tip.amount, 10); var onTipUser = tip.from_user var tipForGame = false; var onTipIsMod = tip.from_user_is_mod; var isAnon = tip.is_anon_tip; if (isAnon) { onTipUser = 'Anonymous'; } if (charadesToggle == 1) { if (tipAmount == charadesPrice) { charadesPlay('tip',onTipUser,false); tipForGame = true; } } }); } // *********************************** Initialize ************************************** { if (initialize == 0) { cb.sendNotice('Dorothy\'s Charades and Pictionary Bot v1.1'); cb.sendNotice('** Version 1.1 was released on 3/27/2020.', cb.room_slug, appNoticeColor); // *** Init Features using toggle functions if (cb.settings.charadesMode == 'Mode 1 - Broadcaster against Broadcaster') { charadesMode = 'M1'; charadesPrice = cb.settings.charadesBABPrice; } else if (cb.settings.charadesMode == 'Mode 2 - Viewer against Room (One Game)') { charadesMode = 'M2'; charadesPrice = cb.settings.charadesVARPrice; } else if (cb.settings.charadesMode == 'Mode 3 - Viewer against Room (Goal Race)') { charadesMode = 'M3'; charadesPrice = cb.settings.charadesVAR2Price; } else if (cb.settings.charadesMode == 'Mode 4 - Viewer against Room (Goal Race Single Tip)') { charadesMode = 'M4'; charadesPrice = cb.settings.charadesVAR3Price; } charadesSetToggle('on',cb.room_slug); initialize = 1; } }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.