Apps Home
|
Create an App
SophiaHang
Author:
erik91383
Description
Source Code
Launch App
Current Users
Created by:
Erik91383
var currentWord = "", currentTipper = "", hiddenWord = "", forPanel = "", modWord = ""; var blank = "__ " var tipper = [], hangman = [], hidden = []; var tippedWord = [] var smallGuess = [0,2,4,6,8,9], bigGuess = [0,1,2,3,4,5,6,7,8,9]; var currentOrder = 0, line = 0; var winsModel = 0, winsTippers = 0; var net = 0, bonus = 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, cheatersTemp = 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: 1, maxLength: 15, label: 'Word to guess', defaultValue: 'Hangman'}, {name: 'name', type: 'str', minLength: 1, maxLength: 15, label: 'Your Name', defaultValue: 'Sophia'}, {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: 'incorrectGuesses', type: 'choice', choice1: '5', choice2: '9', label: 'Guesses before loss', defaultValue: '5'}, {name: 'roundsTotal', type: 'int', minValue: 1, maxValue: 50, defaultValue: 7, label: "Rounds necessary to win Final Prize"}, {name: 'tipperPrize', type: 'str', minLength: 1, maxLength: 255, label: 'Prize if Tippers win', defaultValue: 'Cuchi Cuchi'}, {name: 'letterGIF', type: 'str', minLength: 1, maxLength: 255, label: 'GIF if tipper guesses letter', defaultValue: ':Goodjobjim'}, {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'}, {name: 'timer', type: 'int', minValue: 1, maxValue: 20, defaultValue: 7, label: "Amount of time between turns (In seconds)"}, {name: 'topic', type: 'str', minLength: 1, maxLength: 255, required: false, label: "Room Topic after game over", defaultValue: "Let's copulate over and over ❤"}, {name: 'hashtags', type: 'str', minLength: 1, maxLength: 255, required: false, label: "Hashtags for your topic", defaultValue: "#lovense #ohmibod #sexy #fun"}, {name: 'roundPrizeOption', label: 'Prize for winning a round', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'roundPrize', type: 'str', minLength: 1, maxLength: 255, required: false, label: 'Prize for option above', defaultValue: 'Cuchi Cuchi'}, {name: 'saviorTip', label: 'Allow Tip to add another guess', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'saveTip', type: 'int', 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: 'No'}, {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'}, ]; cb.onDrawPanel(function(user){ if (gameOver == false && roundOver == false){ return{ 'template': '3_rows_11_21_31', row1_value: hiddenWord, row2_value: rowTwo, row3_value: "First to " + cb.settings.roundsTotal + " wins! "+ star +"Tippers: " + winsTippers + "/" + cb.settings.roundsTotal + " | " + cb.settings.name + ": "+ winsModel + "/" + cb.settings.roundsTotal + star + "\nGuesses Remaining: " + guessesRemaining, } } else if(gameOver == false && 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 " + cb.settings.roundsTotal + " wins! "+ star +"Tippers: " + winsTippers + "/" + cb.settings.roundsTotal + " | " + cb.settings.name + ": "+ winsModel + "/" + cb.settings.roundsTotal + star, } } if (gameOver == true && 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 (gameOver == true && 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.tipperPrize, } } }); cb.onTip(function(tip){ var grossTip = parseInt(tip['amount']) if ( tip['message'].match( /optout/i ) != null ){ return; } net += grossTip if(gameOver == false && roundOver == false){ if(grossTip == cb.settings.letterTip){ tippedWord.push(0) receiveTip(tip['from_user']) } else if(grossTip == cb.settings.wordTip){ wordGuess = true tippedWord.push(1) receiveTip(tip['from_user']) } else if(grossTip == cb.settings.saveTip && cb.settings.saviorTip == 'Yes'){ 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(grossTip != cb.settings.letterTip || grossTip !=cb.settings.wordTip || grossTip !=cb.settings.saveTip){ bonus += grossTip } } }); cb.onMessage(function(msg){ if(tipper.indexOf(msg['user']) > 0 && gameOver == false){ cb.chatNotice("Please wait your turn",msg['user'],"",bcp.black,"bold") } else if(tipper.indexOf(msg['user']) == 0 && guessed == false && gameOver == false && wordGuess == false && roundOver == false){ if(msg['m'].includes('!')){ var guess = msg['m'].toString() guess = guess.substr(1,1).toUpperCase() if(guess.length>1){ msg['X-Spam']=true cb.chatNotice("Your guess should only be 1 letter! Try again.",msg['user'],"",bcp.red,"bold") } else{ if(guess.match(/[^a-zA-Z]/g)){ msg['X-Spam']=true cb.chatNotice("Your Guess Needs to be a letter! Try again.",msg['user'],"",bcp.red,"bold") } else if(letters.includes(guess) == false){ msg['X-Spam']=true cb.chatNotice("That letter has already been guessed! Try again.",msg['user'],"",bcp.red,"bold") } else{ if (currentWord.includes(guess) == false){ incorrectGuess++ guessesRemaining-- var i = status() msg['X-Spam']=true guessed = true updateLetters(guess) cb.chatNotice("Sorry, " + guess + " is not a letter in the word. The Current State of the Hangman is:" + "\n:sopphang" + i,"","",bcp.red,"bold") modelWin() } else{ msg['X-spam']=true guessed = true updateBoard(guess) updateLetters(guess) cb.chatNotice("Congratulations, " + msg['user'] + ", for guessing a correct letter!\n" + cb.settings.letterGIF,"","",bcp.green,"bold") userWin() } } } } } else if(tipper.indexOf(msg['user']) == 0 && gameOver == false && wordGuess == true && roundOver == false){ if(msg['m'].includes('!')){ var guess = msg['m'].toString() guess = guess.slice(1).toUpperCase() wordGuess = false guessed = true if(guess == currentWord){ msg['X-spam']=true cb.settings.cheaters = 'No' roundOver = true winsTippers++ userWin() } else if (guess != currentWord){ msg['X-spam']=true incorrectGuess+=2 guessesRemaining-=2 var i = status() cb.chatNotice(msg['user'] + " has incorrectly guessed the word!" + "\nThe Current State of the Hangman is:" + "\n:sopphang" + i,"","",bcp.red,"bold") modelWin() cb.drawPanel() } } } if(msg['m']){ if(cb.settings.cheaters == 'Yes'){ var temp = msg['m'].toString() temp = temp.toUpperCase() if(temp.includes(currentWord)){ msg['X-Spam']=true; msg['m'] = "You shouldn't cheat!" return msg } } } if((msg['m'].substring(0,1)=='/') && gameOver == false){ if(roundOver == true && ((msg['is_mod'])||(msg['user']==cb.room_slug))){ if(msg['m'].substring(0,5)=='/new '){ msg['X-Spam']=true; if(cb.settings.modsNew == 'No' && (msg['is_mod'])){ cb.chatNotice(cb.settings.name + " has chosen not to allow mods to make a new word.",msg['user'],'',bcp.red,"bold") } else if(cb.settings.modsNew == 'No' && (msg['user']==cb.room_slug)){ newWord(msg['m'],msg['user']) } else if (cb.settings.modsNew == 'Yes' && ((msg['is_mod'])||(msg['user']==cb.room_slug))){ if(msg['is_mod']){ var m = true } newWord(msg['m'],msg['user'],m) } } } } if((msg['m'].substring(0,1)=='/') && gameOver == false){ if(msg['m'].substring(0,6)=='/rules'){ msg['X-Spam']=true; rules(msg['user']) } } }); cb.onEnter(function(user){ rules(user['user']) }); function endTurn(){ if(guessed == false && tipper.indexOf(currentTipper) == 0 && roundOver == false){ cb.chatNotice("Sorry, but your turn has ended for taking too long to guess a letter. :kiss",currentTipper,"",bcp.black,"bold") } tipper.shift() tippedWord.shift() if(tipper.length > 0){ if(tippedWord[0] == 1){ wordGuess = true } line-- var n = line if (line > 0){ for(var i = 1; i <= line; i++){ cb.chatNotice("You are now number " + n + " in line.",tipper[i],"",bcp.black,"bold") n++ } } notify(); } }; function gameEnd(){ gameOver = true if(winsModel == cb.settings.roundsTotal){ 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.roundsTotal){ tipperWins = true cb.chatNotice("Congratualtions tippers! You beat " + cb.settings.name + " and are the Winners! Your prize is: " + cb.settings.tipperPrize + "\n" + cb.settings.gameWinT,"","",bcp.green,"bold") } cb.drawPanel() cb.changeRoomSubject("Thanks for playing! " + cb.settings.topic + " " + cb.settings.hashtags) cb.setTimeout(modelUpdate,3500) function modelUpdate(){ cb.chatNotice("Total Tokens for the game: " + net + ". Tokens that were not for playing the game: " + bonus + ". Average tokens per round: " + Math.ceil(net/(winsModel + winsTippers)) + ". Total dollars: $" + parseFloat(net*.05).toFixed(2),cb.room_slug,"",bcp.red,"bold") } }; function modelWin(){ if(cb.settings.incorrectGuesses == '5'){ if(incorrectGuess >= 5){ winsModel++ if(winsModel < cb.settings.roundsTotal){ modelWinSetup() } } } else if(cb.settings.incorrectGuesses == '9'){ if(incorrectGuess >= 9){ winsModel++ if(winsModel < cb.settings.roundsTotal){ modelWinSetup() } } } if(winsModel == cb.settings.roundsTotal){ gameEnd() } }; function modelWinSetup(){ roundOver = true roundOverLoseNotify() forPanel = hidden.join("") cb.drawPanel() cb.setTimeout(newRoundNotify,3000) }; function newBoard(){ var i, o, p, str; str = currentWord for (i = 0; i < currentWord.length; i++){ hiddenWord = hiddenWord + blank }; for (o = 0; o < currentWord.length; o++){ hangman.push(blank) }; for (p = 0; p < currentWord.length; p++){ var l = str.charAt(p) hidden.push(l) }; rowTwo = letters.join(" "); cb.drawPanel() }; function newRound(hang){ hiddenWord = "" hangman = [] hidden = [] incorrectGuess = 0 if(cheatersTemp == true){ cb.settings.cheaters = 'Yes' } var startWord = hang || ""; currentWord = startWord.trim().toUpperCase(); roundGuesses() newBoard(); var i = status() 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 newRoundNotify(){ if(gameOver == false){ cb.sendNotice("Type '/new x' where x is the new word to start the next round",cb.room_slug,"",bcp.red,"bold") if(cb.settings.modsNew == 'Yes'){ cb.sendNotice("Type '/new x' where x is the new word to start the next round","","",bcp.red,"bold",'red') } } }; 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.black,"bold") roundOver = false newRound(words[1]) if(m == true){ cb.sendNotice("The new word is: " + words[1],cb.room_slug,"",bcp.green,"bold") modWord = user } else if(user == cb.room_slug && cb.settings.modsNew == 'Yes'){ cb.sendNotice(cb.settings.name + " has set the new word.","","",bcp.green,"bold",'red') modWord = "" } } } }; function notify(){ guessed = false currentTipper = tipper[0] if(wordGuess == false && roundOver == false){ cb.chatNotice("Guess a letter and Good Luck! " + "\nType '!' before the letter you want to guess " + "\nYou have " + cb.settings.timer + " seconds to make your guess or you will lose your turn.",currentTipper,"",bcp.black,"bold") setTimeout(endTurn, timeToGuess) } else if(wordGuess == true && roundOver == false){ var t = cb.settings.timer+5 var g = timeToGuess+5000 cb.chatNotice("Guess the word and Good Luck! " + "\nType '!' before the word you would like to guess" + "\nYou have " + t + " seconds to make your guess or you will lose your turn.",currentTipper,"",bcp.black,"bold") setTimeout(endTurn, g) } }; function receiveTip(tipped){ tipper.push(tipped) if(cb.settings.modsNew == 'Yes' && tipped == modWord){ tipper.shift() cb.chatNotice("You can't guess a letter or the Word!",tipped,"",bcp.red,"bold") cb.chatNotice(tipped + " is trying to cheat!","","",bcp.red,"bold") } if(tipper.length == 1){ notify() } 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",tipped,"",bcp.black,"bold") cb.chatNotice("You are number " + line + " in line.",tipped,"",bcp.black,"bold") } }; function roundGuesses(){ if(cb.settings.incorrectGuesses == '5'){ guessesRemaining = 5 } else if (cb.settings.incorrectGuesses == '9'){ guessesRemaining = 9 } }; 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 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'){ cb.chatNotice("Your prize for winning is: " + cb.settings.roundPrize,"","",bcp.green,"bold") } } }; function rules(toUser){ var i = status() cb.chatNotice("Welcome to hangman. Guess the word before the hangman falls.\n"+ "To guess a letter, tip " + cb.settings.letterTip + " tokens. To guess the word early, tip " + cb.settings.wordTip + " tokens.",toUser,"",bcp.navy,"bold") if(cb.settings.saviorTip == 'Yes'){ cb.chatNotice("To reverse the state of the hangman by 1, tip " + cb.settings.saveTip + " tokens.",toUser,"",bcp.navy,"bold") } cb.chatNotice("Type '/rules' to see this message again. Good luck!\n"+ "The current state of the hangman is:\n:sopphang" + i,toUser,"",bcp.navy,"bold") }; function status(){ if(cb.settings.incorrectGuesses == '5'){ if(incorrectGuess < 0){ return smallGuess[0] incorrectGuess = 0 } else if(incorrectGuess >= 0 && incorrectGuess <= 5){ return smallGuess[incorrectGuess] } else if(incorrectGuess > 5 ){ return smallGuess[5] incorrectGuess = 5 } } else if(cb.settings.incorrectGuesses == '9'){ if(incorrectGuess < 0){ return bigGuess[0] } else if(incorrectGuess >= 0 && incorrectGuess <= 9){ return bigGuess[incorrectGuess] } else if(incorrectGuess > 9 ){ return smallGuess[9] incorrectGuess = 9 } } }; 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() cb.drawPanel() }; function updateLetters(guess){ letters.splice(letters.indexOf(guess),1) rowTwo = letters.join(" "); cb.drawPanel() } function userWin(){ var str1 = hidden.toString() var str2 = hangman.toString() forPanel = hidden.join("") if(str1 == str2){ roundOver = true winsTippers++ } if(winsTippers < cb.settings.roundsTotal && roundOver == true){ roundOverWinNotify() cb.setTimeout(newRoundNotify,3000) cb.drawPanel() } else if (winsTippers == cb.settings.roundsTotal){ gameEnd() } } function init(){ gameOver = false; var startWord = cb.settings.word || ""; currentWord = startWord.trim().toUpperCase(); cb.changeRoomSubject("We're playing hangman! First to " + cb.settings.roundsTotal + " wins. Prize: " + cb.settings.tipperPrize + ". " + cb.settings.hashtags) newBoard(); rules("") roundGuesses() if(cb.settings.cheaters == 'Yes'){ cheatersTemp = true } }; init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.