JetBrains-Research / JetBrains-Research/Python-Solution-Preference

[013] Mafia Game (MVP)

未关闭
#13 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
没有语言数据
星标
2
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

Overview
Single-room Mafia game. Players coordinate discussion externally; this service manages roles, phases, voting, eliminations, and win conditions. Only one game runs at a time globally.

Build this as a Python backend service with no UI; expose the functionality below through an HTTP API.

Constraints
- No timers; phases end on majority or when the Game Starter manually advances.
- No in-app chat, accounts, or mid-game joining.
- Player count: 4-16.

Lobby
- Players can join when no game is active.
- Joined players are visible to all in the lobby.
- Name requirements: 3-20 characters (letters, numbers, spaces, hyphens, underscores), unique within lobby (case-insensitive).
- Any joined player can start the game once 4+ players are present.
- While a game is in progress, new players cannot join; the lobby reports it is locked.
- When a game ends, the lobby reopens immediately for new players.

Game Start and Roles
- The player who starts the game becomes the Game Starter (controls manual phase advancement).
- Role assignment: Mafia count = max(1, floor(N/3)); remainder are Citizens.
- Each player can privately retrieve their role. Mafia also see all mafia teammates; Citizens see only their own role.
- Game begins at Day 1.

Day Phase
- Player status (Alive/Dead) is visible to all.
- All Alive players vote for one Alive player (self-votes allowed) or an explicit "No Elimination" option.
- Vote counts are public and reflect the current tally.
- Majority threshold = floor(Alive / 2) + 1.
- If any option reaches majority, Day ends immediately:
- Player majority: that player is eliminated (Dead), role revealed.
- No Elimination majority: no one eliminated.
- If the Game Starter ends Day without majority, resolve as No Elimination.
- After resolution, check win conditions; if game continues, transition to Night.

Night Phase
- Only Alive mafia vote; targets must be Alive Citizens (mafia cannot target mafia).
- Mafia see aggregated vote counts among themselves; non-mafia see nothing about night votes.
- Night majority threshold = floor(AliveMafia / 2) + 1. If any target reaches majority, Night ends immediately.
- If the Game Starter ends Night manually:
- Unique highest-vote target: killed, role revealed.
- Tie or no votes: no kill.
- After resolution, check win conditions; if game continues, transition to next Day.

Win Conditions
- Citizens win: all Mafia eliminated (Mafia count = 0).
- Mafia win: Mafia count >= Citizen count.
- Checked immediately after any Day elimination or Night resolution.
- On game end: reveal all roles, freeze voting, release lobby lock.

贡献指南

这个仓库没有索引到贡献指南

调研方向

No files, tests, or API entry points are named. Start by reviewing the repository structure and deciding where the HTTP API and single-game state belong; done means the specified lobby, role, phase, voting, resolution, and win-condition behavior is exposed without UI, timers, accounts, or mid-game joining.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。