side project
Leer en españolArkham chaos bag
The chaos bag from Arkham Horror: The Card Game, on an iPad in the middle of the table. The other players join from their phones to see every draw and draw tokens themselves.
What it is
In Arkham Horror: The Card Game, players draw tokens from a chaos bag to see how a test goes. This app puts that bag on an iPad in the middle of the table, and the other players draw from it on their phones.
How it's built
Arkham Chaos Bag is a native iOS app that replaces the physical chaos bag in Arkham Horror: The Card Game. An iPad in the middle of the table hosts the game and shows the bag, the odds, the phase and every draw. Players join from their phones to draw tokens, seal them or change the bag. A phone can also play solo, or act as a shared "group phone" that anyone at the table uses.
highlights
One host, one source of truth
The iPad holds the only real copy of the game state. Phones never change state themselves. They send an intent, like "draw two tokens", and the host checks it against the rules and sends the new state to everyone. This keeps every device in agreement, even when two players tap at the same moment.
Rules as pure functions
All game rules live in a pure reducer: a function that takes the current state and an intent and returns the new state or a reason it was refused. It has no UI and no networking. It is easy to test, and its test cases are also saved as JSON fixtures that a future Android version can run against.
Play without a router
Discovery uses Bonjour, and connections use Apple's Network framework with peer-to-peer Wi-Fi turned on. So an iPad and a few phones can play at a table with no Wi-Fi network at all. A phone that drops out reconnects on its own and gets its seat back with a resume token.
Password-derived encryption
A table can have a password. The password is never sent over the network. Instead, both sides derive a key from it with a slow hash, and the connection uses TLS with that pre-shared key. Players who already joined get their own per-seat key, so they can rejoin even after the host changes the password.
Saved and resumable tables
The host saves the game to the device after every change, so a table survives the app closing. The save file has a format version, refuses files written by a newer build, and keeps one earlier copy when a new game replaces it. The host's save is protected on disk and kept out of backups because it holds keys.
Checked on every push
A pre-push hook runs the whole gate: lints, a strict build with warnings as errors, about 400 package tests, app tests, a UI test that joins a real host, and an accessibility audit at two text sizes. The repo is graded against a 10-area production-readiness rubric. It went from 3.6 to 4.35 out of 5 over two rounds of fixes.
- Swift
- SwiftUI
- Swift Concurrency
- Network framework
- Bonjour
- TLS-PSK
- String Catalogs
- XCTest and Swift Testing