Skip to content

Commit

Permalink
Additional All Sets page columns
Browse files Browse the repository at this point in the history
  • Loading branch information
gwax committed Sep 7, 2024
1 parent 0ce69ba commit 6a5d6c4
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 42 deletions.
20 changes: 15 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ Acknowledgments
early '90s.
- `Scryfall`_: Scryfall is a fantastic resource for anyone trying to lookup
cards or build software on top of up to date Magic card information.
- `MTG JSON`_: MTG JSON is an amazing resource for anyone looking to build
tools around magic card data. Before Scryfall, MTG JSON was my primary
source for card data and, without it, mtg-ssm would not exist.
- `MTGJSON`_: MTGJSON is an amazing resource for anyone looking to build
tools around magic card data. Before Scryfall, MTGJSON was my primary
source for card data and, without it, mtg-ssm would have died long ago.

.. _Wizards of the Coast: http://magic.wizards.com
.. _Scryfall: https://scryfall.com
.. _MTG JSON: http://mtgjson.com
.. _MTGJSON: http://mtgjson.com


Changelog
Expand Down Expand Up @@ -398,7 +398,7 @@ Development
1.2.3
-----

- Hack to work around missing "releaseDate" and "type" in MTG JSON 3.3.14
- Hack to work around missing "releaseDate" and "type" in MTGJSON 3.3.14

1.2.2
-----
Expand Down Expand Up @@ -440,3 +440,13 @@ Development
-----

- Initial stable release.

GsMtgJson
---------

Before mtg-ssm, this tool lived as a Google Apps Script project called
`GsMtgJson`_. As Magic added more cards, eventually the script became
too slow to function inside the constraints of Google Apps Script and
Google Sheets.

.. _GsMtgJson: https://github.com/gwax/GsMtgJson
27 changes: 18 additions & 9 deletions mtg_ssm/serialization/xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
"release",
"block",
"type",
"cards",
"printed",
"have",
"unique",
"playsets",
"count",
"extras",
"nonfoil",
"foil",
"value",
]

ALL_SETS_SHEET_TOTALS: Sequence[Optional[str]] = ["Total", None, None, None, None] + [
f"=SUM({c}3:{c}65535)" for c in "FGHIJ"
f"=SUM({c}3:{c}65535)" for c in "FGHIJKLM"
]


Expand Down Expand Up @@ -64,9 +67,12 @@ def create_all_sets(sheet: Worksheet, index: ScryfallDataIndex) -> None:
card_set.block,
card_set.set_type.value,
len(index.setcode_to_cards[card_set.code]),
f"=SUM('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')})",
f"=COUNTIF('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')},\">0\")",
f"=COUNTIF('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')},\">=4\")",
f"=SUM('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')})",
f"=SUMIF('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')},\">4\")-4*COUNTIF('{setcode}'!{_setsheet_col('have')}:{_setsheet_col('have')},\">4\")",
f"=SUM('{setcode}'!{_setsheet_col('nonfoil')}:{_setsheet_col('nonfoil')})",
f"=SUM('{setcode}'!{_setsheet_col('foil')}:{_setsheet_col('foil')})",
f"=SUM('{setcode}'!{_setsheet_col('value')}:{_setsheet_col('value')})",
]
sheet.append(row)
Expand All @@ -81,11 +87,14 @@ def style_all_sets(sheet: Worksheet) -> None:
("C", 12, True, None),
("D", 22, True, None),
("E", 15, True, None),
("F", 6, False, None),
("G", 7, False, None),
("H", 8, False, None),
("I", 7, False, None),
("J", 10, False, FORMAT_CURRENCY_USD_SIMPLE),
("F", 7, False, None),
("G", 6, False, None),
("H", 7, False, None),
("I", 8, False, None),
("J", 6, False, None),
("K", 7, False, None),
("L", 5, False, None),
("M", 10, False, FORMAT_CURRENCY_USD_SIMPLE),
]
for col, width, hidden, number_format in col_width_hidden_format:
cdim = sheet.column_dimensions[col]
Expand Down
Loading

0 comments on commit 6a5d6c4

Please sign in to comment.