werewolf
A game engine for playing werewolf within an arbitrary chat client
https://github.com/hjwylde/werewolf
Version on this page: | 1.0.2.2 |
LTS Haskell 7.24: | 1.5.1.1 |
Stackage Nightly 2016-09-14: | 1.5.1.1 |
Latest on Hackage: | 1.5.2.0 |
werewolf-1.0.2.2@sha256:fe081beae7ae117b9e8f686131f3683c7103438efc9bfd627ee87ee39fbb8f4e,4515
Module documentation for 1.0.2.2
- Control
- Control.Lens
- Data
- Data.String
- Game
werewolf
A game engine for playing werewolf within an arbitrary chat client. Werewolf is a well known social party game, commonly also called Mafia. See the Wikipedia article for a rundown on it’s gameplay and history.
If you’re here just to play werewolf, you may wish to skip straight to chat interfaces.
Game description
Long has the woods been home to wild creatures, both kind and cruel. Most have faces and are known to the inhabitants of Fougères in Brittany, France; but no-one from the village has yet to lay eyes on the merciless Werewolf.
Each night Werewolves attack the village and devour the innocent. For centuries no-one knew how to fight this scourge, however recently a theory has taken ahold that mayhaps the Werewolves walk among the Villagers themselves…
Objective of the game:
For the Loners: complete their own objective.
For the Villagers: lynch all of the Werewolves.
For the Werewolves: devour all of the Villagers.
Roles
The implemented roles are split into four categories.
The Ambiguous:
No-one knows the true nature of the Ambiguous, sometimes not even the Ambiguous themselves!
The Ambiguous are able to change allegiance throughout the game.
- Orphan
- Village Drunk
The Loners:
The Loners look out for themselves and themselves alone.
The Loners must complete their own objective.
- Fallen Angel
The Villagers:
Fraught with fear of the unseen enemy, the Villagers must work together to determine the truth and eliminate the threat to Fougères. The task before them will not be easy, but a certain few have learnt some tricks over the years that may turn out rather useful.
The Villagers must lynch all of the Werewolves.
- Beholder
- Crooked Senator
- Druid
- Hunter
- Jester
- Lycan
- Protector
- Scapegoat
- Seer
- Simple Villager
- True Villager
- Witch
The Werewolves:
Hiding in plain sight, the Werewolves are not a small trifle.
The Werewolves must devour all of the Villagers.
- Alpha Wolf
- Simple Werewolf
Installing
Installing werewolf is easiest done using either stack (recommended) or Cabal.
Using stack:
stack install werewolf
export PATH=$PATH:~/.local/bin
Using Cabal:
cabal-install werewolf
export PATH=$PATH:~/.cabal/bin
Usage
This section covers how a chat interface interacts with the werewolf game engine.
All werewolf commands are designed to be run by a user from the chat client. E.g., to start a game:
> werewolf --caller @foo --tag werewolf start --extra-roles seer @bar @baz @qux @quux @corge @grault
{"ok":true,"messages":[
{"to":null,"message":"A new game of werewolf is starting with @foo, @bar, @baz, @qux, @quux, @corge and @grault!"},
{"to":null,"message":"The roles in play are Seer (1), Simple Villager (4) and Simple Werewolf (2) for a total balance of -2."},
{"to":"@foo","message":"You're a Simple Villager.\nA simple, ordinary townsperson in every way. Some may be cobblers, others bakers or even nobles. No matter their differences though, the plight of Werewolves in Fougères unites all the Villagers in this unfortunate time.\nThe Simple Villager has no special abilities, they must use their guile to determine whom among them is not who they say they are."},
...,
{"to":null,"message":"Night falls, the village is asleep."},
{"to":null,"message":"The Seer wakes up."},
{"to":"@corge","message":"Whose allegiance would you like to `see`?"}
]}
In this example, user @foo ran the start
command with the player names as arguments.
Note that the calling user, @foo, was passed in to the --caller
option and a game tag,
werewolf, was passed in to the --tag
option.
All commands require these options (n.b., the tag option is arbitrary, it just enables multiple
games of werewolf to be running at once).
Any command ran returns a JSON result.
The result contains a boolean for whether the command was successful and a list of messages.
The to
header on a message may either be null
—for a public message—or have an intended
recipient.
It’s the Seer’s turn now.
> werewolf --caller @corge --tag werewolf see @grault
{"ok":true,"messages":[
{"to":"@corge","message":"@grault is aligned with the Werewolves."},
{"to":"@quux","message":"You feel restless, like an old curse is keeping you from sleep. It seems you're not the only one... @grault is also emerging from their home."},
{"to":"@grault","message":"You feel restless, like an old curse is keeping you from sleep. It seems you're not the only one... @quux is also emerging from their home."},
{"to":null,"message":"The Werewolves wake up, transform and choose a new victim."},
{"to":"@quux","message":"Whom would you like to `vote` to devour?"},
{"to":"@grault","message":"Whom would you like to `vote` to devour?"}
]}
Let’s have the Werewolves, @quux and @grault, vote to devour a Villager.
> werewolf --caller @quux --tag werewolf vote @foo
{"ok":true,"messages":[
{"to":"@grault","message":"@quux voted to devour @foo."}
]}
> werewolf --caller @grault --tag werewolf vote @foo
{"ok":true,"messages":[
{"to":"@quux","message":"@grault voted to devour @foo."},
{"to":null,"message":"The sun rises. Everybody wakes up and opens their eyes..."},
{"to":null,"message":"As you open them you notice a door broken down and @foo's guts half devoured and spilling out over the cobblestones. From the look of their personal effects, you deduce they were a Simple Villager."},
{"to":null,"message":"As the village gathers in the square the Town Clerk calls for a vote."},
{"to":null,"message":"Whom would you like to `vote` to lynch?"}
]}
Too bad for @foo. Maybe the village can get some vengeance…
> werewolf --caller @corge --tag werewolf vote @grault
{"ok":true,"messages":[]}
This time, even though the command was successful, there are no messages.
> werewolf --caller @corge --tag werewolf vote @grault
{"ok":false,"messages":[{"to":"@corge","message":"You've already voted!"}]}
Here the command was unsuccessful and an error message is sent to @corge. Even though the command was unsuccessful, the chat interface probably won’t need to do anything special. Relaying the error message back to the user should suffice.
Thus a chat interface must implement the following:
- The ability to call werewolf commands. This includes passing the
--caller
and--tag
options and arguments correctly. It is possible to only implement theinterpret
command, which interprets the caller’s input. - The ability to send resultant messages. Resultant messages may be to everyone or to a specific user.
Commands
See werewolf --help
.
Chat interfaces
Click through for instructions on how to run a chat interface and play werewolf.
Changes
Changelog
Upcoming
v1.0.2.2
Revisions
- Bumped max version constraint of lens.
v1.0.2.1
Revisions
- Removed the binary header and updated the program description.
v1.0.2.0
Minor
Revisions
- Moved Seer’s player seen message to Sunrise. (#184)
v1.0.1.0
Minor
- Added the Crooked Senator role. (#142)
v1.0.0.0
Major
- Initial stable release!
v0.5.4.0
Minor
Revisions
- Minor updates to the
help rules
text. - Removed most logical tests and kept error ones. (#164)
v0.5.3.0
Minor
- Removed the Devoted Servant. (#127)
- Renamed the Angel to the Fallen Angel. (#130)
- Renamed the Villager-Villager to the True Villager. (#137)
- Removed the Wolf-hound. (#129)
Revisions
- Changed the Druid’s balance to 3. (#165)
- Updated the Fallen Angel’s description and rules. (#130)
- Updated the Simple Werewolf’s description. (#174)
- Updated the True Villager’s description and rules. (#137)
- Made the roles gender neutral. (#101)
- Made the role descriptions use consistent tenses. (#158)
v0.5.2.0
Minor
Revisions
v0.5.1.0
Minor
- Renamed the Defender to Protector. (#132)
- Automatically delete the game file if the game is over. (#100)
- Added errors for using overloaded commands out of turn. (#100)
Revisions
- Updated the Protector’s description and rules. (#132)
- Improved the English used. (#72)
- Added which player is the Villager-Villager to
status
. (#144)
v0.5.0.0
Major
- Added required
--tag
option for enabling multiple games at once. (#29)
v0.4.12.0
Minor
Revisions
- Updated the Witch’s description and rules. (#138)
- Updated the Scapegoat’s description. (#133)
- Updated the Druid’s description and rules. (#131)
- Updated the Jester’s description and rules. (#136)
v0.4.11.0
Minor
- Removed the advice field from Role. (#134)
Revisions
- Replaced references to Millers Hollow with an original game description. (#126)
- Fixed a bug where extra roles with spaces in them weren’t recognised.
- Fixed Devoted Servant messages to exclude her when joining the Werewolf pack.
- Fixed Devoted Servant help messages to include how to
pass
. - Removed player cap of 24. (#143)
- Fixed a bug where the Wild Child would receive role model died messages when dead. (#145)
- Updated the Simple Villager’s description and rules. (#135)
- Updated the Seer’s description. (#134)
- Updated the Simple Werewolf’s description. (#139)
v0.4.10.0
Minor
- Added
boot
command. (#14)
v0.4.9.0
Minor
- Added player contributed messages upon game over. (#86)
- Changed
choose
command for Scapegoat to take a space separated list rather than comma separated. (#98) - Filtered
help
commands based on the current game. (#94) - Added
--all
option tohelp
commands. (#94) - Added the Devoted Servant role. (#47)
- Added
--force
flag toend
. (#77)
v0.4.8.0
Minor
- Added role allocations to the game over messages. (#27)
Revisions
- Improved prompt to Wolf-hound on how to choose an allegiance. (#90)
- Changed Scapegoat’s balance to 0. (#91)
- Grouped
help commands
to improve readability. (#97) - Changed the
status
andping
commands to tell the caller when the game is over. (#89) - Added roles in game to the
status
command. (#93)
v0.4.7.1
Revisions
- Fixed bug where the Wolf-hound’s turn messages would be displayed on every round. (#87)
- Fixed a bug causing the Angel’s joining Villagers message to be shown every round. (#95)
- Fixed Village Idiot text to have spaces around the name. (#87)
- Fixed a bug where the Werewolves couldn’t win if it was down to 1 Werewolf and the Village Idiot. (#88)
v0.4.7.0
Revisions
- Fixed balance calculation to ensure total balance is between -2 and 2.
- Changed
--random-extra-roles
to have betweenn / 3
andn / 3 + 2
extra roles. - Added prisms and traversals to Role, Player & Game modules. (#20)
- Removed fudging of roles and replaced with fudging of allegiances.
- Wolf-hound now has their allegiance hidden when they are lynched.
- Fixed the grammar on the first Werewolves’ turn messages.
- Moved Wolf-hound’s turn to before the Seer’s so that the Seer may see his allegiance properly.
- Restricted specifying
Simple Villager
orSimple Werewolf
as extra roles.
v0.4.6.1
Revisions
- Fixed Village Idiot text to have spaces around the name. (#87)
- Fixed a bug where the Werewolves couldn’t win if it was down to 1 Werewolf and the Village Idiot. (#88)
v0.4.6.0
Minor
- Added the Village Idiot role. (#41)
- Added the Scapegoat’s ability to choose whom may vote on the next day when he is blamed. (#62)
- Added in balance concept for roles to help balance role selection. (#81)
- Added
--random-extra-roles
option tostart
. (#30) - Added the Bear Tamer role. (#45)
- Added a
circle
command. (#45)
Revisions
- Fixed the Defender being unable to protect himself.
- Restructured library modules to only export relevant functions. (#11)
v0.4.5.0
Minor
- Added the Wolf-hound role. (#50)
- Added a
version
command. (#84) - Added the Wild-child role. (#49)
- Added the Angel role. (#52)
Revisions
- Renamed the Villager role to Simple Villager.
- Renamed the Werewolf role to Simple Werewolf.
- Renamed the devourVoteCommand and lynchVoteCommand to voteDevourCommand and voteLynchCommand. (#49)
- Fixed
quit
to advance the stage when the only role for that stage has quit.
v0.4.4.1
Revisions
- Fixed grammar for the
currentStageMessages
. (#83) - Fixed the
heal
command help message to not require aPLAYER
argument. (#82)
v0.4.4.0
Minor
- Removed
playerHealedMessage
and replaced with the genericnoPlayerDevouredMessage
. (#80) - Removed
playerProtectedMessage
and replaced with the genericnoPlayerDevouredMessage
. (#80)
Revisions
- Privatised underscore methods and changed old uses to using lens. (#20)
- Tidied up arbitrary instances by using
newtype
’s. (#78) - Fixed the
noPlayerDevouredMessage
to be displayed after sunrise. (#80) - Removed
Show
instance forCommand
and usedBlind
. (#78)
v0.4.3.2
Revisions
- Fixed grammar for the
currentStageMessages
. (#83) - Fixed the
heal
command help message to not require aPLAYER
argument. (#82)
v0.4.3.1
Revisions
- Added missing module to Cabal file.
v0.4.3.0
Minor
- Added the Defender role. (#38)
v0.4.2.3
Revisions
- Fixed grammar for the
currentStageMessages
. (#83) - Fixed the
heal
command help message to not require aPLAYER
argument. (#82)
v0.4.2.2
Revisions
- Added missing module to Cabal file.
v0.4.2.1
Revisions
- Fixed a bug causing the Witch being unable to heal themselves. (#76)
v0.4.2.0
Minor
- Added the Villager-Villager role. (#37)
v0.4.1.3
Revisions
- Fixed grammar for the
currentStageMessages
. (#83) - Fixed the
heal
command help message to not require aPLAYER
argument. (#82)
v0.4.1.2
Revisions
- Added missing module to Cabal file.
v0.4.1.1
Revisions
- Fixed a bug causing the Witch being unable to heal themselves. (#76)
v0.4.1.0
Minor
- Added the Witch role. (#5)
v0.4.0.1
Revisions
- Fixed grammar for the
currentStageMessages
. (#83)
v0.4.0.0
Major
- Restricted count of special roles to 1. (#32)
- Changed private message structure to only ever be for a single player. (#21)
Minor
- Renamed
turn
tostage
. (#70) - Renamed
VillagersTurn
toVillagesTurn
. (#70) - Added
events
to the game state. (#71) - Added private pinging to the
ping
command. (#69) - Restricted
end
to players in the current game. (#74)
v0.3.4.0
Minor
- Added a
ping
command. (#64)
Revisions
- Added missing apostrophe to the new turn message. (#63)
- Changed the “Whom would you like to lynch?” text to be a public message displayed after the devoured message. (#56)
- Better prompt to action when villagers vote.
- Changed devour vote messages to be sent immediately. (#57)
- Removed useless
only
function. (#55) - Turned start of day and night into distinct turns.
- Added private message to players when the game is over. (#65)
v0.3.3.2
Revisions
- Fixed missing file in Cabal file. (#18)
v0.3.3.1
Revisions
- Added
noIntersperse
tointerpret
. (#60)
v0.3.3.0
Minor
Revisions
- Added
--
to help description ofinterpret
. (#60)
v0.3.2.0
Minor
- Added a “Whom would you like to lynch?” message during the Villagers’ turn. (#25)
- Allowed lowercase roles for
--extra-roles
in thestart
command. (#33)
Revisions
- Shrunk some of the help text to make it more readable. (#25)
v0.3.1.3
Revisions
- Fixed a bug where Werewolves could devour other Werewolves. (#34)
- Changed Werewolf text from “kill” to “devour”. (#34)
v0.3.1.2
Revisions
- Fixed dead werewolves being informed of votes. (#24)
v0.3.1.1
Revisions
- Tidied up the help text to be smaller. (#26)
- Fixed a bug where the turn was advanced to Werewolves when no Werewolves were alive. (#26)
v0.3.1.0
Minor
- Added a message to say the names of all the players at the start of a game. (#23)
- Added a message to say the roles in play at the start of a game. (#16)
v0.3.0.5
Revisions
- Fixed a bug where Werewolves could devour other Werewolves. (#34)
- Changed Werewolf text from “kill” to “devour”. (#34)
v0.3.0.4
Revisions
- Fixed dead werewolves being informed of votes. (#24)
v0.3.0.3
Revisions
- Tidied up the help text to be smaller. (#26)
- Fixed a bug where the turn was advanced to Werewolves when no Werewolves were alive. (#26)
v0.3.0.2
Revisions
- Tidied up the help text to be smaller. (#26)
- Fixed a bug where the turn was advanced to Werewolves when no Werewolves were alive. (#26)
v0.3.0.1
Revisions
- Fixed
interpret
to display the commands help messages when given invalid arguments. (#22)
v0.3.0.0
Major
Minor
- Allowed
start
to work when the game has ended butend
hasn’t been called. (#15) - Added
quit
command. (#13)
v0.2.0.2
Revisions
- Fixed dead werewolves being informed of votes. (#24)
v0.2.0.1
Revisions
- Tidied up the help text to be smaller. (#26)
- Fixed a bug where the turn was advanced to Werewolves when no Werewolves were alive. (#26)
v0.2.0.0
Major
v0.1.0.0
Major
- Initial implementation with Villagers and Werewolves. (#1)