Files
morse-trainer/README.md

5.0 KiB

Morse Code Practice Game 🎮

A terminal-based morse code practice game built with Deno. Improve your morse code translation skills through interactive gameplay with multiple difficulty levels and comprehensive statistics tracking.

Features

  • Multiple Difficulty Modes

    • 🟢 Easy: Single letters (A-Z)
    • 🟡 Medium: Letters + Numbers (A-Z, 0-9)
    • 🟣 Hard: Letters + Numbers + Punctuation (.,?!-/()@)
    • 🔵 Challenge: Common words
    • 🔴 Expert: Short phrases
  • Interactive TUI Interface

    • Beautiful terminal UI with colors and tables
    • Configurable time limits (3-60 seconds)
    • Dynamic time option for words/phrases (time scales with length)
    • Immediate feedback on answers
    • Progress tracking with streak counter
  • Statistics Tracking

    • Overall accuracy and performance metrics
    • Mode-specific statistics
    • Best streak tracking
    • Historical game data
    • Average time per round
    • Stats saved locally in project folder
  • Smart Feedback

    • Immediate feedback on answers
    • Shows what your morse code translates to when incorrect
    • Helps you learn from mistakes
  • Flexible CLI

    • Interactive menu mode (default)
    • Quick play mode with command-line arguments
    • Stats viewer
    • Built-in morse code reference

Installation

Make sure you have Deno installed.

# Clone or download this repository
cd morse-game

# Make the script executable (optional)
chmod +x main.ts

Usage

Interactive Mode (Default)

Run the game and navigate through the menu:

deno task start
# or
deno run --allow-read --allow-write --allow-env main.ts

Quick Play Mode

Start a game directly with custom settings:

# Play 5 rounds of letters mode with 20 seconds per round
deno task start play --mode letters --rounds 5 --time 20

# Play expert mode
deno task start play --mode phrases --rounds 10 --time 45

Options:

  • -m, --mode <mode> - Game mode: letters, alphanumeric, full, words, or phrases (default: letters)
  • -r, --rounds <number> - Number of rounds (default: 10)
  • -t, --time <seconds> - Seconds per round (default: 30)

View Statistics

deno task start stats

Show Reference

Display a morse code reference chart:

deno task start reference

Reset Statistics

deno task start reset

How to Play

  1. Select a difficulty mode - Choose from:
    • Letters only (A-Z)
    • Alphanumeric (A-Z, 0-9)
    • Full character set (letters, numbers, punctuation)
    • Words or phrases
  2. Configure your game - Set the number of rounds (5-50) and time per round (3-60 seconds)
  3. Enable dynamic time (optional) - For words/phrases, time can scale based on character count
  4. Translate to morse code - You'll be shown a challenge
  5. Enter your answer - Type the morse code using:
    • . (dot) for short signals
    • - (dash) for long signals
    • Space to separate letters
    • / to separate words
  6. Get instant feedback - See if you got it right and what your input translates to if wrong
  7. Review your performance - After all rounds, view detailed statistics

Morse Code Basics

  • Use . for dots and - for dashes
  • Separate letters with spaces
  • Use / for word boundaries
  • Supported punctuation: . , ? ! - / ( ) @
  • Example: HELLO = .... . .-.. .-.. ---
  • Example: SOS = ... --- ...
  • Example: HELLO WORLD = .... . .-.. .-.. --- / .-- --- .-. .-.. -..

Statistics

The game tracks:

  • Total games played
  • Total rounds completed
  • Correct and incorrect answers
  • Overall accuracy percentage
  • Average time per round
  • Best streak (consecutive correct answers)
  • Per-mode statistics

Stats are saved to ./data/stats.json in the project directory.

When you answer incorrectly, the game shows what your morse code input actually translates to, helping you understand and learn from your mistakes.

Development

# Run in watch mode for development
deno task dev

# Run with specific permissions
deno run --allow-read --allow-write --allow-env main.ts

Project Structure

morse-game/
├── main.ts          # CLI entry point and command parser
├── game.ts          # Game logic and session management
├── morse.ts         # Morse code translation utilities
├── stats.ts         # Statistics tracking and persistence
├── ui.ts            # TUI interface and menus
├── deno.json        # Deno configuration and dependencies
└── README.md        # This file

Dependencies

License

MIT

Contributing

Feel free to open issues or submit pull requests!


73 (Best regards in morse code) 📡