Apps Home
|
Create an App
Save and Restore Hangman Test
Author:
schooltobecoool
Description
Source Code
Launch App
Current Users
Created by:
Schooltobecoool
// startof CBSv2 module - not for re-compilation (function(a,h){function f(a){this.message=a}f.prototype=Error();f.prototype.name="InvalidCharacterError";a.btoa||(a.btoa=function(a){a=String(a);for(var g,b,m=0,d=h,q="";a.charAt(m|0)||(d="=",m%1);q+=d.charAt(63&g>>8-m%1*8)){b=a.charCodeAt(m+=.75);if(255<b)throw new f('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');g=g<<8|b}return q});a.atob||(a.atob=function(a){a=String(a).replace(/=+$/,"");if(1==a.length%4)throw new f('"atob" failed: The string to be decoded is not correctly encoded.'); for(var g=0,b,m,d=0,q="";m=a.charAt(d++);~m&&(b=g%4?64*b+m:m,g++%4)?q+=String.fromCharCode(255&b>>(-2*g&6)):0)m=h.indexOf(m);return q})})("undefined"===typeof exports?this:exports,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="); (function(a){var h=cb.onMessage,f=null,p=null,g,b="#"+(cb.settings.hasOwnProperty("slot")?cb.settings.slot:"")+"CBSv2",m=/^\/#[0-3]CBSv2\//;cb.onMessage=function(d){if("function"!==typeof d)throw new TypeError(d+" is not a function");h(function(h){var e=h.m.replace(/\s*/g,"").split("/"),k,r;3<e.length&&""===e[0]&&e[1]===b?(f&&p&&h.user===cb.room_slug&&(k=e[2],4===e.length?(e[3]="?",h.m=e.join("/")):6===e.length?((g||{}).hasOwnProperty(k)||(r=f(),g={},g[k]=a.btoa(a.unescape(a.encodeURIComponent(r))), r||cb.log("onSave returned no data.")),g.hasOwnProperty(k)&&(r=parseInt(e[3],10),k=g[k].slice(r,r+512),e[4]=k,e[5]=k.length,h.m=e.join("/"))):7===e.length&&("0"===e[3]&&(g={},g[k]=""),g.hasOwnProperty(k)&&(e[3]=g[k].length,e[6]=e[4].length,h.m=e.join("/"),e[4]?g[k]+=e[4]:(r=a.decodeURIComponent(a.escape(a.atob(g[k]))),p(r),cb.sendNotice("Previously Saved Data Restored.",cb.room_slug))))),h["X-Spam"]=!0):m.test(h.m)&&(h["X-Spam"]=!0);return d(h)});return d};cb.onRestore=function(a){if("function"!== typeof a)throw new TypeError(a+" is not a function");return p=a};cb.onSave=function(a){if("function"!==typeof a)throw new TypeError(a+" is not a function");return f=a};cb.onMessage(function(a){return a})})("undefined"===typeof exports?this:exports); // endof CBSv2 module - not for re-compilation var b={"Best Actor/Actress Oscar Winners":"Emil Jannings;Warner Baxter;George Arliss;Lionel Barrymore;Wallace Beery;Fredric March;Charles Laughton;Clark Gable;Victor McLaglen;Paul Muni;Spencer Tracy;Robert Donat;James Stewart;Gary Cooper;James Cagney;Paul Lukas;Bing Crosby;Ray Milland;Fredric March;Ronald Colman;Laurence Olivier;Broderick Crawford;Jos\u00e9 Ferrer;Humphrey Bogart;Gary Cooper;William Holden;Marlon Brando;Ernest Borgnine;Yul Brynner;Alec Guinness;David Niven;Charlton Heston;Burt Lancaster;Maximilian Schell;Gregory Peck;Sidney Poitier;Rex Harrison;Lee Marvin;Paul Scofield;Rod Steiger;Cliff Robertson;John Wayne;George C. Scott;Gene Hackman;Jack Lemmon;Art Carney;Jack Nicholson;Peter Finch;Richard Dreyfuss;Jon Voight;Dustin Hoffman;Robert De Niro;Henry Fonda;Ben Kingsley;Robert Duvall;F. Murray Abraham;William Hurt;Paul Newman;Michael Douglas;Dustin Hoffman;Daniel Day-Lewis;Jeremy Irons;Anthony Hopkins;Al Pacino;Tom Hanks;Nicolas Cage;Geoffrey Rush;Roberto Benigni;Kevin Spacey;Russell Crowe;Denzel Washington;Adrien Brody;Sean Penn;Jamie Foxx;Philip Seymour Hoffman;Forest Whitaker;Daniel Day-Lewis;Sean Penn;Jeff Bridges;Colin Firth;Jean Dujardin;Matthew McConaughey;Eddie Redmayne;Janet Gaynor;Mary Pickford;Norma Shearer;Marie Dressler;Helen Hayes;Katharine Hepburn;Claudette Colbert;Bette Davis;Luise Rainer;Vivien Leigh;Ginger Rogers;Joan Fontaine;Greer Garson;Jennifer Jones;Ingrid Bergman;Joan Crawford;Olivia de Havilland;Loretta Young;Jane Wyman;Judy Holliday;Shirley Booth;Audrey Hepburn;Grace Kelly;Anna Magnani;Joanne Woodward;Susan Hayward;Simone Signoret;Elizabeth Taylor;Sophia Loren;Anne Bancroft;Patricia Neal;Julie Andrews;Julie Christie;Elizabeth Taylor;Barbra Streisand;Maggie Smith;Glenda Jackson;Jane Fonda;Liza Minnelli;Glenda Jackson;Ellen Burstyn;Louise Fletcher;Faye Dunaway;Diane Keaton;Sally Field;Sissy Spacek;Meryl Streep;Shirley MacLaine;Geraldine Page;Marlee Matlin;Cher;Jodie Foster;Jessica Tandy;Kathy Bates;Emma Thompson;Holly Hunter;Jessica Lange;Susan Sarandon;Frances McDormand;Helen Hunt;Gwyneth Paltrow;Hilary Swank;Julia Roberts;Halle Berry;Nicole Kidman;Charlize Theron;Reese Witherspoon;Helen Mirren;Marion Cotillard;Kate Winslet;Sandra Bullock;Natalie Portman;Jennifer Lawrence;Cate Blanchett;Julianne Moore".split(";"), "Best Picture Oscar Winners":"Wings;The Broadway Melody;All Quiet on the Western Front;Cimarron;Grand Hotel;Cavalcade;It Happened One Night;Mutiny on the Bounty;The Great Ziegfeld;The Life of Emile Zola;You Can't Take It With You;Gone with the Wind;Rebecca;How Green Was My Valley;Mrs. Miniver;Casablanca;Going My Way;The Lost Weekend;The Best Years of Our Lives;Gentleman's Agreement;Hamlet;All the King's Men;All About Eve;An American in Paris;The Greatest Show on Earth;From Here to Eternity;On the Waterfront;Marty;Around the World in 80 Days;The Bridge on the River Kwai;Gigi;Ben-Hur;The Apartment;West Side Story;Lawrence of Arabia;Tom Jones;My Fair Lady;The Sound of Music;A Man for All Seasons;In the Heat of the Night;Oliver!;Midnight Cowboy;Patton;The French Connection;The Godfather;The Sting;The Godfather Part II;One Flew Over the Cuckoo's Nest;Rocky;Annie Hall;The Deer Hunter;Kramer vs. Kramer;Ordinary People;Chariots of Fire;Gandhi;Terms of Endearment;Amadeus;Out of Africa;Platoon;The Last Emperor;Rain Man;Driving Miss Daisy;Dances with Wolves;The Silence of the Lambs;Unforgiven;Schindler's List;Forrest Gump;Braveheart;The English Patient;Titanic;Shakespeare in Love;American Beauty;Gladiator;A Beautiful Mind;Chicago;The Lord of the Rings: The Return of the King;Million Dollar Baby;Crash;The Departed;No Country for Old Men;Slumdog Millionaire;The Hurt Locker;The King's Speech;The Artist;Argo;12 Years a Slave;Birdman or (The Unexpected Virtue of Ignorance)".split(";"), "US Presidents":"George Washington;John Adams;Thomas Jefferson;James Madison;James Monroe;John Quincy Adams;Andrew Jackson;Martin Van Buren;William Henry Harrison;John Tyler;James K. Polk;Zachary Taylor;Millard Fillmore;Franklin Pierce;James Buchanan;Abraham Lincoln;Andrew Johnson;Ulysses S. Grant;Rutherford B. Hayes;James A. Garfield;Chester A. Arthur;Grover Cleveland;Benjamin Harrison;William McKinley;Theodore Roosevelt;William Howard Taft;Woodrow Wilson;Warren G. Harding;Calvin Coolidge;Herbert Hoover;Franklin D. Roosevelt;Harry S. Truman;Dwight D. Eisenhower;John F. Kennedy;Lyndon B. Johnson;Richard Nixon;Gerald Ford;Jimmy Carter;Ronald Reagan;George H. W. Bush;Bill Clinton;George W. Bush;Barack Obama".split(";"), "US State Capitals":"Montgomery;Juneau;Phoenix;Little Rock;Sacramento;Denver;Hartford;Dover;Tallahassee;Atlanta;Honolulu;Boise;Springfield;Indianapolis;Des Moines;Topeka;Frankfort;Baton Rouge;Augusta;Annapolis;Boston;Lansing;Saint Paul;Jackson;Jefferson City;Helena;Lincoln;Carson City;Concord;Trenton;Santa Fe;Albany;Raleigh;Bismarck;Columbus;Oklahoma City;Salem;Harrisburg;Providence;Columbia;Pierre;Nashville;Austin;Salt Lake City;Montpelier;Richmond;Olympia;Charleston;Madison;Cheyenne".split(";")}, g="\n\n\n\n\n_____;\n|\n|\n|\n|\n|____; ____\n|\n|\n|\n|\n|____; ____\n|/\n|\n|\n|\n|____; ____\n|/ |\n|\n|\n|\n|____; ____\n|/ |\n| O\n|\n|\n|____; ____\n|/ |\n| O\n| |\n|\n|____; ____\n|/ |\n| O\n| /|\n|\n|____; ____\n|/ |\n| O\n| /|\\\n|\n|____; ____\n|/ |\n| O\n| /|\\\n| /\n|____; ____\n|/ |\n| O\n| /|\\\n| / \\\n|____".split(";"),h=cb.settings,k="",l={template:"3_rows_11_21_31",row1_value:"...",row2_value:"...",row3_value:"..."},n;function p(a){return a} function q(a,c,d){return d.indexOf(a)===c}function r(a){a=h[a]||"";var c=/[\u0081-\u00ff]{1,}\u0080[\u0081-\u00ff]{1,}/g;null!==a.match(c)&&(a=a.replace(c,""));return a}function t(a){var c=/\\u([0-9a-f]{4})/gi,d,e=[];for(a=a||"";null!==(d=c.exec(a));)e.push(d[1]);if(e.length)for(e=e.filter(q),c=0,d=e.length;c<d;c++)a=a.replace(new RegExp("\\\\u"+e[c],"gi"),String.fromCharCode(parseInt(e[c],16)));return a}cb.onDrawPanel(function(){return l}); function u(a){l.row2_value=a.split("").join("\u00a0");l.row3_value=h.winner?h.winner+" wins!":"Misses: "+h.misses.toLowerCase();cb.drawPanel()}function v(){var a="#hangman ",a=h.gameAnswer===h.gameShownAnswer?a+("- "+h.winner+" wins!"):1<g.length-h.misses.length?a+(h.price+" tkns per letter guess ["+h.misses.length+"/"+(g.length-1)+" misses]"):a+("- "+cb.room_slug+" wins!");k!==a&&(cb.changeRoomSubject(a),k=a)} function w(a){var c=a.m.toLowerCase(),d=a.user,e=d===cb.room_slug;if(a["X-Spam"])return a;if(e&&("!start"===c||"/start"===c))x(),a["X-Spam"]=!0;else if("!"===c[0]||"/"===c[0])cb.sendNotice("Hangman:"+(e&&!h.winner?" "+h.gameAnswer:"")+" type "+(e?'"/start" to start a new puzzle.':'"/tip '+h.price+' X" to guess letter "X".'),d,"#dc5500","#ffffff"),a["X-Spam"]=!0;return a} function x(){var a;for(a=h.answers.length;!a;)y(),a=h.answers.length;a=h.answers.splice(Math.floor(Math.random()*a),1)[0].toUpperCase();h.gameAnswer=a;a=h.gameAnswer.replace(/[A-Z]/g,"_");h.gameShownAnswer=a;h.misses="";h.winner="";n=[];l.row1_value=h.clue;u(h.gameShownAnswer);v();w({m:"/?",user:""})} function y(){function a(){return(b[h.clue]||[]).join("|").toUpperCase().split("|").filter(p).filter(q)}cb.log("rubzombie@gibbot: version: 08.01.1990_0 Hangman. Select one of the predefined question categories, or use the Custom category to set your own list of word puzzles for tippers to solve.");b.hasOwnProperty(h.cat)?(h.clue=h.cat,h.answers=a()):(h.clue=t(r("custom_cat")).trim(),h.answers=t(r("custom_puzzle")).trim().toUpperCase().split(/\s*\|\s*/).filter(p).filter(q));h.clue&&h.answers.length|| (h.clue=Object.keys(b)[Math.floor(Math.random()*Object.keys(b).length)],h.answers=a());x()} cb.settings_choices=[{label:"Custom Puzzle Category (e.g. 'Outstanding Drama Series Emmy Award Winners', see Description for details)",minLength:1,name:"custom_cat",required:!1,type:"str"},{label:"Custom Puzzle Answers (e.g. 'L.A. Law|Northern Exposure|Picket Fences|NYPD Blue|ER|Law & Order|The Practice|The West Wing|Lost|Twentyfour|The Sopranos|Mad Men|Homeland|Breaking Bad', see Description for details)",minLength:1,name:"custom_puzzle",required:!1,type:"str"},{defaultValue:25,label:"(Minimum) Tokens per Letter Guess", minValue:1,name:"price",type:"int"}];cb.settings_choices.unshift(new (Function.prototype.bind.apply(function(a,c,d,e){var f,m=arguments.length-4;if(1<m&&-1<Array.prototype.slice.call(arguments).indexOf(e,4))for(f=0;f<m;f++)this["choice"+(f+1)]=arguments[f+4];else for(m++,f=0;f<m;f++)this["choice"+(f+1)]=arguments[f+3];this.defaultValue=e;this.label=a;this.name=c;null===d||d||(this.required=!!d);this.type="choice"},[null,"Puzzle Category","cat",null].concat("CUSTOM",Object.keys(b)))));cb.onMessage(w); cb.onTip(function(a){var c=a.from_user,d=a.amount;a=(a.message||"").toUpperCase();var e="";if(h.winner)-1===n.indexOf(c)&&(cb.sendNotice("Sorry, the current game is over. But, thank you for tipping :)",c,"#dc5500","#ffffff","bold"),n.push(c));else if(/^[A-Z]$/.test(a))if(d<h.price)cb.sendNotice("Sorry, each letter guess requires at least "+h.price+" token"+(1===parseInt(h.price,10)?"":"s")+". But, thank you for tipping :)",c,"#dc5500","#ffffff","bold");else if(-1<h.misses.indexOf(a)||-1<h.gameShownAnswer.indexOf(a))cb.sendNotice("Sorry, "+ a+" has already been guessed. But, thank you for tipping :)",c,"#dc5500","#ffffff","bold");else{for(var d=h.gameShownAnswer,e=h.gameAnswer,f=0,f=e.indexOf(a);0<=f;)d=d.substr(0,f)+a+d.substr(f+1,d.length),f=e.indexOf(a,f+1);e=d;e!==h.gameShownAnswer?(h.gameShownAnswer=e,h.gameShownAnswer===h.gameAnswer&&(cb.sendNotice("Oh no! You lost. Time to take something off ;)",cb.room_slug,"#dc5500","#ffffff","bold"),h.winner=c),u(h.gameShownAnswer)):(h.misses+=a,1===g.length-h.misses.length&&(cb.sendNotice("Yay! You won. Time to put something back on ;)", cb.room_slug,"#dc5500","#ffffff","bold"),h.winner=cb.room_slug,h.gameShownAnswer=h.gameAnswer),u(h.gameShownAnswer),cb.chatNotice("Hangman: "+h.clue+"\n"+l.row2_value+"\n"+g[h.misses.length].replace(/ /g,"\u00a0")+"\n"+l.row2_value+"\n"+l.row3_value,""));v()}else a.toUpperCase().replace(/[^A-Z]/g,"")===h.gameAnswer.replace(/[^A-Z]/g,"")?cb.sendNotice("Sorry, only single letter guesses are allowed. But, thank you for tipping :)",c,"#dc5500","#ffffff","bold"):cb.sendNotice("Thank you for tipping :)", c,"#dc5500","#ffffff","bold")});cb.onSave(function(){return JSON.stringify(cb.settings)});cb.onRestore(function(a){var c=cb.settings,d=JSON.parse(a),e=["slot"];Object.keys(d).forEach(function(a){-1===e.indexOf(a)&&(c[a]=d[a])});l.row1_value=c.clue;u(c.gameShownAnswer);v();w({m:"/?",user:c.winner?cb.room_slug:""})});y();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.