Bots Home
|
Create an App
Word Game (Credit to Erik913)
Author:
elric77
Description
Source Code
Launch Bot
Current Users
Created by:
Elric77
function startPlay(e){1==tipper.length?play(e):tipper.length>1&&(line++,cb.chatNotice("Thank you for your tip. When it's your turn to guess, you will receive a message in the chat.\nYou are number "+line+" in line.",e,"",bcp.black,"bold"))}function play(e){if(0==roundOver){var t="It's time to guess. Good Luck!",n="\nType '/g x' where x is the letter for the letter you want to guess in to the chat.",s="\nType '/g xxxx' where xxxx is the word for the word you want to guess in to the chat .",o="\nYou have "+cb.settings.timer+" seconds to make your guess or you will lose your turn.";if(0==wordGuess){cb.chatNotice(t+n+o,e,"",bcp.black,"bold");var r=timeToGuess}else{var r=timeToGuess+5e3,i="\nYou have "+r/1e3+" seconds to make your guess or you will lose your turn.";cb.chatNotice(t+s+i,e,"",bcp.black,"bold")}setTimeout(function(){endTurn(e)},r)}else if(1==roundOver){for(var a=0;a<tipper.length;a++)cb.chatNotice("Thanks for tipping to play but the round over. Please play again next round! :kiss",tipper[a],"","","bold");tipper=[],tippedWord=[]}}function endTurn(e){if(0==guessed&&tipper[0]==e&&cb.chatNotice("Sorry, but your turn has ended for taking too long to make a guess. :kiss",e,"",bcp.black,"bold"),wordGuess=!1,guessed=!1,tipper.shift(),tippedWord.shift(),tipper.length>=1){var t=tipper[0];if(2==tippedWord[0]&&(wordGuess=!0),line--,line>1)for(i=1;i<=line;i++)cb.chatNotice("You are now number "+i+" in line.",tipper[i],"",bcp.black,"bold");play(t)}}function winner(e,t){if("tipper"==e){forPanel=hidden.join("");var n=hiddenWord.replace(/ /g,"");(forPanel==t||forPanel==n)&&(roundOver=!0,winsTippers++),winsTippers<cb.settings.rounds&&1==roundOver?(roundOverWinNotify(),cb.setTimeout(newRoundNotify,3e3),cb.drawPanel()):winsTippers==cb.settings.rounds&&gameEnd()}else"model"==e&&(incorrectGuess>=cb.settings.guesses&&(winsModel++,roundOver=!0,winsModel<cb.settings.rounds&&modelWinSetup()),winsModel==cb.settings.rounds&&gameEnd())}function roundOverWinNotify(){if(0==gameOver&&(cb.chatNotice("Congratulations! "+cb.settings.name+" has lost this round. Nice work!\n"+cb.settings.wordGIF,"","",bcp.green,"bold"),"Yes"==cb.settings.roundPrizeOption)){var e=getPrize();cb.chatNotice("Your prize for winning the round is: "+e,"","",bcp.green,"bold")}}function getPrize(){var e=Math.floor(Math.random()*prizes.length),t=prizes[e];return t}function modelWinSetup(){roundOverLoseNotify(),forPanel=hidden.join(""),cb.drawPanel(),cb.setTimeout(newRoundNotify,3e3)}function roundOverLoseNotify(){0==gameOver&&cb.chatNotice("You lost! "+cb.settings.name+" has won! Better luck next round.\n"+cb.settings.modelGIF,"","",bcp.purple,"bold")}function newRoundNotify(){0==gameOver&&(cb.sendNotice("Type '/new xxxx' where xxxx is the new word to start the next round",cb.room_slug,"",bcp.red,"bold"),"Yes"==cb.settings.modsNew&&cb.sendNotice("Type '/new xxxx' where xxxx is the new word to start the next round","","",bcp.red,"bold","red"))}function gameEnd(){function e(){cb.chatNotice("Total Tokens for the game: "+net+". Average tokens per round: "+Math.ceil(net/(winsModel+winsTippers))+". Total dollars: $"+parseFloat(.05*net).toFixed(2),cb.room_slug,"",bcp.red,"bold")}gameOver=!0,winsModel==cb.settings.rounds&&(modelWins=!0,cb.chatNotice("Too bad, "+cb.settings.name+" is the winner. Better luck next time!\n"+cb.settings.gameWinM,"","",bcp.maroon,"bold")),winsTippers==cb.settings.rounds&&(tipperWins=!0,cb.chatNotice("Congratualtions tippers! You beat "+cb.settings.name+" and are the Winners! Your prize is: "+cb.settings.prize+"\n"+cb.settings.gameWinT,"","",bcp.green,"bold")),cb.drawPanel(),cb.changeRoomSubject("Thanks for playing! "+cb.settings.topic+" "+cb.settings.hashtags),cb.setTimeout(e,2500)}function newBoard(){for(var e=currentWord,t=0;t<currentWord.length;t++){hiddenWord+=blank,hangman.push(blank);var n=e.charAt(t);hidden.push(n)}rowTwo=letters.join(" "),cb.drawPanel()}function newWord(e,t,n){var s=e.split(" ");s[1].match(/[^a-zA-Z]/g)?cb.chatNotice("Your word cannot include numbers, symbols, or spaces! Try again.",t,"",bcp.red,"bold"):0==s[1].length?cb.chatNotice("There must be a new word in order to start a new round.",t,"",bcp.red,"bold"):s[1].length<4?cb.chatNotice("Your word should more than "+s[1].length+" characters long!",t,"",bcp.red,"bold"):s[1].length>=4&&(cb.chatNotice("You have successfully set a new word.",t,"",bcp.green,"bold"),roundOver=!1,newRound(s[1]),1==n&&cb.sendNotice(t+" Has set the word. The new word is: "+s[1],cb.room_slug,"",bcp.green,"bold"),modWord=t)}function newRound(e){letters=[],letters=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],hiddenWord="",hangman=[],hidden=[],incorrectGuess=0;var t=e||"";currentWord=t.trim().toUpperCase(),roundGuesses(),newBoard();var n=incorrectGuess;cb.chatNotice("A new word has been set. Good luck and don't let the hangman die!\nThe Current State of the Hangman is:\n:sopphang"+n,"","",bcp.black,"bold")}function updateBoard(e){for(var t,n=0;n<=hangman.length;n++)hidden[n]==e&&(hangman[n]=e);t=hangman.join(" "),hiddenWord=t.toString(),letters.splice(letters.indexOf(e),1),rowTwo=letters.join(" "),cb.drawPanel()}function roundGuesses(){"5"==cb.settings.guesses?guessesRemaining=5:"9"==cb.settings.guesses&&(guessesRemaining=9)}function status(){var e;return incorrectGuess>cb.settings.guesses?e=cb.settings.guesses:"5"==cb.settings.guesses?e=smallGuess[incorrectGuess]:"9"==cb.settings.guesses&&(e=bigGuess[incorrectGuess]),e}function rules(e){var t=status(),n="Welcome to hangman. Guess the word before the hangman falls. ",s="To guess a letter, tip "+cb.settings.letterTip+" tokens and then type '/g x' where x is the letter you're guessing in to the chat. To guess the word early, tip "+cb.settings.wordTip+" tokens and then type /g xxxx' where xxxx is the word you're trying to guess. ",o="An incorrect letter guess will decrease the remaining guesses by 1, and an incorrect word guess will decrease the remaining guesses by 2! ",r="To reverse the state of the hangman by 1, tip "+cb.settings.addTip+" tokens. ",i="Type '/rules' to see this message again. Good luck! The current state of the hangman is:\n:sopphang"+t;"Yes"==cb.settings.addGuess?cb.chatNotice(n+s+o+r+i,e,"",bcp.navy,"bold"):cb.chatNotice(n+s+o+i,e,"",bcp.navy,"bold")}function prizeNotice(){if("Yes"==cb.settings.roundPrizeOption){var e=cb.settings.roundPrize;if(prizes=e.split(","),0==gameOver){var t=prizes.join(" "+heart+" ").toString();cb.chatNotice("Winning the round will win one of these random prizes:\n "+heart+" "+t+" "+heart,"","",bcp.maroon,"bold")}cb.setTimeout(prizeNotice,36e4)}}function notifier(){cb.chatNotice("We're playing hangman. Type '/rules' in the chat to see how to play!","","",bcp.blue,"bold"),cb.setTimeout(notifier,3e5)}function init(){var e=cb.settings.word||"";currentWord=e.trim().toUpperCase(),cb.changeRoomSubject("We're playing hangman! First to "+cb.settings.rounds+" wins. Prize: "+cb.settings.prize+". "+cb.settings.hashtags),newBoard(),roundGuesses(),cb.setTimeout(rules,1e3),cb.setTimeout(prizeNotice,5e3),cb.setTimeout(notifier,3e5)}var currentWord="",hiddenWord="",forPanel="",modWord="",blank="__ ",tipper=[],hangman=[],hidden=[],tippedWord=[],prizes=[],smallGuess=[0,2,4,6,8,9],bigGuess=[0,1,2,3,4,5,6,7,8,9],line=0,winsModel=0,winsTippers=0,net=0,incorrectGuess=0,guessesRemaining=0,timeToGuess=1e3*cb.settings.timer,letters=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],rowTwo="",gameOver=!1,roundOver=!1,modelWins=!1,tipperWins=!1,guessed=!1,wordGuess=!1,star="★",heart="♥",bcp={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",grey:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"};cb.settings_choices=[{name:"word",type:"str",minLength:4,maxLength:15,label:"1) GAME SETUP..........................Word to guess",defaultValue:"Hangman"},{name:"letterTip",type:"int",minValue:1,maxValue:1e3,defaultValue:30,label:"Tip amount to guess a Letter"},{name:"wordTip",type:"int",minValue:2,maxValue:2e3,defaultValue:100,label:"Tip amount to guess the Word"},{name:"guesses",type:"choice",choice1:"5",choice2:"9",label:"Incorrect guesses until Round Over",defaultValue:"5"},{name:"rounds",type:"int",minValue:1,maxValue:50,defaultValue:7,label:"Rounds necessary to win Final Prize"},{name:"prize",type:"str",minLength:1,maxLength:255,label:"Prize if Tippers win",defaultValue:"Dress Off"},{name:"timer",type:"int",minValue:1,maxValue:20,defaultValue:10,label:"Amount of time between turns (In seconds)"},{name:"roundPrizeOption",label:"Random Prize for winning a round?",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"No"},{name:"roundPrize",type:"str",minLength:1,maxLength:255,required:!1,label:"List little prizes for winning a round (Seperate by a comma and no spaces. It is okay to have only 1 prize if preferred.)",defaultValue:"Flash,A Smile,A Kiss,2 Spanks"},{name:"name",type:"str",minLength:1,maxLength:15,label:"2) ROOM SETUP............................Your Name",defaultValue:"Sophia"},{name:"topic",type:"str",minLength:1,maxLength:255,label:"Room Topic after game over",defaultValue:"Let's copulate over and over ❤"},{name:"hashtags",type:"str",minLength:1,maxLength:255,label:"Hashtags for your topic",defaultValue:"#lovense #ohmibod #sexy #fun"},{name:"addGuess",label:"3) GAME CUSTOMIZATION.............Allow tip to add another guess",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"No"},{name:"addTip",type:"int",required:!1,minValue:1,maxValue:1e4,defaultValue:250,label:"Tip for another guess"},{name:"modsNew",type:"choice",choice1:"No",choice2:"Yes",label:"Mods can pick the new word?",defaultValue:"Yes"},{name:"cheaters",type:"choice",choice1:"No",choice2:"Yes",label:"Stop users from guessing the word in chat (This will catch any comment with the 'word' and prevent it from showing in chat)",defaultValue:"No"},{name:"wordGIF",type:"str",minLength:1,maxLength:255,label:"GIF if tippers win a round",defaultValue:":goodjobguys5567"},{name:"modelGIF",type:"str",minLength:1,maxLength:255,label:"GIF if you win a round",defaultValue:":sophiapush5"},{name:"gameWinT",type:"str",minLength:1,maxLength:255,label:"GIF if tippers win the game",defaultValue:":congratulationslove"},{name:"gameWinM",type:"str",minLength:1,maxLength:255,label:"GIF if you win the game",defaultValue:":sophiadance"}],cb.onDrawPanel(function(e){var t=cb.settings.rounds;if(0==gameOver){if(0==roundOver)return{template:"3_rows_11_21_31",row1_value:hiddenWord,row2_value:rowTwo,row3_value:"First to "+t+" wins! "+star+"Tippers: "+winsTippers+"/"+t+" | "+cb.settings.name+": "+winsModel+"/"+t+star+"\nGuesses Remaining: "+guessesRemaining};if(1==roundOver)return{template:"3_rows_11_21_31",row1_value:"The word was: "+forPanel,row2_value:"Waiting for the New Word to be chosen",row3_value:"First to "+t+" wins! "+star+"Tippers: "+winsTippers+"/"+t+" | "+cb.settings.name+": "+winsModel+"/"+t+star}}else if(1==gameOver){if(1==modelWins)return{template:"3_rows_11_21_31",row1_value:"Thank you all for playing!",row2_value:cb.settings.name+" is the winner!",row3_value:"Better Luck Next Time."};if(1==tipperWins)return{template:"3_rows_11_21_31",row1_value:"Thank you all for playing!",row2_value:"Congratulations, tippers! You beat "+cb.settings.name,row3_value:"Your Prize: "+cb.settings.prize}}}),cb.onTip(function(e){var t=parseInt(e.amount),n=e.from_user,s=cb.room_slug;if(net+=t,0==gameOver)if(1==roundOver)(t==cb.settings.letterTip||t==cb.settings.wordTip||t==cb.setting.addTip)&&(cb.chatNotice("Please wait for the next round to begin.",n,"","","bold"),cb.chatNotice("Hey "+cb.settings.name+"! Your tippers want to play the next round.\nPick a new word already :wink3",s,"","","bold"));else if(0==roundOver&&n!=modWord){if(t==cb.settings.letterTip)tipper.push(n),tippedWord.push(1),startPlay(n);else if(t==cb.settings.wordTip)tipper.push(n),wordGuess=!0,tippedWord.push(2),startPlay(n);else if(t==cb.settings.addTip)if(0==incorrectGuess)cb.chatNotice("Thank you for your tip, but the hangman already has the maximum amount of turns. :kiss",n);else{incorrectGuess--,guessesRemaining++;var o=status();cb.chatNotice(e.from_user+" has tipped to keep the hangman 1 guess closer to living!\nThe Current State of the Hangman is:\n:sopphang"+o,"","",bcp.black,"bold"),cb.drawPanel()}}else 0==roundOver&&n==modWord&&(t==cb.settings.wordTip||t==cb.settings.letterTip)&&(cb.chatNotice("You can't play this round!",n,"",bcp.red,"bold"),cb.chatNotice(n+" is trying to cheat!","","",bcp.red,"bold"))}),cb.onMessage(function(e){var t,n=e.user;if("/g "==e.m.substring(0,3))if(e["X-Spam"]=!0,0==roundOver&&0==wordGuess)if(n==tipper[0]){var s=e.m.split(" ");if(1!=s[1].length)cb.chatNotice("Please make a proper guess: '/g x' where x is the letter.",n,"","","bold");else if(1==s[1].length){var o=s[1].toString().toUpperCase();o.match(/[^a-zA-Z]/g)?cb.chatNotice("Your guess needs to be a letter! Try again.",n,"","","bold"):0==letters.includes(o)?cb.chatNotice("That letter has already been guessed! Try again.",n,"","","bold"):1==letters.includes(o)&&(guessed=!0,currentWord.includes(o)?(updateBoard(o),cb.chatNotice("Congratulations, "+n+", for guessing a correct letter!","","",bcp.green,"bold"),winner("tipper",o)):(incorrectGuess++,guessesRemaining--,updateBoard(o),t=status(),cb.chatNotice("Sorry, "+o+" is not a letter in the word. The current state of the Hangman is:\n:sopphang"+t,"","",bcp.red,"bold"),winner("model",o)))}}else n!=tipper[0]&&tipper.includes(n)&&cb.chatNotice("Please wait your turn.",n,"","","bold");else if(0==roundOver&&1==wordGuess)if(n==tipper[0]){var s=e.m.split(" ");if(s[1].length<4)cb.chatNotice("Please make a proper guess: '/g xxxx' where xxxx is the word.",n,"","","bold");else if(s[1].length>=4){var r=s[1].toString().toUpperCase();r.match(/[^a-zA-Z]/g)?cb.chatNotice("Your guess needs to be a real word! Try again.",n,"","","bold"):(wordGuess=!1,guessed=!0,r==currentWord?winner("tipper",r):(incorrectGuess+=2,guessesRemaining-=2,t=status(),cb.chatNotice(n+" has incorrectly guessed the word! The Current State of the Hangman is:\n:sopphang"+t,"","",bcp.red,"bold"),winner("model",r),cb.drawPanel()))}}else n!=tipper[0]&&tipper.includes(n)&&cb.chatNotice("Please wait your turn.",n,"","","bold");if(e.m&&"Yes"==cb.settings.cheaters&&0==roundOver&&n!=tipper[0]){var i=e.m.toString();i=i.toUpperCase(),i.includes(currentWord)&&(e["X-Spam"]=!0,e.c=bcp.red,e.m="You shouldn't cheat!")}if("/new "==e.m.substring(0,5)&&(e["X-Spam"]=!0,0==gameOver&&1==roundOver))if("No"==cb.settings.modsNew){if(e.is_mod)cb.chatNotice(cb.settings.name+" has chosen not to allow mods to make a new word.",n,"",bcp.red,"bold");else if(e.user==cb.room_slug){var a=!1;newWord(e.m,e.user,a)}}else if("Yes"==cb.settings.modsNew&&(e.is_mod||e.user==cb.room_slug)){if(e.is_mod)var a=!0;newWord(e.m,n,a)}return"/rules"==e.m.substring(0,6)&&(e["X-Spam"]=!0,rules(n)),e}),cb.onEnter(function(e){e.has_tokens&&cb.chatNotice("We're playing Hangman! Type '/rules' in the chat to see how to play. Good luck!",e.user,"",bcp.maroon,"bold")}),init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.