~q3cpma/mtg-tools

Magic: The Gathering tools to manage lists
List updates #2
Modernize scripts and update lists
List updates and sxiv geometry change

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.sh:        find all cards matching an ERE and view them with sxiv.
* list_collage.sh:     produce a fancy collage from a list.
* list_size.sh:        count the card number in a list.
* mana_curve.sh:       create a CSV describing the mana curve of a list.
* mana_curve_plot.sh:  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 (and extracted) from [1].


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

* POSIX environment
* GNU parallel (`list_collage.sh`)
* unzip (`extract_pictures.sh`)
* sxiv (`find_card.sh`, can easily be changed)
* imagemagick 7 (`list_collage.sh`)
* gnuplot (`mana_curve_plot.sh`)

Portability requirements are detailed in each script. To resume it, the base
portability is GNU, *BSD, MacOS and Illumos, but `list_collage.sh` needs
`sort -V` which is not present on NetBSD, MacOS nor Illumos. Fortunately, it
can easily be replaced by other natural sorting tools (a simple and fast one
can be had at [2]).


    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.sh` 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
  http://www.slightlymagic.net/wiki/Magic_Album filenames.
* 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.sh` (these comments are actually needed by `list_collage.sh`,
  or no entry at all will be included).


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

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


[1] http://www.slightlymagic.net/wiki/Magic_Album
[2] https://git.sr.ht/~q3cpma/misc-tools