1
1
namespace MagicCollectionHelper.Core
2
2
3
3
open SimpleOptics
4
+ open System
4
5
5
6
[<AutoOpen>]
6
7
module DomainTypesModules =
@@ -17,18 +18,27 @@ module DomainTypesModules =
17
18
let toEntry cardInfoMap ( entry : DeckStatsCardEntry ) =
18
19
match entry.set, entry.language with
19
20
| 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
21
+ let lookupByName set =
25
22
cardInfoMap
26
23
|> Map.tryFind ( entry.name, set)
27
24
|> Option.map ( fun info ->
28
25
Card.create entry.foil lang info.collectorNumber set
29
26
|> Entry.create entry.amount)
27
+
28
+ match set, entry.number with
29
+ // Special case for "The List", because older entrys can have different ids than scryfall
30
+ | MagicSet " PLST" as set, Some( CollectorNumber numberValue) when Int32.TryParse numberValue |> fst ->
31
+ lookupByName set
32
+ | set, None ->
33
+ // We try to determine the number with name and set
34
+ lookupByName set
30
35
| set, Some number -> Card.create entry.foil lang number set |> Entry.create entry.amount |> Some
31
36
| _ -> None // We need set and lang as minimum
37
+ #if DEBUG
38
+ |> Option.orElseWith ( fun () ->
39
+ printfn " Not enough info found for %A " entry
40
+ None)
41
+ #endif
32
42
33
43
let listToEntries cardInfoMap ( entries : DeckStatsCardEntry list ) =
34
44
// We change the map to improve lookup perf
0 commit comments