1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Guest, PO has ceased our separate tiering and adopted Smogon tiers for SM. More information and updates here.

    Dismiss Notice

[Server Scripting] Plugin - Hangman Game

Discussion in 'Server and Client Scripting' started by IceKirby, Sep 21, 2012.

  1. IceKirby

    IceKirby A.K.A. RiceKirby

    Joined:
    Apr 26, 2011
    Messages:
    2,176
    Likes Received:
    635
    PO Trainer Name:
    RiceKirby
    A simple plugin game I made when I was bored. Someone defines a word and a hint, other players must guess the word.

    Link to code here

    Code (text):
    1. /*jshint noarg:true, noempty:true, eqeqeq:true, bitwise:true, undef:true, curly:true, browser:true, indent:4, maxerr:50 */
    2. /*global sys:true, sendChanAll:true, sendChanHtmlAll:true, module:true, SESSION:true */
    3. module.exports = function () {
    4.     var hangman = this;
    5.     var hangchan;
    6.  
    7.     var defaultMaster = "RiceKirby";
    8.     var defaultChannel = "Hangman Game";
    9.     var minBodyParts = 5;
    10.     var winnerDelay = 60;
    11.     var answerDelay = 10;
    12.  
    13.     var host;
    14.     var hostName;
    15.     var winner;
    16.     var nextGame;
    17.  
    18.     var word;
    19.     var currentWord = [];
    20.     var usedLetters = [];
    21.     var hint = "";
    22.     var parts;
    23.  
    24.     var points;
    25.     var misses;
    26.  
    27.     this.guessCharacter = function (src, commandData) {
    28.         if (sys.ip(src) === host) {
    29.             sys.sendMessage(src, "±Game: You started the game, so you can't answer!", hangchan);
    30.             return;
    31.         }
    32.         if (!word) {
    33.             sys.sendMessage(src, "±Game: No game is running!", hangchan);
    34.             return;
    35.         }
    36.         var now = (new Date()).getTime();
    37.         if (now < SESSION.users(src).hangmanTime) {
    38.             sys.sendMessage(src, "±Game: You need to wait for another " + (Math.floor((SESSION.users(src).hangmanTime - now) / 1000) + 1) + " seconds before submitting another guess!", hangchan);
    39.             return;
    40.         }
    41.         var letter = commandData.toLowerCase();
    42.         if (letter.length > 1) {
    43.             sys.sendMessage(src, "±Game: This is not a valid answer!", hangchan);
    44.             return;
    45.         }
    46.         if ("abcdefghijklmnopqrstuvwxyz".indexOf(letter) === -1) {
    47.             sys.sendMessage(src, "±Game: This is not a valid answer!", hangchan);
    48.             return;
    49.         }
    50.         if (usedLetters.indexOf(letter) >= 0) {
    51.             sys.sendMessage(src, "±Game: This letter was already used!", hangchan);
    52.             return;
    53.         }
    54.  
    55.         if (!points[sys.name(src)]) {
    56.             points[sys.name(src)] = 0;
    57.         }
    58.  
    59.         var p = 0, correct = false, e;
    60.         if (word.indexOf(letter) >= 0) {
    61.             correct = true;
    62.             for (e = 0; e < word.length; e++) {
    63.                 if (word[e].toLowerCase() === letter) {
    64.                     currentWord[e] = letter.toUpperCase();
    65.                     ++p;
    66.                 }
    67.             }
    68.         }
    69.  
    70.         usedLetters.push(commandData.toLowerCase());
    71.         sendChanHtmlAll(" ", hangchan);
    72.         sendChanHtmlAll("<font color='red'><timestamp/> <b>" + sys.name(src) + "</b> guessed <b>" + letter.toUpperCase() + "</b> and got it " + (correct ? "right":"wrong") + "!. <b>Current Word</b>: " + currentWord.join(" ") + "</font>", hangchan);
    73.  
    74.         if (currentWord.indexOf("_") === -1) {
    75.             this.applyPoints(src, p + 2);
    76.             sendChanAll("*** ************************************************************ ***", hangchan);
    77.             sendChanAll("±Game: " + sys.name(src) + " completed the word '" + currentWord.join("") + "'!", hangchan);
    78.             sendChanAll("±Game: " + sys.name(src) + " received " + p + " point(s)!", hangchan);
    79.             this.countPoints();
    80.             sendChanAll("*** ************************************************************ ***", hangchan);
    81.             sendChanHtmlAll(" ", hangchan);
    82.         } else {
    83.             if (!correct) {
    84.                 this.addMiss(src);
    85.                 parts--;
    86.             }
    87.             if (parts > 0) {
    88.                 sendChanHtmlAll("<font color='red'><timestamp/> [Hint: " + hint + "]  [Letters used: " +  usedLetters.map(function (x) { return x.toUpperCase(); }).join(", ") + "]  [Chances left: " + parts + "] </font>", hangchan);
    89.                 sendChanAll("±Game: " + sys.name(src) + " received " + p + " point(s)!", hangchan);
    90.                 sendChanHtmlAll(" ", hangchan);
    91.                 this.applyPoints(src, p);
    92.                 SESSION.users(src).hangmanTime = (new Date()).getTime() + answerDelay * 1000;
    93.             } else {
    94.                 sendChanAll("*** ************************************************************ ***", hangchan);
    95.                 sendChanAll("±Game: HANGED! No one guessed the word '" + word.toUpperCase() + "' correctly, so the host (" + hostName + ") has won this game!", hangchan);
    96.                 sendChanAll("*** ************************************************************ ***", hangchan);
    97.                 sendChanHtmlAll(" ", hangchan);
    98.                 this.setWinner(hostName);
    99.             }
    100.         }
    101.     };
    102.     this.submitAnswer = function (src, commandData) {
    103.         if (sys.ip(src) === host) {
    104.             sys.sendMessage(src, "±Game: You started the game, so you can't answer!", hangchan);
    105.             return;
    106.         }
    107.         if (!word) {
    108.             sys.sendMessage(src, "±Game: No game is running!", hangchan);
    109.             return;
    110.         }
    111.         var now = (new Date()).getTime();
    112.         if (now < SESSION.users(src).hangmanTime) {
    113.             sys.sendMessage(src, "±Game: You need to wait for another " + (Math.floor((SESSION.users(src).hangmanTime - now) / 1000) + 1) + " seconds before submitting another guess!", hangchan);
    114.             return;
    115.         }
    116.  
    117.         sendChanHtmlAll(" ", hangchan);
    118.         sendChanHtmlAll("<font color='red'><timestamp/> <b>" + sys.name(src) + "</b> answered <b>" + commandData + "</b>!</font>", hangchan);
    119.         if (commandData.toLowerCase() === word.toLowerCase()) {
    120.             var p = 0, e;
    121.             for (e in currentWord) {
    122.                 if (currentWord[e] === "_") {
    123.                     p++;
    124.                 }
    125.             }
    126.             p = Math.floor(p * 1.5) + (p === 1 ? 2 : 1);
    127.             this.applyPoints(src, p);
    128.  
    129.             sendChanAll("*** ************************************************************ ***", hangchan);
    130.             sendChanAll("±Game: " + sys.name(src) + " answered correctly and got " + p + " points!", hangchan);
    131.             this.countPoints();
    132.             sendChanAll("*** ************************************************************ ***", hangchan);
    133.             sendChanHtmlAll(" ", hangchan);
    134.         } else {
    135.             this.addMiss(src);
    136.             sendChanHtmlAll("<font color='red'><timestamp/> <b>" + sys.name(src) + "'</b>s answer was wrong! The game continues!</font>", hangchan);
    137.             sendChanHtmlAll(" ", hangchan);
    138.             SESSION.users(src).hangmanTime = (new Date()).getTime() + answerDelay * 2000;
    139.         }
    140.     };
    141.     this.startGame = function (src, commandData) {
    142.         if (word) {
    143.             sys.sendMessage(src, "±Game: A game is already running! You can start a new one once this game is over!", hangchan);
    144.             return;
    145.         }
    146.         if (winner && (new Date()).getTime() < nextGame && sys.name(src).toLowerCase() !== winner.toLowerCase()) {
    147.             sys.sendMessage(src, "±Game: Only the last winner can start a game! If the winner takes more than " + winnerDelay + " seconds, anyone can start a new game!", hangchan);
    148.             return;
    149.         }
    150.         var a = commandData.split(":")[0];
    151.         var h = commandData.split(":")[1];
    152.         var p = commandData.split(":")[2];
    153.  
    154.         if (!a) {
    155.             sys.sendMessage(src, "±Game: You need to choose a word!", hangchan);
    156.             return;
    157.         }
    158.         var validCharacters = "abcdefghijklmnopqrstuvwxyz", validAnswer = false, l;
    159.         for (l = 0; l < a.length; l++) {
    160.             if (validCharacters.indexOf(a[l].toLowerCase()) !== -1) {
    161.                 validAnswer = true;
    162.                 break;
    163.             }
    164.         }
    165.         if (!validAnswer) {
    166.             sys.sendMessage(src, "±Game: Answer must containt at least one valid letter (A-Z characters)!", hangchan);
    167.             return;
    168.         }
    169.         if (!h) {
    170.             sys.sendMessage(src, "±Game: You need to write a hint!", hangchan);
    171.             return;
    172.         }
    173.  
    174.         hint = h;
    175.         word = a.toLowerCase();
    176.         parts = (p && parseInt(p, 10) > 0) ? parseInt(p, 10) : minBodyParts;
    177.         parts = (parts < minBodyParts) ? minBodyParts : parts;
    178.         points = {};
    179.         misses = {};
    180.  
    181.         usedLetters = [];
    182.         currentWord = [];
    183.         var e;
    184.         for (e = 0; e < word.length; e++) {
    185.             if (word[e] === " ") {
    186.                 currentWord.push("-");
    187.             } else if (validCharacters.indexOf(word[e]) !== -1) {
    188.                 currentWord.push("_");
    189.             } else {
    190.                 currentWord.push(word[e].toUpperCase());
    191.             }
    192.         }
    193.  
    194.         host = sys.ip(src);
    195.         hostName = sys.name(src);
    196.  
    197.         sendChanHtmlAll(" ", hangchan);
    198.         sendChanAll("*** ************************************************************ ***", hangchan);
    199.         sendChanAll("±Game: " + sys.name(src) + " started a new game of Hangman!", hangchan);
    200.         sendChanAll("±Word: " + currentWord.join(" "), hangchan);
    201.         sendChanAll("±Hint: " + hint, hangchan);
    202.         sendChanAll("*** ************************************************************ ***", hangchan);
    203.         sendChanHtmlAll(" ", hangchan);
    204.     };
    205.     this.applyPoints = function (src, p) {
    206.         if (!points[sys.name(src)]) {
    207.             points[sys.name(src)] = 0;
    208.         }
    209.         points[sys.name(src)] += p;
    210.     };
    211.     this.addMiss = function (src) {
    212.         if (!misses[sys.name(src)]) {
    213.             misses[sys.name(src)] = 0;
    214.         }
    215.         misses[sys.name(src)] += 1;
    216.     };
    217.     this.countPoints = function () {
    218.         var maxPoints = 0, winners = [], w;
    219.         for (w in points) {
    220.             if (points[w] > maxPoints) {
    221.                 winners = [];
    222.                 maxPoints = points[w];
    223.             }
    224.             if (points[w] === maxPoints) {
    225.                 winners.push(w);
    226.             }
    227.         }
    228.         if (winners.length > 1) {
    229.             var m, miss = [], nomiss = [], minMiss = Number.MAX_VALUE;
    230.             for (m in winners) {
    231.                 var n = winners[m];
    232.                 if (n in misses) {
    233.                     if (misses[n] < minMiss) {
    234.                         miss = [];
    235.                         minMiss = misses[n];
    236.                     }
    237.                     miss.push(n);
    238.                 } else {
    239.                     nomiss.push(n);
    240.                 }
    241.             }
    242.             if (nomiss.length > 0) {
    243.                 if (nomiss.length === 1) {
    244.                     w = nomiss[0];
    245.                 } else {
    246.                     w = nomiss[0];
    247.                 }
    248.             } else {
    249.                 if (miss.length === 1) {
    250.                     w = miss[0];
    251.                 } else {
    252.                     w = miss[0];
    253.                 }
    254.             }
    255.         } else {
    256.             w = winners[0];
    257.         }
    258.         sendChanAll("±Game: " + w + " has won this game with " + maxPoints + " points!", hangchan);
    259.         var ranking = [], p;
    260.         for (p in points) {
    261.             ranking.push(p + " (" + points[p] + " points" + (p in misses ? ", " + misses[p] + " miss(es)" : "") + ")");
    262.         }
    263.         sendChanAll("±Results: " + ranking.join(", "), hangchan);
    264.         this.setWinner(w);
    265.     };
    266.     this.setWinner = function (name) {
    267.         word = undefined;
    268.         winner = name;
    269.         nextGame = (new Date()).getTime() + winnerDelay * 1000;
    270.         this.resetTimers();
    271.     };
    272.     this.endGame = function (src) {
    273.         if (word) {
    274.             sendChanHtmlAll(" ", hangchan);
    275.             sendChanAll("*** ************************************************************ ***", hangchan);
    276.             sendChanAll("±Game: " + sys.name(src) + " stopped the game!", hangchan);
    277.             sendChanAll("*** ************************************************************ ***", hangchan);
    278.             sendChanHtmlAll(" ", hangchan);
    279.             word = undefined;
    280.             winner = undefined;
    281.             this.resetTimers();
    282.         } else {
    283.             sys.sendMessage(src, "±Game: No game is running!", hangchan);
    284.         }
    285.     };
    286.     this.resetTimers = function () {
    287.         var p, players = sys.playersOfChannel(hangchan), now = (new Date()).getTime();
    288.         for (p in players) {
    289.             SESSION.users(players[p]).hangmanTime = now;
    290.         }
    291.     };
    292.     this.viewGame = function (src) {
    293.         if (!word) {
    294.             sys.sendMessage(src, "±Game: No game is running!", hangchan);
    295.             return;
    296.         }
    297.         sys.sendHtmlMessage(src, " ", hangchan);
    298.         sys.sendHtmlMessage(src, "<font color='red'><b>Current Word</b>: " + currentWord.join(" ") + "</font>", hangchan);
    299.         sys.sendHtmlMessage(src, "<font color='red'>[Hint: " + hint + "]  [Letters used: " +  usedLetters.map(function (x) { return x.toUpperCase(); }).join(", ") + "]  [Chances left: " + parts + "] </font>", hangchan);
    300.         sys.sendHtmlMessage(src, " ", hangchan);
    301.     };
    302.     this.showHelp = function (src) {
    303.         var x, help = [
    304.             "",
    305.             "*** *********************************************************************** ***",
    306.             "±Goal: Your goal is to guess a word on a letter by letter basis. A hint and the number of characters will be provided as a help.",
    307.             "±Goal: Whenever someone guess a letter correctly, that letter will be filled in the word.",
    308.             "*** *********************************************************************** ***",
    309.             "±Actions: To guess a character, type /g [character]. For example, to guess F, type /g F.",
    310.             "±Actions: If you think you already know the answer, you can use /a [answer] to submit a full answer.",
    311.             "±Actions: If you guess wrong too many times, the host wins!",
    312.             "*** *********************************************************************** ***",
    313.             "±Hosting: To host a game, type /start Answer:Hint. The host can't guess or answer during their own game.",
    314.             "±Hosting: You can also type /start Answer:Hint:Number to set how many wrong guesses must be made before you win (minimum of " + minBodyParts + ").",
    315.             "±Hosting: The winner of the previous game have priority for hosting the next game. If the winner doesn't start a new game within " + winnerDelay + " seconds, anyone can host.",
    316.             "*** *********************************************************************** ***",
    317.             "±Rules: Server rules apply in this channel too.",
    318.             "*** *********************************************************************** ***",
    319.             ""
    320.         ];
    321.         for (x in help) {
    322.             sys.sendMessage(src, help[x], hangchan);
    323.         }
    324.     };
    325.     this.configGame = function (src, commandData) {
    326.         var param = commandData.split(":")[0];
    327.         var val = commandData.split(":")[1];
    328.         if (!param || !val) {
    329.             sys.sendHtmlMessage(src, " ", hangchan);
    330.             sys.sendMessage(src, "±How to use /config: Use /config [parameter]:[value]. Possible parameters are:", hangchan);
    331.             sys.sendMessage(src, "chances: Set minimum number of chances for any game (currently set to " + minBodyParts + " chances). ", hangchan);
    332.             sys.sendMessage(src, "delay: Set delay (in seconds) between each guess. Full answers take double the time (currently set to " + answerDelay + " seconds). ", hangchan);
    333.             sys.sendMessage(src, "winner: Set how many seconds the winner of a game have to start a new one before anyone can start (currently set to " + winnerDelay + " seconds). ", hangchan);
    334.             sys.sendHtmlMessage(src, " ", hangchan);
    335.             return;
    336.         }
    337.         if (parseInt(val, 10) <= 0) {
    338.             sys.sendMessage(src, "±Game: Value must be a valid number!", hangchan);
    339.             return;
    340.         }
    341.         val = parseInt(val, 10);
    342.  
    343.         switch (param.toLowerCase()) {
    344.         case "chances":
    345.             minBodyParts = val;
    346.             sys.sendMessage(src, "±Game: Minimum chances set to " + val + ".", hangchan);
    347.             break;
    348.         case "delay":
    349.             answerDelay = val;
    350.             sys.sendMessage(src, "±Game: Delay between guesses set to " + val + " second(s).", hangchan);
    351.             break;
    352.         case "winner":
    353.             winnerDelay = val;
    354.             sys.sendMessage(src, "±Game: Winner will have " + val + " second(s) to start a new game.", hangchan);
    355.             break;
    356.         }
    357.     };
    358.     this.commands = {
    359.         user: {
    360.             help: [this.showHelp, "For a how-to-play guide"],
    361.             g: [this.guessCharacter, "To guess a letter."],
    362.             a: [this.submitAnswer, "To answer the question."],
    363.             view: [this.viewGame, "To view the current game's state."],
    364.             start: [this.startGame, "To start a new game of Hangman."]
    365.         },
    366.         op: {
    367.             end: [this.endGame, "To stop a game."]
    368.         },
    369.         admin: {
    370.             config: [this.configGame, "To change the answer delay time and other settings."]
    371.         }
    372.     };
    373.     this.handleCommand = function (src, message, channel) {
    374.         if (channel !== hangchan) {
    375.             return;
    376.         }
    377.         try {
    378.             var command;
    379.             var commandData = '*';
    380.             var pos = message.indexOf(' ');
    381.             if (pos !== -1) {
    382.                 command = message.substring(0, pos).toLowerCase();
    383.                 commandData = message.substr(pos + 1);
    384.             } else {
    385.                 command = message.substr(0).toLowerCase();
    386.             }
    387.  
    388.             if (command in hangman.commands.user) {
    389.                 hangman.commands.user[command][0].call(hangman, src, commandData);
    390.                 return true;
    391.             }
    392.  
    393.             if (sys.ip(src) === host && command === "end") {
    394.                 hangman.commands.op[command][0].call(hangman, src, commandData);
    395.                 return true;
    396.             }
    397.  
    398.             if (hangman.authLevel(src) < 1) {
    399.                 throw ("No valid command");
    400.             }
    401.  
    402.             if (command in hangman.commands.op) {
    403.                 hangman.commands.op[command][0].call(hangman, src, commandData);
    404.                 return true;
    405.             }
    406.  
    407.             if (hangman.authLevel(src) < 2) {
    408.                 throw ("No valid command");
    409.             }
    410.  
    411.             if (command in hangman.commands.admin) {
    412.                 hangman.commands.admin[command][0].call(hangman, src, commandData);
    413.                 return true;
    414.             }
    415.  
    416.             throw ("No valid command");
    417.         } catch (e) {
    418.             if (e !== "No valid command") {
    419.                 sendChanAll("Error on hangman command: " + e, hangchan);
    420.                 return true;
    421.             }
    422.         }
    423.     };
    424.     this.authLevel = function (src) {
    425.         if (sys.auth(src) > 0) {
    426.             return 3;
    427.         } else if (SESSION.channels(hangchan).masters.indexOf(sys.name(src).toLowerCase()) !== -1) {
    428.             return 3;
    429.         } else if (SESSION.channels(hangchan).admins.indexOf(sys.name(src).toLowerCase()) !== -1) {
    430.             return 2;
    431.         } else if (SESSION.channels(hangchan).operators.indexOf(sys.name(src).toLowerCase()) !== -1) {
    432.             return 1;
    433.         }
    434.         return 0;
    435.     };
    436.     this.init = function () {
    437.         var name = defaultChannel;
    438.         if (sys.existChannel(name)) {
    439.             hangchan = sys.channelId(name);
    440.         } else {
    441.             hangchan = sys.createChannel(name);
    442.         }
    443.         SESSION.global().channelManager.restoreSettings(hangchan);
    444.         SESSION.channels(hangchan).perm = true;
    445.         SESSION.channels(hangchan).master = defaultMaster;
    446.     };
    447.     this.beforeChannelJoin = function (src, channel) {
    448.         if (channel !== hangchan) {
    449.             return false;
    450.         }
    451.         if (SESSION.users(src).hangmanTime === undefined) {
    452.             SESSION.users(src).hangmanTime = (new Date()).getTime();
    453.         }
    454.         return false;
    455.     };
    456.     return {
    457.         init: hangman.init,
    458.         handleCommand: hangman.handleCommand,
    459.         beforeChannelJoin: hangman.beforeChannelJoin
    460.     };
    461. }();
    [/HIDE]

    Probably lots of stuff could be optimized, especially the stuff related to the modules/exports/etc (most of that I simply used what I saw in Mafia/Evolution Game).
    Also, I used channel Op/Admin to restrict access to some commands, I hope that's not a problem.

    Feel free to use it, suggest stuff, point errors, bash my coding abilities or suggest a new tie-breaking parameter.
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    I'll most likely add this to the main server when I get chance. My only real worry is that it might go down the path of Evo Game :< (Though to be fair, imo evo game sucks :x )
     
  3. Shiny Rayquaza

    Shiny Rayquaza Your nightmare!

    Joined:
    Jan 20, 2012
    Messages:
    398
    Likes Received:
    0
    A hangman game? Yay, that sounds awesome (hopefully It will be better than Evo Game)
     
  4. IceKirby

    IceKirby A.K.A. RiceKirby

    Joined:
    Apr 26, 2011
    Messages:
    2,176
    Likes Received:
    635
    PO Trainer Name:
    RiceKirby
    I don't know what "Go down the path of Evo game" means, but at least Hangman works even with only 2 players, and it's not as spammy (and cauth won't need to win the game to actually use their commands). In any case, it's only supposed to be a simple pastime game.
     
  5. sulcata

    sulcata stéphane curry best waifu Forum Moderator Server Administrator Forum Moderator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    I would suggest that you sanitize your strings as somebody messed up the game when they entered angle brackets :x
     
  6. IceKirby

    IceKirby A.K.A. RiceKirby

    Joined:
    Apr 26, 2011
    Messages:
    2,176
    Likes Received:
    635
    PO Trainer Name:
    RiceKirby
    I will work on that. My plan is to only allow A-Z characters, numbers, space and apostrophe, but only A-Z will be available for guesses (all others will be automatically filled). Would that be good enough?
     
  7. Arceus

    Arceus Member

    Joined:
    May 20, 2010
    Messages:
    238
    Likes Received:
    0
    If you used sys.sendAll instead of sys.sendHtmlAll it would work fine also.
     
  8. Desolate

    Desolate Member

    Joined:
    Feb 26, 2012
    Messages:
    84
    Likes Received:
    0
    You can use the JavaScript match() method to sanitize partially invalid strings.

    For example, if the variable guess contained the guess, you could use the following to only match valid characters (A-Z, a-z, 0-9, white space, and apostrophe):
    Code (text):
    1. var guess = 'an inval!d guess';
    2. guess = guess.match(/^[A-Za-z0-9\s']*$/);
    guess would then be: an invald guess
     
  9. Morty.

    Morty. Learning Scripting

    Joined:
    Jan 12, 2014
    Messages:
    32
    Likes Received:
    0
    PO Trainer Name:
    Morty
    how can I addapt this game to my current scripts? q.q
     
  10. Yttrium

    Yttrium Well-Known Member Developer Developer

    Joined:
    Sep 29, 2010
    Messages:
    619
    Likes Received:
    283
    PO Trainer Name:
    Yttrium
    I have no idea where to put this, but it's a suggestion for the hangman script sooo maybe if someone still reads these threads

    Since Pokemon is such a common hangman theme, you could add something like
    Code (text):
    1.  
    2. if (hint.toLowerCase() == "pokemon" && sys.pokeNum(word) === undefined) {
    3.     hangbot.sendMessage(src, "You started a game with the hint 'Pokemon' but '" + word.toUpperCase() + "' is not a Pokemon! Please check for typos.", hangchan);
    4. }
    5.  
    to warn someone if they make a typo. idk how useful this could be, but it's a thought, albeit a small one.
     
    Nightfall Alicorn and IceKirby like this.
  11. Crystal Moogle

    Crystal Moogle Ayaya~

    Joined:
    Jul 19, 2010
    Messages:
    3,204
    Likes Received:
    530
    PO Trainer Name:
    Hanako
    You could always make a pull request :D
    I'd add "pokémon" too, but other than that, I don't see an issue. Outside of maybe disagreeing with forme names, but I don't think I've ever seen a game with one.
     
    Nightfall Alicorn likes this.
  12. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    I let the other hangman staff know and see what they think of it. Personally I think it might be handy to have.
     
  13. Strudels

    Strudels ・◡・ Super Moderator Server Administrator Super Moderator Server Administrator

    Joined:
    Oct 31, 2013
    Messages:
    273
    Likes Received:
    1,058
    PO Trainer Name:
    Ripper Roo
    well some people do "keldeo-resolute" over "keldeo-r" etc which i guess are still valid games, but those are really rare and it doesnt actually restrict them. this isnt really a bad thing to have
     
    Nightfall Alicorn likes this.
  14. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Maybe we could add something like this for added checks.
    Code (JavaScript):
    1.  
    2. if ((hint.toLowerCase() === "pokemon" || hint.toLowerCase() === "pokémon") && (sys.pokeNum(word) === undefined && ["keldeo-resolute"].indexOf(word) === -1)) {
    3.     hangbot.sendMessage(src, "You started a game with the hint 'Pokemon' but '" + word.toUpperCase() + "' is not a Pokemon! Please check for typos.", hangchan);
    4. }
    5.  
    I've added "pokémon" with the "é" since some use it. Also an array check for entries sys.pokeNum may not have.
     
  15. Strudels

    Strudels ・◡・ Super Moderator Server Administrator Super Moderator Server Administrator

    Joined:
    Oct 31, 2013
    Messages:
    273
    Likes Received:
    1,058
    PO Trainer Name:
    Ripper Roo
    well if you're really up to adding in shaymin-sky, tornadus-therian etc then sure

    but it's not a big deal honestly :v