ndrewwm / scRyfall

An R wrapper for the Scryfall API.
MIT License
0 stars 0 forks source link

Determine how to represent double-faced cards #1

Closed ndrewwm closed 2 years ago

ndrewwm commented 3 years ago

Double-faced cards are more complicated objects. If returning every card as a single row in a tibble is desirable, it will likely entail use of list columns (given that e.g. double-faced creatures have multiple values for power/toughness). It's also much more common for DFCs to be multiple types (e.g. creature -> artifact, creature -> land, etc.).

ndrewwm commented 2 years ago

I think this has been resolved by f935633d35d7435b00277aa4e367917b6757f7da. If a query's results contain both DFC and SFC, some of the fields will be NA for the DFCs. For example:

search_cards("type:werewolf") %>%
  select(name, set, power, toughness, card_faces) %>%
  tail()
# A tibble: 6 × 5
# name                 set   power toughness card_faces
# <chr>                <chr> <chr> <chr>     <list>    
#     1 Village Ironsmith /… isd   NA    NA        <list [2]>
#     2 Village Messenger /… soi   NA    NA        <list [2]>
#     3 Villagers of Estwal… isd   NA    NA        <list [2]>
#     4 Village Watch // Vi… mid   NA    NA        <list [2]>
#     5 Werewolf Pack Leader afr   3     3         <NULL>    
#     6 Wolfbitten Captive … dka   NA    NA        <list [2]>

For DFCs, card text for each side is stored within card_faces as a list.