📜 ⬆️ ⬇️

To help the leading "Mafia"

Everyone knows the game "Mafia". Surely many of the habrasoobschestva played it. Players are required to have the ability to think logically, observation, speech skills and much more. A little more is required from the master. We will talk about this in more detail.

My experience of playing and conducting “Mafia” is not that big, only about two years. However, I do not even bother to calculate how many games I have spent. The biggest inconvenience I encountered was nothing to write about. Therefore, I had the idea to write a simple little program so that it would be easier to take into account actions and not to bother with drawing rulers, curved handwriting and all such other things.

The key point in choosing what, in fact, to write, was cross-platform. As a result, the script was born for the lead "Mafia" with the use of JavaScript and jQuery. I am far from a perfectionist, so the script is also far from the possible perfection, however, I use it very successfully.

Player recruitment


')
The interface is made in minimalism - nothing superfluous. With the "+" button we add players, with the "-" button opposite the player - we remove it. Small buttons allow you to move players up or down the list if players at the table suddenly decide to switch places.

Since at first I was not even going to tell anyone about this script, then “protection against a fool” is not provided almost anywhere. The leader himself must make sure that there are not two detectives or maniacs in the game, for example.

The game can begin only with the presence of five players, to start the game, you must press the "Start game" button.

Start



Before starting, all editable fields are automatically converted into plain text. This was done so that later you could just save the page to disk, if you suddenly want to "save the game protocol."

It is always possible to return to the beginning, for example, if a couple more people suddenly came, and the game did not really begin. When you click the "Reapply" button, all information about game actions is "forgotten", only the names and roles that can be changed again remain - the game returns to the state before pressing the "Start game" button.

Then night falls, the city falls asleep and the mafia wakes up ...



When you press the buttons, they are highlighted, so the presenter sees that he presses. Until the day comes (the “Day” button is not pressed), everything can be changed.

The day has come, the presenter reports sad news, then the day events take place - discussion, performance, voting. And the arrest of a potential criminal. Or hanging - as you wish.

As I said above, there is practically no “protection against a fool”, the program has almost no control over the leader. Thus, a day without death and a night without murder can happen.

True, usually this does not happen.


To make it easier for the presenter to navigate the situation, if by agreement between the players, the eliminated roles are not announced, the buttons of the eliminated roles are blocked, but not removed at all. Every night, the facilitator can see which roles he should “awaken,” even if they have dropped out.

End of the game


For this script, there is no concept of "end of the game." He is ready to endlessly handle pressing the buttons "Night" and "Day", here again everything is on the conscience of the presenter.

Addition


In fact, the whole program is an html-page and scripts that change information. Since I do not always have the opportunity to connect to the Internet, everything works locally - just open the html file in the browser. Of course, the necessary scripts should be in the same folder as the html file.

What's in the plans


Add another bunch of different roles. Someone, for example, lacks a lawyer, a sheriff. Add a miscalculation of the situation to facilitate the work of the lead, for example, when the game should end 100%. To add the same adjustable “protection against a fool”, for example, to exclude the possibility of a day without death.

Waiting for your additions and comments.

PS


Interested individuals can download the script here . Currently version 1.2.

Version 1.2:
Added tab "Settings", there you can load another style to display the elements.
The configuration lines are in a separate config.js file, so they are easier to find if someone wants to change something ...
Files are divided into folders - scripts in js, styles - in css.
The $ Debug variable has been added, which includes the debugging mode, and the showDebugInfo function, which displays information in the dDebug layer.
Fixed a bug that occurs when changing the number of players.
Added a button with a timer. By default, the timer is detected by three minutes.

Version 1.1:
Added ideas and design from Meft : button layout, action icons.
The interface is made more convenient - control buttons are moved up, the reference information is placed separately.
Added the ability to automatically assign roles depending on the number of players.
Added highlighting of mafia lines.

Version 1.0:
Roles: Mafia, Mafia Boss, Commissioner, Doctor, Suicide Bomber, Pretty Woman (Mistress), Thief, Maniac, Immortal.

Source: https://habr.com/ru/post/237633/


All Articles