Empire of Choice
Tycoon idle game shipped to web and Android
- Server Actions for game state mutations (no API routes)
- Offline progress calculation with last-played timestamp diff
- i18n via next-intl, multi-language ready from day one
- Capacitor Android build with native AdMob monetization
- Auto-save with Prisma + Neon serverless Postgres
- Tier system and contracts driving the idle loop
Overview
Empire of Choice is a tycoon idle game where players grow an industrial empire, buildings, contracts, finances and achievements all feeding a progression loop. Shipped to web (empire-of-choice.vercel.app) and packaged for Android via Capacitor with AdMob monetization.
Problem
Most idle game tutorials end at "click the button, number go up." Real production idle games need: persistent state across sessions, offline progress, monetization that doesn't ruin pacing, internationalization, and a build pipeline that targets both web and mobile from one codebase.
Solution
Single Next.js 16 codebase serving the web app and packaged into Android via Capacitor. Game state lives in Postgres (Neon serverless) through Prisma 7. Server Actions handle every mutation, no separate API layer. Offline progress is computed at session resume by diffing lastPlayed against now and replaying the production loop.
next-intl handles localization with namespaced message files. AdMob is wired through @capacitor-community/admob for native ad placements (interstitial + rewarded). Zustand owns transient UI state; persisted game state stays in the database.
Tech rationale
- Next.js 16 App Router + Server Actions: eliminate the API/client split, mutations are typed end-to-end
- Neon Postgres: serverless scales to zero, perfect for a free-tier hobby project
- Prisma 7 + adapter-pg: modern driver, ready for edge if needed
- Capacitor: one codebase, native shell, easy to push to Play Store
- shadcn/ui: accessible primitives, easy to style for game aesthetics
- Vercel: git-push deployment, preview URLs for every branch
Lessons learned
- Server Actions feel like RPC done right, but you still need optimistic UI for game feel
- AdMob integration on Capacitor is fiddly on first setup, then forgettable
- Offline progress math gets weird at the edges (sleep + clock skew), clamp aggressively