Skip to content
yelouisPublic

About

A social deduction party game where players compete to craft the most convincing deceptions for their friends' personal stories

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Gaslight

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.

Getting Started

This project is a Flutter application that uses Firebase for its backend and flutter_dotenv for environment variable management.

Prerequisites

  • Flutter SDK (>=3.0.6 <4.0.0)
  • Dart SDK
  • A Firebase project with Firestore enabled

Setting up API Keys

This project uses flutter_dotenv to manage Firebase API keys. The keys must not be exposed in source control.

  1. Navigate to the project root directory.
  2. Locate the .env.example file, and create a copy of it named .env:
    cp .env.example .env
  3. Open the newly created .env file and replace the placeholder values with your actual Firebase API keys found in your Firebase console:
    FIREBASE_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
    Note: The .env file is excluded from git via .gitignore to prevent secret leaks.

Installation & Launch

  1. Fetch the project dependencies:
    flutter pub get
  2. Run the application on your connected device or emulator:
    flutter run

Emulator & Simulator Networking Setup

When testing the application locally with a local Firebase emulator suite or calling local servers, configuring networking is required:

  • iOS Simulator: Connects directly to localhost or 127.0.0.1.
  • Android Emulator: Cannot resolve 127.0.0.1 as the host machine. Instead, use the special loopback IP address 10.0.2.2 which 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 using adb reverse tcp:8080 tcp:8080 (or appropriate Firestore/auth ports).

Duplicate-Answer Filtering

  • 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.

Testing & Running the Game

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).

Automated test suites (run before any playtest)

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 scoring

The backend suite needs firebase-tools (invoked via npx) and Java (for the Firestore emulator). It boots the emulators itself via emulators:exec.


Option A — Local testing (Firebase Emulator, no cloud account needed)

Everything (Auth, Firestore, Cloud Functions) runs on your machine. Best for solo smoke tests with bots, and for multi-simulator play at your desk.

  1. 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
  2. Point the app at the emulator — either add USE_EMULATOR=true to your .env, or pass it at launch:
    flutter run --dart-define=USE_EMULATOR=true
  3. 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).
  4. 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.
  5. 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.

Option B — Apple developer testing (TestFlight, for real playtests with friends)

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):

  1. 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.
  2. 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
  3. In the Firebase console, enable Authentication → Sign-in method → Anonymous.
  4. Make sure your .env contains the real FIREBASE_API_KEY_IOS (and Android key if building there), and that USE_EMULATOR is not set.

One-time Apple setup:

  1. Enroll in the Apple Developer Program ($99/year) and create an app record in App Store Connect (bundle ID must match ios/Runner).
  2. In Xcode (open ios/Runner.xcworkspace), set your Team under Signing & Capabilities.

Each test build:

flutter build ipa

Upload 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 --release and sideloading build/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.

What to verify in a playtest

  • 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.

Releasing

The runbook for shipping a new build. Three surfaces — web, iOS beta, and Cloud Functions — deploy independently; do only the ones your change touches.

0. Preflight (always)

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 analyze exits 1 even when clean. It returns non-zero on infos, whose current count is in docs/agent_execution_guide.md §1 (withOpacity deprecations, avoid_print in 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: ... | tail reports the pipe's status, which is always 0.

Use flutter analyze lib test, never bare flutter analyze — the bare form walks build/{ios,macos}/SourcePackages and reports ~678 phantom errors from vendored plugin source.

1. Web app

./scripts/run_web_smoke.sh        # must exit 0 — about 5 minutes
flutter build web --release
npx firebase-tools deploy --only hosting

Run the web smoke first, and do not build or deploy unless it exits 0. ./scripts/run_web_smoke.sh builds an emulator-only copy of the app into a scratch directory (never build/web: that build talks to the emulators and must never be deployed), starts the Auth, Functions and Firestore emulators with firebase 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 in test/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.

⚠️ .env is a declared Flutter asset (pubspec.yaml), so it builds to build/web/assets/.env, and main.dart calls dotenv.load() before runApp(). If it is missing, the app dies before it paints anything.

  • The ignore list in firebase.json must never gain a dot-file glob (the **/.* pattern) — it would exclude the deployed .env. There is a comment in firebase.json saying exactly this; heed it.
  • Before building, confirm .env holds the real API keys and that USE_EMULATOR is 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.

2. iOS beta (TestFlight)

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.

  1. Look up the highest build already in App Store Connect.

  2. Make sure version: in pubspec.yaml exceeds it (1.0.0+N). Check whether a previous commit already bumped it before adding one.

  3. 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, exportArchive errors with No Accounts and No signing certificate "iOS Distribution" found. This is not a build failure — the .xcarchive is 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.

  4. Verify the archive — not the .ipa. A stale .ipa from an earlier successful export sits in build/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.

  5. 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.

  6. 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.

  7. 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 enables ENABLE_USER_SCRIPT_SANDBOXING and breaks the iOS build. This has bitten before.

iPhone-only (Wave AI / AI13). The Runner target sets TARGETED_DEVICE_FAMILY = 1 in 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 in ios/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 → only 1.

3. Cloud Functions — and the flag that vanishes

Only when your change touches functions/src.

npx firebase-tools deploy --only functions

predeploy 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_RUN lives 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.sh compares deploy timestamps against the newest functions/src commit, so deploying and then committing turns that gate red by construction. Afterwards it must exit 0.

4. Order

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.

Version Control

When contributing to this repository, please adhere to the following guidelines regarding file commits.

What to Commit

  • 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)

What NOT to Commit

  • 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.

About

A social deduction party game where players compete to craft the most convincing deceptions for their friends' personal stories

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages