# HG changeset patch # User David Demelier # Date 1463951906 -7200 # Node ID f554d131420844c3206b0ffcf6fb796cff22a317 # Parent 70da13c626de49617010590cac929071899b4c4a Plugin hangman: fix formats and invalid number of tries diff -r 70da13c626de -r f554d1314208 plugins/hangman/hangman.js --- a/plugins/hangman/hangman.js Fri May 20 13:28:20 2016 +0200 +++ b/plugins/hangman/hangman.js Sun May 22 23:18:26 2016 +0200 @@ -16,6 +16,14 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +// Plugin information. +info = { + author: "David Demelier ", + license: "ISC", + summary: "A hangman game for IRC", + version: "@IRCCD_VERSION@" +}; + // Modules. var Logger = Irccd.Logger; var File = Irccd.File; @@ -24,14 +32,6 @@ var Unicode = Irccd.Unicode var Util = Irccd.Util; -// Plugin information. -info = { - author: "David Demelier ", - license: "ISC", - summary: "A hangman game for IRC", - version: "@IRCCD_VERSION@" -}; - // Default options. Plugin.config["collaborative"] = "true"; @@ -125,7 +125,7 @@ { var path; - /* User specified file? */ + // User specified file? if (Plugin.config["file"]) path = Plugin.config["file"]; else @@ -155,7 +155,7 @@ */ Hangman.loadFormats = function () { - // --- DEPRECATED ------------------------------------------ + // --- DEPRECATED ------------------------------------------- // // This code will be removed. // @@ -182,7 +182,7 @@ */ Hangman.prototype.select = function () { - /* Reload the words if empty */ + // Reload the words if empty. if (!this.words || this.words.length === 0) this.words = Hangman.words.slice(0); @@ -191,7 +191,7 @@ this.word = this.words[i]; this.words.splice(i, 1); - /* Fill table */ + // Fill table. this.table = {}; for (var j = 0; j < this.word.length; ++j) @@ -233,7 +233,7 @@ { var status = "found"; - /* Check for collaborative mode */ + // Check for collaborative mode. if (Plugin.config["collaborative"] === "true") { if (this.last !== undefined && this.last === nickname) return "wrong-player"; @@ -260,11 +260,11 @@ status = "win"; } - /* Check if dead */ - if (this.tries < 0) + // Check if dead. + if (this.tries <= 0) status = "dead"; - /* Check if win */ + // Check if win. var win = true; for (var i = 0; i < this.word.length; ++i) { @@ -292,7 +292,7 @@ { var kw = { channel: channel, - command: server.info().commandChar, + command: server.info().commandChar + Plugin.info().name, nickname: Util.splituser(origin), origin: origin, plugin: Plugin.info().name, @@ -309,6 +309,7 @@ case "wrong-letter": case "wrong-player": case "wrong-word": + kw.word = proposition; case "asked": kw.letter = String.fromCharCode(proposition); server.message(channel, Util.format(Plugin.format[st], kw)); @@ -331,11 +332,11 @@ var game = Hangman.find(server, channel); var kw = { channel: channel, - command: server.info().commandChar, + command: server.info().commandChar + Plugin.info().name, nickname: Util.splituser(origin), origin: origin, plugin: Plugin.info().name, - server: server + server: server.toString() }; if (game) {