~q3cpma/mtg-tools

Magic: The Gathering tools to manage lists
List tweaks (#3) and handle commas in card names
List tweaks (#2)

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~q3cpma/mtg-tools
read/write
git@git.sr.ht:~q3cpma/mtg-tools

You can also use your local clone with git send-email.

    Utilities
    =========

* find_card:        find all cards matching an ERE and view them with sxiv.
* list_collage:     produce a fancy collage from a list.
* list_size:        count the card number in a list.
* mana_curve:       create a CSV describing the mana curve of a list.
* mana_curve_plot:  same as above, but produces a nice plot instead of a CSV.

Most of these require the MTG_IMGDIR environment variable set to where you put
the Magic picture album that you downloaded from slightlymagic.


    Dependencies and portability
    ============================

* POSIX environment
* sh with local/typeset, realpath, xargs -0, sed -E and find -iname
* GNU parallel, imagemagick 7 (list_collage)
* gnuplot (mana_curve_plot)

Basically, it should work fine on GNU, *BSD and MacOS.


    List format
    ===========

+----------------------------------------------------------------+
| count="[0-9]+"                                                 |
| name="[[:graph:] ]+"                                           |
| set="[^)]+"                                                    |
| ERE="^($count[[:blank:]]+$name([[:blank:]]+\($set\))?\$|#|\$)" |
+----------------------------------------------------------------+

A line is valid if `grep -E "$ERE"` can match it. To validate a list named
`list.txt`:
+-----------------------------------------------------+
| grep -vEq "$ERE" list.txt && echo FAIL || echo PASS |
+-----------------------------------------------------+


Some remarks about the format:

* Empty lines or lines starting with `#` are ignored.
* If `count` is 0, `list_collage` won't put a count sticker on the card
  (useful for double-faced cards).
* `name` and `set` are matched case insensitively. They come from the
  slightlymagic.net download filenames.
  Sets are named by their code, a set_codes.txt file can be found at the repo
  root to easily make your symlinks and enjoy more readable names.
* Split cards are named like this: `Fire//Ice`.
* If a card has more than one illustration (like basic lands), use `name [n]`
  as `name` to get the nth illustration.
* The comment `#CMCn` has a special meaning: the entries following it (until
  another comment, an empty line or EOF appears) are considered as having the
  converted mana cost `n` by the mana curve tools.
* Same for `#Type` (as in Creatures, Artifacts, etc...): the entries following
  it (until an empty line or EOF appears) are considered as having said type by
  `list_collage` (these comments are actually needed by `list_collage`, or no
  entry at all will be included).


    Example list
    ============

+---------------------------+
| #Creatures                |
| #CMC1                     |
| 3   Delver of Secrets     |
| 0   Insectile Aberration  |
| #CMC0                     |
| 4   Ornithopther    (ATQ) |
|                           |
| #Artifacts                |
| #CMC0                     |
| 2   Welding Jar           |
|                           |
| #Instants                 |
| #CMC2                     |
| 2   Fire//Ice       (APC) |
|                           |
| #Lands                    |
| 20  Plains [4]      (ODY) |
+---------------------------+