From 871d2af2da8d8bbf3f0f1bb26966c76a417d3291 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Fri, 31 Jan 2025 23:31:58 +0000 Subject: [PATCH] Added a first test to see whether a card is available --- scryfall_deser/src/lib.rs | 21 ++-- scryfall_deser/test_files/nissa.json | 142 +++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 13 deletions(-) create mode 100644 scryfall_deser/test_files/nissa.json diff --git a/scryfall_deser/src/lib.rs b/scryfall_deser/src/lib.rs index fad4c6c..d1b688d 100644 --- a/scryfall_deser/src/lib.rs +++ b/scryfall_deser/src/lib.rs @@ -2,6 +2,7 @@ use serde::Deserialize; // Info from here: // https://scryfall.com/docs/api/cards +#[allow(dead_code)] #[derive(Deserialize)] struct ScryfallCard { // Core Card Fields @@ -28,8 +29,8 @@ struct ScryfallCard { } - // https://scryfall.com/docs/api/cards#card-face-objects +#[allow(dead_code)] #[derive(Deserialize)] struct ScryfallCardFaceObject { pub artist: Option, @@ -43,6 +44,7 @@ struct ScryfallCardFaceObject { } // https://scryfall.com/docs/api/cards#related-card-objects +#[allow(dead_code)] #[derive(Deserialize)] struct ScryfallRelatedCardObject { pub id: String, // UUID @@ -63,22 +65,15 @@ enum Colour { Colourless } -pub fn deserialise_card(data: String) -> Card { - - Card -} - -pub fn add(left: usize, right: usize) -> usize { - left + right -} - #[cfg(test)] mod tests { use super::*; + use std::path::PathBuf; #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); + fn deserialise_nissa() { + let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + d.push("test_files/nissa.json"); + assert!(d.exists()); } } diff --git a/scryfall_deser/test_files/nissa.json b/scryfall_deser/test_files/nissa.json new file mode 100644 index 0000000..2a40d8a --- /dev/null +++ b/scryfall_deser/test_files/nissa.json @@ -0,0 +1,142 @@ +{ + "object": "card", + "id": "7b3f0e26-7784-452d-acc8-9f7181e0f7d5", + "oracle_id": "c1fc5923-c3cd-448a-98d1-c154661c2812", + "multiverse_ids": [ + 615951 + ], + "mtgo_id": 109062, + "tcgplayer_id": 495791, + "cardmarket_id": 710527, + "name": "Nissa, Resurgent Animist", + "lang": "en", + "released_at": "2023-05-12", + "uri": "https://api.scryfall.com/cards/7b3f0e26-7784-452d-acc8-9f7181e0f7d5", + "scryfall_uri": "https://scryfall.com/card/mat/162/nissa-resurgent-animist?utm_source=api", + "layout": "normal", + "highres_image": true, + "image_status": "highres_scan", + "image_uris": { + "small": "https://cards.scryfall.io/small/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.jpg?1684341884", + "normal": "https://cards.scryfall.io/normal/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.jpg?1684341884", + "large": "https://cards.scryfall.io/large/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.jpg?1684341884", + "png": "https://cards.scryfall.io/png/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.png?1684341884", + "art_crop": "https://cards.scryfall.io/art_crop/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.jpg?1684341884", + "border_crop": "https://cards.scryfall.io/border_crop/front/7/b/7b3f0e26-7784-452d-acc8-9f7181e0f7d5.jpg?1684341884" + }, + "mana_cost": "{2}{G}", + "cmc": 3, + "type_line": "Legendary Creature — Elf Scout", + "oracle_text": "Landfall — Whenever a land you control enters, add one mana of any color. Then if this is the second time this ability has resolved this turn, reveal cards from the top of your library until you reveal an Elf or Elemental card. Put that card into your hand and the rest on the bottom of your library in a random order.", + "power": "3", + "toughness": "3", + "colors": [ + "G" + ], + "color_identity": [ + "G" + ], + "keywords": [ + "Landfall" + ], + "produced_mana": [ + "B", + "G", + "R", + "U", + "W" + ], + "legalities": { + "standard": "legal", + "future": "legal", + "historic": "legal", + "timeless": "legal", + "gladiator": "legal", + "pioneer": "legal", + "explorer": "legal", + "modern": "legal", + "legacy": "legal", + "pauper": "not_legal", + "vintage": "legal", + "penny": "not_legal", + "commander": "legal", + "oathbreaker": "legal", + "standardbrawl": "legal", + "brawl": "legal", + "alchemy": "not_legal", + "paupercommander": "not_legal", + "duel": "legal", + "oldschool": "not_legal", + "premodern": "not_legal", + "predh": "not_legal" + }, + "games": [ + "paper", + "arena", + "mtgo" + ], + "reserved": false, + "foil": true, + "nonfoil": true, + "finishes": [ + "nonfoil", + "foil" + ], + "oversized": false, + "promo": false, + "reprint": false, + "variation": false, + "set_id": "6727e43d-31b6-45b0-ae05-7a811ba72f70", + "set": "mat", + "set_name": "March of the Machine: The Aftermath", + "set_type": "expansion", + "set_uri": "https://api.scryfall.com/sets/6727e43d-31b6-45b0-ae05-7a811ba72f70", + "set_search_uri": "https://api.scryfall.com/cards/search?order=set&q=e%3Amat&unique=prints", + "scryfall_set_uri": "https://scryfall.com/sets/mat?utm_source=api", + "rulings_uri": "https://api.scryfall.com/cards/7b3f0e26-7784-452d-acc8-9f7181e0f7d5/rulings", + "prints_search_uri": "https://api.scryfall.com/cards/search?order=released&q=oracleid%3Ac1fc5923-c3cd-448a-98d1-c154661c2812&unique=prints", + "collector_number": "162", + "digital": false, + "rarity": "mythic", + "watermark": "desparked", + "card_back_id": "0aeebaf5-8c7d-4636-9e82-8c27447861f7", + "artist": "Tuan Duong Chu", + "artist_ids": [ + "d84246f9-a536-485f-a21d-a237302ed100" + ], + "illustration_id": "66ab8b7b-9e90-4db9-8d5e-10629a4acce4", + "border_color": "black", + "frame": "2015", + "frame_effects": [ + "legendary", + "extendedart" + ], + "security_stamp": "oval", + "full_art": false, + "textless": false, + "booster": false, + "story_spotlight": false, + "promo_types": [ + "boosterfun" + ], + "edhrec_rank": 2163, + "prices": { + "usd": "24.96", + "usd_foil": "32.13", + "usd_etched": null, + "eur": "27.94", + "eur_foil": "35.15", + "tix": "0.99" + }, + "related_uris": { + "gatherer": "https://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=615951&printed=false", + "tcgplayer_infinite_articles": "https://partner.tcgplayer.com/c/4931599/1830156/21018?subId1=api&trafcat=infinite&u=https%3A%2F%2Finfinite.tcgplayer.com%2Fsearch%3FcontentMode%3Darticle%26game%3Dmagic%26q%3DNissa%252C%2BResurgent%2BAnimist", + "tcgplayer_infinite_decks": "https://partner.tcgplayer.com/c/4931599/1830156/21018?subId1=api&trafcat=infinite&u=https%3A%2F%2Finfinite.tcgplayer.com%2Fsearch%3FcontentMode%3Ddeck%26game%3Dmagic%26q%3DNissa%252C%2BResurgent%2BAnimist", + "edhrec": "https://edhrec.com/route/?cc=Nissa%2C+Resurgent+Animist" + }, + "purchase_uris": { + "tcgplayer": "https://partner.tcgplayer.com/c/4931599/1830156/21018?subId1=api&u=https%3A%2F%2Fwww.tcgplayer.com%2Fproduct%2F495791%3Fpage%3D1", + "cardmarket": "https://www.cardmarket.com/en/Magic/Products/Singles/MoM-TA-E/Nissa-Resurgent-Animist-V3?referrer=scryfall&utm_campaign=card_prices&utm_medium=text&utm_source=scryfall", + "cardhoarder": "https://www.cardhoarder.com/cards/109062?affiliate_id=scryfall&ref=card-profile&utm_campaign=affiliate&utm_medium=card&utm_source=scryfall" + } +}