Go reimplementation of DECWAR, a 1981 DEC mainframe real-time multiplayer space battle game. Players command Federation or Empire ships in a 75x75 sector galaxy, battling enemy ships, starbases, and planets using phasers and torpedoes. Up to 18 players (9 per side) plus a computer-controlled Romulan.
The original FORTRAN source code from the DEC PDP-11/VAX era is preserved in the original/ directory.
- Real-time Multiplayer: Up to 18 players over WebSocket, 9 Federation vs 9 Empire
- Two Factions: Federation (Excalibur, Farragut, Intrepid, Lexington, Nimitz, Savannah, Trenton, Vulcan, Yorktown) and Empire (Buzzard, Cobra, Demon, Goblin, Hawk, Jackal, Manta, Panther, Wolf)
- Space Combat: Phaser fire (dual banks, 50-500 power) and torpedo salvos (1-3 with burst targeting)
- Territory Control: Capture neutral planets, build fortifications, defend starbases
- Ship Operations: Docking for repair/resupply, energy transfer between ships, tractor beams, shield management
- Romulan NPC: Computer-controlled enemy that attacks both sides
- 29+ Commands: Movement, combat, information, and utility commands faithful to the original game
- Terminal Themes: Green, amber, or white color schemes via
/colorchat command - ASCII Interface: Classic terminal-style gameplay rendered in the browser
Players interact through abbreviated text commands. See docs/COMMANDS.md for full implementation status.
| Category | Commands |
|---|---|
| Movement | MOVE (warp), IMPULSE, DOCK |
| Combat | PHASERS, TORPEDO, CAPTURE, BUILD |
| Defense | SHIELDS, REPAIR, TRACTOR |
| Information | SRSCAN, SCAN, STATUS, DAMAGES, TARGETS, PLANETS, BASES, SUMMARY, USERS, POINTS, TIME |
| Communication | TELL, RADIO (GAG/UNGAG), GRIPE, NEWS |
| Configuration | SET (NAME, OUTPUT, SCAN, PROMPT, ICDEF, OCDEF, SAVE, CLEAR), TYPE, ENERGY |
| Other | HELP, QUIT |
- Backend: Go with Gin web framework
- WebSocket: Gorilla WebSocket for real-time communication
- Database: SQLite with WAL mode (pure Go, no CGO)
- Feature Flags: go-feature-flag with YAML config
- Authentication: bcrypt password hashing with cookie-based sessions
- Frontend: HTML templates with vanilla JavaScript
Five layers, each communicating via channels:
Browser (WebSocket)
|
Transport (internal/transport) - Hub manages clients, broadcasts, pub/sub
| |
Chat Game Engine (internal/game/engine)
lobby single run() goroutine, all state mutations
/activate |
wizard -----> joinCh
Concurrency model: Both Hub and Engine use a single-goroutine event loop. All state mutations happen inside their respective run() goroutines.
Wire protocol: JSON envelopes {type, payload} over WebSocket. Types: "chat", "game", "status", "redirect", "prompt".
Player flow: Login → /chat lobby → /activate wizard (pick side → pick ship) → Engine spawns ship → redirect to /game.
Game tick: Every 2 seconds the engine runs respawn checks, disconnect timeouts, device repair, energy regen, planet/base fire, Romulan AI, and win condition checks.
# Run (default port 9090)
go run ./cmd/decwar
# Build
go build -o decwar ./cmd/decwar
# Test
go test ./...| Variable | Default | Purpose |
|---|---|---|
ADDR |
:9090 |
Server listen address |
DB_PATH |
decwar.db |
SQLite database path |
FLAGS_PATH |
flags.yaml |
Feature flags config |
SESSION_SECRET |
(required in prod) | Cookie encryption key |
DEBUG_ADDR |
(disabled) | Debug galaxy viewer address |
Deploys to GCP Cloud Run. See DEPLOY.md for instructions.
Derivative work of the original DECWAR (Copyright 1979, 2011 Bob Hysick, Jeff Potter, The University of Texas at Austin). Licensed under the GNU General Public License v3.0.