Apps Home
|
Create an App
newhangman
Author:
erik91383
Description
Source Code
Launch App
Current Users
Created by:
Erik91383
var currentWord = "", hiddenWord = "", forPanel = "", modWord = ""; var blank = "__ " var tipper = [], hangman = [], hidden = [],tippedWord = [], prizes = []; var smallGuess = [0,2,4,6,8,9], bigGuess = [0,1,2,3,4,5,6,7,8,9]; var line = 0, winsModel = 0, winsTippers = 0; var net = 0; var incorrectGuess = 0, guessesRemaining = 0; var timeToGuess = cb.settings.timer*1000; var 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']; var rowTwo = ""; var gameOver = false, roundOver = false, modelWins = false, tipperWins = false, guessed = false, wordGuess = false; var star = '\u2605'; // ★ var heart = '\u2665'; // ♥ var 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: 1000, defaultValue: 30, label: "Tip amount to guess a Letter"}, {name: 'wordTip', type: 'int', minValue: 2, maxValue: 2000, 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: false, 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: false, minValue: 1, maxValue: 10000, 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(user){ var rounds = cb.settings.rounds if (gameOver == false){ if(roundOver == false) return{ 'template': '3_rows_11_21_31', row1_value: hiddenWord, row2_value: rowTwo, row3_value: "First to " + rounds + " wins! "+ star +"Tippers: " + winsTippers + "/" + rounds + " | " + cb.settings.name + ": "+ winsModel + "/" + rounds + star + "\nGuesses Remaining: " + guessesRemaining, } else if(roundOver == true){ 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 " + rounds + " wins! "+ star +"Tippers: " + winsTippers + "/" + rounds + " | " + cb.settings.name + ": "+ winsModel + "/" + rounds + star, } } } else if (gameOver == true){ if(modelWins == true ){ 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.", } } else if (tipperWins == true){ 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(tip){ var grossTip = parseInt(tip['amount']) var tipped = tip['from_user'] var model = cb.room_slug net += grossTip if(gameOver == false){ if(roundOver == true){ if(grossTip == cb.settings.letterTip || grossTip == cb.settings.wordTip || grossTip == cb.setting.addTip){ cb.chatNotice("Please wait for the next round to begin.",tipped,"","","bold") cb.chatNotice("Hey " + cb.settings.name + "! Your tippers want to play the next round.\nPick a new word already :wink3",model,"","","bold") } } else if(roundOver == false && tipped != modWord){ if(grossTip == cb.settings.letterTip){ tipper.push(tipped) tippedWord.push(1) startPlay(tipped) } else if(grossTip == cb.settings.wordTip){ tipper.push(tipped) wordGuess = true tippedWord.push(2) startPlay(tipped) } else if(grossTip == cb.settings.addTip){ if(incorrectGuess == 0){ cb.chatNotice("Thank you for your tip, but the hangman already has the maximum amount of turns. :kiss",tipped) } else{ incorrectGuess-- guessesRemaining++ var i = status() cb.chatNotice(tip['from_user'] + " has tipped to keep the hangman 1 guess closer to living!" + "\nThe Current State of the Hangman is:" + "\n:sopphang" + i,"","",bcp.black,"bold") cb.drawPanel() } } } else if(roundOver == false && tipped == modWord){ if(grossTip == cb.settings.wordTip || grossTip == cb.settings.letterTip){ cb.chatNotice("You can't play this round!",tipped,"",bcp.red,"bold") cb.chatNotice(tipped + " is trying to cheat!","","",bcp.red,"bold") } } } }); cb.onMessage(function(msg){ var user = msg['user'] var y if(msg['m'].substring(0,3) == '/g '){ msg['X-Spam'] = true if(roundOver == false && wordGuess == false){ if(user == tipper[0]){ var words = msg['m'].split(" ") if(words[1].length != 1){ cb.chatNotice("Please make a proper guess: '/g x' where x is the letter.",user,"","","bold") } else if(words[1].length == 1){ var letter = words[1].toString().toUpperCase() if(letter.match(/[^a-zA-Z]/g)){ cb.chatNotice("Your guess needs to be a letter! Try again.",user,"","","bold") } else if(letters.includes(letter) == false){ cb.chatNotice("That letter has already been guessed! Try again.",user,"","","bold") } else if(letters.includes(letter) == true){ guessed = true if(currentWord.includes(letter)){ updateBoard(letter) cb.chatNotice("Congratulations, " + user + ", for guessing a correct letter!","","",bcp.green,"bold") winner("tipper",letter) } else{ incorrectGuess++ guessesRemaining-- updateBoard(letter) y = status() cb.chatNotice("Sorry, " + letter + " is not a letter in the word. The current state of the Hangman is:" + "\n:sopphang" + y,"","",bcp.red,"bold") winner("model",letter) } } } } else if(user != tipper[0] && tipper.includes(user)){ cb.chatNotice("Please wait your turn.",user,"","","bold") } } else if(roundOver == false && wordGuess == true){ if(user == tipper[0]){ var words = msg['m'].split(" ") if(words[1].length < 4){ cb.chatNotice("Please make a proper guess: '/g xxxx' where xxxx is the word.",user,"","","bold") } else if(words[1].length >=4){ var guess = words[1].toString().toUpperCase() if(guess.match(/[^a-zA-Z]/g)){ cb.chatNotice("Your guess needs to be a real word! Try again.",user,"","","bold") } else{ wordGuess = false guessed = true if(guess == currentWord){ winner("tipper",guess) } else{ incorrectGuess+=2 guessesRemaining-=2 y = status() cb.chatNotice(user + " has incorrectly guessed the word! The Current State of the Hangman is:" + "\n:sopphang" + y,"","",bcp.red,"bold") winner("model",guess) cb.drawPanel() } } } } else if(user != tipper[0] && tipper.includes(user)){ cb.chatNotice("Please wait your turn.",user,"","","bold") } } } if(msg['m']){ if(cb.settings.cheaters == 'Yes' && roundOver == false && user != tipper[0]){ var temp = msg['m'].toString() temp = temp.toUpperCase() if(temp.includes(currentWord)){ msg['X-Spam']=true; msg['c'] = bcp.red msg['m'] = "You shouldn't cheat!" } } } if(msg['m'].substring(0,5) == '/new '){ msg['X-Spam'] = true if(gameOver == false && roundOver == true){ if(cb.settings.modsNew == 'No'){ if(msg['is_mod']){ cb.chatNotice(cb.settings.name + " has chosen not to allow mods to make a new word.",user,"",bcp.red,"bold") } else if(msg['user']==cb.room_slug){ var m = false newWord(msg['m'],msg['user'],m) } } else if (cb.settings.modsNew == 'Yes'){ if((msg['is_mod'])||(msg['user']==cb.room_slug)){ if(msg['is_mod']){ var m = true } newWord(msg['m'],user,m) } } } } if(msg['m'].substring(0,6)=='/rules'){ msg['X-Spam']=true; rules(user) } return msg }); cb.onEnter(function(user){ if(user['has_tokens']){ cb.chatNotice("We're playing Hangman! Type '/rules' in the chat to see how to play. Good luck!",user['user'],"",bcp.maroon,"bold") } }); function startPlay(x){ if(tipper.length == 1){ play(x) } else if(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.\n"+ "You are number " + line + " in line.",x,"",bcp.black,"bold") } }; function play(x){ if(roundOver == false){ var str1 = "It's time to guess. Good Luck!" var str2 = "\nType '/g x' where x is the letter for the letter you want to guess in to the chat." var str3 = "\nType '/g xxxx' where xxxx is the word for the word you want to guess in to the chat ." var str4 = "\nYou have " + cb.settings.timer + " seconds to make your guess or you will lose your turn." if(wordGuess == false){ cb.chatNotice(str1 + str2 + str4,x,"",bcp.black,"bold") var t = timeToGuess } else{ var t = timeToGuess + 5000 var str5 = "\nYou have " + (t/1000) + " seconds to make your guess or you will lose your turn." cb.chatNotice(str1 + str3 + str5,x,"",bcp.black,"bold") } setTimeout(function(){endTurn(x)},t) } else if(roundOver == true){ for(var i=0;i<tipper.length;i++){ cb.chatNotice("Thanks for tipping to play but the round over. Please play again next round! :kiss",tipper[i],"","","bold") } tipper = [] tippedWord = [] } }; function endTurn(x){ if(guessed == false && tipper[0] == x){ cb.chatNotice("Sorry, but your turn has ended for taking too long to make a guess. :kiss",x,"",bcp.black,"bold") } wordGuess = false guessed = false tipper.shift() tippedWord.shift() if(tipper.length >= 1){ var player = tipper[0] if(tippedWord[0] == 2){ wordGuess = true } line-- if(line > 1){ for(i=1;i<=line;i++){ cb.chatNotice("You are now number " + i + " in line.",tipper[i],"",bcp.black,"bold") } } play(player) } }; function winner(x,guess){ if(x == "tipper"){ forPanel = hidden.join("") var word = hiddenWord.replace(/ /g,'') if(forPanel == guess || forPanel == word){ roundOver = true winsTippers++ } if((winsTippers < cb.settings.rounds) && roundOver == true){ roundOverWinNotify() cb.setTimeout(newRoundNotify,3000) cb.drawPanel() } else if (winsTippers == cb.settings.rounds){ gameEnd() } } else if(x == "model"){ if(incorrectGuess >= cb.settings.guesses){ winsModel++ roundOver = true if(winsModel < cb.settings.rounds){ modelWinSetup() } } if(winsModel == cb.settings.rounds){ gameEnd() } } }; function roundOverWinNotify(){ if(gameOver == false){ cb.chatNotice("Congratulations! " + cb.settings.name + " has lost this round. Nice work!\n" + cb.settings.wordGIF,"","",bcp.green,"bold") if(cb.settings.roundPrizeOption == 'Yes'){ var i = getPrize() cb.chatNotice("Your prize for winning the round is: " + i,"","",bcp.green,"bold") } } }; function getPrize(){ var ran = Math.floor(Math.random() * prizes.length) var prizeWon = prizes[ran] return prizeWon }; function modelWinSetup(){ roundOverLoseNotify() forPanel = hidden.join("") cb.drawPanel() cb.setTimeout(newRoundNotify,3000) }; function roundOverLoseNotify(){ if(gameOver == false){ cb.chatNotice("You lost! " + cb.settings.name + " has won! Better luck next round.\n" + cb.settings.modelGIF,"","",bcp.purple,"bold") } } function newRoundNotify(){ if(gameOver == false){ cb.sendNotice("Type '/new xxxx' where xxxx is the new word to start the next round",cb.room_slug,"",bcp.red,"bold") if(cb.settings.modsNew == 'Yes'){ cb.sendNotice("Type '/new xxxx' where xxxx is the new word to start the next round","","",bcp.red,"bold",'red') } } }; function gameEnd(){ gameOver = true if(winsModel == cb.settings.rounds){ modelWins = true cb.chatNotice("Too bad, " + cb.settings.name + " is the winner. Better luck next time!\n" + cb.settings.gameWinM,"","",bcp.maroon,"bold") } if (winsTippers == cb.settings.rounds){ tipperWins = true 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(modelUpdate,2500) function modelUpdate(){ cb.chatNotice("Total Tokens for the game: " + net + ". Average tokens per round: " + Math.ceil(net/(winsModel + winsTippers)) + ". Total dollars: $" + parseFloat(net*.05).toFixed(2),cb.room_slug,"",bcp.red,"bold") } }; function newBoard(){ var str = currentWord for (var i = 0; i < currentWord.length; i++){ hiddenWord = hiddenWord + blank hangman.push(blank) var l = str.charAt(i) hidden.push(l) }; rowTwo = letters.join(" "); cb.drawPanel() }; function newWord(message,user,m){ var words = message.split(" "); if(words[1].match(/[^a-zA-Z]/g)){ cb.chatNotice("Your word cannot include numbers, symbols, or spaces! Try again.",user,"",bcp.red,"bold") } else{ if (words[1].length == 0){ cb.chatNotice("There must be a new word in order to start a new round.",user,'',bcp.red,"bold") } else if(words[1].length < 4){ cb.chatNotice("Your word should more than " + words[1].length + " characters long!",user,'',bcp.red,"bold") } else if(words[1].length >= 4){ cb.chatNotice("You have successfully set a new word.",user,'',bcp.green,"bold") roundOver = false newRound(words[1]) if(m == true){ cb.sendNotice(user + " Has set the word. The new word is: " + words[1],cb.room_slug,"",bcp.green,"bold") } modWord = user } } }; function newRound(hang){ 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 startWord = hang || ""; currentWord = startWord.trim().toUpperCase(); roundGuesses() newBoard(); var i = 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" + i,"","",bcp.black,"bold") } function updateBoard(guess){ var temp for (var i =0; i <= hangman.length; i++){ if(hidden[i] == guess){ hangman[i] = guess } } temp = hangman.join(" ") hiddenWord = temp.toString() letters.splice(letters.indexOf(guess),1) rowTwo = letters.join(" "); cb.drawPanel() }; function roundGuesses(){ if(cb.settings.guesses == '5'){ guessesRemaining = 5 } else if (cb.settings.guesses == '9'){ guessesRemaining = 9 } }; function status(){ var i if(incorrectGuess > cb.settings.guesses){ i = cb.settings.guesses } else{ if (cb.settings.guesses == '5'){ i = smallGuess[incorrectGuess] } else if(cb.settings.guesses == '9'){ i = bigGuess[incorrectGuess] } } return i }; function rules(toUser){ var i = status() var str1 = "Welcome to hangman. Guess the word before the hangman falls. " var str2 = "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. " var str3 = "An incorrect letter guess will decrease the remaining guesses by 1, and an incorrect word guess will decrease the remaining guesses by 2! " var str4 = "To reverse the state of the hangman by 1, tip " + cb.settings.addTip + " tokens. " var str5 = "Type '/rules' to see this message again. Good luck! The current state of the hangman is:\n:sopphang" + i if(cb.settings.addGuess == 'Yes'){ cb.chatNotice(str1+str2+str3+str4+str5,toUser,"",bcp.navy,"bold") } else{ cb.chatNotice(str1+str2+str3+str5,toUser,"",bcp.navy,"bold") } }; function prizeNotice(){ if(cb.settings.roundPrizeOption == 'Yes'){ var temp = cb.settings.roundPrize prizes = temp.split(",") if(gameOver == false){ var list = prizes.join(" " + heart + " ").toString() cb.chatNotice("Winning the round will win one of these random prizes:\n" + " " + heart + " " + list + " " + heart,"","",bcp.maroon,"bold") } cb.setTimeout(prizeNotice,360000) } }; function notifier(){ cb.chatNotice("We're playing hangman. Type '/rules' in the chat to see how to play!","","",bcp.blue,"bold") cb.setTimeout(notifier,300000) }; function init(){ var startWord = cb.settings.word || "" currentWord = startWord.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,1000) cb.setTimeout(prizeNotice,5000) cb.setTimeout(notifier,300000) }; init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.