Bots Home
|
Create an App
Family Feud
Author:
dorothy
Description
Source Code
Launch Bot
Current Users
Created by:
Dorothy
/** Name: Family Feud Author: butter_my_toast **/ //** Enable for ESLINT syntax check, Disable for CB compile //var cb = ''; //var cbjs = ''; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 var textColorArray = { dispname: ['White/No Color', 'Black', 'Dark Grey', 'Dark Red', 'Dark Orange', 'Dark Green', 'Dark Aqua', 'Dark Blue', 'Dark Purple', 'Dark Pink', 'Dark Gold', 'Dark Teal', 'Dark Brown', 'Dark Bronze', 'Dark Periwinkle', 'Dark Fuschia', 'Dark Lime', 'Dark Plum' ], name: ['white', 'black', 'darkgrey', 'darkred', 'darkorange', 'darkgreen', 'darkaqua', 'darkblue', 'darkpurple', 'darkpink', 'darkgold', 'darkteal', 'darkbrown', 'darkbronze', 'darkperiwinkle', 'darkfuschia', 'darklime', 'darkplum' ], colorID: ['#FFFFFF', '#000000', '#737373', '#cc0000', '#e77400', '#006600', '#006767', '#0629AC', '#3d003d', '#ff6680', '#998100', '#003f1f', '#582c00', '#a56728', '#155bd7', '#d6155c', '#6b790c', '#7f13bf' ]}; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 var bgColorArray = { dispname: ['White/No Color', 'Light Yellow', 'Light Blue', 'Light Pink', 'Light Red', 'Light Green', 'Light Purple', 'Light Orange', 'Light Grey', 'Light Aqua', 'Light Teal', 'Cream', 'Light Bronze', 'Light Periwinkle', 'Light Fuschia', 'Light Lime', 'Light Plum'], name: ['white', 'lightyellow', 'lightblue', 'lightpink', 'lightred', 'lightgreen', 'lightpurple', 'lightorange', 'lightgrey', 'lightaqua', 'lightteal', 'cream', 'lightbronze', 'lightperiwinkle', 'lightfuschia', 'lightlime', 'lightplum' ], colorID: ['#FFFFFF', '#ffff94', '#d1eaee', '#FFE6EA', '#ff9a9a', '#94e594', '#f2cdff', '#ffd9b3', '#e6e6e6', '#adeaea', '#d7fbee', '#f9f6ed', '#ebccad', '#d7e4fb', '#fbd7e4', '#ecf6a7', '#e3c0f9' ]}; cb.settings_choices = [ {name: 'dummyIntro', label: ' ******************* Introduction ********************* Latest Update: 8/11/2021 (version 1.0) ', type: 'choice',required: false}, {name: 'dummyFamilyFeud', label: 'Welcome! To play Family Feud, first decide if you as the broadcaster will be the Game Host or will be on one of the teams. If you are the host, you can either set up each game individually below with questions and answers, or you can enter them with commands. If you set them up each time and restart the bot, you will not be able to keep track of scores across multiple rounds (since data is not saved on restart). If you don\'t restart the bot, and you or the assigned Game Host enter the question and answers for each round via commands, you can keep a running total of the team scores. Once each game is started, the viewers can join a team, and then the teams compete against each other to guess what the most common answers were for the question according to the people polled. The questions and answers can be provided from any website (there are lots of sample games you can look up by googling "Family Feud Questions and Answers" - the game does not have preset entries. The Game Host is responsible for deciding the correctness of answers, moving the game along, and entering the question and answer lists if you put them in as you go. You can either configure the game to let people join for free, join for free with approval, or join by tipping.', type: 'choice',required: false}, {name: 'ffJoinMode', label: 'How do players join the game?',required: false, type: 'choice', choice1: 'Anyone can join', choice2: 'Any non-gray user can join', choice3: 'Anyone can join - require approval', choice4: 'Tip to join', defaultValue: 'Any non-gray user can join'}, {name: 'ffJoinPrice', label: 'Price to join -- This setting is only used if setting above is configured as "Tip to Join"', type: 'int', minValue: 1, maxValue: 99999, defaultValue: 37}, {name: 'ffHostName', label: 'CB username of the "host" for the game -- Enter the username here, or use the command /ffhost to assign them after starting the bot. You can be the host (but then you cannot play), or you can assign a trustworthy user from the room',type: 'str',minLength: 1, maxLength: 50,required: false}, {name: 'ffHostNickName', label: 'Nickname for the host -- (Optional) Enter a text string here, it will be shown as a nickname in [brackets] next to their CB username in the chat',type: 'str',minLength: 1, maxLength: 50,required: false}, {name: 'ffSource', label: 'Source of Questions and Answers -- If you will be the Game Host (not playing on a team), you can enter the question and answers below and restart the bot for each round. If you are playing the game on one of the teams, leave these blank and let the Game Host enter them with commands',required: false, type: 'choice', choice1: 'Entered Below - Single Game', choice2: 'Added by Host During Game', defaultValue: 'Added by Host During Game'}, {name: 'dummyFamilyFeud2', label: 'If you selected the option "Entered Below - Single Game" as the Source, list the questions and answers below. Up to 8 answers can be provided, but it is only required to have at least 3. If using point values for each answer, use a ":" to separate the answer and point value from each other, in a format such as "Marbles:35". Note that the host will confirm if an answer is correct if it is not an exact match, so the entered answers do not have to exactly match the guesses, but if they do they will be automatically accepted',required: false,type: 'str',minLength: 1, maxLength: 2000}, {name: 'ffQuestion', label: 'Question',required: false,type: 'str',minLength: 1, maxLength: 200}, {name: 'ffAnswer1', label: 'Answer 1',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer2', label: 'Answer 2',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer3', label: 'Answer 3',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer4', label: 'Answer 4',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer5', label: 'Answer 5',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer6', label: 'Answer 6',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer7', label: 'Answer 7',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'ffAnswer8', label: 'Answer 8',required: false,type: 'str',minLength: 1, maxLength: 50}, // {name: 'ffWinMode', label: 'How is the winner determined? (Configure "X" below)',required: false, type: 'choice', choice1: 'Best out of X rounds', choice2: 'Highest Points after X Rounds', defaultValue: 'Best out of X rounds'}, {name: 'ffWinMode', label: 'How is the winner determined? (Configure "X" below)',required: false, type: 'choice', choice1: 'Best out of X rounds', defaultValue: 'Best out of X rounds'}, {name: 'ffNumRounds', label: 'Number of Rounds to play -- If playing "Best out of X rounds", this should be an odd number so that a winner is determined (such as "Best of 7" would mean first team to win 4 rounds)',type: 'int',minValue: 1,maxValue: 99, defaultValue: 5}, {name: 'ffCoinTossAlt', label: 'How does the game determine the team to start playing each round?',type: 'choice', choice1: 'Coin Toss', choice2: 'Alternate Teams', defaultValue: 'Alternate Teams'}, {name: 'ffPrize', label: 'Prize - Is there a prize for the winning team? -- Any text value can be entered, such as "Loser team captain gets an ice bath" or "Winning Captain Spanks Losing Captain" (good for couples shows) or "Broadcaster removes clothing if their team loses"',required: false,type: 'str'}, {name: 'ffMaxTeamSize', label: 'Max Team Size -- Allow up to this many people to join each team',type: 'int',minValue: 2,maxValue: 20, defaultValue: 8}, {name: 'ffHostBgColor', label: 'Background/Highlight Color for Game Host chat',type: 'choice', choice1: bgColorArray.dispname[0],choice2: bgColorArray.dispname[1],choice3: bgColorArray.dispname[2],choice4: bgColorArray.dispname[3],choice5: bgColorArray.dispname[4],choice6: bgColorArray.dispname[5],choice7: bgColorArray.dispname[6],choice8: bgColorArray.dispname[7],choice9: bgColorArray.dispname[8],choice10: bgColorArray.dispname[9],choice11: bgColorArray.dispname[10],choice12: bgColorArray.dispname[11],choice13: bgColorArray.dispname[12],choice14: bgColorArray.dispname[13],choice15: bgColorArray.dispname[14],choice16: bgColorArray.dispname[15],choice17: bgColorArray.dispname[16],defaultValue: bgColorArray.dispname[15]}, {name: 'ffTeam1Name', label: 'Team 1 Name -- This will also be shown as a nickname in [brackets] in the chat next to the username of each user who joins team 1',type: 'str',minLength: 1, maxLength: 50,defaultValue: 'Team 1'}, {name: 'ffTeam1Captain', label: 'Team 1 Captain -- If there is a team captain such as if in a couple show each broadcaster is a team captain but does not answer due, add their name here. There are special commands to allow team captains to get credit if they answer verbally without having to type in the chat',type: 'str',minLength: 1, maxLength: 50,required: false}, {name: 'ffTeam1BgColor', label: 'Team 1 Chat Background/Highlight Color',type: 'choice', choice1: bgColorArray.dispname[0],choice2: bgColorArray.dispname[1],choice3: bgColorArray.dispname[2],choice4: bgColorArray.dispname[3],choice5: bgColorArray.dispname[4],choice6: bgColorArray.dispname[5],choice7: bgColorArray.dispname[6],choice8: bgColorArray.dispname[7],choice9: bgColorArray.dispname[8],choice10: bgColorArray.dispname[9],choice11: bgColorArray.dispname[10],choice12: bgColorArray.dispname[11],choice13: bgColorArray.dispname[12],choice14: bgColorArray.dispname[13],choice15: bgColorArray.dispname[14],choice16: bgColorArray.dispname[15],choice17: bgColorArray.dispname[16],defaultValue: bgColorArray.dispname[2]}, {name: 'ffTeam2Name', label: 'Team 2 Name -- This will also be shown as a nickname in [brackets] in the chat next to the username of each user who joins team 1',type: 'str',minLength: 1, maxLength: 50,defaultValue: 'Team 2'}, {name: 'ffTeam2Captain', label: 'Team 2 Captain -- If there is a team captain such as if in a couple show each broadcaster is a team captain but does not answer due, add their name here. There are special commands to allow team captains to get credit if they answer verbally without having to type in the chat',type: 'str',minLength: 1, maxLength: 50,required: false}, {name: 'ffTeam2BgColor', label: 'Team 2 Chat Background/Highlight Color',type: 'choice', choice1: bgColorArray.dispname[0],choice2: bgColorArray.dispname[1],choice3: bgColorArray.dispname[2],choice4: bgColorArray.dispname[3],choice5: bgColorArray.dispname[4],choice6: bgColorArray.dispname[5],choice7: bgColorArray.dispname[6],choice8: bgColorArray.dispname[7],choice9: bgColorArray.dispname[8],choice10: bgColorArray.dispname[9],choice11: bgColorArray.dispname[10],choice12: bgColorArray.dispname[11],choice13: bgColorArray.dispname[12],choice14: bgColorArray.dispname[13],choice15: bgColorArray.dispname[14],choice16: bgColorArray.dispname[15],choice17: bgColorArray.dispname[16],defaultValue: bgColorArray.dispname[3]}, {name: 'ffNoticeInterval', 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: 3.6}, {name: 'ffNoticeTextColor', label: 'Notice Text Color',type: 'choice',choice1: textColorArray.dispname[0],choice2: textColorArray.dispname[1],choice3: textColorArray.dispname[2],choice4: textColorArray.dispname[3],choice5: textColorArray.dispname[4],choice6: textColorArray.dispname[5],choice7: textColorArray.dispname[6],choice8: textColorArray.dispname[7],choice9: textColorArray.dispname[8],choice10: textColorArray.dispname[9],choice11: textColorArray.dispname[10],choice12: textColorArray.dispname[11],choice13: textColorArray.dispname[12],choice14: textColorArray.dispname[13],choice15: textColorArray.dispname[14],choice16: textColorArray.dispname[15],choice17: textColorArray.dispname[16],choice18: textColorArray.dispname[17],defaultValue: textColorArray.dispname[7]}, {name: 'ffNoticeBgColor', label: 'Notice Background/Highlight Color',required: false,type: 'choice', choice1: bgColorArray.dispname[0],choice2: bgColorArray.dispname[1],choice3: bgColorArray.dispname[2],choice4: bgColorArray.dispname[3],choice5: bgColorArray.dispname[4],choice6: bgColorArray.dispname[5],choice7: bgColorArray.dispname[6],choice8: bgColorArray.dispname[7],choice9: bgColorArray.dispname[8],choice10: bgColorArray.dispname[9],choice11: bgColorArray.dispname[10],choice12: bgColorArray.dispname[11],choice13: bgColorArray.dispname[12],choice14: bgColorArray.dispname[13],choice15: bgColorArray.dispname[14],choice16: bgColorArray.dispname[15],choice17: bgColorArray.dispname[16],defaultValue: bgColorArray.dispname[1]} ]; // *********************************** Variables and Arrays ************************************** var initialize = 0; var BC = cb.room_slug; 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 botName = 'Family Feud: '; // ************ Variables var ffToggle = false; var ffActive = false; var validFF = true; var ffRound = 0; var ffHostName = ''; var ffCurrentGuesser = ''; var ffMinsRemain = 0; var ffSecsRemain = 0; var ffJoinMode = ''; var ffSource = ''; var ffQuestion = ''; var ffPrize = cb.settings.ffPrize; var ffJoinPrice = cb.settings.ffJoinPrice; var ffTeam1Name = cb.settings.ffTeam1Name; var ffTeam2Name = cb.settings.ffTeam2Name; var ffTimerLength = parseInt(cb.settings.ffTimerLength); var ffMaxTeamSize = cb.settings.ffMaxTeamSize; var ffNumRounds = cb.settings.ffNumRounds; var ffWinRounds = 0; var ffWinMode = cb.settings.ffWinMode; var ffHostNickName = cb.settings.ffHostNickName; var ffForTheWinFlag = false; var ffNumIncorrect = 0; var ffTeam1Wins = 0; var ffTeam2Wins = 0; var ffTeam1Score = 0; var ffTeam2Score = 0; var ffCurrentRound = 1; var ffTeam1PlayerIdx = 0; var ffTeam2PlayerIdx = 0; var ffGuessed = false; var ffInt = 3.6; var ffCurrentTeam = 2; var ffCurrentCaptain = ''; var ffCurrentCorrectAnswers = 0; var ffUsingPoints = false; var ffAnswer1 = cb.settings.ffAnswer1; var ffAnswer2 = cb.settings.ffAnswer2; var ffAnswer3 = cb.settings.ffAnswer3; var ffAnswer4 = cb.settings.ffAnswer4; var ffAnswer5 = cb.settings.ffAnswer5; var ffAnswer6 = cb.settings.ffAnswer6; var ffAnswer7 = cb.settings.ffAnswer7; var ffAnswer8 = cb.settings.ffAnswer8; // ************ Arrays var ffAnswers = {answertext: [], pointvalue: [0], guessed: []}; var ffTippedList = []; var ffTeam1WaitList = []; var ffTeam2WaitList = []; var ffTeam1Players = []; var ffTeam2Players = []; var modList = []; // *********************************** Initialize ************************************** if (initialize == 0) { cb.sendNotice('Family Feud Bot v1.0'); cb.sendNotice('** Version 1.0 was released on Aug 12, 2021.', BC, appNoticeColor); var ffNoticeTextColor = setTextColor(cb.settings.ffNoticeTextColor,'Notice Text',BC); var ffNoticeBgColor = setBgColor(cb.settings.ffNoticeBgColor,'Notice Background',BC); var ffTeam1BgColor = setBgColor(cb.settings.ffTeam1BgColor,'Team 1 Background',BC); var ffTeam2BgColor = setBgColor(cb.settings.ffTeam2BgColor,'Team 2 Background',BC); var ffHostBgColor = setBgColor(cb.settings.ffHostBgColor,'Host Background',BC); var ffValidHost = false; if (cb.settings.ffHostName) { ffAssignHost(cb.settings.ffHostName); } else { cb.sendNotice(botName + 'A "Host" was not identified on launch, you (or a moderator) can indicate who you would like to be the host using the /ffhost command. /nAnyone can be the host, including the broadcaster or a moderator, but the host cannot play the game.', BC, appNoticeColor); cb.sendNotice(botName + 'A "Host" was not identified on launch, moderators can assign the host using the /ffhost command. /nAnyone can be the host, including the broadcaster or a moderator, but the host cannot play the game.', BC, appNoticeColor, '', '', 'red'); } if (cb.settings.ffSource == 'Entered Below - Single Game') { ffSource = 'launch'; if (cb.settings.ffQuestion) { ffQuestion = cb.settings.ffQuestion; } else { validFF = false; cb.sendNotice(botName + 'Game Setup Notice - Configuration set for entering the Question and Answers on the launch page, but no Question was entered.\nYou can either restart the bot and enter a Question (if you are the Game Host), or the Game Host can use the commands for adding them.', BC, appNoticeColor, '', 'bold'); } for (let loadindex = 1; loadindex <= 8; loadindex++) { let anstext = this["ffAnswer"+loadindex]; if (anstext) { ffAnswers.answertext.push(anstext); ffAnswers.pointvalue.push(0); ffAnswers.guessed.push(false); } } if (ffAnswers.answertext.length < 3) { validFF = false; cb.sendNotice(botName + 'Game Setup Notice - Configuration set for entering the Question and Answers on the launch page, but less than 3 Answers entered.\nYou can either restart the bot and finish entering the answers (if you are the Game Host), or the Game Host can use the commands for adding them.', BC, appNoticeColor, '', 'bold'); } } else if (cb.settings.ffSource == 'Added by Host During Game') { ffSource = 'command'; } if (cb.settings.ffJoinMode == 'Anyone can join') { ffJoinMode = 'command'; } else if (cb.settings.ffJoinMode == 'Any non-gray user can join') { ffJoinMode = 'commandng'; } else if (cb.settings.ffJoinMode == 'Anyone can join - require approval') { ffJoinMode = 'commandv'; } else if (cb.settings.ffJoinMode == 'Tip to Join') { ffJoinMode = 'tip'; } if (ffWinMode == 'Best out of X rounds') { if (checkeven(ffNumRounds)) { ffNumRounds++; cb.sendNotice(botName + 'The value entered for the number of rounds must be an odd number when configured for "Best of X rounds".\nThe configured number of rounds has been increased by 1 to ' + ffNumRounds + ' rounds.\nYou can continue with this number or restart the bot and change the setting.',BC,appNoticeColor); } ffWinRounds = Math.floor(ffNumRounds/2) + 1; } if (cb.settings.ffTeam1Captain) { ffAddToTeam1(cb.settings.ffTeam1Captain); } if (cb.settings.ffTeam2Captain) { ffAddToTeam2(cb.settings.ffTeam2Captain); } ffSetToggle('on',BC); initialize = 1; } // *********************************** Functions ************************************** function setTextColor(inputtextcolor,inputtextcolortype,inputtextcolorsendto) { let selectedtextcolor = '#FFFFFF'; if (cbjs.arrayContains(textColorArray.dispname,inputtextcolor)) { let txtclridx = textColorArray.dispname.indexOf(inputtextcolor); selectedtextcolor = textColorArray.colorID[txtclridx]; } else { cb.sendNotice(botName + ' ' + inputtextcolortype + ' - Error while setting the text color. It must be in a HEX code format. Using default value of black text.', inputtextcolorsendto, appWarningColor); } return selectedtextcolor; } function setBgColor(inputbgcolor,inputbgcolortype,inputbgcolorsendto) { let selectedbgcolor = '#FFFFFF'; if (cbjs.arrayContains(bgColorArray.dispname,inputbgcolor)) { let clridx = bgColorArray.dispname.indexOf(inputbgcolor); selectedbgcolor = bgColorArray.colorID[clridx]; } else { cb.sendNotice(botName + ' ' + inputbgcolortype + ' - Error while setting the background color. It must be in a HEX code format. Using default value of white/no background.', inputbgcolorsendto, appWarningColor); } if (selectedbgcolor != '#FFFFFF') { selectedbgcolor = 'linear-gradient(to right, ' + selectedbgcolor + ', #FFFFFF)'; } return selectedbgcolor; } // *********************************** Functions ************************************** function ffSetToggle(settogoption, settogmod) { if (settogoption == 'on') { if (ffToggle == true) { cb.sendNotice('The Family Feud Game is already enabled.', settogmod, appNoticeColor); } else { ffInit(); if (validFF == true) { ffToggle = true; ffInitNoticeTimer(); cb.sendNotice('You have enabled the Family Feud Game.', settogmod, appNoticeColor); } else { cb.sendNotice('Invalid setting, the Family Feud Game could not be started.', settogmod, appWarningColor, appWarningTextColor, 'bold'); } } } else if (settogoption == 'off') { if (ffToggle == false) { cb.sendNotice('The Family Feud Game is already disabled.', settogmod, appNoticeColor); } else { ffToggle = false; cb.sendNotice('You have disabled the Family Feud Game.', settogmod, appNoticeColor); cb.sendNotice('The Family Feud game has been disabled, tips will no longer start a Family Feud game.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } } function ffInit() { ffActive = false; ffCurrentRound = 1; ffTeam1PlayerIdx = 0; ffTeam2PlayerIdx = 0; } function ffAssignHost(usertoassignfunc) { ffHostName = usertoassignfunc; if (ffHostName == BC) { cb.sendNotice(botName + 'The broadcaster will be the Game Host.', '', appNoticeColor); ffValidHost = true; } else if (cbjs.arrayContains(modList,ffHostName)) { cb.sendNotice(botName + 'Moderator ' + ffHostName + ' has been assigned as the Game Host.', '', appNoticeColor); ffValidHost = true; } else { cb.sendNotice(botName + 'The broadcaster has requested that you host the game of Family Feud.\nTo indicate you accept being the host, please type: /ffaccept',ffHostName,appNoticeColor); cb.sendNotice(botName + 'A message was sent to ' + ffHostName + ' to confirm they agree to host the game.\nIf they do not agree, or their name was entered incorrectly, you (or a moderator)can use the /ffhost command to assign someone else or correct their name.',BC,appNoticeColor); cb.sendNotice(botName + 'A message was sent to ' + ffHostName + ' to confirm they agree to host the game.\nIf they do not agree, or their name was entered incorrectly, moderators can use the /ffhost command to assign someone else or correct their name.',BC,appNoticeColor,'','','red'); } } function ffInitNoticeTimer() { if (!cb.settings.ffNoticeInterval) { cb.sendNotice(botName + 'Warning - Chat Notice Interval was not set. Using default value of 3.6 minutes.', BC, appWarningColor, '', 'bold'); } else { ffInt = parseFloat(cb.settings.ffNoticeInterval); } if (ffInt < 1) { cb.sendNotice(botName + 'Warning - Chat Notice Interval setting is too short, must be at least 1 minute. Using default value of 3.6 minutes.', BC, appWarningColor, '', 'bold'); ffInt = 3.6; } ffInt *= 60000; ffInt = parseInt(ffInt); ffNoticeTimer(); } function ffNoticeTimer() { if (ffToggle) { ffShowNotice(''); cb.setTimeout(ffNoticeTimer,ffInt); } } function ffShowNotice(sendto) { var msg = 'The Family Feud Game is active.'; if (ffTeam1Players.length >= ffMaxTeamSize && ffTeam2Players.length >= ffMaxTeamSize) { msg += 'Both teams are full, please wait until the next game to join.'; if (ffJoinMode == 'tip') { msg += '\nDo not tip to join the game as you will not be added!'; } } else { team1cap = ''; team2cap = ''; if (cb.settings.ffTeam1Captain) { team1cap = '- ' + cb.settings.ffTeam1Captain + '\'s Team'; } if (cb.settings.ffTeam2Captain) { team2cap = '- ' + cb.settings.ffTeam2Captain + '\'s Team'; } if (ffTeam1Players.length >= ffMaxTeamSize) { msg += '\nTeam 1 ' + team1cap + ' (' + ffTeam1Name + ') is full'; } else { msg += '\nTeam 1 ' + team1cap + ' (' + ffTeam1Name + ') : ' + ffTeam1Players.length + ' out of ' + ffMaxTeamSize + ' spots taken.'; } if (ffTeam2Players.length >= ffMaxTeamSize) { msg += '\nTeam 2 ' + team2cap + ' (' + ffTeam2Name + ') is full'; } else { msg += '\nTeam 2 ' + team2cap + ' (' + ffTeam2Name + ') : ' + ffTeam2Players.length + ' out of ' + ffMaxTeamSize + ' spots taken.'; } msg += '\nJoin mode: ' + cb.settings.ffJoinMode; if (ffJoinMode == 'tip') { msg += '\nTip ' + ffJoinPrice + ' tokens to join a team (enter the team number in your tip note).'; } else if (ffJoinMode == 'commandv') { msg += '\nTo request to join team 1 or 2 (requires approval), type: /ffj1 or /ffj2'; } else { msg += '\nTo join team 1 or 2, type: /ffj1 or /ffj2'; } } if (ffWinMode == 'Best out of X rounds') { msg += '\nFirst team to win ' + ffWinRounds + ' rounds wins the prize.'; } else { msg += '\nTeam with the highest score after ' + ffNumRounds + ' rounds wins the prize.'; } msg += '\nPrize for the winning team: ' + ffPrize; msg += '\nUse the command "/ffi" to see more info on game play and commands.'; cb.sendNotice(msg, sendto, ffNoticeBgColor, ffNoticeTextColor, 'bold'); } function ffInfo(sendto,usertype) { var msg = 'Family Feud Game Instructions and Commands'; if (ffTeam1Players.length >= ffMaxTeamSize && ffTeam2Players.length >= ffMaxTeamSize) { msg += 'Both teams are full, please wait until the next game to join.'; } else { team1cap = ''; team2cap = ''; if (cb.settings.ffTeam1Captain) { team1cap = '- ' + cb.settings.ffTeam1Captain + '\'s Team'; } if (cb.settings.ffTeam2Captain) { team2cap = '- ' + cb.settings.ffTeam2Captain + '\'s Team'; } if (ffTeam1Players.length >= ffMaxTeamSize) { msg += '\nTeam 1 ' + team1cap + ' (' + ffTeam1Name + ') is full'; } else { msg += '\nTeam 1 ' + team1cap + ' (' + ffTeam1Name + ') : ' + ffTeam1Players.length + ' out of ' + ffMaxTeamSize + ' spots taken.'; } if (ffTeam2Players.length >= ffMaxTeamSize) { msg += '\nTeam 2 ' + team2cap + ' (' + ffTeam2Name + ') is full'; } else { msg += '\nTeam 2 ' + team2cap + ' (' + ffTeam2Name + ') : ' + ffTeam2Players.length + ' out of ' + ffMaxTeamSize + ' spots taken.'; } msg += '\nJoin mode: ' + cb.settings.ffJoinMode; if (ffJoinMode == 'tip') { msg += '\nTip ' + ffJoinPrice + ' tokens to join a team (enter the team number in your tip note).'; } else if (ffJoinMode == 'commandv') { msg += '\nTo request to join team 1 or 2 (requires approval), type: /ffj1 or /ffj2'; } else { msg += '\nTo join team 1 or 2, type: /ffj1 or /ffj2'; } } if (ffWinMode == 'Best out of X rounds') { msg += '\nFirst team to win ' + ffWinRounds + ' rounds wins the prize.'; } else { msg += '\nTeam with the highest score after ' + ffNumRounds + ' rounds wins the prize.'; } msg += '\nPrize for the winning team: ' + ffPrize + '.'; msg += '\n*** Game Play ***'; msg += '\nOnce the bot is started and a Game Host is assigned, the host will input the Question and Answers for the first round.'; msg += '\nAlternatively, the broadcaster can be the Game Host and input them on the launch page and restart the bot each round.'; msg += '\nHowever, in that format, you can only play one game at a time, and can\'t keep a cumualtive score.'; msg += '\nUsers from the room can join a team by tipping or through commands if configured for free play (see below).'; msg += '\nUsers can join anytime, either before or after the Game Board for the current round is created and guessing starts.'; msg += '\nWhen the board is ready, the Game Host will start the game and perform a "coin toss" to determine which team goes first.'; msg += '\nThe bot will then show the question and prompt the members of that team for answers in the order they joined.'; msg += '\nThe bot will monitor for the correct answer, checking with the Game Host if there is not an exact match.'; msg += '\nThe Game Host will enter a command to indicate if the answer was on the board or not (see below).'; msg += '\nThe team in control continues guessing until they get all of the answers on the board, or until they get three incorrect answers.'; msg += '\nIf they get all of the answers, they win that round.'; msg += '\nIf they get three wrong answers, the other team gets one chance to get one of the remaining answers to "steal" the round.'; msg += '\n*** Commands ***'; msg += '\nUse the command "/ffteams" to see the current teams and who has the next turn on each team.'; msg += '\nUse the command "/ffj1" or "/ffj2" to join a team (must tip first if tipping required to join).'; msg += '\nUse the command "/ffsb" to display the Family Feud scoreboard.'; if (usertype == 'BC') { msg += '\nFor Broadcasters and Moderators:'; msg += '\nThe Family Feud game can be turned on or off with the command "/ff on" or "/ff off". '; msg += '\nUse the command "/ffprice xx" to update the price for playing Family Feud to the new value of xx.'; msg += '\nUse the command "/ffend" to end the current game if you decide not to finish it. Does not end the Family Feud feature, just the current question and answer and resets the game to wait for a new round.'; msg += '\nUse the command "/ffboard" to display the board to everyone - answers not guessed yet will stay hidden.'; msg += '\nUse the command "/ffapprove" to approve a user joining a team when the Join mode requires approval. Can also be done by Game Host.'; msg += '\nFor Game Host:'; msg += '\nUse the command "/ffaccept" to accept the assignment of Game Host when prompted.'; msg += '\nUse the command "/ffplay" once the question and answers are all configured to start the game (requires at least 3 answers). This will trigger the coin toss and then the winning team can start guessing.'; msg += '\nUse the command "/ffq" to set or update the question for the current round.'; msg += '\nUse the command "/ffa1" through "/ffa8" to set or update up to 8 answers to the question for the current round.'; msg += '\nUse the command "/ffyes X" or "/ffno" to manually confirm if the Guesser correctly guessed an answer, including the answer ID (position on the board) of the one they guessed correctly for /ffyes'; msg += '\nUse the command "/ffskip" to skip a Guesser who is not answering or has left the room.'; } cb.sendNotice(msg, sendto, ffNoticeBgColor, ffNoticeTextColor); } function ffPlay() { ffActive = true; cb.sendNotice('The next round of Family Feud is starting NOW!\nCoin toss to determine first team to play...', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); cb.setTimeout(ffCoinToss,2000); } function ffCoinToss() { if (cb.settings.ffCoinTossAlt == 'Coin Toss') { ffCurrentTeam = Math.floor(Math.random() * 2) + 1; } else { if (ffCurrentTeam == 1) { ffCurrentTeam = 2; } else { ffCurrentTeam = 1; } } if (ffCurrentTeam == 1) { cb.sendNotice('>> ' + ffTeam1Name + ' << have won the coin toss!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffCurrentCaptain = cb.settings.ffTeam1Captain; } else { cb.sendNotice('>> ' + ffTeam2Name + ' << have won the coin toss!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffCurrentCaptain = cb.settings.ffTeam2Captain; } cb.sendNotice('Starting this round...', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffDisplayQuestion(''); ffShowBoard('current',''); ffNextGuesser(); } function ffDisplayQuestion(questionsendto) { cb.sendNotice('*** Round #' + ffCurrentRound + ' Question:\n ' + ffQuestion, questionsendto, ffNoticeBgColor, ffNoticeTextColor, 'bold'); } function ffNextGuesser() { if (ffCurrentTeam == 1) { ffTeam1PlayerIdx++; if (ffTeam1PlayerIdx > ffTeam1Players.length) { ffTeam1PlayerIdx = 1; } ffCurrentGuesser = ffTeam1Players[ffTeam1PlayerIdx-1]; cb.sendNotice(ffCurrentGuesser + ' from team ' + ffTeam1Name + ' is the current guesser.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { ffTeam2PlayerIdx++; if (ffTeam2PlayerIdx > ffTeam2Players.length) { ffTeam2PlayerIdx = 1; } ffCurrentGuesser = ffTeam2Players[ffTeam2PlayerIdx-1]; cb.sendNotice(ffCurrentGuesser + ' from team ' + ffTeam2Name + ' is the current guesser.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } function ffCorrectAnswer(guessedby,answernumber) { cb.sendNotice(guessedby + ' correctly guessed Answer #' + answernumber + ' (' + ffAnswers.answertext[answernumber-1] + ').', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffCurrentCorrectAnswers++; ffAnswers.guessed[answernumber-1] = true; if (ffUsingPoints) { let currentpoints = ffAnswers.pointvalue[answernumber-1]; if (ffCurrentTeam == 1) { ffTeam1Score += currentpoints; } else { ffTeam2Score += currentpoints; } } if (ffCurrentCorrectAnswers >= ffAnswers.answertext.length || ffForTheWinFlag == true) { ffBoardCompleted(); } else { ffShowBoard('current',''); ffNextGuesser(); } } function ffIncorrectAnswer(guessedby) { ffNumIncorrect++; cb.sendNotice(':famfeudX' + ffNumIncorrect, '', ffNoticeBgColor, ffNoticeTextColor); cb.sendNotice(guessedby + '\'s guess is incorrect!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); if (ffNumIncorrect >= 3) { ffStealTheBoard(); } else { ffNextGuesser(); } } function ffBoardCompleted() { if (ffCurrentTeam == 1) { cb.sendNotice(ffTeam1Name + ' has won this Round!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffTeam1Wins++; } else { cb.sendNotice(ffTeam2Name + ' has won this Round!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffTeam2Wins++; } ffShowBoard('all',''); if (ffWinMode != 'Best out of X rounds' && ffCurrentRound >= ffNumRounds || ffWinMode == 'Best out of X rounds' && (ffTeam1Score >= ffWinRounds || ffTeam2Score >= ffWinRounds)) { if (ffWinMode == 'Best out of X rounds') { if (ffTeam1Wins > ffTeam2Wins) { cb.sendNotice('We\'ve played the configured number of rounds, and ' + ffTeam1Name + ' has won the Game (' + ffTeam1Wins + '-' + ffTeam2Wins + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { cb.sendNotice('We\'ve played the configured number of rounds, and ' + ffTeam2Name + ' has won the Game (' + ffTeam2Wins + '-' + ffTeam1Wins + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } else { if (ffTeam1Score > ffTeam2Score) { cb.sendNotice('We\'ve played the configured number of rounds, and ' + ffTeam1Name + ' has won the Game (' + ffTeam1Score + '-' + ffTeam2Score + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { cb.sendNotice('We\'ve played the configured number of rounds, and ' + ffTeam2Name + ' has won the Game (' + ffTeam2Score + '-' + ffTeam1Score + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } cb.sendNotice('The prize for the winning team is:\n' + ffPrize, '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); cb.sendNotice(botName + 'The game is completed. The Broadcaster or a Moderator can start a brand new game with the command /ffreset', ffHostName, appWarningColor); cb.sendNotice(botName + 'The game is completed. You can start a brand new game with the command /ffreset or turn off the game by typing: /ff off', BC, appWarningColor); cb.sendNotice(botName + 'The game is completed. You can start a brand new game with the command /ffreset or turn off the game by typing: /ff off', BC, appWarningColor, '', '', 'red'); } else { if (ffWinMode == 'Best out of X rounds') { if (ffTeam1Wins > ffTeam2Wins) { cb.sendNotice(ffTeam1Name + ' is currently in the lead (' + ffTeam1Wins + '-' + ffTeam2Wins + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else if (ffTeam2Wins > ffTeam1Wins) { cb.sendNotice(ffTeam2Name + ' is currently in the lead (' + ffTeam2Wins + '-' + ffTeam1Wins + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { cb.sendNotice('The Game is currently tied (' + ffTeam1Wins + '-' + ffTeam2Wins + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } else { if (ffTeam1Score > ffTeam2Score) { cb.sendNotice(ffTeam1Name + ' is currently in the lead (' + ffTeam1Score + '-' + ffTeam2Score + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else if (ffTeam2Score > ffTeam1Score) { cb.sendNotice(ffTeam2Name + ' is currently in the lead (' + ffTeam2Score + '-' + ffTeam1Score + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { cb.sendNotice('The score is currently tied (' + ffTeam2Score + '-' + ffTeam1Score + ')!', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); } } } cb.setTimeout(ffNewBoard,2000); } function ffNewBoard() { ffActive = false; ffForTheWinFlag = false; ffGuessed = false; ffQuestion = ''; ffAnswers.answertext.length = 0; ffAnswers.pointvalue.length = 0; ffAnswers.guessed.length = 0; ffNumIncorrect = 0; ffCurrentCorrectAnswers = 0; ffCurrentGuesser = ''; cb.sendNotice('The board will now be cleared and you can input the next round Question and Answers', ffHostName, appWarningColor); cb.sendNotice('The board will now be cleared and you can either restart the bot (if you are the Game Host) or ask the Game Host to input the next round Question and Answers', BC, appWarningColor); cb.sendNotice('The board will now be cleared and the broadcaster can restart the bot (if they are the Game Host) or you can ask the Game Host to input the next round Question and Answers', BC, appWarningColor, '', '', 'red'); } function ffStealTheBoard() { ffForTheWinFlag = true; if (ffCurrentTeam == 1) { cb.sendNotice(ffTeam1Name + ' has guessed 3 incorrect answers, ' + ffTeam2Name + ' will now have a chance to steal the board.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffCurrentTeam = 2; ffCurrentCaptain = cb.settings.ffTeam2Captain; } else { cb.sendNotice(ffTeam2Name + ' has guessed 3 incorrect answers, ' + ffTeam1Name + ' will now have a chance to steal the board.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); ffCurrentTeam = 1; ffCurrentCaptain = cb.settings.ffTeam1Captain; } ffShowBoard('current',''); ffNextGuesser(); } function ffShowBoard(showall,boardsendto) { let boardmsg = ''; if (showall == 'all') { boardmsg += '\u22A1 \u22A1 \u22A1 \u22A1 Completed Board \u22A1 \u22A1 \u22A1 \u22A1'; } else { boardmsg += '\u22A1 \u22A1 \u22A1 \u22A1 Current Board \u22A1 \u22A1 \u22A1 \u22A1'; } for (let i = 0; i < ffAnswers.guessed.length; i++) { if (showall == 'all') { boardmsg += '\n' + (i+1) + '. ' + ffAnswers.answertext[i]; } else { if (ffAnswers.guessed[i] == true) { boardmsg += '\n' + (i+1) + '. ' + ffAnswers.answertext[i]; } else { boardmsg += '\n' + (i+1) + '. HIDDEN'; } } } cb.sendNotice(boardmsg,boardsendto,ffNoticeBgColor,ffNoticeTextColor,'bold'); } function ffAddToTeam1(addteam1user) { ffTeam1Players.push(addteam1user); let addteam1msg = addteam1user + ' has joined team 1 (' + ffTeam1Name + ') - '; if (ffTeam1Players.length >= ffMaxTeamSize) { addteam1msg += 'Team 1 is now full!'; } else { addteam1msg += (ffMaxTeamSize - ffTeam1Players.length) + ' spot' + ((ffMaxTeamSize - ffTeam1Players.length) == 1 ? '' : 's') + ' remaining on this team.' } cb.sendNotice(addteam1msg,'',ffNoticeBgColor,ffNoticeTextColor,'bold'); } function ffAddToTeam2(addteam2user) { ffTeam2Players.push(addteam2user); let addteam2msg = addteam2user + ' has joined team 2 (' + ffTeam2Name + ') - '; if (ffTeam2Players.length >= ffMaxTeamSize) { addteam2msg += 'Team 2 is now full!'; } else { addteam2msg += (ffMaxTeamSize - ffTeam2Players.length) + ' spot' + ((ffMaxTeamSize - ffTeam2Players.length) == 1 ? '' : 's') + ' remaining on this team.' } cb.sendNotice(addteam2msg,'',ffNoticeBgColor,ffNoticeTextColor,'bold'); } function checkeven(inputcheck) { if (inputcheck % 2 == 0) { return true; } else { return false; } } // ******************************* Upon user entry of a Message ************************************** cb.onMessage(function (msg) { let msgarray = msg.m.split(' '); let recognizedcmd = false; let listRegExp = /[,\s]+/; let msgentered = msg.m; let msguser = msg.user; let msgismod = msg.is_mod; let msgisbc = (msguser == cb.room_slug); let msgishost = (msguser == ffHostName); let msgisgray = false; let command = msgarray[0] let commandVar1 = parseInt(msgarray[1]); let commandVar2 = parseInt(msgarray[2]); if (msgismod) { if (!cbjs.arrayContains(modList,msguser)) { modList.push(msguser); } } if (!msg.has_tokens) { msgisgray = true; } if (msguser == ffCurrentGuesser) { ffGuessed = true; if (msgarray[0].charAt(0) != '/') { let ffguess = msgentered; if (msgarray[0].charAt(0) == '[' || msgarray[0].charAt(0) == '|' || msgarray[0].charAt(0) == ':') { for (let msgindex = 0; msgindex < 4; msgindex++) { if (msgarray[0]) { if (msgarray[0].charAt(0) == ':') { msgarray.splice(0,1); } } if (msgarray[0]) { if (msgarray[0].charAt(0) == '|') { msgarray.splice(0,1); } } if (msgarray[0]) { if (msgarray[0].charAt(0) == '[') { msgarray.splice(0,1); } } } ffguess = cbjs.arrayJoin(msgarray, ' '); } ffguess = ffguess.toLowerCase().trim(); ffguess = ffguess.replace(/[^a-z0-9]/g, ''); let correctanswer = 0; for (let ansidx = 0; ansidx < ffAnswers.answertext.length; ansidx++) { let ffcompareanswer = ffAnswers.answertext[ansidx]; ffcompareanswer = ffcompareanswer.toLowerCase().trim(); ffcompareanswer = ffcompareanswer.replace(/[^a-z0-9]/g, ''); if (ffguess == ffcompareanswer) { correctanswer = ansidx + 1; } } if (correctanswer > 0) { ffCorrectAnswer(msguser,correctanswer); } else { cb.sendNotice(botName + ffCurrentGuesser + ' has guessed the following, which was not an exact match to any answer:\n "' + msg.m + '"\nPlease type either /ffyes or /ffno to indicate if their answer is correct.\nIf this was not their final answer, wait for them to answer again and you will get this prompt again.', ffHostName, appWarningColor); } } } if (msgarray[0]) { if (msgarray[0].charAt(0) == '/') { msg['X-Spam'] = true; var ntc = null; for (let i = 1; i < msgarray.length; i++) { if (i == 1) { ntc = msgarray[i]; } else { ntc += " " + msgarray[i]; } } var cmdval = null; for (let j = 1; j < msgarray.length; j++) { if (j == 1) { cmdval = msgarray[j]; } else { cmdval += " " + msgarray[j]; } } switch(command) { case '/ffi': { recognizedcmd = true; if (ffToggle) { if (msgisbc || msgismod || msgishost) { ffInfo(msguser,'BC'); } else { ffInfo(msguser,'common'); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffhost': { recognizedcmd = true; if (ffToggle) { if (msgisbc || msgismod) { if (msgarray[1]) { let usertoassign = msgarray[1].toLowerCase(); if (usertoassign.charAt(0) == '@') { usertoassign = usertoassign.substring(1); } if (cbjs.arrayContains(ffTeam1WaitList,usertoassign)) { cb.sendNotice(botName + usertoassign + ' has already requested to join team 1. \nYou can use /ffrmv to remove them from the waiting list so they can be the host.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam2WaitList,usertoassign)) { cb.sendNotice(botName + usertoassign + ' has already requested to join team 2. \nYou can use /ffrmv to remove them from the waiting list so they can be the host.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam1Players,usertoassign) || cbjs.arrayContains(ffTeam2Players,usertoassign)) { cb.sendNotice(botName + usertoassign + ' has already joined a team. \nYou can use /ffrmv to remove them from their team so they can be the host.',msguser,appNoticeColor); } else { ffAssignHost(usertoassign); } } else { cb.sendNotice(botName + 'A parameter is required for the /ffhost command and should be an exact match for the username to assign as host. \nYou can use the "@" tag to ensure you enter the name correctly.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the broadcaster or a moderator can assign the host.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffaccept': { recognizedcmd = true; if (ffToggle) { if (ffHostName) { if (msgishost) { ffValidHost = true; cb.sendNotice(botName + ffHostName + ' has agreed to be the host.','',ffNoticeBgColor,ffNoticeTextColor,'bold'); cb.sendNotice(botName + 'Thank you for accepting your responsibilities to be the Game Gost.\nTo see more information on the game and commands, you can type: /ffi',msguser,appNoticeColor); } else { cb.sendNotice(botName + 'Only the user requested to be the host (' + ffHostName + ') can use this command.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'A user ID has not been requested/assigned to be the host.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffapprove': { recognizedcmd = true; if (ffToggle) { if (msgisbc || msgismod || msgishost) { if (msgarray[1]) { let usertoapprove = msgarray[1].toLowerCase(); if (usertoapprove.charAt(0) == '@') { usertoapprove = usertoapprove.substring(1); } if (cbjs.arrayContains(ffTeam1WaitList,usertoapprove)) { let ffj1index = ffTeam1WaitList.indexOf(usertoapprove); ffTeam1WaitList.splice(ffj1index,1); ffAddToTeam1(usertoapprove); } else if (cbjs.arrayContains(ffTeam2WaitList,usertoapprove)) { let ffj2index = ffTeam2WaitList.indexOf(msguser); ffTeam2WaitList.splice(ffj2index,1); ffAddToTeam2(usertoapprove); } else if (cbjs.arrayContains(ffTeam1Players,usertoapprove)) { cb.sendNotice(botName + usertoapprove + ' has already been approved and added to Team 1.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam2Players,usertoapprove)) { cb.sendNotice(botName + usertoapprove + ' has already been approved and added to Team 2.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'A parameter is required for the /ffapprove command and should be an exact match for the username to approve. \nYou can use the "@" tag to ensure you enter the name correctly.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the broadcaster, moderators, or the Game Host can use this command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffanswerlist': { recognizedcmd = true; if (msgishost) { cb.sendNotice(botName + 'Current Game Question:\n' + ffQuestion + '\nAnswer List:\n' + cbjs.arrayJoin(ffAnswers.answertext, ', '),msguser,appNoticeColor); } else { cb.sendNotice(botName + 'Only the game host is able to view the answer list.',msguser,appNoticeColor); } break; } case '/ffwl': { recognizedcmd = true; if (ffToggle) { if (ffTeam1WaitList.length > 0) { cb.sendNotice(botName + 'Team 1 Wait / Approval List: \n' + cbjs.arrayJoin(ffTeam1WaitList, ', '),msguser,appNoticeColor); } else { cb.sendNotice(botName + 'There are no Team 1 Wait List entries',msguser,appNoticeColor); } if (ffTeam2WaitList.length > 0) { cb.sendNotice(botName + 'Team 2 Wait / Approval List: \n' + cbjs.arrayJoin(ffTeam2WaitList, ', '),msguser,appNoticeColor); } else { cb.sendNotice(botName + 'There are no Team 2 Wait List entries',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/fftl': { recognizedcmd = true; if (ffToggle) { if (ffTippedList.length > 0) { cb.sendNotice(botName + 'Tipped List (still need to join a team): \n' + cbjs.arrayJoin(ffTippedList, ', '),msguser,appNoticeColor); } else { cb.sendNotice(botName + 'There are no "Tipped List" users who have tipped and not joined a team.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffplay': { recognizedcmd = true; if (msgisbc || msgismod || msgishost) { if (ffToggle) { if (!ffQuestion) { cb.sendNotice(botName + 'The Game Board is not yet ready to start, question not defined for this round.\n To add a question, use the command: /ffq',msguser,appNoticeColor); } else if (ffAnswers.answertext.length < 3) { cb.sendNotice(botName + 'The Game Board is not yet ready to start, at least three answers must be added.\n To add an answer, use the commands: /ffa1-/ffa8',msguser,appNoticeColor); // } else if (ffTeam1Players.length < 2 || ffTeam2Players.length < 2) { // cb.sendNotice(botName + 'At least 2 players are required on both teams.',msguser,appNoticeColor); } else { ffPlay(); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } } else { cb.sendNotice('Only broadcasters, moderators, or the game host are able to use that command.',msguser,appNoticeColor); } break; } case '/ffa1': case '/ffa2': case '/ffa3': case '/ffa4': case '/ffa5': case '/ffa6': case '/ffa7': case '/ffa8': { recognizedcmd = true; if (msgishost) { if (cmdval) { let newffanswer = msg.m.substring(6).trim(); let newffansweridx = (parseInt(msgarray[0].substring(4))) - 1; if (cbjs.arrayContains(ffAnswers.answertext,newffanswer)) { cb.sendNotice(newffanswer + ' is already in the Answer list.',msguser,appNoticeColor); } else { if (ffAnswers.answertext[newffansweridx]) { cb.sendNotice(botName + 'You have updated answer ' + (newffansweridx+1) + ' to "' + newffanswer + '" in the Answer List.',msguser,appNoticeColor); } else { cb.sendNotice(botName + 'You have added "' + newffanswer + '" to the Answer List.',msguser,appNoticeColor); } ffAnswers.answertext[newffansweridx] = newffanswer; ffAnswers.pointvalue[newffansweridx] = 0; ffAnswers.guessed[newffansweridx] = false; } } else { cb.sendNotice(botName + 'A parameter is required for this command and should be the word or phrase you would like to add as an answer.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the Game Host is able to add answers for the current game.',msguser,appNoticeColor); } break; } case '/ffdq': { recognizedcmd = true; let ffqsendto = msguser; if (msgisbc || msgismod || msgishost) { ffqsendto = ''; } if (ffQuestion) { cb.sendNotice(botName + 'The current Question is:\n' + ffQuestion,ffqsendto,appNoticeColor); } else if (msgisbc || msgismod || msgishost) { cb.sendNotice(botName + 'A question has not yet been set for the current round.\nTo set the question, type: /ffq',msguser,appNoticeColor); } break; } case '/ffquestion': case '/ffq': { recognizedcmd = true; if (msgishost) { if (cmdval) { ffQuestion = msg.m.substring(5).trim(); cb.sendNotice(botName + 'You have updated the Question for the current game to "' + ffQuestion + '".',msguser,appNoticeColor); } else { cb.sendNotice(botName + 'A parameter is required for the /ffq command and should be the word or phrase you would like to update as the Question for this round.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the Game Host is able to update the Question for the current game.',msguser,appNoticeColor); } break; } case '/ffrmvuser': { recognizedcmd = true; if (msgisbc || msgismod || msgishost) { if (msgarray[1]) { let usertormv = msgarray[1].toLowerCase(); if (usertormv.charAt(0) == '@') { usertormv = usertormv.substring(1); } if (cbjs.arrayContains(ffTeam1WaitList,usertormv)) { cb.sendNotice(botName + usertormv + ' has been removed from the waiting list.',msguser,appNoticeColor); let ffj1index = ffTeam1WaitList.indexOf(msguser); ffTeam1WaitList.splice(ffj1index,1); } else if (cbjs.arrayContains(ffTeam2WaitList,usertormv)) { cb.sendNotice(botName + usertormv + ' has been removed from the waiting list.',msguser,appNoticeColor); let ffj2index = ffTeam2WaitList.indexOf(msguser); ffTeam2WaitList.splice(ffj2index,1); } else if (cbjs.arrayContains(ffTeam1Players,usertormv)) { cb.sendNotice(botName + usertormv + ' has been removed from Team 1.',msguser,appNoticeColor); let ffj1index = ffTeam1Players.indexOf(msguser); ffTeam1Players.splice(ffj1index,1); } else if (cbjs.arrayContains(ffTeam2Players,usertormv)) { cb.sendNotice(botName + usertormv + ' has been removed from Team 2.',msguser,appNoticeColor); let ffj2index = ffTeam2Players.indexOf(msguser); ffTeam2Players.splice(ffj2index,1); } } else { cb.sendNotice(botName + 'A parameter is required for the /ffrmvuser command and should be an exact match for the username to remove from the game. \nYou can use the "@" tag to ensure you enter the name correctly.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only broadcasters, moderators, and the Game Host are able to remove users from the show.',msguser,appNoticeColor); } break; } case '/ffprice': { recognizedcmd = true; if (msgisbc || msgismod) { if (msgarray[1]) { let numprice = parseInt(msgarray[1]); if (isNaN(numprice)) { cb.sendNotice(botName + 'The value entered for the new price is not numeric, please try again.',msguser,appNoticeColor); } else if (numprice < 1 || numprice > 9999) { cb.sendNotice(botName + 'The value entered for the new price is outside allowable values from 1 to 9999, please try again.',msguser,appNoticeColor); } else { ffJoinPrice = numprice; cb.sendNotice(botName + msguser + ' has updated the price to join to ' + ffJoinPrice + ' tokens.', '', ffNoticeBgColor, ffNoticeTextColor,'bold'); } } else { cb.sendNotice(botName + 'A parameter is required for the tip to play price, and it must be a number from 1 to 9999.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only broadcasters and moderators are able to set the price to join.',msguser,appNoticeColor); } break; } case '/ffteamsize': { recognizedcmd = true; if (msgisbc || msgismod) { if (msgarray[1]) { let numsize = parseInt(msgarray[1]); if (isNaN(numsize)) { cb.sendNotice(botName + 'The value entered for the new max team size is not numeric, please try again.',msguser,appNoticeColor); } else if (numsize < 2 || numsize > 99) { cb.sendNotice(botName + 'The value entered for the new max team size is outside allowable values from 2 to 99, please try again.',msguser,appNoticeColor); } else { ffMaxTeamSize = numsize; cb.sendNotice(botName + msguser + ' has updated the max team size to ' + ffMaxTeamSize + ' people.', '', ffNoticeBgColor, ffNoticeTextColor,'bold'); } } else { cb.sendNotice(botName + 'A parameter is required for the new maximum team size, and it must be a number from 2 to 99.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only broadcasters and moderators are able to set the max team size.',msguser,appNoticeColor); } break; } case '/ffnumrounds': { recognizedcmd = true; if (msgisbc || msgismod) { if (msgarray[1]) { let numrounds = parseInt(msgarray[1]); if (isNaN(numrounds)) { cb.sendNotice(botName + 'The value entered for the new number of rounds is not numeric, please try again.',msguser,appNoticeColor); } else if (numrounds < 1 || numrounds > 99) { cb.sendNotice(botName + 'The value entered for the new number of rounds is outside allowable values from 1 to 99, please try again.',msguser,appNoticeColor); } else if (numrounds < ffCurrentRound) { cb.sendNotice(botName + 'The value entered for the new number of rounds is less than the current round (' + ffCurrentRound + '), please try again.',msguser,appNoticeColor); } else if (checkeven(numrounds)) { cb.sendNotice(botName + 'The value entered for the new number of rounds must be an odd number, please try again.',msguser,appNoticeColor); } else { ffNumRounds = numrounds; ffWinRounds = Math.floor(ffNumRounds/2) + 1 cb.sendNotice(msguser + ' has updated the total number of rounds to ' + ffNumRounds + ' rounds.', '', ffNoticeBgColor, ffNoticeTextColor,'bold'); if (ffWinMode == 'Best out of X rounds') { cb.sendNotice('\nSince configured for "Best out of ' + ffNumRounds + '" rounds, first team to win ' + ffWinRounds + ' rounds wins the prize.', '', ffNoticeBgColor, ffNoticeTextColor,'bold'); } else { cb.sendNotice('\nTeam with the highest score after ' + ffNumRounds + ' rounds wins the prize.', '', ffNoticeBgColor, ffNoticeTextColor,'bold'); } } } else { cb.sendNotice(botName + 'A parameter is required for the number of rounds you are updating, it must be a number and if playing a "Best of X Rounds" format, it should be an odd number.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only broadcasters and moderators are able to update the number of rounds to play.',msguser,appNoticeColor); } break; } case '/ffjoin1': case '/ffj1': { recognizedcmd = true; if (ffToggle) { if (msgishost) { cb.sendNotice(botName + 'You are currently assigned as the host. The host cannot join a team.',msguser,appNoticeColor); } else if (ffTeam1Players.length >= ffMaxTeamSize) { cb.sendNotice(botName + 'Team 1 has already reached maximum size, you can try to play the next game.',msguser,appNoticeColor); } else if (msguser == ffCurrentGuesser) { cb.sendNotice(botName + 'You cannot join or change teams while it is your turn to guess.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam1Players,msguser)) { cb.sendNotice(botName + 'You have already joined Team 1.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam2Players,msguser)) { cb.sendNotice(botName + 'You have previously joined Team 2, moving you to Team 1.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has moved from team 2 to team 1 (' + ffTeam1Name + ').', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has moved from team 2 to team 1 (' + ffTeam1Name + ').', BC, appWarningColor, '', '', 'red'); let ffj1index = ffTeam2Players.indexOf(msguser); ffTeam2Players.splice(ffj1index,1); ffAddToTeam1(msguser); } else if (cbjs.arrayContains(ffTeam1WaitList,msguser)) { cb.sendNotice(botName + 'You are on the waiting list for Team 1, awaiting approval.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam2WaitList,msguser)) { cb.sendNotice(botName + 'You have previously requested to join Team 2, moving your request to Team 1.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has moved their request to join team 1 (' + ffTeam1Name + ').', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has moved their request to join team 1 (' + ffTeam1Name + ').', BC, appWarningColor, '', '', 'red'); let ffj1index = ffTeam2WaitList.indexOf(msguser); ffTeam2WaitList.splice(ffj1index,1); ffTeam1WaitList.push(msguser); } else if (cbjs.arrayContains(ffTippedList,msguser)) { let ffj1index = ffTippedList.indexOf(msguser); ffTippedList.splice(ffj1index,1); ffAddToTeam1(msguser); } else { if (ffJoinMode == 'command' || (ffJoinMode == 'commandng' && !msgisgray)) { ffAddToTeam1(msguser); } else if (ffJoinMode == 'commandng' && msgisgray) { cb.sendNotice(botName + 'Sorry, gray users are not currently allowed to join the game.',msguser,appNoticeColor); } else if (ffJoinMode == 'commandv') { cb.sendNotice(botName + 'Your request to Team 1 is awaiting approval.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has requested to join team 1 (' + ffTeam1Name + ').\nYou (or a moderator) can approve their request by typing: /ffapprove username \nYou can use the @username tagging to more easily enter the user', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has requested to join team 1 (' + ffTeam1Name + ').\nYou can approve their request by typing: /ffapprove username \nYou can use the @username tagging to more easily enter the user', BC, appWarningColor, '', '', 'red'); ffTeam1WaitList.push(msguser); } else if (ffJoinMode == 'tip') { cb.sendNotice(botName + 'You must first tip to join, then you can use this command to join a team, or include the team ID (1 or 2) in your tip note.', msguser, appWarningColor); } } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffjoin2': case '/ffj2': { recognizedcmd = true; if (ffToggle) { if (msgishost) { cb.sendNotice(botName + 'You are currently assigned as the host. The host cannot join a team.',msguser,appNoticeColor); } else if (ffTeam2Players.length >= ffMaxTeamSize) { cb.sendNotice(botName + 'Team 2 has already reached maximum size, you can try to play the next game.',msguser,appNoticeColor); } else if (msguser == ffCurrentGuesser) { cb.sendNotice(botName + 'You cannot join or change teams while it is your turn to guess.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam2Players,msguser)) { cb.sendNotice(botName + 'You have already joined Team 2.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam1Players,msguser)) { cb.sendNotice(botName + 'You have previously joined Team 1, moving you to Team 2.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has moved from team 1 to team 2 (' + ffTeam2Name + ').', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has moved from team 1 to team 2 (' + ffTeam2Name + ').', BC, appWarningColor, '', '', 'red'); let ffj2index = ffTeam1Players.indexOf(msguser); ffTeam1Players.splice(ffj2index,1); ffAddToTeam2(botName + msguser); } else if (cbjs.arrayContains(ffTeam2WaitList,msguser)) { cb.sendNotice(botName + 'You are on the waiting list for Team 2, awaiting approval.',msguser,appNoticeColor); } else if (cbjs.arrayContains(ffTeam1WaitList,msguser)) { cb.sendNotice(botName + 'You have previously requested to join Team 1, moving your request to Team 2.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has moved their request to join team 2 (' + ffTeam2Name + ').', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has moved their request to join team 2 (' + ffTeam2Name + ').', BC, appWarningColor, '', '', 'red'); let ffj2index = ffTeam1WaitList.indexOf(msguser); ffTeam1WaitList.splice(ffj2index,1); ffTeam2WaitList.push(msguser); } else if (cbjs.arrayContains(ffTippedList,msguser)) { let ffj2index = ffTippedList.indexOf(msguser); ffTippedList.splice(ffj2index,1); ffAddToTeam2(msguser); } else { if (ffJoinMode == 'command' || (ffJoinMode == 'commandng' && !msgisgray)) { ffAddToTeam2(msguser); } else if (ffJoinMode == 'commandng' && msgisgray) { cb.sendNotice(botName + 'Sorry, gray users are not currently allowed to join the game.',msguser,appNoticeColor); } else if (ffJoinMode == 'commandv') { cb.sendNotice(botName + 'Your request to Team 2 is awaiting approval.',msguser,appNoticeColor); cb.sendNotice(botName + msguser + ' has requested to join team 2 (' + ffTeam1Name + ').\nYou (or a moderator) can approve their request by typing: /ffapprove username \nYou can use the @username tagging to more easily enter the user', BC, appWarningColor); cb.sendNotice(botName + msguser + ' has requested to join team 2 (' + ffTeam1Name + ').\nYou can approve their request by typing: /ffapprove username \nYou can use the @username tagging to more easily enter the user', BC, appWarningColor, '', '', 'red'); cb.sendNotice(botName + msguser + ' has requested to join team 2 (' + ffTeam1Name + ').\nYou can approve their request by typing: /ffapprove username \nYou can use the @username tagging to more easily enter the user', ffHostName, appWarningColor, '', '', 'red'); ffTeam2WaitList.push(msguser); } else if (ffJoinMode == 'tip') { cb.sendNotice(botName + 'You must first tip to join, then you can use this command to join a team, or include the team ID (1 or 2) in your tip note.', msguser, appWarningColor); } } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffnewround': case '/ffendround': { recognizedcmd = true; if (ffToggle) { if (msgisbc || msgismod) { if (ffActive) { ffNewBoard(); } else { cb.sendNotice(botName + 'A new round has not yet been started.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only broadcasters and moderators are able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffyes': { recognizedcmd = true; if (ffToggle) { if (msgishost) { if (ffGuessed) { if (msgarray[1]) { let numanswer = parseInt(msgarray[1]); if (isNaN(numanswer)) { cb.sendNotice(botName + 'The value entered for the answer ID is not numeric, please try again.',msguser,appNoticeColor); } else if (numanswer < 1 || numanswer > 8) { cb.sendNotice(botName + 'The value entered for the answer ID is outside allowable values from 1 to 8, please try again.',msguser,appNoticeColor); } else { if (ffAnswers.guessed[numanswer-1]) { cb.sendNotice(botName + 'The answer ID ' + numanswer + ' has already been correctly guessed, please try again.',msguser,appNoticeColor); } else { ffCorrectAnswer(ffCurrentGuesser,numanswer); ffGuessed = false; } } } else { cb.sendNotice(botName + 'A parameter is required for the Answer ID of the Answer you are giving credit for, it must be a number from 1 to 8 to coincide with the position on the board.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'The current player has not yet made a guess.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the Game Host is able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffyescap': { recognizedcmd = true; if (ffToggle) { if (msgishost) { if (msgarray[1]) { let numanswer = parseInt(msgarray[1]); if (isNaN(numanswer)) { cb.sendNotice(botName + 'The value entered for the answer ID is not numeric, please try again.',msguser,appNoticeColor); } else if (numanswer < 1 || numanswer > 8) { cb.sendNotice(botName + 'The value entered for the answer ID is outside allowable values from 1 to 8, please try again.',msguser,appNoticeColor); } else { if (ffAnswers.guessed[numanswer-1]) { cb.sendNotice(botName + 'The answer ID ' + numanswer + ' has already been correctly guessed, please try again.',msguser,appNoticeColor); } else { ffCorrectAnswer(ffCurrentCaptain,numanswer); ffGuessed = false; } } } else { cb.sendNotice(botName + 'A parameter is required for the Answer ID of the Answer you are giving credit for, it must be a number from 1 to 8 to coincide with the position on the board.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the Game Host is able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffno': { recognizedcmd = true; if (ffToggle) { if (msgishost) { if (ffGuessed) { ffIncorrectAnswer(ffCurrentGuesser); ffGuessed = false; } else { cb.sendNotice(botName + 'The current player has not yet made a guess.',msguser,appNoticeColor); } } else { cb.sendNotice(botName + 'Only the Game Host is able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffnocap': { recognizedcmd = true; if (ffToggle) { if (msgishost) { ffIncorrectAnswer(ffCurrentCaptain); ffGuessed = false; } else { cb.sendNotice(botName + 'Only the Game Host is able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffskip': { recognizedcmd = true; if (ffToggle) { if (msgishost || msgisbc || msgismod) { ffNextGuesser(); } else { cb.sendNotice(botName + 'Only broadcasters, moderators, and the Game Host are able to use that command.',msguser,appNoticeColor); } } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffsb': case '/ffscoreboard': { recognizedcmd = true; if (ffToggle) { let sbsendto = msguser; if (msgisbc || msgismod || msgishost) { sbsendto = ''; } cb.sendNotice(botName + (sbsendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\nCurrent Score -\nTeam 1 (' + ffTeam1Name + '): ' + ffTeam1Wins + ' wins' + (ffUsingPoints ? (' : ' + ffTeam1Score + ' points') : '') + '\nTeam 2 (' + ffTeam2Name + '): ' + ffTeam2Wins + ' wins' + (ffUsingPoints ? (' : ' + ffTeam2Score + ' points') : ''), sbsendto, ffNoticeBgColor, ffNoticeTextColor, 'bold'); } else { cb.sendNotice('The Family Feud Game is not enabled.',msguser,appNoticeColor); } break; } case '/ffboard': { recognizedcmd = true; if (ffToggle && ffActive) { let boardsendto = msguser; let boardshow = 'current'; if ((msgisbc || msgismod) && !msgishost) { boardsendto = ''; } if (msgishost) { boardshow = 'all'; } ffShowBoard(boardshow,boardsendto); } else { cb.sendNotice('The Family Feud Game is not enabled, or the board has not yet been created.',msguser,appNoticeColor); } break; } case '/ffteams': { recognizedcmd = true; if (ffToggle) { let teamsmsg = 'Fantasy Feud Teams' teamsmsg += '\n\nTeam 1 (' + ffTeam1Name + '):' if (ffTeam1Players.length > 0) { for (let tm1idx = 0; tm1idx < ffTeam1Players.length; tm1idx++) { teamsmsg += '\n' + (tm1idx+1) + '. ' + ffTeam1Players[tm1idx] + (tm1idx == (ffTeam1PlayerIdx-1) ? ' << Team\'s Current Guesser' : ''); } } else { teamsmsg += '\nNo team members yet'; } teamsmsg += '\n\nTeam 2 (' + ffTeam2Name + '):' if (ffTeam2Players.length > 0) { for (let tm2idx = 0; tm2idx < ffTeam2Players.length; tm2idx++) { teamsmsg += '\n' + (tm2idx+1) + '. ' + ffTeam2Players[tm2idx] + (tm2idx == (ffTeam2PlayerIdx-1) ? ' << Team\'s Current Guesser' : ''); } } else { teamsmsg += '\nNo team members yet'; } cb.sendNotice(teamsmsg,msguser,appNoticeColor); } else { cb.sendNotice('The Family Feud Game is not enabled, or the board has not yet been created.',msguser,appNoticeColor); } break; } } if (msgarray[0].length > 1) { if (!recognizedcmd && msgarray[0].charAt(1) == 'f' && msgarray[0].charAt(2) == 'f') { cb.sendNotice(msgarray[0] + ' is not a recognized Family Feud command.\n To see the list of available commands, type: /ffi', msguser, appNoticeColor); } } } } if (msgarray[0].charAt(0) != '/' && msgarray[0].charAt(0) != '!') { let pfxnickname = null; if (cbjs.arrayContains(ffTeam1Players,msguser)) { pfxnickname = '[' + ffTeam1Name + '] '; msg.m = (pfxnickname != null ? pfxnickname + ' ' : '') + msg.m; msg.background = ffTeam1BgColor; } else if (cbjs.arrayContains(ffTeam2Players,msguser)) { pfxnickname = '[' + ffTeam2Name + '] '; msg.m = (pfxnickname != null ? pfxnickname + ' ' : '') + msg.m; msg.background = ffTeam2BgColor; } else if (msguser == ffHostName) { pfxnickname = '[' + ffHostNickName + '] '; msg.m = (pfxnickname != null ? pfxnickname + ' ' : '') + msg.m; msg.background = ffHostBgColor; } } return msg; }); // *********************************** Actions on user entering ************************************** cb.onEnter(function(user) { let enterismod = user.is_mod; let enteruser = user.user; if (enterismod) { if (!cbjs.arrayContains(modList,enteruser)) { modList.push(enteruser); } } }); // *********************************** Actions upon leaving ************************************** cb.onLeave(function(user) { }); // *********************************** Actions upon tipping ************************************** cb.onTip(function (tip) { let tipamount = Number.parseInt(tip.amount, 10); let tipuser = tip.from_user let tipnote = tip.message; if (ffToggle && ffJoinMode == 'tip') { if (tipuser == ffHostName) { cb.sendNotice(botName + 'As the Game Host, you cannot tip to join the game', tipuser, appWarningColor); } else if (cbjs.arrayContains(ffTeam1Players,tipuser)) { cb.sendNotice(botName + 'You have already joined team ' + ffTeam1Name + ', you do not need to tip again to join.', tipuser, appWarningColor); } else if (cbjs.arrayContains(ffTeam2Players,tipuser)) { cb.sendNotice(botName + 'You have already joined team ' + ffTeam2Name + ', you do not need to tip again to join.', tipuser, appWarningColor); } else if (cbjs.arrayContains(ffTippedList,tipuser)) { cb.sendNotice(botName + 'You have already tipped to play, the game is still waiting on you to pick your team. Type /j1 to join team 1 (' + ffTeam1Name + ') or type /j2 to join team 2 (' + ffTeam2Name + ').', tipuser, appWarningColor); } else if (tipamount == ffJoinPrice) { if (tipnote.charAt(0) == '1') { if (ffTeam1Players.length >= ffMaxTeamSize) { cb.sendNotice('Team 1 is full! You\'ve been added to the wait list and can join Team 2 if there is a spot available, or wait until the next game.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection (selected team 1 is full).', BC, appWarningColor); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection (selected team 1 is full).', BC, appWarningColor, '', '', 'red'); ffTippedList.push(tipuser); } else { ffAddToTeam1(tipuser); } } else if (tipnote.charAt(0) == '2') { if (ffTeam2Players.length >= ffMaxTeamSize) { cb.sendNotice('Team 2 is full! You\'ve been added to the wait list and can join Team 1 if there is a spot available, or wait until the next game.', '', ffNoticeBgColor, ffNoticeTextColor, 'bold'); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection (selected team 2 is full).', BC, appWarningColor); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection (selected team 2 is full).', BC, appWarningColor, '', '', 'red'); ffTippedList.push(tipuser); } else { ffAddToTeam2(tipuser); } } else { cb.sendNotice('Congratulations! You have tipped to play. \nType "/ffj1" to join team 1 (' + ffTeam1Name + '). \nType "/ffj2" to join team 2 (' + ffTeam2Name + ').', tipuser, appWarningColor); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection.', BC, appWarningColor); cb.sendNotice(botName + tipuser + ' has tipped to play and been added to the game, awaiting team selection.', BC, appWarningColor, '', '', 'red'); ffTippedList.push(tipuser); } } } });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.