2022-02-18 19:34:35 +00:00
:PROPERTIES:
:ID: e79ad4ee-17d0-44f9-8270-2f19b65bc949
2022-12-08 20:20:49 +00:00
:header-args:sql: :engine postgresql :dbhost reason :dbuser tutor :dbpassword tutor :database tutor :exports both
:header-args: :eval no-export
2022-02-18 19:34:35 +00:00
:END:
#+title : Tutor
A [[id:cda9c620-fec5-4549-b979-22fc06819d77 ][Python ]] application backed by a SQLite database for tracking my [[id:d5efa5bd-dac9-4ef5-b352-a2b794a37bd0][Magic: The
Gathering]] card collection.
https://git.phoenixinquis.net/correlr/tutor
* Finding cards for a deck
Decklist -- Alive -- Shared via TopDecked MTG
Main (100)
1 Serra Ascendant
1 Soul's Attendant
1 Ajani's Pridemate
1 Alabaster Mage
1 Grateful Apparition
1 Suture Priest
1 Trelasarra, Moon Dancer
1 Angel of Vitality
1 Celestial Unicorn
1 Evolution Sage
1 Lurking Roper
1 Spike Feeder
1 Splendor Mare
1 Armorcraft Judge
1 Bloom Hulk
1 Core Prowler
1 Lathiel, the Bounteous Dawn
1 Lightkeeper of Emeria
1 Hamza, Guardian of Arashin
1 Ajani Goldmane
1 The Wanderer
1 Blossoming Wreath
1 Condemn
1 Fortifying Draught
1 Healing Salve
1 Light of Hope
1 Divine Offering
1 Revitalize
1 Abuna's Chant
1 Angel's Mercy
1 Blunt the Assault
1 Congregate
1 Refreshing Rain
1 War Report
1 Corrosive Gale
1 Bond of Flourishing
1 Courage in Crisis
1 Survival Cache
1 Hunters' Feast
1 Primal Command
1 Wanderer's Strike
1 Planewide Celebration
1 Fountain of Youth
1 Elixir of Immortality
1 Golden Urn
1 Sol Ring
1 Soul Net
1 The Ozolith
1 Contagion Clasp
1 Throne of Geth
1 Marble Chalice
1 Staff of Domination
1 Soul Conduit
1 Lifelink
1 Spirit Link
1 Ajani's Mantra
1 Inner Sanctum
1 Luminous Wake
1 Faith's Fetters
1 First Response
1 Vigil for the Lost
1 Noble Purpose
1 Noble Stand
1 Celestial Mantle
1 Blossoming Sands
1 Command Tower
14 Forest
1 Karn's Bastion
16 Plains
1 Razorverge Thicket
1 Sunpetal Grove
1 Yavimaya Hollow
Shared via TopDecked MTG
https://www.topdecked.com/decks/alive/833c308f-219f-4624-8b32-1adedcb477f0
#+caption : Adding the deck list to the database
#+begin_src sql :exports code :eval never
INSERT INTO decks (deck_id, name) VALUES (2, 'Alive');
INSERT INTO deck_cards (deck_id, oracle_id)
SELECT DISTINCT 2, oracle_id FROM cards WHERE name IN
(
'Serra Ascendant',
'Soul''s Attendant',
'Ajani''s Pridemate',
'Alabaster Mage',
'Grateful Apparition',
'Suture Priest',
'Trelasarra, Moon Dancer',
'Angel of Vitality',
'Celestial Unicorn',
'Evolution Sage',
'Lurking Roper',
'Spike Feeder',
'Splendor Mare',
'Armorcraft Judge',
'Bloom Hulk',
'Core Prowler',
'Lathiel, the Bounteous Dawn',
'Lightkeeper of Emeria',
'Hamza, Guardian of Arashin',
'Ajani Goldmane',
'The Wanderer',
'Blossoming Wreath',
'Condemn',
'Fortifying Draught',
'Healing Salve',
'Light of Hope',
'Divine Offering',
'Revitalize',
'Abuna''s Chant',
'Angel''s Mercy',
'Blunt the Assault',
'Congregate',
'Refreshing Rain',
'War Report',
'Corrosive Gale',
'Bond of Flourishing',
'Courage in Crisis',
'Survival Cache',
'Hunters'' Feast',
'Primal Command',
'Wanderer''s Strike',
'Planewide Celebration',
'Fountain of Youth',
'Elixir of Immortality',
'Golden Urn',
'Sol Ring',
'Soul Net',
'The Ozolith',
'Contagion Clasp',
'Throne of Geth',
'Marble Chalice',
'Staff of Domination',
'Soul Conduit',
'Lifelink',
'Spirit Link',
'Ajani''s Mantra',
'Inner Sanctum',
'Luminous Wake',
'Faith''s Fetters',
'First Response',
'Vigil for the Lost',
'Noble Purpose',
'Noble Stand',
'Celestial Mantle',
'Blossoming Sands',
'Command Tower',
'Forest',
'Karn''s Bastion',
'Plains',
'Razorverge Thicket',
'Sunpetal Grove',
'Yavimaya Hollow'
);
#+end_src
#+caption : Finding cards in the collection
2023-02-15 23:50:15 +00:00
#+begin_src sql :exports code
SELECT set_code
, release_date
, color_identity
, cards.name
, type_line
, sets.name
, rarity
, collection
FROM deck_list
JOIN cards USING(oracle_id)
JOIN copies USING (scryfall_id)
JOIN sets USING(set_code)
WHERE deck_id = 13 AND type_line not like 'Basic Land%'
GROUP BY set_code
, release_date
, color_identity
, cards.name
, type_line
, sets.name
, rarity
, collection
ORDER BY CASE WHEN rarity >= 'rare'::rarity THEN 0 ELSE 1 END -- Is it in a binder?
, CASE WHEN LENGTH(color_identity) > 1 THEN 0 ELSE 1 END -- Sort gold cards before mono-colored
, color_identity
, CASE WHEN rarity > 'rare'::rarity THEN 0 ELSE 1 END -- Mythics are separated from rares in binders
, release_date ASC, set_code -- Older cards are better organized in boxes
, cards.name
2022-02-18 19:34:35 +00:00
#+end_src
2023-02-15 23:50:15 +00:00
#+RESULTS :
| set_code | release_date | color_identity | name | type_line | name | rarity | collection |
|----------+--------------+----------------+-----------------------------+--------------------------------------+---------------------------------------------+----------+-----------------------------|
| SOM | 2010-10-01 | UB | Darkslick Shores | Land | Scars of Mirrodin | rare | Boxes |
| C19 | 2019-08-23 | UB | Sunken Hollow | Land — Island Swamp | Commander 2019 | rare | Boxes |
| BRC | 2022-11-18 | UB | Sunken Hollow | Land — Island Swamp | The Brothers' War Commander | rare | Boxes |
| ISD | 2011-09-30 | WB | Isolated Chapel | Land | Innistrad | rare | Boxes |
| M20 | 2019-07-12 | WB | Temple of Silence | Land | Core Set 2020 | rare | Boxes |
| CMR | 2020-11-20 | WB | Vault of Champions | Land | Commander Legends | rare | Boxes |
| DMU | 2022-09-09 | WB | Caves of Koilos | Land | Dominaria United | rare | Boxes |
| BRC | 2022-11-18 | WB | Temple of Silence | Land | The Brothers' War Commander | rare | Boxes |
| 5ED | 1997-03-24 | WU | Adarkar Wastes | Land | Fifth Edition | rare | Boxes |
| PLS | 2001-02-05 | WU | Cloud Cover | Enchantment | Planeshift | rare | Red binder |
| NEO | 2022-02-18 | WU | Tameshi, Reality Architect | Legendary Creature — Moonfolk Wizard | Kamigawa: Neon Dynasty | rare | Boxes |
| DMU | 2022-09-09 | WU | Adarkar Wastes | Land | Dominaria United | rare | Boxes |
| WTH | 1997-06-09 | B | Wave of Terror | Enchantment | Weatherlight | rare | Red binder |
| APC | 2001-06-04 | U | Ice Cave | Enchantment | Apocalypse | rare | Red binder |
| APC | 2001-06-04 | U | Ice Cave | Enchantment | Apocalypse | rare | Ancient Deck Box |
| SLD | 2022-05-04 | W | Triumphant Reckoning | Sorcery | Secret Lair Drop | mythic | Pride Across the Multiverse |
| M20 | 2019-07-12 | W | Starfield Mystic | Creature — Human Cleric | Core Set 2020 | rare | Boxes |
| NEO | 2022-02-18 | W | Brilliant Restoration | Sorcery | Kamigawa: Neon Dynasty | rare | Boxes |
| NEO | 2022-02-18 | W | Light-Paws, Emperor's Voice | Legendary Creature — Fox Advisor | Kamigawa: Neon Dynasty | rare | Boxes |
| TOR | 2002-02-04 | UB | Tainted Isle | Land | Torment | uncommon | Red binder |
| GRN | 2018-10-05 | UB | Dimir Guildgate | Land — Gate | Guilds of Ravnica | common | Boxes |
| M20 | 2019-07-12 | UB | Dismal Backwater | Land | Core Set 2020 | common | Boxes |
| C19 | 2019-08-23 | UB | Dimir Aqueduct | Land | Commander 2019 | uncommon | Boxes |
| IKO | 2020-04-24 | UB | Dismal Backwater | Land | Ikoria: Lair of Behemoths | common | Boxes |
| NEO | 2022-02-18 | UB | Dismal Backwater | Land | Kamigawa: Neon Dynasty | common | Boxes |
| 2X2 | 2022-07-08 | UB | Dimir Aqueduct | Land | Double Masters 2022 | uncommon | Boxes |
| BRC | 2022-11-18 | UB | Dimir Aqueduct | Land | The Brothers' War Commander | uncommon | Boxes |
| RIX | 2018-01-19 | WB | Forsaken Sanctuary | Land | Rivals of Ixalan | uncommon | Boxes |
| M20 | 2019-07-12 | WB | Scoured Barrens | Land | Core Set 2020 | common | Boxes |
| IKO | 2020-04-24 | WB | Scoured Barrens | Land | Ikoria: Lair of Behemoths | common | Boxes |
| STX | 2021-04-23 | WB | Silverquill Campus | Land | Strixhaven: School of Mages | common | Boxes |
| NEO | 2022-02-18 | WB | Scoured Barrens | Land | Kamigawa: Neon Dynasty | common | Boxes |
| 2X2 | 2022-07-08 | WB | Orzhov Basilica | Land | Double Masters 2022 | uncommon | Boxes |
| DMU | 2022-09-09 | WB | Sunlit Marsh | Land — Plains Swamp | Dominaria United | common | Boxes |
| BRC | 2022-11-18 | WB | Orzhov Basilica | Land | The Brothers' War Commander | uncommon | Boxes |
| INV | 2000-10-02 | WU | Coastal Tower | Land | Invasion | uncommon | Red binder |
| ZEN | 2009-10-02 | WU | Sejiri Refuge | Land | Zendikar | uncommon | Boxes |
| RNA | 2019-01-25 | WU | Azorius Guildgate | Land — Gate | Ravnica Allegiance | common | Boxes |
| RNA | 2019-01-25 | WU | Lawmage's Binding | Enchantment — Aura | Ravnica Allegiance | common | Boxes |
| M20 | 2019-07-12 | WU | Tranquil Cove | Land | Core Set 2020 | common | Boxes |
| THB | 2020-01-24 | WU | Staggering Insight | Enchantment — Aura | Theros Beyond Death | uncommon | Boxes |
| IKO | 2020-04-24 | WU | Tranquil Cove | Land | Ikoria: Lair of Behemoths | common | Boxes |
| NEO | 2022-02-18 | WU | Tranquil Cove | Land | Kamigawa: Neon Dynasty | common | Boxes |
| SNC | 2022-04-29 | WU | Skybridge Towers | Land | Streets of New Capenna | common | Boxes |
| 2X2 | 2022-07-08 | WU | Azorius Chancery | Land | Double Masters 2022 | uncommon | Boxes |
| BRC | 2022-11-18 | WU | Azorius Chancery | Land | The Brothers' War Commander | uncommon | Boxes |
| M10 | 2009-07-17 | | Terramorphic Expanse | Land | Magic 2010 | common | Boxes |
| ROE | 2010-04-23 | | Evolving Wilds | Land | Rise of the Eldrazi | common | Boxes |
| M11 | 2010-07-16 | | Terramorphic Expanse | Land | Magic 2011 | common | Boxes |
| M13 | 2012-07-13 | | Evolving Wilds | Land | Magic 2013 | common | Boxes |
| M20 | 2019-07-12 | | Evolving Wilds | Land | Core Set 2020 | common | Boxes |
| C19 | 2019-08-23 | | Command Tower | Land | Commander 2019 | common | Boxes |
| C19 | 2019-08-23 | | Evolving Wilds | Land | Commander 2019 | common | Boxes |
| C19 | 2019-08-23 | | Myriad Landscape | Land | Commander 2019 | uncommon | Boxes |
| C19 | 2019-08-23 | | Terramorphic Expanse | Land | Commander 2019 | common | Boxes |
| IKO | 2020-04-24 | | Evolving Wilds | Land | Ikoria: Lair of Behemoths | common | Boxes |
| ZNC | 2020-09-25 | | Command Tower | Land | Zendikar Rising Commander | common | Deckbox |
| ZNC | 2020-09-25 | | Evolving Wilds | Land | Zendikar Rising Commander | common | Deckbox |
| ZNC | 2020-09-25 | | Myriad Landscape | Land | Zendikar Rising Commander | uncommon | Deckbox |
| ZNC | 2020-09-25 | | Terramorphic Expanse | Land | Zendikar Rising Commander | common | Deckbox |
| CMR | 2020-11-20 | | Command Tower | Land | Commander Legends | common | Boxes |
| CMR | 2020-11-20 | | Path of Ancestry | Land | Commander Legends | common | Boxes |
| CMR | 2020-11-20 | | Terramorphic Expanse | Land | Commander Legends | common | Boxes |
| KHC | 2021-02-05 | | Command Tower | Land | Kaldheim Commander | common | KHM Elven Empire Precon |
| KHC | 2021-02-05 | | Myriad Landscape | Land | Kaldheim Commander | uncommon | KHM Elven Empire Precon |
| KHC | 2021-02-05 | | Path of Ancestry | Land | Kaldheim Commander | common | KHM Elven Empire Precon |
| C21 | 2021-04-23 | | Command Tower | Land | Commander 2021 | common | STX Quantum Quandrix Precon |
| C21 | 2021-04-23 | | Myriad Landscape | Land | Commander 2021 | uncommon | STX Quantum Quandrix Precon |
| AFC | 2021-07-23 | | Command Tower | Land | Forgotten Realms Commander | common | AFR Vrondiss Precon |
| AFC | 2021-07-23 | | Path of Ancestry | Land | Forgotten Realms Commander | common | AFR Vrondiss Precon |
| AFR | 2021-07-23 | | Evolving Wilds | Land | Adventures in the Forgotten Realms | common | Boxes |
| MID | 2021-09-24 | | Evolving Wilds | Land | Innistrad: Midnight Hunt | common | Boxes |
| CLB | 2022-06-10 | | Command Tower | Land | Commander Legends: Battle for Baldur's Gate | common | Boxes |
| CLB | 2022-06-10 | | Evolving Wilds | Land | Commander Legends: Battle for Baldur's Gate | common | Boxes |
| BRC | 2022-11-18 | | Command Tower | Land | The Brothers' War Commander | common | Boxes |
| BRC | 2022-11-18 | | Evolving Wilds | Land | The Brothers' War Commander | common | Boxes |
| BRC | 2022-11-18 | | Myriad Landscape | Land | The Brothers' War Commander | uncommon | Boxes |
| BRC | 2022-11-18 | | Path of Ancestry | Land | The Brothers' War Commander | common | Boxes |
| BRC | 2022-11-18 | | Terramorphic Expanse | Land | The Brothers' War Commander | common | Boxes |
| BRO | 2022-11-18 | | Thran Power Suit | Artifact — Equipment | The Brothers' War | uncommon | Boxes |
| ONE | 2023-02-03 | | Terramorphic Expanse | Land | Phyrexia: All Will Be One | common | Boxes |
| 3ED | 1994-04-01 | B | Pestilence | Enchantment | Revised Edition | common | Ancient Deck Box |
| 4ED | 1995-04-01 | B | Pestilence | Enchantment | Fourth Edition | common | Ancient Deck Box |
| 5ED | 1997-03-24 | B | Deathgrip | Enchantment | Fifth Edition | uncommon | Boxes |
| TMP | 1997-10-14 | B | Endless Scream | Enchantment — Aura | Tempest | common | Boxes |
| TMP | 1997-10-14 | B | Sadistic Glee | Enchantment — Aura | Tempest | common | Boxes |
| USG | 1998-10-12 | B | Pestilence | Enchantment | Urza's Saga | common | Ancient Deck Box |
| 6ED | 1999-04-21 | B | Pestilence | Enchantment | Classic Sixth Edition | uncommon | Ancient Deck Box |
| SCG | 2003-05-26 | B | Lingering Death | Enchantment — Aura | Scourge | common | Boxes |
| MBS | 2011-02-04 | B | Phyresis | Enchantment — Aura | Mirrodin Besieged | common | Boxes |
| MBS | 2011-02-04 | B | Phyresis | Enchantment — Aura | Mirrodin Besieged | common | Red binder |
| CMR | 2020-11-20 | B | Vow of Torment | Enchantment — Aura | Commander Legends | uncommon | Boxes |
| CLB | 2022-06-10 | B | Scion of Halaster | Legendary Enchantment — Background | Commander Legends: Battle for Baldur's Gate | common | Boxes |
| 4ED | 1995-04-01 | U | Gaseous Form | Enchantment — Aura | Fourth Edition | common | Boxes |
| MIR | 1996-10-08 | U | Teferi's Curse | Enchantment — Aura | Mirage | common | Boxes |
| STH | 1998-03-02 | U | Contempt | Enchantment — Aura | Stronghold | common | Boxes |
| EXO | 1998-06-15 | U | Curiosity | Enchantment — Aura | Exodus | uncommon | Red binder |
| EXO | 1998-06-15 | U | Robe of Mirrors | Enchantment — Aura | Exodus | common | Boxes |
| USG | 1998-10-12 | U | Cloak of Mists | Enchantment — Aura | Urza's Saga | common | Boxes |
| USG | 1998-10-12 | U | Confiscate | Enchantment — Aura | Urza's Saga | uncommon | Red binder |
| USG | 1998-10-12 | U | Telepathy | Enchantment | Urza's Saga | uncommon | Boxes |
| 6ED | 1999-04-21 | U | Gaseous Form | Enchantment — Aura | Classic Sixth Edition | common | Boxes |
| MMQ | 1999-10-04 | U | Diplomatic Immunity | Enchantment — Aura | Mercadian Masques | common | Boxes |
| INV | 2000-10-02 | U | Traveler's Cloak | Enchantment — Aura | Invasion | common | Boxes |
| ROE | 2010-04-23 | U | Narcolepsy | Enchantment — Aura | Rise of the Eldrazi | common | Boxes |
| ROE | 2010-04-23 | U | Narcolepsy | Enchantment — Aura | Rise of the Eldrazi | common | Deckbox |
| SOM | 2010-10-01 | U | Turn Aside | Instant | Scars of Mirrodin | common | Boxes |
| SOM | 2010-10-01 | U | Volition Reins | Enchantment — Aura | Scars of Mirrodin | uncommon | Boxes |
| ISD | 2011-09-30 | U | Curiosity | Enchantment — Aura | Innistrad | uncommon | Boxes |
| THS | 2013-09-27 | U | Aqueous Form | Enchantment — Aura | Theros | common | Boxes |
| M15 | 2014-07-18 | U | Encrust | Enchantment — Aura | Magic 2015 | common | Boxes |
| WAR | 2019-05-03 | U | Kasmina's Transmutation | Enchantment — Aura | War of the Spark | common | Boxes |
| IKO | 2020-04-24 | U | Mystic Subdual | Enchantment — Aura | Ikoria: Lair of Behemoths | uncommon | Boxes |
| CMR | 2020-11-20 | U | Aqueous Form | Enchantment — Aura | Commander Legends | common | Boxes |
| CMR | 2020-11-20 | U | Confiscate | Enchantment — Aura | Commander Legends | uncommon | Boxes |
| AFR | 2021-07-23 | U | Wizard Class | Enchantment — Class | Adventures in the Forgotten Realms | uncommon | Boxes |
| SNC | 2022-04-29 | U | Public Enemy | Enchantment — Aura | Streets of New Capenna | uncommon | Boxes |
| SNC | 2022-04-29 | U | Security Bypass | Enchantment — Aura | Streets of New Capenna | common | Boxes |
| 2X2 | 2022-07-08 | U | Kasmina's Transmutation | Enchantment — Aura | Double Masters 2022 | common | Boxes |
| DMR | 2023-01-13 | U | Confiscate | Enchantment — Aura | Dominaria Remastered | uncommon | Boxes |
| DRK | 1994-08-01 | W | Brainwash | Enchantment — Aura | The Dark | common | Boxes |
| 4ED | 1995-04-01 | W | Brainwash | Enchantment — Aura | Fourth Edition | common | Boxes |
| MMQ | 1999-10-04 | W | Arrest | Enchantment — Aura | Mercadian Masques | uncommon | Red binder |
| MMQ | 1999-10-04 | W | Muzzle | Enchantment — Aura | Mercadian Masques | common | Boxes |
| NEM | 2000-02-14 | W | Seal of Cleansing | Enchantment | Nemesis | common | Boxes |
| ODY | 2001-10-01 | W | Auramancer | Creature — Human Wizard | Odyssey | common | Boxes |
| SCG | 2003-05-26 | W | Guilty Conscience | Enchantment — Aura | Scourge | common | Boxes |
| 5DN | 2004-06-04 | W | Stasis Cocoon | Enchantment — Aura | Fifth Dawn | common | Boxes |
| ZEN | 2009-10-02 | W | Journey to Nowhere | Enchantment | Zendikar | common | Boxes |
| ROE | 2010-04-23 | W | Hyena Umbra | Enchantment — Aura | Rise of the Eldrazi | common | Boxes |
| ROE | 2010-04-23 | W | Hyena Umbra | Enchantment — Aura | Rise of the Eldrazi | common | Red binder |
| ROE | 2010-04-23 | W | Mammoth Umbra | Enchantment — Aura | Rise of the Eldrazi | uncommon | Boxes |
| SOM | 2010-10-01 | W | Arrest | Enchantment — Aura | Scars of Mirrodin | common | Boxes |
| SOM | 2010-10-01 | W | Arrest | Enchantment — Aura | Scars of Mirrodin | common | Deckbox |
| M12 | 2011-07-15 | W | Auramancer | Creature — Human Wizard | Magic 2012 | common | Deckbox |
| M12 | 2011-07-15 | W | Spirit Mantle | Enchantment — Aura | Magic 2012 | uncommon | Boxes |
| M13 | 2012-07-13 | W | Oblivion Ring | Enchantment | Magic 2013 | uncommon | Boxes |
| RTR | 2012-10-05 | W | Ethereal Armor | Enchantment — Aura | Return to Ravnica | common | Boxes |
| MB1 | 2019-11-07 | W | Hyena Umbra | Enchantment — Aura | Mystery Booster | common | Boxes |
| THB | 2020-01-24 | W | Banishing Light | Enchantment | Theros Beyond Death | uncommon | Boxes |
| THB | 2020-01-24 | W | Transcendent Envoy | Enchantment Creature — Griffin | Theros Beyond Death | common | Boxes |
| ZNC | 2020-09-25 | W | Banishing Light | Enchantment | Zendikar Rising Commander | uncommon | Deckbox |
| CMR | 2020-11-20 | W | Vow of Duty | Enchantment — Aura | Commander Legends | uncommon | Boxes |
| CLB | 2022-06-10 | W | Citadel Gate | Land — Gate | Commander Legends: Battle for Baldur's Gate | common | Boxes |
| 2X2 | 2022-07-08 | W | Hyena Umbra | Enchantment — Aura | Double Masters 2022 | common | Boxes |
| 2X2 | 2022-07-08 | W | Myth Realized | Enchantment | Double Masters 2022 | uncommon | Boxes |
2022-02-18 19:34:35 +00:00
** Questions
- Where are the cards in my collection I need to build a deck?
- Which cards do I want in one deck that are currently in another?
- Which cards do I need more copies of?
- Which cards do I need that would improve specific decks?
2022-10-17 22:41:06 +00:00
** Types
: import Text -> (ValidCardNames, InvalidCardNames)
: import Text -> (ValidCards, InvalidCards)
: PreferredCard = PreferredCard { name: ValidCardName, card: Maybe ValidCard }
: import Text -> ([PreferredCard], [InvalidCardNames])
: decklist DeckName -> ValidCardNames -> DeckList
: commanderDeckList -> DeckList -> Either InvalidCommanderDeck CommanderDecklist
: Deck = Deck [PreferredCard]
2022-12-08 20:20:49 +00:00
2022-12-21 21:29:10 +00:00
* Collection stats
#+begin_src sql
SELECT COUNT("copies"."id") AS cards
, SUM(
CASE WHEN "copies"."isFoil"
THEN "card_prices"."usd_foil"
ELSE "card_prices"."usd"
END
) AS value
, COUNT(DISTINCT cards.set_code) AS sets
FROM "copies"
JOIN "cards" USING ("scryfall_id")
LEFT JOIN "card_prices" USING ("scryfall_id")
WHERE "card_prices"."date" = (SELECT "value" FROM "vars" where "key" = 'last_update')
#+end_src
#+RESULTS :
| cards | value | sets |
|-------+---------+------|
| 12871 | 7289.44 | 161 |
#+begin_src sql
SELECT COUNT("copies"."id") AS cards
FROM "copies"
JOIN "cards" USING ("scryfall_id")
LEFT JOIN "card_prices" USING ("scryfall_id")
WHERE "card_prices"."date" = (SELECT "value" FROM "vars" where "key" = 'last_update')
#+end_src
#+RESULTS :
| cards |
|-------|
| 12871 |
#+begin_src sql
select count(*) from copies
#+end_src
#+RESULTS :
| count |
|-------|
| 12871 |
2022-12-08 20:20:49 +00:00
* Identifying and ordering sets
#+name : sets
#+begin_src sql
SELECT s.set_code
, s.name
, COUNT(co.id) AS cards
, MIN(c.release_date) AS release_date
FROM sets AS s
JOIN cards AS c USING (set_code)
JOIN copies AS co USING (scryfall_id)
GROUP BY s.set_code, s.name
ORDER BY min(c.release_date) DESC
#+end_src
#+RESULTS : sets
| set_code | name | cards | release_date |
|----------+-----------------------------------------------+-------+--------------|
2023-02-25 04:00:08 +00:00
| ONC | Phyrexia: All Will Be One Commander | 4 | 2023-02-03 |
| ONE | Phyrexia: All Will Be One | 387 | 2023-02-03 |
| DMR | Dominaria Remastered | 255 | 2023-01-13 |
| J22 | Jumpstart 2022 | 1 | 2022-12-02 |
2022-12-08 20:20:49 +00:00
| BOT | Transformers | 14 | 2022-11-18 |
2023-02-25 04:00:08 +00:00
| TBOT | Transformers Tokens | 1 | 2022-11-18 |
| BRR | The Brothers' War Retro Artifacts | 58 | 2022-11-18 |
| BRO | The Brothers' War | 203 | 2022-11-18 |
| BRC | The Brothers' War Commander | 210 | 2022-11-18 |
2022-12-08 20:20:49 +00:00
| UNF | Unfinity | 42 | 2022-10-07 |
2023-02-25 04:00:08 +00:00
| DMU | Dominaria United | 218 | 2022-09-09 |
2022-12-08 20:20:49 +00:00
| DMC | Dominaria United Commander | 35 | 2022-09-09 |
2023-02-25 04:00:08 +00:00
| P30A | 30th Anniversary Play Promos | 2 | 2022-09-02 |
2022-12-08 20:20:49 +00:00
| 2X2 | Double Masters 2022 | 459 | 2022-07-08 |
| CLB | Commander Legends: Battle for Baldur's Gate | 94 | 2022-06-10 |
| NCC | New Capenna Commander | 2 | 2022-04-29 |
2023-02-25 04:00:08 +00:00
| SNC | Streets of New Capenna | 203 | 2022-04-29 |
| SLX | Universes Within | 3 | 2022-03-03 |
2022-12-08 20:20:49 +00:00
| NEC | Neon Dynasty Commander | 14 | 2022-02-18 |
2023-02-25 04:00:08 +00:00
| NEO | Kamigawa: Neon Dynasty | 857 | 2022-02-18 |
2022-12-08 20:20:49 +00:00
| VOW | Innistrad: Crimson Vow | 105 | 2021-11-19 |
2023-02-25 04:00:08 +00:00
| VOC | Crimson Vow Commander | 1 | 2021-11-19 |
| MID | Innistrad: Midnight Hunt | 15 | 2021-09-24 |
2022-12-08 20:20:49 +00:00
| CMB2 | Mystery Booster Playtest Cards 2021 | 3 | 2021-08-20 |
| OAFC | Forgotten Realms Commander Display Commanders | 1 | 2021-07-23 |
2023-02-25 04:00:08 +00:00
| AAFR | Adventures in the Forgotten Realms Art Series | 3 | 2021-07-23 |
| AFC | Forgotten Realms Commander | 70 | 2021-07-23 |
| AFR | Adventures in the Forgotten Realms | 214 | 2021-07-23 |
2022-12-08 20:20:49 +00:00
| PLG21 | Love Your LGS 2021 | 1 | 2021-06-22 |
2023-02-25 04:00:08 +00:00
| MH2 | Modern Horizons 2 | 27 | 2021-06-18 |
| STX | Strixhaven: School of Mages | 383 | 2021-04-23 |
2022-12-08 20:20:49 +00:00
| TSTX | Strixhaven: School of Mages Tokens | 6 | 2021-04-23 |
2023-02-25 04:00:08 +00:00
| STA | Strixhaven Mystical Archive | 30 | 2021-04-23 |
| C21 | Commander 2021 | 75 | 2021-04-23 |
| OC21 | Commander 2021 Display Commanders | 1 | 2021-04-23 |
| TSR | Time Spiral Remastered | 3 | 2021-03-19 |
2022-12-08 20:20:49 +00:00
| TKHM | Kaldheim Tokens | 1 | 2021-02-05 |
| KHC | Kaldheim Commander | 59 | 2021-02-05 |
2023-02-25 04:00:08 +00:00
| KHM | Kaldheim | 174 | 2021-02-05 |
2022-12-08 20:20:49 +00:00
| CMR | Commander Legends | 481 | 2020-11-20 |
| PLIST | The List | 8 | 2020-09-26 |
| ZNC | Zendikar Rising Commander | 77 | 2020-09-25 |
2023-02-25 04:00:08 +00:00
| ZNR | Zendikar Rising | 54 | 2020-09-25 |
| 2XM | Double Masters | 2 | 2020-08-07 |
| JMP | Jumpstart | 2 | 2020-07-17 |
| M21 | Core Set 2021 | 5 | 2020-07-03 |
2022-12-08 20:20:49 +00:00
| PLG20 | Love Your LGS 2020 | 1 | 2020-05-18 |
| IKO | Ikoria: Lair of Behemoths | 560 | 2020-04-24 |
| C20 | Commander 2020 | 1 | 2020-04-17 |
| TTHB | Theros Beyond Death Tokens | 1 | 2020-01-24 |
2023-02-25 04:00:08 +00:00
| THB | Theros Beyond Death | 96 | 2020-01-24 |
2022-12-08 20:20:49 +00:00
| SLD | Secret Lair Drop | 10 | 2019-12-16 |
| MB1 | Mystery Booster | 42 | 2019-11-07 |
2023-02-25 04:00:08 +00:00
| ELD | Throne of Eldraine | 148 | 2019-10-04 |
2022-12-08 20:20:49 +00:00
| C19 | Commander 2019 | 101 | 2019-08-23 |
| PM20 | Core Set 2020 Promos | 1 | 2019-07-12 |
| M20 | Core Set 2020 | 600 | 2019-07-12 |
| SS2 | Signature Spellbook: Gideon | 2 | 2019-06-28 |
| WAR | War of the Spark | 544 | 2019-05-03 |
2023-02-25 04:00:08 +00:00
| TWAR | War of the Spark Tokens | 36 | 2019-05-03 |
| RNA | Ravnica Allegiance | 17 | 2019-01-25 |
2022-12-08 20:20:49 +00:00
| PRNA | Ravnica Allegiance Promos | 1 | 2019-01-25 |
| GRN | Guilds of Ravnica | 127 | 2018-10-05 |
| C18 | Commander 2018 | 3 | 2018-08-09 |
2023-02-25 04:00:08 +00:00
| M19 | Core Set 2019 | 2 | 2018-07-13 |
2022-12-08 20:20:49 +00:00
| BBD | Battlebond | 1 | 2018-06-08 |
| TDOM | Dominaria Tokens | 1 | 2018-04-27 |
2023-02-25 04:00:08 +00:00
| DOM | Dominaria | 18 | 2018-04-27 |
2022-12-08 20:20:49 +00:00
| TRIX | Rivals of Ixalan Tokens | 1 | 2018-01-19 |
2023-02-25 04:00:08 +00:00
| RIX | Rivals of Ixalan | 29 | 2018-01-19 |
2022-12-08 20:20:49 +00:00
| UST | Unstable | 119 | 2017-12-08 |
| E02 | Explorers of Ixalan | 1 | 2017-11-24 |
2023-02-25 04:00:08 +00:00
| IMA | Iconic Masters | 1 | 2017-11-17 |
2022-12-08 20:20:49 +00:00
| XLN | Ixalan | 2 | 2017-09-29 |
| C17 | Commander 2017 | 2 | 2017-08-25 |
| THOU | Hour of Devastation Tokens | 1 | 2017-07-14 |
| HOU | Hour of Devastation | 29 | 2017-07-14 |
| E01 | Archenemy: Nicol Bolas | 1 | 2017-06-16 |
| CMA | Commander Anthology | 1 | 2017-06-09 |
2023-02-25 04:00:08 +00:00
| MM3 | Modern Masters 2017 | 3 | 2017-03-17 |
| AER | Aether Revolt | 3 | 2017-01-20 |
| C16 | Commander 2016 | 2 | 2016-11-11 |
2022-12-08 20:20:49 +00:00
| PKLD | Kaladesh Promos | 1 | 2016-09-30 |
| KLD | Kaladesh | 68 | 2016-09-30 |
| EMN | Eldritch Moon | 1 | 2016-07-22 |
| SOI | Shadows over Innistrad | 1 | 2016-04-08 |
| C15 | Commander 2015 | 1 | 2015-11-13 |
| ORI | Magic Origins | 1 | 2015-07-17 |
2023-02-25 04:00:08 +00:00
| C14 | Commander 2014 | 1 | 2014-11-07 |
2022-12-08 20:20:49 +00:00
| M15 | Magic 2015 | 44 | 2014-07-18 |
2023-02-25 04:00:08 +00:00
| BNG | Born of the Gods | 1 | 2014-02-07 |
2022-12-08 20:20:49 +00:00
| C13 | Commander 2013 | 1 | 2013-11-01 |
| THS | Theros | 30 | 2013-09-27 |
| M14 | Magic 2014 | 2 | 2013-07-19 |
| GTC | Gatecrash | 1 | 2013-02-01 |
2023-02-25 04:00:08 +00:00
| RTR | Return to Ravnica | 30 | 2012-10-05 |
2022-12-08 20:20:49 +00:00
| M13 | Magic 2013 | 91 | 2012-07-13 |
2023-02-25 04:00:08 +00:00
| AVR | Avacyn Restored | 48 | 2012-05-04 |
2022-12-08 20:20:49 +00:00
| DKA | Dark Ascension | 52 | 2012-02-03 |
2023-02-25 04:00:08 +00:00
| ISD | Innistrad | 355 | 2011-09-30 |
2022-12-08 20:20:49 +00:00
| V11 | From the Vault: Legends | 1 | 2011-08-26 |
| M12 | Magic 2012 | 244 | 2011-07-15 |
2023-02-25 04:00:08 +00:00
| NPH | New Phyrexia | 245 | 2011-05-13 |
| MBS | Mirrodin Besieged | 371 | 2011-02-04 |
2022-12-08 20:20:49 +00:00
| PMBS | Mirrodin Besieged Promos | 1 | 2011-02-03 |
| SOM | Scars of Mirrodin | 325 | 2010-10-01 |
| PSOM | Scars of Mirrodin Promos | 1 | 2010-09-30 |
| M11 | Magic 2011 | 320 | 2010-07-16 |
| ROE | Rise of the Eldrazi | 329 | 2010-04-23 |
| PWWK | Worldwake Promos | 2 | 2010-02-05 |
| WWK | Worldwake | 149 | 2010-02-05 |
| F10 | Friday Night Magic 2010 | 1 | 2010-01-01 |
| ZEN | Zendikar | 76 | 2009-10-02 |
| HOP | Planechase | 17 | 2009-09-04 |
| M10 | Magic 2010 | 89 | 2009-07-17 |
| CON | Conflux | 14 | 2009-02-06 |
| PCON | Conflux Promos | 1 | 2009-01-31 |
| PW09 | Wizards Play Network 2009 | 1 | 2009-01-01 |
| DD2 | Duel Decks: Jace vs. Chandra | 120 | 2008-11-07 |
| ALA | Shards of Alara | 22 | 2008-10-03 |
| MOR | Morningtide | 1 | 2008-02-01 |
| LRW | Lorwyn | 1 | 2007-10-12 |
| 10E | Tenth Edition | 2 | 2007-07-13 |
2023-02-25 04:00:08 +00:00
| PLC | Planar Chaos | 2 | 2007-02-02 |
2022-12-08 20:20:49 +00:00
| CSP | Coldsnap | 2 | 2006-07-21 |
2023-02-25 04:00:08 +00:00
| RAV | Ravnica: City of Guilds | 2 | 2005-10-07 |
2022-12-08 20:20:49 +00:00
| 9ED | Ninth Edition | 1 | 2005-07-29 |
| BOK | Betrayers of Kamigawa | 1 | 2005-02-04 |
| CHK | Champions of Kamigawa | 5 | 2004-10-01 |
| 5DN | Fifth Dawn | 46 | 2004-06-04 |
| DST | Darksteel | 49 | 2004-02-06 |
| MRD | Mirrodin | 102 | 2003-10-02 |
| 8ED | Eighth Edition | 2 | 2003-07-28 |
| SCG | Scourge | 53 | 2003-05-26 |
| LGN | Legions | 37 | 2003-02-03 |
| ONS | Onslaught | 32 | 2002-10-07 |
| TOR | Torment | 29 | 2002-02-04 |
| ODY | Odyssey | 230 | 2001-10-01 |
| APC | Apocalypse | 672 | 2001-06-04 |
| PAPC | Apocalypse Promos | 1 | 2001-05-26 |
| 7ED | Seventh Edition | 196 | 2001-04-11 |
| PLS | Planeshift | 42 | 2001-02-05 |
| INV | Invasion | 141 | 2000-10-02 |
| PCY | Prophecy | 32 | 2000-06-05 |
| S00 | Starter 2000 | 6 | 2000-04-01 |
| NEM | Nemesis | 98 | 2000-02-14 |
| MMQ | Mercadian Masques | 165 | 1999-10-04 |
| S99 | Starter 1999 | 3 | 1999-07-01 |
| UDS | Urza's Destiny | 39 | 1999-06-07 |
| 6ED | Classic Sixth Edition | 118 | 1999-04-21 |
| ULG | Urza's Legacy | 38 | 1999-02-15 |
| USG | Urza's Saga | 155 | 1998-10-12 |
| EXO | Exodus | 21 | 1998-06-15 |
| STH | Stronghold | 37 | 1998-03-02 |
| TMP | Tempest | 35 | 1997-10-14 |
| WTH | Weatherlight | 81 | 1997-06-09 |
| 5ED | Fifth Edition | 73 | 1997-03-24 |
| VIS | Visions | 4 | 1997-02-03 |
| MIR | Mirage | 221 | 1996-10-08 |
| ALL | Alliances | 13 | 1996-06-10 |
| HML | Homelands | 45 | 1995-10-01 |
| CHR | Chronicles | 2 | 1995-07-01 |
| ICE | Ice Age | 116 | 1995-06-03 |
2023-02-25 04:00:08 +00:00
| 4ED | Fourth Edition | 128 | 1995-04-01 |
2022-12-08 20:20:49 +00:00
| FEM | Fallen Empires | 16 | 1994-11-01 |
| DRK | The Dark | 3 | 1994-08-01 |
| LEG | Legends | 2 | 1994-06-01 |
| 3ED | Revised Edition | 43 | 1994-04-01 |
| ATQ | Antiquities | 1 | 1994-03-04 |
#+begin_src python :var data=sets :var filename= "tutor-sets.png" :results file :exports results
from datetime import datetime
import matplotlib
matplotlib.use('SVG')
import matplotlib.pyplot as plt
import pandas as pd
data = [{'code': code,
'name': name,
'cards': int(cards),
'date': datetime.strptime(date, '%Y-%m-%d'),
}
for code, name, cards, date in data]
data = pd.DataFrame(data).set_index('date').sort_index()
fig, ax = plt.subplots(figsize= (14,8))
data['cumcards'] = data['cards'].cumsum()
data.plot(y='cumcards', ax=ax)
for date, row in data[data['cards'] > 300].iterrows():
ax.text(date, row['cumcards'], row['code'])
plt.xlabel("Time")
plt.ylabel("Cards")
ax.get_legend().remove()
plt.savefig(filename, transparent=True)
return filename
#+end_src
#+RESULTS :
[[file:tutor-sets.png ]]
2023-01-21 19:45:49 +00:00
* Identifying default cards for oracle entries
#+begin_src sql
SELECT oracle.oracle_id
, oracle.name
, scryfall.scryfall_id
, scryfall.set_code
, scryfall.collector_number
FROM oracle
JOIN (
SELECT DISTINCT ON (oracle_id) *
FROM scryfall
ORDER BY oracle_id, release_date DESC
) scryfall USING (oracle_id)
WHERE oracle.name IN ('Rampant Growth', 'Counterspell', 'Demonic Tutor', 'Jin-Gitaxias, Progress Tyrant')
#+end_src
#+RESULTS :
| oracle_id | name | scryfall_id | set_code | collector_number |
|--------------------------------------+-------------------------------+--------------------------------------+----------+------------------|
| 82004860-e589-4e38-8d61-8c0210e4ea39 | Demonic Tutor | 085ed548-a8c8-40b3-8183-51c060bc95cb | 30A | 398 |
| 8539f295-5d58-4436-a73a-b9277c4c7795 | Rampant Growth | ba3026d2-334d-41bd-8c6b-7de7d78e54e0 | 40K | 220 |
| cc187110-1148-4090-bbb8-e205694a39f5 | Counterspell | d14d5ff3-40c0-4f22-91ad-d6c8447cb9e0 | DMR | 281 |
| f5daadc1-98ff-480a-82bb-fe7bfaa7b60e | Jin-Gitaxias, Progress Tyrant | 9a5ffb0d-1fc3-40da-ac1f-19465aa8412b | NEO | 514 |
2023-02-22 15:51:17 +00:00
* Defining Decks
** Basic Deck List
The minimum card requirements for defining a deck are its unique name or
equivalent identifier, and a quantity.
** Quantity vs individual records
In order to refine card selection, it would be more straightforward to have one
record per card instance associated with a deck, leaving quantity bundling as an
exercise for the UI to streamline deck construction.
** Refining selected cards
Card selections may be narrowed by assigning the following qualities, the sum of
which should restrict the selection to a specific printing:
- Set
- Collector Number
- Language
- Foil or Non-Foil
| Property | Default |
|------------------+-----------------------|
| Set | Latest |
| Collector Number | Lowest |
| Language | English |
| Foil or Non-Foil | Non-Foil if available |
** Availability of cards in the collection
** Marking cards as proxied
Any card in a deck may be marked as proxied. Proxied cards will not reduce the
available number of matching cards in the collection for deckbuilding.