Skip to content

bowman025/mtg-deck-analyzer

Repository files navigation

MTG Deck Analyzer

A command-line tool that analyzes Magic: The Gathering decklists using the Scryfall API.

Features

  • Mana curve breakdown with ASCII bar chart
  • Color and card type distribution
  • Average CMC (excluding lands)
  • Format legality check
  • Estimated deck price (USD and EUR)
  • Local card cache to avoid redundant API calls

Requirements

Python 3.10+ and the requests library:

pip install requests

Usage

python main.py <decklist>                        # basic analysis
python main.py <decklist> --format modern        # include legality check
python main.py <decklist> --no-price             # skip price data
python main.py <decklist> --output json          # output as JSON
python main.py <decklist> --clear-cache          # wipe cache, then analyze
python main.py --clear-cache                     # wipe cache and exit

Supported --format values: standard, pioneer, modern, legacy, vintage, commander

Decklist format

Plain .txt file, one card per line. All of these are supported:

4 Lightning Bolt
4x Lightning Bolt
4X Lightning Bolt
Lightning Bolt x4
Lightning Bolt       # no quantity — assumes 1
// this is a comment
Creatures            # section headers are ignored

Project structure

mtg-deck-analyzer/
├── main.py          # entry point, argparse
├── parser.py        # decklist file parsing
├── scryfall.py      # Scryfall API client
├── cache.py         # local JSON card cache
├── analyzer.py      # deck statistics
├── display.py       # terminal output formatting
└── cache/           # auto-created, stores cached card data

Running tests

python -m unittest discover -p "test_*.py" -v

105 tests across test_parser.py, test_analyzer.py, test_cache.py, and test_scryfall.py.

Notes

  • Basic lands (Forest, Mountain, etc.) have no price data on Scryfall and are excluded from price totals
  • Single-word card names without a quantity (e.g. Brainstorm) will be skipped — add a quantity to include them
  • Card data is cached in cache/cards.json after the first fetch; use --clear-cache to refresh it

About

A simple MTG deck analyzer for the command line.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages