diff plugins/hangman/hangman.js @ 272:8fb6bd57878c

Plugin hangman: allow usage in query, closes #424
author David Demelier <markand@malikania.fr>
date Wed, 28 Sep 2016 13:00:38 +0200
parents 6635b9187d71
children c6fbb6e0e06d
line wrap: on
line diff
--- a/plugins/hangman/hangman.js	Fri Sep 23 18:20:08 2016 +0200
+++ b/plugins/hangman/hangman.js	Wed Sep 28 13:00:38 2016 +0200
@@ -234,7 +234,7 @@
     var status = "found";
 
     // Check for collaborative mode.
-    if (Plugin.config["collaborative"] === "true") {
+    if (Plugin.config["collaborative"] === "true" && !this.query) {
         if (this.last !== undefined && this.last === nickname)
             return "wrong-player";
 
@@ -355,6 +355,8 @@
         kw.word = game.formatWord();
         server.message(channel, Util.format(Plugin.format["start"], kw));
     }
+
+    return game;
 }
 
 function onMessage(server, origin, channel, message)
@@ -367,3 +369,13 @@
     if (message.length === 1 && Unicode.isLetter(message.charCodeAt(0)))
         propose(server, channel, origin, game, message.charCodeAt(0));
 }
+
+function onQueryCommand(server, origin, message)
+{
+    onCommand(server, origin, Util.splituser(origin), message).query = true;
+}
+
+function onQuery(server, origin, message)
+{
+    onMessage(server, origin, Util.splituser(origin), message);
+}