Mercurial > irccd
diff plugins/roulette/roulette.js @ 207:6635b9187d71
Irccd: switch to 4 spaces indent, #518
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 21 Jun 2016 20:52:17 +0200 |
parents | 52affa4ade71 |
children | c6fbb6e0e06d |
line wrap: on
line diff
--- a/plugins/roulette/roulette.js Tue Jun 21 12:36:46 2016 +0200 +++ b/plugins/roulette/roulette.js Tue Jun 21 20:52:17 2016 +0200 @@ -18,10 +18,10 @@ // Plugin information. info = { - author: "David Demelier <markand@malikania.fr>", - license: "ISC", - summary: "A russian roulette for IRC", - version: "@IRCCD_VERSION@" + author: "David Demelier <markand@malikania.fr>", + license: "ISC", + summary: "A russian roulette for IRC", + version: "@IRCCD_VERSION@" }; // Modules. @@ -34,16 +34,16 @@ * Formats for writing. */ Plugin.format = { - "lucky": "#{nickname}, you're lucky this time", - "shot": "HEADSHOT" + "lucky": "#{nickname}, you're lucky this time", + "shot": "HEADSHOT" }; function Gun(server, channel) { - this.server = server; - this.channel = channel; - this.index = 0; - this.bullet = Math.floor(Math.random() * 6); + this.server = server; + this.channel = channel; + this.index = 0; + this.bullet = Math.floor(Math.random() * 6); } /** @@ -60,7 +60,7 @@ */ Gun.find = function (server, channel) { - return Gun.map[server.toString() + '@' + channel]; + return Gun.map[server.toString() + '@' + channel]; } /** @@ -72,7 +72,7 @@ */ Gun.create = function (server, channel) { - return Gun.map[server.toString() + "@" + channel] = new Gun(server, channel); + return Gun.map[server.toString() + "@" + channel] = new Gun(server, channel); } /** @@ -82,7 +82,7 @@ */ Gun.remove = function (game) { - delete Gun.map[game.server + "@" + game.channel]; + delete Gun.map[game.server + "@" + game.channel]; } /** @@ -90,61 +90,61 @@ */ Gun.loadFormats = function () { - // --- DEPRECATED ------------------------------------------ - // - // This code will be removed. - // - // Since: 2.1.0 - // Until: 3.0.0 - // Reason: new [format] section replaces it. - // - // ---------------------------------------------------------- - for (var key in Plugin.format) { - var optname = "format-" + key; + // --- DEPRECATED ------------------------------------------ + // + // This code will be removed. + // + // Since: 2.1.0 + // Until: 3.0.0 + // Reason: new [format] section replaces it. + // + // ---------------------------------------------------------- + for (var key in Plugin.format) { + var optname = "format-" + key; - if (typeof (Plugin.config[optname]) !== "string") - continue; + if (typeof (Plugin.config[optname]) !== "string") + continue; - if (Plugin.config[optname].length === 0) - Logger.warning("skipping empty '" + optname + "' format"); - else - Plugin.format[key] = Plugin.config[optname]; - } + if (Plugin.config[optname].length === 0) + Logger.warning("skipping empty '" + optname + "' format"); + else + Plugin.format[key] = Plugin.config[optname]; + } } Gun.prototype.shot = function () { - return this.index++ === this.bullet; + return this.index++ === this.bullet; } function onLoad() { - Gun.loadFormats(); + Gun.loadFormats(); } onReload = onLoad; function onCommand(server, origin, channel) { - var kw = { - channel: channel, - command: server.info().commandChar + Plugin.info().name, - nickname: Util.splituser(origin), - origin: origin, - server: server.toString(), - plugin: Plugin.info().name - }; + var kw = { + channel: channel, + command: server.info().commandChar + Plugin.info().name, + nickname: Util.splituser(origin), + origin: origin, + server: server.toString(), + plugin: Plugin.info().name + }; - var game = Gun.find(server, channel); + var game = Gun.find(server, channel); - if (!game) - game = Gun.create(server, channel); + if (!game) + game = Gun.create(server, channel); - if (game.shot()) { - server.kick(Util.splituser(origin), channel, Util.format(Plugin.format["shot"], kw)); - Gun.remove(game); - } else { - kw.count = (6 - game.index).toString(); - server.message(channel, Util.format(Plugin.format["lucky"], kw)); - } + if (game.shot()) { + server.kick(Util.splituser(origin), channel, Util.format(Plugin.format["shot"], kw)); + Gun.remove(game); + } else { + kw.count = (6 - game.index).toString(); + server.message(channel, Util.format(Plugin.format["lucky"], kw)); + } }