中文文档 → README.zh-CN.md
A real-time multiplayer idle clicker game where everyone shares the same game world. Click to earn gold, buy facilities, enhance with diamonds, and work your way from a tiny office to a multiversal corporation.
- Multiplayer by Default — All connected players share and mutate the same global game state in real time.
- Click to Earn — Tap the big coin to earn gold. Upgrade your click power.
- 60 Facilities — 30 workplace-themed (AI, servers, space colonies) + 30 cultivation-themed (Qi, tribulations, immortal realms).
- Diamond Bonus — Each click has a 1 % chance to drop a diamond. Use diamonds to enhance facilities (+1 % per level).
- Auto Income — Facilities produce gold every tick. Income accumulates even while you are offline (up to 7 days).
- Live Chat — Real-time chat panel. The last 200 messages are persisted.
- IP-based Identity — Your display name is a masked IP and your theme colour is deterministically derived from your IP.
- Shared Progress — Every purchase and upgrade is visible to all connected players instantly.
- Embedded Web UI — All HTML, CSS and JavaScript are compiled into a single binary via
go:embed.
| Currency | Use | Source |
|---|---|---|
| Gold 🪙 | Buy facilities, upgrade click power | Click the big coin, auto-income from facilities |
| Diamond 💎 | Enhance facilities (×1.01 per level) | Random drop (1 % per click) |
Upgrade with gold. Cost and power both grow by ×1.05 per level.
60 facilities, each with:
- Base cost (gold)
- Base CPS (coins per second)
- Cost growth multiplier (1.05 / 1.25 / 1.50 / 1.75 / 2.0 depending on tier)
- Enhance multiplier (×1.01 per diamond spent)
When the server restarts, it computes up to 7 days of missed CPS income and adds it to the gold pool.
- Language Go 1.26.3
- HTTP Framework Gin
- WebSocket gorilla/websocket
- Database SQLite via modernc.org/sqlite (pure-Go, no CGO needed)
- Templating
html/template - Frontend Vanilla JavaScript + CSS (embedded in the binary)
- Financial Arithmetic Custom 128-bit
Amounttype usingmath/big.Float, serialized as scientific notation strings
main.go
├── game/engine.go — Shared game state, action handlers, tick loop
├── game/hub.go — WebSocket client lifecycle, message broadcast
├── game/store.go — SQLite persistence (schema, load, save, chat)
├── game/ip.go — IP masking and deterministic colour derivation
├── game/facilities.go — Facility definitions and economy formulas
├── game/amount.go — 128-bit Amount type with scientific-notation IO
├── static/js/app.js — Browser WebSocket client
├── static/css/style.css — Styles
└── templates/index.html — HTML shell
The game is global, not per-user. Every WebSocket client reads and mutates a single Engine instance protected by a mutex. State snapshots are broadcast to all connected clients every second.
- Go 1.26.3+
# From the repository root
go run .The server listens on :3001 by default.
Visit http://localhost:3001.
| Variable | Default | Description |
|---|---|---|
PORT |
3001 |
HTTP listen port |
No other configuration knobs are exposed at runtime. The database path is fixed to data/game.db relative to the working directory.
- Game state is saved to
data/game.db(SQLite) every 5 seconds if dirty, and force-saved onSIGINT/SIGTERM. - Chat messages are persisted; only the most recent 200 rows are kept.
- Legacy databases using a
REALgold column are automatically migrated to the bounded Amount format. - Do not edit
data/game.dbby hand while the server is running.
Persist the entire data/ directory across restarts to preserve progress.
# Native
go build -trimpath -ldflags="-s -w" -o click .
# Windows (cross from Linux/macOS)
GOOS=windows go build -trimpath -ldflags="-s -w" -o click.exe .
# Linux
GOOS=linux go build -trimpath -ldflags="-s -w" -o click-linux .The binary is self-contained — no external assets need to be copied alongside it.
go vet ./...
go test ./...
go test ./game -run '^TestName$' # run a specific testTests use t.TempDir() stores and never touch the live data/game.db.
.
├── main.go # Entry point, routing, asset embedding
├── go.mod / go.sum # Dependencies
├── game/
│ ├── engine.go # Core game loop, action handlers
│ ├── hub.go # WebSocket client registry, message dispatch
│ ├── store.go # SQLite schema, CRUD, migration
│ ├── ip.go # IP masking, theme colour
│ ├── facilities.go # Facility catalog, economy formulas
│ ├── amount.go # 128-bit Amount type
│ ├── amount_test.go
│ ├── engine_cache_test.go
│ ├── click_aggregation_test.go
│ └── migration_test.go
├── static/
│ ├── css/style.css
│ └── js/app.js
├── templates/
│ └── index.html
├── data/ # SQLite database (ignored, created at runtime)
├── .github/workflows/ci.yml
├── .gitattributes
├── .gitignore
├── AGENTS.md
├── CONTRIBUTING.md
├── LICENSE
├── SECURITY.md
├── README.md
└── README.zh-CN.md
See CONTRIBUTING.md.
See SECURITY.md.
MIT © 2026 miniwater

