Skip to content

A personal learning project to explore Ink (React for terminals) and Bun runtime through building a terminal-based D&D adventure game.

License

Notifications You must be signed in to change notification settings

wanyukang/DND-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DND CLI - Terminal-based Dungeons & Dragons Adventure Game

A terminal-based Dungeons & Dragons (D&D) adventure game built with React and Ink. The application provides an interactive CLI interface for a simple combat game where players create characters and engage in battles against enemies.

📸 Screenshots

Character Creation
Character Creation Screen
Combat Scene
Combat Scene

🎮 Features

  • Character Creation: Create and customize your character with a name
  • Turn-based Combat: Engage in battles with enemies
  • Visual Terminal UI: Rich terminal interface using Ink (React for terminals)
  • Chinese Localization: Fully localized in Chinese
  • Cross-platform: Builds available for Windows, macOS, and Linux
  • Self-contained Executables: Single-file executables with no external dependencies

🛠️ Technologies Used

  • Runtime Environment: Bun (primary) / Node.js
  • Framework: React (v18.3.1) with Ink for terminal UI
  • Language: TypeScript
  • Build System: Bun with esbuild
  • UI Library: Ink (React-based terminal UI framework)
  • Input Handling: ink-text-input for character creation

🚀 Getting Started

Prerequisites

  • Bun (recommended) or Node.js with npm

Installation & Development

# Clone the repository
git clone <repository-url>

# Navigate to project directory
cd dnd_cli

# Install dependencies
bun install
# or if using npm: npm install

# Run in development mode
bun run dev

🏗️ Building Executables

Build for your current platform

# Build for Linux/macOS (executables placed in build/ directory)
bun run build

# Build for Windows
bun run build:win

# Build for macOS specifically
bun run build:mac

Executing

After building:

  • Linux/macOS: ./build/dnd
  • Windows: ./build/dnd.exe (in the build directory)

Or install globally:

npm link # or bun link if using bun

Then run with dnd command anywhere.

🎲 Game Mechanics

  • Players start with 100 HP, 15 attack, and 5 defense
  • Enemies (currently only Goblins) have 50 HP, 10 attack, and 3 defense
  • Player attacks by pressing 'A' key during their turn
  • Damage calculation: max(attack - opponent.defense, 1)
  • 20% chance for critical hits that deal double damage
  • Turn alternates between player and enemy automatically

📁 Project Structure

src/
├── CharacterCreation.tsx  # Handles character creation
├── Combat.tsx            # Manages battle mechanics
├── Game.tsx              # Main game controller
├── index.tsx             # Entry point
└── types.ts              # Type definitions

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

📄 License

This project is licensed under the MIT License.

About

A personal learning project to explore Ink (React for terminals) and Bun runtime through building a terminal-based D&D adventure game.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published