Ma Sói Role Designer
Workflow
- Define role concept: name, team, emoji, description, night action (if any), passive (if any), trigger conditions.
- Check balance against existing roles using
references/role-template.md. - Implement server-side:
- Add to
ROLESobject inserver/gameEngine.js. - Update
getRoleConfig()distribution logic. - Add night action handler in
server/index.js→night_action. - Add to
checkNightComplete()if role has night action. - Add to
resolveNight()orresolveVote()if role has special triggers. - Update
isWolf()helper if new wolf-team role.
- Add to
- Implement client-side:
- Add night UI in
client/src/pages/NightPhase.jsx. - Add any special prompts or result displays.
- Update
client/src/hooks/useGame.jsfor new socket events. - Update
client/src/pages/GuidePage.jsxwith role description. - Update
client/src/pages/WaitingRoom.jsxrole config UI.
- Add night UI in
- Update documentation:
- Update
docs/GAME_LOGIC.mdwith role behavior and socket events. - Update
README.mdrole table.
- Update
- Verify:
node --check server/index.jsnode --check server/gameEngine.jscd client && npm run build
Balance Guidelines
- Wolf team should always be less than half the players.
- Max 3 wolves total (including wolf variants).
- Each village special role should have clear counterplay (wolves can target them).
- Avoid roles that create unfun "kingmaker" dynamics (one player decides the game with no risk).
- New night-action roles increase night duration — consider timer impact.
- Passive roles (like IDIOT) are simpler to implement but still need edge case testing.
File Modification Checklist
When adding a new role, you MUST touch these files:
Server (Required)
| File | What to Add |
|---|---|
server/gameEngine.js |
ROLES entry, getRoleConfig() logic, update sanitizeCustomRoles() |
server/index.js |
Night action handler, skip handler, resolution logic, reconnect state |
Client (Required)
| File | What to Add |
|---|---|
client/src/pages/NightPhase.jsx |
Night UI panel, target selection, confirm button |
client/src/hooks/useGame.js |
New socket event listeners, state variables, action emitters |
client/src/pages/GuidePage.jsx |
Role description in guide |
client/src/pages/WaitingRoom.jsx |
Role in custom config picker |
Documentation (Required)
| File | What to Add |
|---|---|
docs/GAME_LOGIC.md |
Role behavior section, socket events, edge cases |
README.md |
Role table entry |
Optional
| File | When Needed |
|---|---|
client/src/components/RoleCard.jsx |
If role has unique visual treatment |
client/src/pages/ResultScreen.jsx |
If role has special end-game display |
client/src/pages/DayPhase.jsx |
If role has day-phase actions |
References
Load references/role-template.md when designing or implementing a new role.