Apps Home
|
Create an App
Hawt Hangman
Author:
hawt_girl
Description
Source Code
Launch App
Current Users
Created by:
Hawt_Girl
cb.settings_choices = [ {name: 'admins', label: '[GENERAL SETTINGS] --------- Users who can access app commands', type: 'str', defaultValue: 'Hawt_girl', required: false}, {name: 'words', label: 'Words/phrases (separated by commas)', type: 'str', defaultValue: 'xbox, destiny, horse, reliable, spanking, thong, pokies, deathnote, shower, camgirl, drinks, boobies, lactation, party, cellphone, tippers, jackpot, vibrator, dildo, banned, titties, squirt, pancake, turtle, texas', required: false}, {name: 'mute', label: 'Auto-hide messages that give away the answer?', type: 'choice', choice1: 'Yes', choice2: 'No'}, {name: 'timer', label: 'Show the board after how many seconds without guesses?', type: 'int', defaultValue: 120, minValue: 60}, {name: 'goals', label: '[GOAL SETTINGS] --------- Goal list (points: text)', type: 'str', defaultValue: '1: topless 3 minutes, 2: Spin prize wheel, 3: top off, 4: spin prize wheel, 5: spin prize wheel, 6: bottoms off 3 minutes, 7:spin prize wheel, 8: bottoms off, 9: 3 minute vibrator tease, 10: Cum Show!', required: false}, {name: 'penalty', label: 'Reduce score if a dude is hanged?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'guessCost', label: '[VIEWER ACTIONS] --------- Cost to guess a letter', type: 'int', minValue: 1, defaultValue: 10}, {name: 'guessWordCost', label: 'Cost to guess the word', type: 'int', minValue: 1, defaultValue: 50}, {name: 'pardonCost', label: 'Cost to pardon (instawin)', type: 'int', minValue: 1, defaultValue: 105}, {name: 'flexiGuess', label: 'Mark a word guess as right if the answer is CONTAINED in the text rather than requiring an exact match', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'fg', label: '[COSMETICS] --------- Foreground color', type: 'str', defaultValue: '#990000', required: false}, {name: 'bg', label: 'Background color', type: 'str', defaultValue: '#FFFFFF', required: false}, {name: 'wt', label: 'Font weight', type: 'choice', choice1: 'bold', choice2: 'normal', defaultValue: 'bold'}, {name: 'subj', label: 'Room subject', type: 'str', defaultValue: 'We are playing #hangman! Type /b to see the board! #milk #milf #bigass #dice', required: false}, ]; /********** ------------ SETUP ------------ **********/ var cbs = JSON.parse(JSON.stringify(cb.settings)); var divider = '\u2013'.repeat(30); var tipCount = 0; if (cbs.subj && cbs.subj.trim().length > 0) cb.changeRoomSubject(cbs.subj); say(' :hawtwelcome1'); say(' :hawtwelcome2'); say(' :hawtwelcome3'); say(' :hawtwelcome4'); say(' :cdn_hmlogo'); say('Type /help for all commands!\nQuestions? Problems? Email codeanon@protonmail.com!', cb.room_slug); var timer = {}; timer.secs = cbs.timer + 1; timer.reset = () => timer.secs = cbs.timer + 1; timer.tick = function () { timer.secs--; cb.log(timer.secs); if (timer.secs === 0) { timer.reset(); if (currentWord) { currentWord.showAll(); showRules(); } } cb.setTimeout(timer.tick, 1000); }; var score = 0; var goals = function () { var output = []; if (cbs.goals) { cbs.goals.split(',').forEach(function (item) { var goal = item.split(':'); var num = Number(goal[0]); var val = goal[1]; if (val && num !== NaN) output.push({num: num, val: capitalizeFirstLetter(val.trim())}); }); } output.sort((a,b) => a.num - b.num); return output; }(); var words = function () { if (cbs.words && cbs.words.length > 0) { var sanitized = cbs.words.toUpperCase().replace(/[^A-Z\s,]/g, '').replace(/\s+/g,' '); while (/,\s*,/.test(sanitized)) sanitized = sanitized.replace(/,\s*,/g, ','); var array = sanitized.split(',').map((elm) => elm.trim()); for (var i = 0; i < array.length; i++) { var z = array[i].trim(); if (z === '' || z === null || z === void 0) { array.splice(i, 1); i--; } } var currentIndex = array.length, temporaryValue, randomIndex; while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; }; return []; }(); var currentWord = words[0] ? makeWord(words.shift()) : void 0; function makeWord(input) { var word = []; word.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'; word.progress = 1; word.showLetters = () => word.letters; word.showPic = () => ' :cdnhm' + word.progress; word.isSolved = false; word.guessCost = cbs.guessWordCost; word.showWord = function () { var str = ''; word.forEach((letter) => str += (!letter.guessed ? '_' : letter.letter.replace(' ','\u2007'))); return '[' + wordOrPhrase(word.rawWord).toUpperCase() + '] \u2007 ' + str.split('').join(' '); }; word.showAll = function (user) { var output = [divider, word.showWord(), 'Tip ' + cbs.pardonCost + ' to insta-win this ' + wordOrPhrase(word.rawWord) + '!', word.showPic(), word.showLetters(), 'SCORE: ' + score + (goals[0] ? ' (' + goals[0].val + ' at ' + goals[0].num + ')' : ''), divider ]; say(output.join('\n'), user); }; word.solve = function () { word.forEach((letter) => letter.guessed = true); word.isSolved = true; }; input.split('').forEach((l) => word.push({letter: l, guessed: l === ' '})); word.rawWord = function () { var str = ''; word.forEach((letter) => str += letter.letter); return str; }(); word.showAll(); return word; } /********** ------------ PANEL ------------ **********/ cb.onDrawPanel(function () { return { 'template': '3_rows_11_22_32', 'row1_label': currentWord ? currentWord.showWord().trim().replace(new RegExp('\u2007', 'g'), '\u2007\u2007\u2007\u2007') : '', 'row2_label': 'SCORE', 'row2_value': score + ' (' + tipCount + ' tks)', 'row3_label': 'GOAL', 'row3_value': goals[0] ? goals[0].val + ' @ ' + goals[0].num : '' }; }); /********** ------------ MESSAGES ------------ **********/ var commanders = cbs.admins ? cbs.admins.split(',').map((elm) => elm.trim().toLowerCase()) : []; var isCommander = (user) => user === cb.room_slug || commanders.includes(user); cb.onMessage(function (msg) { msg.m = msg.m.trim(); if (msg.m.charAt(0) === '/') { msg['X-Spam'] = true; if (isCommander(msg.user)) cmd(msg.m.slice(1), msg.user); if (msg.m === '/rules' || msg.m === '/b') { showRules(msg.user); if (currentWord) currentWord.showAll(msg.user); } } else if (cbs.mute === 'Yes' && messageGivesHint(msg.m)) { msg['X-Spam'] = true; cb.log('Hidden.'); } return msg; }); function messageGivesHint(text) { if (currentWord) { var exp = new RegExp('\\b' + currentWord.rawWord + 's?\\b','i'); return exp.test(text); } return false; } cb.onEnter(function (u) { if (currentWord) { say(' :cdn_hmlogo', u.user); currentWord.showAll(u.user); showRules(u.user); } }); function cmd(str, user) { var text = str.split(' '); switch(text[0]) { case 'h': case 'help': showHelp(user); break; case 's': case 'a': case 'answer': currentWord ? say('*** The answer is: ' + currentWord.rawWord + ' ***', user) : say('*** No word currently set! ***', user); break; case '#': if (!text[1]) break; evaluate(text.slice(1).join(' '), user); break; case 'lg': case 'hmg': if (!text[1]) break; doLetterGuess(text.slice(1).join(' '), user); timer.reset(); break; case 'wg': case 'hmw': if (!text[1]) break; doWordGuess(text.slice(1).join(' '), 'The Invisible Mod'); timer.reset(); break; case 'add': case 'word': if (!text[1]) break; var word = text.slice(1).join(' ').toUpperCase().replace(/[^A-Z\s,]/g, '').replace(/\s+/g,' '); if (word.length > 0) { if (currentWord) { words.push(word); say('"' + word + '" has been added to the queue.', user); } else { currentWord = makeWord(word); showRules(); } } break; case 'addNow': case 'wordNow': if (!text[1]) break; var word = text.slice(1).join(' ').toUpperCase().replace(/[^A-Z\s,]/g, '').replace(/\s+/g,' '); if (word.length > 0) { currentWord = makeWord(word); showRules(); } break; case 'addGoal': if (!text[1] || !text[2]) break; var num = Number(text[1]); var val = text.slice(2).join(' ').trim(); if (!isNaN(num) && num > score && val.length > 0) { var ind = goals.findIndex((elm) => elm.num === num); if (ind > -1) { goals[ind].val = capitalizeFirstLetter(val); } else { goals.push({num: num, val: capitalizeFirstLetter(val)}); goals.sort((a,b) => a.num - b.num); } say('Goals modified.', user); } break; case 'remGoal': if (!text[1]) break; var num = Number(text[1]); if (!isNaN(num)) { var ind = goals.findIndex((elm) => elm.num === num); if (ind > -1) { goals.splice(ind, 1); say('Goals modified.', user); } } break; case 'solve': if (currentWord) doPardon(); break; } cb.drawPanel(); } function showHelp(user) { var text = [' :cdn_hmlogo', '*********************', '/h or /help -- show this menu again', '/a or /answer -- tell me the answer to the current word/phrase', '/word [word or phrase] -- adds the word or phrase to the queue', '/wordNow [word or phrase] -- immediately sets the active word or phrase', '/addGoal [number] [text] -- adds/overwrites a goal at the specified score', '/remGoal [number] -- removes a goal at the specified number', '/solve -- instantly solves the current word and increases the score', '*********************', 'Questions? Problems? Email codeanon@protonmail.com!' ].join('\n'); say(text, user); } function evaluate(str, user) { try { var result = eval(str); var notice = 'INPUT: ' + str + '\nTYPE: ' + typeof result + '\nVALUE: '; result === void 0 ? notice += 'undefined' : notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007'); cb.setTimeout(() => {cb.sendNotice(newLines(notice), user, '', '#00CC00', '', '')}, 100); } catch (e) { cb.setTimeout(() => {cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', '')}, 100); } cb.drawPanel(); } /********** ------------ TIPS ------------ **********/ cb.onTip((tip) => doTip(tip)); function doTip(tip) { tipCount += tip.amount; if (currentWord && !currentWord.solved) { if (tip.amount === cbs.guessCost && tip.message && tip.message.length && currentWord) { timer.reset(); doLetterGuess(tip.message, tip.from_user); } else if (tip.amount === cbs.guessWordCost && tip.message.length > 0) { timer.reset(); doWordGuess(tip.message, tip.from_user); } else if (tip.amount === cbs.pardonCost && currentWord) { timer.reset(); doPardon(tip.from_user); } } cb.drawPanel(); cb.setTimeout(() => cb.drawPanel(), 3000); } function doPardon(user) { if (user) say(user + ' tipped ' + cbs.pardonCost + ' to pardon the dude!') currentWord.solve() checkStatus(); } function doWordGuess(message, user) { var guess = message.toUpperCase().replace(/[^A-Z\s]/g, ''); if (cbs.flexiGuess) { if ((new RegExp('\\b' + currentWord.rawWord + '\\b')).test(guess)) { say(user + ' guessed ' + currentWord.rawWord + '.'); currentWord.solve(); checkStatus(); } else { say(user + ' says: [' + message + '] That\'s not correct.'); currentWord.progress++; checkStatus(); } } else { if (guess === currentWord.rawWord) { say(user + ' guessed ' + currentWord.rawWord + '.'); currentWord.solve(); checkStatus(); } else { say(user + ' guessed ' + guess + '...and was wrong.'); currentWord.progress++; checkStatus(); } } } function doLetterGuess(message, user) { var sanitized = message.toUpperCase().replace(/[^A-Z]/g, ''); var letter = sanitized.charAt(0); if (sanitized.length > 1) cb.setTimeout(() => say('Psst -- if you\'re trying to guess the entire ' + wordOrPhrase(currentWord.rawWord) + ', you need to tip ' + cbs.guessWordCost + '!', user), 2000); if (currentWord && letter) { if (currentWord.letters.includes(letter)) { var found = 0; currentWord.letters = currentWord.letters.replace(letter, '_'); for (var i = 0; i < currentWord.length; i++) { if (currentWord[i].letter === letter) { currentWord[i].guessed = true; found++; } } say(user + ' guessed ' + letter + ' and found ' + found + ' match' + (found === 1 ? '.' : 'es.')); if (found === 0) currentWord.progress++; checkStatus(); } else { say('Somebody already guessed the letter ' + letter + '!'); } } } function isGuessed() { return currentWord.find((elm) => elm.guessed === false) ? false : true; } function nextWord() { if (words[0]) { say('New word in ten seconds...\n'); cb.setTimeout(() => { currentWord = makeWord(words.shift()) showRules(); cb.drawPanel(); }, 10000); } else { currentWord = void 0; say('Awaiting new word...'); } } function checkStatus () { if (currentWord) { if (isGuessed()) { score++; currentWord.solved = true; var output = ' :starx \n' + currentWord.showWord() + '\n[SCORE] \u2007 ' + score + '\n'; if (goals[0] && score >= goals[0].num) { output += '[REACHED] ' + String.fromCharCode(8199) + goals[0].val + '\n'; goals.shift(); } output += ' :starx'; say(output); nextWord(); cb.drawPanel(); } else if (currentWord.progress === 7) { currentWord.solved = true; say(divider + '\nYou killed him. You are a terrible, terrible person.\n' + (cbs.penalty === 'Yes' ? '[SCORE DECREASED]\n' : '') + ':cdnhm7\nThe answer was ' + currentWord.rawWord + '.\n' + divider); if (cbs.penalty === 'Yes' && score > 0) score--; nextWord(); cb.drawPanel(); } else { currentWord.showAll(); showRules(); cb.drawPanel(); } } } function wordOrPhrase(input) { word = input || function () {if (currentWord) return currentWord.rawWord}(); if (word) return /\s/.test(word) ? 'phrase' : 'word'; return 'word'; } function showRules(user) { if (currentWord) { say([cbs.guessCost + ' tks = guess a letter, ' + cbs.guessWordCost + ' tks = guess the entire ' + wordOrPhrase(currentWord.rawWord), 'Put your guess in the tip note!' ].join('\n'), user); } } /********** ------------ COMMUNICATION ------------ **********/ function say(text, user, fg, bg) { cb.sendNotice(newLines(text), user, (bg || cbs.bg), (fg || cbs.fg), cbs.wt, ''); } function newLines(input) { return '\u25A0 \u2007' + input.replace(new RegExp('\n', 'g'), '\n\u25A0 \u2007'); } /********** ------------ MISC ------------ **********/ function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } /********** ------------ INIT ------------ **********/ showRules(); timer.tick();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.