Drugwars for the terminal, rebuilt in Rust 🦀
By urrick hunt
Current version: 0.6.69
This started from the same game idea, but it is no longer a straight port. The codebase has been completely refactored and the game itself has been expanded with music, a revised gun system, shotgun combat, stronger validation, better feedback, and a more readable small screen text flow.
- Complete refactor from a monolithic single file game into a modular Rust project with separate rules, UI, model, flow, and view layers.
- Optional background music, when a supported player is available, with
M/mtoggle support at theBUY / SELL / JETprompt. - New ANSI title presentation with a logo splash screen and typewriter style intro/instructions screens.
- Revised weapon system: up to two handguns, with better fight odds when carrying two, plus a shotgun upgrade with its own combat behavior.
- Guns are no longer random daily events; they are sold in the Ghetto as a dedicated market encounter.
- Context-aware positive and negative messages throughout trading, bank, loan, stash, combat, and event flows.
- Amount prompts are stricter and clearer: non-numeric input is ignored,
oversized numbers no longer collapse to
0, and failed actions return to the same field with a clear message. - Buy screens show both what you can afford and, when relevant, what you can still carry.
- Event and confirmation text is split more cleanly for smaller terminal screens.
- High scores are stored in a per-user app data directory instead of the current working directory or binary folder.
- Color-coded market events, drug price swings, and clearer outcome messaging.
- Music uses
mpvif available, then falls back toffplay. - If no supported player is installed, the game still runs normally; music is simply disabled.
- Windows example: install
mpvwith Scoop viascoop install mpv. - macOS example: install
mpvwith Homebrew viabrew install mpv. - macOS: install
mpvorffplayand make sure it is onPATH. - Linux: install
mpvorffplayfrom your distro packages and make sure it is onPATH.
Y/Nfor confirmations.- At the
BUY / SELL / JETprompt:Bbuy,Ssell,Jjet,Mtoggle music. - The HUD music note shows as a green
♪when music is playing and a grey♪when it is off, paused, or unavailable. - Drug keys are prompt-based:
Ccocaine,Hheroin,Aacid,Wweed,Sspeed,Lludes. - Travel uses
1through6.
cargo install drugwars-rust
drugwars-rustcargo run --releaseStandard release build:
cargo build --release
./target/release/drugwars-rustcargo run --profile release-ltoor build the binary directly:
cargo build --profile release-lto
./target/release-lto/drugwars-rustOn Windows Git Bash / mintty, run the built executable through winpty:
winpty ./target/release/drugwars-rust.exe
winpty ./target/release-lto/drugwars-rust.exeIf drugwars-rust.exe is already on your PATH, this also works:
winpty drugwars-rustcargo run -- --version- Linux:
$XDG_DATA_HOME/drugwars-rust/highscores.txtor~/.local/share/drugwars-rust/highscores.txt - macOS:
~/Library/Application Support/drugwars-rust/highscores.txt - Windows:
%APPDATA%\drugwars-rust\highscores.txt
cargo test
cargo clippy -- -W clippy::pedantic -W clippy::nursery -W clippy::cargoFor crate tests, use crate::test_support::game_builder() to build focused
GameState fixtures instead of wiring the internals by hand:
let game = crate::test_support::game_builder()
.with_cash(10_000)
.with_price(Drug::Cocaine, 20_000)
.with_cops(3)
.build();- macOS
- Linux
- Windows
MIT
