Mafia is a thrilling social deduction game where deception and strategy are key to survival. This game is developed using HTML, CSS, and JavaScript, with a Flask backend hosted on Vercel. Playable on both mobile and desktop screens, Mafia offers an engaging experience for all players. The game includes sound effects to enhance the experience, with audio cues for kills, votes, and other key moments.
-
Mafia (Killer) - Kills one person per night.๐ช
-
Doctor - Saves one person per night.๐ฉบ
-
Police - Investigates one person per night to determine if they are the Mafia.๐ฎโโ๏ธ
-
Prankster - Pranks one person per night, preventing them from using their power.๐ญ
-
Civilian (Villager) - A normal villager with no special powers.๐ค
Go to MAFIA website. Enter your name and join a room. You can create a new room or join an existing one. The host will start the game, and each player will receive a role card.
Depending on your role, you will perform the following actions:
- Mafia: Choose one player to kill.๐
- Doctor: Choose one player to save.๐ก๏ธ
- Police: Choose one player to investigate.๐
- Prankster: Choose one player to prank.๐
- Civilian: Your choice does not affect the game.๐ค
- Discussion Round: Players discuss who they think the Mafia is.๐ฃ๏ธ
- Voting Round: Players vote on who they think the Mafia is.๐ณ๏ธ
- Voting Results: If the Mafia is voted out, the game ends. If not, the game continues to the next night phase.โป๏ธ
The game continues until either the Mafia is voted out or the Mafia successfully kills all other players.
For a visual representation of the game flow and states, refer to the diagram given below.
All game dev components used can be found here.
Mafia game project structure:
- API Folder ๐
-
app.py
: Main server file.๐ฅ๏ธ -
templates
folder:๐create.html
: Create a new game room.index.html
: Check if the game is working (old play.html).join.html
: Join a game room.landing.html
: Landing page for the main game.main.html
: Previous landing page (old landing.html).play.html
: Main file for playing the game.spectator.html
: Spectator page to watch the game.UI.html
: Basic UI components for development.
-
Static
folder:๐ผ๏ธ๐assets
folder: SVG images.audio
folder: Audio files.images
folder: JPG or PNG images.
-
The game was inspired by the traditional Mafia game played with friends using chats and a human host. This digital version automates the process, making it faster and more convenient, allowing everyone to participate without the need for a dedicated host.
How we used to play... ๐ฒ
We used to make paper chits or cards, and in those chits, we would write the names of the roles like Civilian, Mafia, Police, and others. These chits were then distributed among the players. There would be a god or a host who controlled the entire game. The host would ask everyone to close their eyes, then call on the Mafia to open their eyes and choose someone to kill. Afterward, the Doctor would open their eyes and choose someone to save. The game was very sequential, with each role acting one after another, making the process quite lengthy and sometimes frustratingly slow. The entire game took a lot of time.
Additionally, some players used to cheat between rounds, trying to gain an advantage by peeking or signaling to each other. This added an extra layer of challenge and suspicion to the game.
![Chits game](https://private-user-images.githubusercontent.com/83262693/333491165-344a2363-2f8d-480e-bb34-4014dd332fe1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4NjkxMjUsIm5iZiI6MTcyNDg2ODgyNSwicGF0aCI6Ii84MzI2MjY5My8zMzM0OTExNjUtMzQ0YTIzNjMtMmY4ZC00ODBlLWJiMzQtNDAxNGRkMzMyZmUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI4VDE4MTM0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg3MmRmM2E3MmM5ODEyMThkZWQ0NTZiMGM3NzIzNGZhOWY3MWQzZGY4ZjRiOGEyNWNiMzgyNWU1NGM3NjUxYTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.U0CZeLP8po-Ct1ii2eYJJnXYvk5MdwyKHOIl5c-LUQE)
If you encounter any issues or have suggestions for improvements, feel free to raise an issue or contribute to the project.
Thank you for playing Mafia! Enjoy the game and may the best detective win.๐ต๏ธโโ๏ธ