view plugins/hangman/hangman.md @ 30:1ea775153cdc

Plugin hangman: various fixes in the documentation
author David Demelier <markand@malikania.fr>
date Mon, 22 Feb 2016 13:13:15 +0100
parents 8384df86e195
children c4fe9a8b1a62
line wrap: on
line source

---
title: "Hangman plugin"
header: "Hangman plugin"
---

Hangman is a plugin to play the hangman game.

## Installation

The plugin **hangman** is distributed with irccd. To enable it add the following to your `plugins` section:

````ini
[plugins]
hangman = ""
````

## Usage

The **hangman** plugin starts when a user execute its special command with no arguments.

````nohighlight
markand: !hangman
irccd: markand, the game is started, the word to find is: _ _ _ _ _ _ _ _ _ _ _
````

### Proposal

There are two ways for proposing a response to the game. You can either just ask for a letter or for a whole word.

#### By letter

When asking a letter, the message must be one letter.

````nohighlight
markand: c
irccd: markand, nice! the word is now c _ _ _ _
jean: k
irccd: jean, there is no 'k'.
````

#### By full word

When asking by a word, just put one word as command argument.

````nohighlight
markand: !hangman couch
irccd: markand, this is not the word.
jean: !hangman candy
irccd: jean, congratulations, the word is candy.
````

## Configuration

The **hangman** plugin can be configured to show different messages.

The following options are available under the `[plugin.hangman]` section:

  - **file**: (string) the path to the database file (Optional, default: configuration directory),
  - **collaborative**: (bool) set to true to enable collaborative mode, a player can't propose two consecutives proposals (Optional, default: true),
  - **format-asked**: (string) when a letter has been already asked but present in the word (Optional),
  - **format-dead**: (string) when the man was hung (Optional),
  - **format-found**: (string) when a correct letter has been placed (Optional),
  - **format-running**: (string) when a game is requested but it's already running (Optional),
  - **format-start**: (string) when the game starts (Optional),
  - **format-win**: (string) when the game succeeded (Optional),
  - **format-wrong-word**: (string) when a word proposal is wrong (Optional),
  - **format-wrong-letter**: (string) when a letter proposal is wrong (Optional).

### Keywords supported

The following keywords are supported:

| Format                  | Keywords                          | Notes                           |
|-------------------------|-----------------------------------|---------------------------------|
| (any)                   | server, channel, nickname, origin | all formats                     |
| **format-asked**        | letter                            | the letter proposal             |
| **format-dead**         | word                              | the word to find                |
| **format-found**        | word                              | the hidden word                 |
| **format-start**        | word                              | the hidden word                 |
| **format-win**          | word                              | the word to find                |
| **format-wrong-word**   | word                              | the invalid word proposal       |
| **format-wrong-letter** | letter                            | the letter proposal             |

Example:

<div class="panel panel-info">
 <div class="panel-heading">~/.config/irccd/irccd.conf</div>
 <div class="panel-body">
````ini
[plugin.hangman]
format-win = "nice job, the word was #{word}!"
format-wrong-letter = "please try again, there is no #{letter}"
````
 </div>
</div>

## Database file

The database file must contains one word per line, it must be saved as UTF-8.

<div class="panel panel-info">
 <div class="panel-heading">~/.config/irccd/plugin/hangman/words.conf</div>
 <div class="panel-body">
````nohighlight
sky
irccd
FreeBSD
door
cat
````