=== Mafia Game ===
Contributors: cornelcaba
Tags: game, mafia, party, werewolf, social
Requires at least: 5.8
Tested up to: 6.5
Requires PHP: 7.4
Stable tag: 1.1.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Run a Mafia (Lupus in Tabula) party game on your WordPress site. Narrator-driven, mobile friendly, no accounts required.

== Description ==

Mafia Game is a self-contained WordPress plugin that lets you organize Mafia parties (also known as Werewolf or Lupus in Tabula) at events, friends gatherings, classroom activities, or family dinners.

A narrator creates a room and shares a 4-character code. Each player joins from their phone by entering the code and a nickname. When everyone is in, an administrator distributes the roles from the WordPress admin panel and every player automatically sees their secret role on their own device.

= Features =

* Four classic roles: **Mafia, Detective, Doctor, Citizen**.
* **No accounts required**. Players are identified by a token saved in the browser.
* **Admin-only role distribution**: with proper nonce and capability checks.
* **Per-room admin view**: see all characters, their roles, current status (alive / eliminated), and act on each (eliminate, lynch, restore).
* **Live polling**: each player's screen refreshes automatically every 3 seconds.
* **Action log** of every game event for the narrator.
* **Internationalisation ready**: shipped with English (default) and Italian (it_IT) translations.
* Lightweight, no external services, no tracking.

= How it works =

1. Add the shortcode `[mafia_game]` to a page (e.g. `/mafia/`).
2. The narrator opens that page on a tablet or laptop and creates a new room.
3. Players open the same page on their phones, enter the 4-character code, type their nickname.
4. When everyone has joined, the WordPress administrator clicks **Distribute roles** from **WP Admin -> Mafia Game**.
5. Each player automatically sees their role within a few seconds.
6. The administrator manages the night/day phases and marks eliminations from the admin panel.

= Privacy =

The plugin stores game data in three custom database tables (`{prefix}_mafia_rooms`, `{prefix}_mafia_players`, `{prefix}_mafia_actions`). No data is sent to external servers.

== Installation ==

1. Upload the `mafia-game` folder to `/wp-content/plugins/`, or install the .zip from **Plugins -> Add New -> Upload Plugin**.
2. Activate the plugin from the **Plugins** menu in WordPress.
3. Create a page (for example `/mafia/`) and insert the shortcode `[mafia_game]`.
4. Open the page on your phone: players enter with the room code, the narrator creates the room from the same page, and you (the administrator) distribute roles from **WP Admin -> Mafia Game**.

== Frequently Asked Questions ==

= How do I see the assigned roles for each player? =

WordPress -> Mafia Game -> click on the room code (or the **View players** button). You will see the full list of characters with name, role, alive/eliminated status, and quick actions.

= Can I customize the number of roles? =

Yes. When creating a new game you choose how many Mafia, Detectives, Doctors, and Citizens you want. The total must match the number of players.

= Who is allowed to distribute the roles? =

Only WordPress users with the `manage_options` capability (typically site administrators).

= Does it work on WordPress.com? =

Only on plans that allow custom plugins (Business or higher).

= Is it translated? =

Default language is English. Italian (it_IT) is bundled. The plugin is fully i18n-ready, so you can add translations using a plugin like Loco Translate.

== Screenshots ==

1. Public landing page: players join with a room code, the narrator creates a new game.
2. Role configuration screen for the narrator with steppers for each role.
3. Lobby waiting view with the room code, QR-friendly layout, and connected players list.
4. Personal role reveal card on each player's phone (tap to reveal).
5. Administrator detail view of a room with all characters, roles, status, and quick actions.

== Changelog ==

= 1.1.5 =
* Default language is now English. Italian translation included as `mafia-game-it_IT.po/.mo`.
* Removed third-party update checker (incompatible with WordPress.org guidelines).
* Stricter sanitisation across admin requests.
* Author updated to Cornel Caba (cornelcaba.com).

= 1.1.3 =
* New admin per-room detail view with full character list and quick actions (Eliminate / Lynch / Restore).

= 1.1.2 =
* Fix: shipped files were truncated in 1.1.1, restored full files.

= 1.1.1 =
* Fix: added explicit `type="button"` and click `preventDefault()` to avoid accidental form submits on themes that wrap the page content in a form.

= 1.1.0 =
* Role distribution restricted to the WP admin panel (nonce + capability check).
* Automatic role reveal on each player's phone via REST polling.
* Removed colour differentiation between roles in the player UI.
* Detective icon updated.

= 1.0.0 =
* First release: rooms, role distribution, narrator dashboard, personal role reveal.

== Upgrade Notice ==

= 1.1.5 =
First release prepared for the WordPress.org plugin directory. Default language is English; Italian translation included.
