Mercurial > irccd
comparison plugins/hangman/hangman.js @ 847:a23b7b574ed2
irccd: rename [format] section to [templates], closes #1671
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Jul 2019 20:10:00 +0200 |
parents | 06cc2f95f479 |
children | 5e25439fe98d |
comparison
equal
deleted
inserted
replaced
846:dcef68d82fd3 | 847:a23b7b574ed2 |
---|---|
35 | 35 |
36 // Default options. | 36 // Default options. |
37 Plugin.config["collaborative"] = "true"; | 37 Plugin.config["collaborative"] = "true"; |
38 | 38 |
39 // Formats. | 39 // Formats. |
40 Plugin.format = { | 40 Plugin.templates = { |
41 "asked": "#{nickname}, '#{letter}' was already asked.", | 41 "asked": "#{nickname}, '#{letter}' was already asked.", |
42 "dead": "#{nickname}, fail the word was: #{word}.", | 42 "dead": "#{nickname}, fail the word was: #{word}.", |
43 "found": "#{nickname}, nice! the word is now #{word}", | 43 "found": "#{nickname}, nice! the word is now #{word}", |
44 "running": "#{nickname}, the game is already running and the word is: #{word}", | 44 "running": "#{nickname}, the game is already running and the word is: #{word}", |
45 "start": "#{nickname}, the game is started, the word to find is: #{word}", | 45 "start": "#{nickname}, the game is started, the word to find is: #{word}", |
282 var st = game.propose(proposition, kw.nickname); | 282 var st = game.propose(proposition, kw.nickname); |
283 | 283 |
284 switch (st) { | 284 switch (st) { |
285 case "found": | 285 case "found": |
286 kw.word = game.formatWord(); | 286 kw.word = game.formatWord(); |
287 server.message(channel, Util.format(Plugin.format["found"], kw)); | 287 server.message(channel, Util.format(Plugin.templates["found"], kw)); |
288 break; | 288 break; |
289 case "wrong-letter": | 289 case "wrong-letter": |
290 case "wrong-player": | 290 case "wrong-player": |
291 case "wrong-word": | 291 case "wrong-word": |
292 kw.word = proposition; | 292 kw.word = proposition; |
293 case "asked": | 293 case "asked": |
294 kw.letter = String.fromCharCode(proposition); | 294 kw.letter = String.fromCharCode(proposition); |
295 server.message(channel, Util.format(Plugin.format[st], kw)); | 295 server.message(channel, Util.format(Plugin.templates[st], kw)); |
296 break; | 296 break; |
297 case "dead": | 297 case "dead": |
298 case "win": | 298 case "win": |
299 kw.word = game.word; | 299 kw.word = game.word; |
300 server.message(channel, Util.format(Plugin.format[st], kw)); | 300 server.message(channel, Util.format(Plugin.templates[st], kw)); |
301 | 301 |
302 // Remove the game. | 302 // Remove the game. |
303 Hangman.remove(game); | 303 Hangman.remove(game); |
304 break; | 304 break; |
305 default: | 305 default: |
329 if (game) { | 329 if (game) { |
330 var list = message.split(" \t"); | 330 var list = message.split(" \t"); |
331 | 331 |
332 if (list.length === 0 || String(list[0]).length === 0) { | 332 if (list.length === 0 || String(list[0]).length === 0) { |
333 kw.word = game.formatWord(); | 333 kw.word = game.formatWord(); |
334 server.message(channel, Util.format(Plugin.format["running"], kw)); | 334 server.message(channel, Util.format(Plugin.templates["running"], kw)); |
335 } else { | 335 } else { |
336 var word = String(list[0]); | 336 var word = String(list[0]); |
337 | 337 |
338 if (Hangman.isWord(word)) | 338 if (Hangman.isWord(word)) |
339 propose(server, channel, origin, game, word); | 339 propose(server, channel, origin, game, word); |
340 } | 340 } |
341 } else { | 341 } else { |
342 game = Hangman.create(server, channel); | 342 game = Hangman.create(server, channel); |
343 game.query = isquery; | 343 game.query = isquery; |
344 kw.word = game.formatWord(); | 344 kw.word = game.formatWord(); |
345 server.message(channel, Util.format(Plugin.format["start"], kw)); | 345 server.message(channel, Util.format(Plugin.templates["start"], kw)); |
346 } | 346 } |
347 | 347 |
348 return game; | 348 return game; |
349 } | 349 } |
350 | 350 |