A Victorian-parlor social bluffing game for phones (Android + iOS), built with Flutter. Players write forged answers on each other's prompt cards, vote to find the truth, and unmask the forgers. The game is server-authoritative: all game rules run in Firebase Cloud Functions, so a live (or emulated) backend is required for any play session.
This project is a Flutter application that uses Firebase for its backend and flutter_dotenv for environment variable management.
- Flutter SDK (>=3.0.6 <4.0.0)
- Dart SDK
- A Firebase project with Firestore enabled
This project uses flutter_dotenv to manage Firebase API keys. The keys must not be exposed in source control.
- Navigate to the project root directory.
- Locate the
.env.examplefile, and create a copy of it named.env:cp .env.example .env
- Open the newly created
.envfile and replace the placeholder values with your actual Firebase API keys found in your Firebase console:Note: TheFIREBASE_API_KEY_WEB=your_actual_web_api_key FIREBASE_API_KEY_ANDROID=your_actual_android_api_key FIREBASE_API_KEY_IOS=your_actual_ios_api_key
.envfile is excluded from git via.gitignoreto prevent secret leaks.
- Fetch the project dependencies:
flutter pub get
- Run the application on your connected device or emulator:
flutter run
When testing the application locally with a local Firebase emulator suite or calling local servers, configuring networking is required:
- iOS Simulator: Connects directly to
localhostor127.0.0.1. - Android Emulator: Cannot resolve
127.0.0.1as the host machine. Instead, use the special loopback IP address10.0.2.2which redirects to your host machine's loopback (127.0.0.1). - Physical Android Device: Ensure both your host machine and mobile device are connected to the same Wi-Fi network, and target the host machine's IP address (e.g.
192.168.x.x). Alternatively, perform port forwarding usingadb reverse tcp:8080 tcp:8080(or appropriate Firestore/auth ports).
- Lexical Heuristic: Duplicate-answer detection is implemented as a local, offline lexical heuristic (normalized Jaccard / containment / Levenshtein metrics) to prevent duplicate or near-duplicate forgeries. No external AI APIs or keys are required.
There are three layers of testing: automated suites (run these first, always), Option A: local playtesting against the Firebase Emulator (free, no accounts, works offline), and Option B: Apple developer testing via TestFlight (the real pre-release path for playing with friends on their own iPhones).
flutter analyze lib test # 0 errors · 0 warnings · infos per docs/agent_execution_guide.md §1 (exits 1 even when clean)
flutter test # client widget/unit tests (incl. 360×640 phone-layout tests)
npm --prefix functions test # backend E2E on the Firebase emulator: full game loops,
# security rules, bots, custom decks, unmasking/revenge scoringThe backend suite needs firebase-tools (invoked via npx) and Java (for the Firestore emulator). It boots the emulators itself via emulators:exec.
Everything (Auth, Firestore, Cloud Functions) runs on your machine. Best for solo smoke tests with bots, and for multi-simulator play at your desk.
- Build the functions and start the emulators (ports are preconfigured in
firebase.json: Auth 9099, Functions 5001, Firestore 8080):cd functions && npm install && npm run build && cd .. npx firebase-tools emulators:start --only auth,functions,firestore
- Point the app at the emulator — either add
USE_EMULATOR=trueto your.env, or pass it at launch:flutter run --dart-define=USE_EMULATOR=true
- Networking per device (the client targets
localhost):- iOS Simulator: works as-is.
- Android Emulator: forward the ports first:
adb reverse tcp:8080 tcp:8080 && adb reverse tcp:5001 tcp:5001 && adb reverse tcp:9099 tcp:9099. - Physical device on your Wi-Fi: use
adb reverse(Android) or point the hosts at your machine's LAN IP (see the networking section above).
- Solo play with bots: debug builds create rooms with debug tooling enabled — in the lobby tap DEBUG: ADD BOTS (9 bots join), start the game, and use DEBUG: BOTS SUBMIT on each phase to drive them. This exercises the full loop end-to-end alone.
- Local multiplayer: launch the app on two or more simulators/devices (step 3 applies to each), create a room on one, and join with the room code from the others. Same-room-code play works entirely against the local emulator.
Note: the emulator wipes all data on shutdown — rooms don't persist between sessions. That's a feature for testing.
This is the path that matches what you'll submit to the App Store: a real build, the real cloud backend, friends installing on their own iPhones.
One-time backend deployment (the game cannot run multiplayer without it):
- You need a Firebase project on the Blaze (pay-as-you-go) plan — Cloud Functions do not deploy on the free Spark plan. Playtest usage costs cents.
- Link the project and deploy the backend:
npx firebase-tools login npx firebase-tools use --add # select your Firebase project cd functions && npm run build && cd .. npx firebase-tools deploy --only functions,firestore:rules
- In the Firebase console, enable Authentication → Sign-in method → Anonymous.
- Make sure your
.envcontains the realFIREBASE_API_KEY_IOS(and Android key if building there), and thatUSE_EMULATORis not set.
One-time Apple setup:
- Enroll in the Apple Developer Program ($99/year) and create an app record in App Store Connect (bundle ID must match
ios/Runner). - In Xcode (
open ios/Runner.xcworkspace), set your Team under Signing & Capabilities.
Each test build:
flutter build ipaUpload build/ios/ipa/*.ipa to App Store Connect via Xcode's Organizer or the Transporter app. Then in App Store Connect → TestFlight:
- Add friends as Internal Testers (up to 100, by email — builds are available to them within minutes, no review wait), or create a public TestFlight link for external testers (first external build requires a brief Beta App Review).
- Friends install the TestFlight app on their iPhone, accept the invite, and install Gaslight.
Playtest flow: one player creates a room and shares the 4-letter code (tap the brass room-code plaque to copy/share it); everyone else joins with the code. Minimum 2 players; the game needs more players than forgery rounds (default 2), so 3+ is the practical minimum and 4–6 is the sweet spot.
Android testers: the equivalent path is
flutter build apk --releaseand sideloadingbuild/app/outputs/flutter-apk/app-release.apk, or Play Console → Internal testing. The same deployed Firebase backend serves both platforms — iOS and Android friends can play in the same room.
- A non-host player can submit forgeries, vote, and ready up (the server-authoritative path).
- The Unmask the Forger window: fall for a lie, then guess its author before the forgers are revealed.
- Custom Decks: everyone writes prompts in the lobby; confirm you never receive your own prompt.
- Drop-out/rejoin: force-quit mid-game and reopen — you should recover your seat.
- Sound: quill scratch on submit, wax thunk on vote, the bell on the Truth reveal; the handbell icon mutes everything.
The runbook for shipping a new build. Three surfaces — web, iOS beta, and Cloud Functions — deploy independently; do only the ones your change touches.
Every gate must be green before anything ships. The current expected numbers live in docs/agent_execution_guide.md §1 — that file is the source of truth, not this list.
flutter analyze lib test # bar is 0 errors + 0 warnings
flutter test
npm --prefix functions run build
npm --prefix functions test
./scripts/check_decks_in_sync.sh
./scripts/check_deploy_fresh.sh
./scripts/check_playthrough_evidence.sh
./scripts/check_web_e2e_strings.sh
flutter analyzeexits 1 even when clean. It returns non-zero on infos, whose current count is in docs/agent_execution_guide.md §1 (withOpacitydeprecations,avoid_printin tests). Read the error and warning counts, not the exit code. Every other gate is judged on its exit code — and read those bare, never through a pipe:... | tailreports the pipe's status, which is always 0.
Use
flutter analyze lib test, never bareflutter analyze— the bare form walksbuild/{ios,macos}/SourcePackagesand reports ~678 phantom errors from vendored plugin source.
./scripts/run_web_smoke.sh # must exit 0 — about 5 minutes
flutter build web --release
npx firebase-tools deploy --only hostingRun the web smoke first, and do not build or deploy unless it exits 0.
./scripts/run_web_smoke.shbuilds an emulator-only copy of the app into a scratch directory (neverbuild/web: that build talks to the emulators and must never be deployed), starts the Auth, Functions and Firestore emulators withfirebase emulators:exec, and plays two full games with three browsers (test/web_e2e/): a one-round game through the whole journey and a two-round game with its match summary. It exits 0 only if both reach game over.
- It needs Java for the emulators (
brew install openjdk) and Playwright's Chromium intest/web_e2e/node_modules(cd test/web_e2e && npm install && npx playwright install chromium).- It takes about 5 minutes. It starts its own emulators, so it refuses to run while port 8777, 8080, 9099, 5001, 4000, 4400, 4500 or 9150 is busy; it prints the owner and kills nothing.
- Screenshots and logs go to the scratch directory it prints, never to
docs/playthroughs/evidence/. Re-capturing that recorded evidence is a separate, deliberate step.
⚠️ .envis a declared Flutter asset (pubspec.yaml), so it builds tobuild/web/assets/.env, andmain.dartcallsdotenv.load()beforerunApp(). If it is missing, the app dies before it paints anything.
- The
ignorelist infirebase.jsonmust never gain a dot-file glob (the**/.*pattern) — it would exclude the deployed.env. There is a comment infirebase.jsonsaying exactly this; heed it.- Before building, confirm
.envholds the real API keys and thatUSE_EMULATORis not true. It is baked into the bundle at build time — changing it afterwards has no effect.
Hosting already has SPA rewrites (** → /index.html), so deep links resolve.
Check the build number first — this is the step that wastes a build if skipped. iOS takes its version straight from pubspec.yaml: CFBundleShortVersionString = $(FLUTTER_BUILD_NAME) and CFBundleVersion = $(FLUTTER_BUILD_NUMBER). App Store Connect rejects a duplicate build number, and you only find out after the upload.
-
Look up the highest build already in App Store Connect.
-
Make sure
version:inpubspec.yamlexceeds it (1.0.0+N). Check whether a previous commit already bumped it before adding one. -
Build:
flutter build ipa
⚠️ Expect this to fail at the export step, and expect that to be fine. On a machine with no Apple Distribution certificate in the keychain,exportArchiveerrors withNo AccountsandNo signing certificate "iOS Distribution" found. This is not a build failure — the.xcarchiveis still produced, and that is the only thing you need. The command-line exporter cannot create a distribution certificate; Xcode's Distribute flow can, interactively, which is why step 4 works when this step does not.Check with
security find-identity -v -p codesigning— if you only see Apple Development, the CLI export will never succeed on this machine. -
Verify the archive — not the
.ipa. A stale.ipafrom an earlier successful export sits inbuild/ios/ipa/indefinitely and will happily upload the wrong build. Check the artefact you are about to distribute:stat -f "%Sm" -t "%Y-%m-%d %H:%M" build/ios/archive/Runner.xcarchive /usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleVersion" \ build/ios/archive/Runner.xcarchive/Info.plist
The timestamp must be from this build and the version must be the number you intend to ship.
-
Distribute from Xcode's Organizer — this is the path that works, not Transporter:
open build/ios/archive/Runner.xcarchive
Organizer opens with the archive selected → Distribute App → App Store Connect → Upload. Let it manage signing; that is what creates the distribution certificate. Transporter is only useful when you already have a valid
.ipa, which you will not have if step 3's export failed. -
In App Store Connect → TestFlight: internal testers (up to 100, by email) get the build within minutes with no review. External testers need a one-time Beta App Review on the first build.
-
Expire the previous build so testers stop playing an older client, and put a line in What to Test so they know what changed.
⚠️ Never accept Xcode's "Update to recommended settings" prompt. It enablesENABLE_USER_SCRIPT_SANDBOXINGand breaks the iOS build. This has bitten before.
iPhone-only (Wave AI / AI13). The Runner target sets
TARGETED_DEVICE_FAMILY = 1in all three build configurations, so the binary is iPhone-only: iPad users get the iPhone app in compatibility mode, and App Store Connect needs no iPad screenshots. Adding iPad later is allowed; removing it after an iPad-capable version is live is not — do not set it back to"1,2"without a decision (docs/design_ui_direction.md§10). Edit the setting as text inios/Runner.xcodeproj/project.pbxproj, never through Xcode's settings UI (the warning above). Check the built artefact with/usr/libexec/PlistBuddy -c "Print :UIDeviceFamily" build/ios/iphoneos/Runner.app/Info.plist→ only1.
Only when your change touches functions/src.
npx firebase-tools deploy --only functionspredeploy runs the functions build and test suite, so a red suite blocks the deploy. That is intended — do not bypass it.
⚠️ Re-apply the cleanup flag immediately afterwards:gcloud run services update cleanupdaily --region us-central1 --update-env-vars CLEANUP_DRY_RUN=false
CLEANUP_DRY_RUNlives on the Cloud Run revision, and a deploy creates a new revision without it — silently reverting the nightly cleanup to dry-run. The job keeps running and keeps logging; it just stops deleting. It fails in the safe direction, which is exactly why nobody notices. Read the value back to confirm:gcloud run services describe cleanupdaily --region us-central1 \ --format='value(spec.template.spec.containers[0].env)'Full detail in
docs/design_database_and_security.md§10.5.
⚠️ Commit before you deploy../scripts/check_deploy_fresh.shcompares deploy timestamps against the newestfunctions/srccommit, so deploying and then committing turns that gate red by construction. Afterwards it must exit 0.
Land and commit your changes → run the full preflight → bump the build number → deploy functions (if touched, then re-apply the flag) → build and upload the IPA → deploy hosting. Client-side changes must land before the IPA is built, or they will not be in the beta.
When contributing to this repository, please adhere to the following guidelines regarding file commits.
- Source code directories (
lib/,test/) - Project configuration files (
pubspec.yaml,pubspec.lock) - Platform-specific project files (
android/,ios/,web/) excluding build artifacts - Asset files (
assets/) - Documentation updates (e.g., this
README.md)
- Local environment files (e.g.,
.env) that contain sensitive information like API keys or secrets. - Build directories and generated files (e.g.,
build/,.dart_tool/). - IDE configuration files specific to your local setup (e.g., macOS
.DS_Store, local workspace settings). - Crash logs or locally generated temporary files.
When in doubt, consult the .gitignore file to see the patterns of files that should be excluded from version control.