Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

landcalc

Recommend how many lands a Commander deck should run, using this heuristic from Frank Karsten's How Many Lands Should You Play? video.

lands = 31.42 + 3.13 * avg_mv - 0.28 * cheap_card_draw_or_ramp

where:

  • avg_mv is the average mana value of the non-land cards ("spells") in the deck, and
  • cheap_card_draw_or_ramp is the number of spells with mana value 3 or less that tap for mana, draw cards, or reduce mana costs.

How it works

  1. The deck is fetched from a given URL. Moxfield and Archidekt are supported.
  2. Each spell with mana value 3 or less is classified using Scryfall's functional oracle tags. Rather than query the search API per deck, landcalc downloads Scryfall's bulk data dumps (Oracle Tags and Oracle Cards) once and classifies offline. The dumps are cached in a .landcalc_cache directory in the current working directory (override with LANDCALC_CACHE_DIR) and refreshed when older than a week.

Modal double-faced cards with a land on either side are counted as lands.

Install

uv sync

Command-line usage

Example runs:

uv run landcalc https://moxfield.com/decks/9CUA-IuKoUeMEA6xb-jF0Q
uv run landcalc https://archidekt.com/decks/23847627/the_vision

Example output:

Fetching and classifying deck ...
Deck: Birds!

==================================================
Non-land spells .............. 62
Average mana value ........... 3.00
Cheap ramp/draw (mv<=3) ...... 15
--------------------------------------------------
  31.42 + 3.13*avg_mv - 0.28*cheap_ramp_draw
= 31.42 + 3.13*3.00 - 0.28*15
==================================================
  RECOMMENDED lands ....   37   (36.61 exact)
  CURRENTLY in deck ....   37   (right on target)
==================================================

Web app

The same calculation is available as a small web app. It ships a dependency-free Python server (stdlib http.server) that serves the static frontend and a JSON API.

uv run landcalc-web                       # binds 127.0.0.1 on $PORT (default 8000)
uv run landcalc-web --host 0.0.0.0 --port 8080

Then open the printed URL, paste a deck URL, and click Calculate.

It binds 127.0.0.1 by default. To deploy on a host like Render, set HOST=0.0.0.0 (the platform's PORT is already honored); --host/--port override the environment.

How the pieces fit together

  • src/landcalc/core.py — the deck fetch + land calculation (analyze(url)), shared by both interfaces.
  • src/landcalc/cli.py — the command-line interface.
  • src/landcalc/web.py — the HTTP server (GET /api/analyze?url=… returns the analysis as JSON; every other path serves a static file).
  • src/landcalc/web/static/ — the frontend (index.html, style.css, app.js), plain HTML and JS with no build step.

About

Recommend how many lands a Commander deck should run.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages