Contents
Fehér Úr is the phone version of a familiar social word game. Civilians receive a shared secret word, the spies receive a similar one, and Fehér Úr receives nothing and has to bluff. Around a table, spoken aloud, it sounds simple. The moment an app has to decide a tie or a shared victory, it turns out how many rules were never said out loud.
The problem
The spoken rules are full of “we’ll sort that out” situations:
- What happens on a tie vote? Do we draw lots, or vote again?
- If an eliminated Fehér Úr guesses the word, do they win immediately? And if a spy and Fehér Úr are both still alive?
- Do spies who are already out still win if their team wins?
- How many spies and Fehér Úr roles should there be at five, nine or fifteen players, so the game stays tense?
- How do we stop the same player from always being Fehér Úr?
- How does the role stay secret when a single phone is passed around the table?
If these decisions are scattered through the screen code, the bugs only show up during a live game, in front of a group of friends. That is what we wanted to avoid.
The solution
1. The rules moved into code that does not know about the screens
We described the flow as an explicit state machine: setup → role reveal → clue round → vote → elimination → Fehér Úr’s guess → result. A single function says which state can lead to which. A normalizing step brings a damaged or half-finished save back to a valid state.
Every rule is a pure function: it receives a game state and returns a new one. There are no side effects. Role assignment, word choice, vote counting, deciding the winner and the statistics are each a module that can be tested on its own. The app’s state store (Zustand) only calls these and saves the result.
2. We said every unspoken rule out loud
- Ties: no drawing of lots. The players involved vote again until the result is unambiguous.
- Victory matrix: civilians win if no spy and no Fehér Úr remain. Spies, and Fehér Úr, win if at most one civilian is left and they are still in the game. An eliminated Fehér Úr can also win with a correct guess. A shared spy and Fehér Úr victory exists, and eliminated spies share their team’s win.
- Role ratios: at least three players, and always at least two civilians. The suggested mix grows with the group size, and the four modes (Classic, Spy, Chaos, Custom) are built on that.
- Fair assignment: someone who was Fehér Úr or a spy last round is less likely, by weight, to get the same role again, but the chance is not zero, so the game stays unpredictable. The starting player is chosen with weights too.
3. Secrecy on a single phone
- The secret word is never written to persistent storage. It is not visible when a half-finished game is resumed either.
- If the app goes to the background, the revealed card disappears automatically.
- In a secret vote, a cover screen appears between every vote, and there is an “I forgot who I am” button, also behind a cover.
4. A product around the rules
The product was built on the tested engine: 619 Hungarian word pairs in 17 topics and four difficulty levels, custom word pairs, saved teams, per-player statistics and streaks, plus an introduction and a rules explanation. The app works fully offline. There is no account, no advertising and no analytics. Every piece of data stays on the phone. The interface is built with Expo and React Native, so iOS and Android come from a single codebase.
Measured results
67
Automated test cases on the rules engine
54 test blocks, expanded with parameterized cases
10,000
Simulated role assignments per test
a statistical check of the fair distribution
619
Built-in word pairs
17 topics, 4 difficulty levels
2 days
First commit → signed 1.1.0 build
release packages for both iOS and Android
- The tests play full games with 3, 5, 7, 10 and 12 players, a continuous session of 50 rounds, and ten thousand word picks without repetition.
- Tie, victory and resignation rules are pinned by named test cases, so changing one rule does not silently break another.
- Zero network calls: the game is complete in airplane mode too.
Fehér Úr