Skip to content

Commit 8050f89

Browse files
committed
Fix some list cards
The problem is that deckstats and scryfall use different collector numbers. Therefore we ignore collector numbers on the list set and search by name.
1 parent 279c086 commit 8050f89

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/MagicCollectionHelper/Core/Types/Domain.Modules.fs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ module DomainTypesModules =
1515
[<RequireQualifiedAccess>]
1616
module DeckStatsCardEntry =
1717
let toEntry cardInfoMap (entry: DeckStatsCardEntry) =
18-
match entry.set, entry.number, entry.language with
19-
| Some set, Some number, Some lang ->
20-
Card.create entry.foil lang number set |> Entry.create entry.amount |> Some
21-
// We try to determine the number with name and set
22-
| Some set, None, Some lang ->
23-
cardInfoMap
24-
|> Map.tryFind (entry.name, set)
25-
|> Option.map (fun info ->
26-
Card.create entry.foil lang info.collectorNumber set
27-
|> Entry.create entry.amount)
28-
| _ -> None
18+
match entry.set, entry.language with
19+
| Some set, Some lang ->
20+
match set, entry.number with
21+
// Special case for "The List", because numbers differ between scryfall and deckstats
22+
| MagicSet "PLST" as set, _
23+
| set, None ->
24+
// We try to determine the number with name and set
25+
cardInfoMap
26+
|> Map.tryFind (entry.name, set)
27+
|> Option.map (fun info ->
28+
Card.create entry.foil lang info.collectorNumber set
29+
|> Entry.create entry.amount)
30+
| set, Some number -> Card.create entry.foil lang number set |> Entry.create entry.amount |> Some
31+
| _ -> None // We need set and lang as minimum
2932

3033
let listToEntries cardInfoMap (entries: DeckStatsCardEntry list) =
3134
// We change the map to improve lookup perf

0 commit comments

Comments
 (0)