jjallaire / draftpod

Draft simulator for Magic the Gathering
https://draftpod.org
MIT License
37 stars 7 forks source link

support for importing from deckbox #19

Closed jjallaire closed 5 years ago

jjallaire commented 5 years ago

It would be great to be able to import from Deckbox as well as Decked Builder. From what I can see the standard CSV export from Deckbox has the info we need to match up to Scryfall data:

screen shot 2019-01-29 at 9 29 22 am

We will need the "Count", "Edition", and "Card Number" fields to do the import. I'll polk around a bit to see if anything in our current code needs to change significantly to accommodate this.

jjallaire commented 5 years ago

Here's my take on what we'd need to do here. All of the action happens in the upload.js file here: https://github.com/jjallaire/draftpod/blob/master/src/components/navigator/cardpool/upload.js

First, we'll need to update our extraction/validation logic to look for the "Count", "Edition", and "Card Number" fields. That code is here:

https://github.com/jjallaire/draftpod/blob/master/src/components/navigator/cardpool/upload.js#L76-L99

We'll want to read the Edition and then validate that it matches the passed set_code. We can probably do this for the existing sets by comparing "Edition" to the return value of set.name(set_code). If it doesn't match then we'll want to set valid to false and push an appropriate error.

In terms of the other fields, we'll probably want to add support for "Card Number" and "Count" to the readers for id and quantity respectively.

Finally, we'll want the code in completeCardpoolUpload() to be updated to do conversions from collector number ("Card Number") to Multiverse ID (we do that in this function b/c that's where we currently get access to the full Scryfall dataset: https://github.com/jjallaire/draftpod/blob/master/src/components/navigator/cardpool/upload.js#L136

I think the best way to do the conversion is probably to build a hashtable of collector number => card then just do lookups. We'll also need a way to determine when the conversion is actually necessary. This could be done a number of different ways, including using the presence of certain field names (e.g. "Card Number") in the CSV as an indicator, or even just the fact that the id's don't fall into the normal Mvid range. I don't have a strong opinion on how this should work.

jjallaire commented 5 years ago

@dci2112 Do you mind if I take a shot at implementing this? I am trying to get to code freeze and I'd really like to have this feature make the cut before I lock things down.

dci2112 commented 5 years ago

Go for it...I just started looking into it last night. My free time hasn’t been very much lately :-(

On Mon, Feb 4, 2019 at 6:00 AM J.J. Allaire notifications@github.com wrote:

@dci2112 https://github.com/dci2112 Do you mind if I take a shot at implementing this? I am trying to get to code freeze and I'd really like to have this feature make the cut before I lock things down.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/jjallaire/draftpod/issues/19#issuecomment-460241887, or mute the thread https://github.com/notifications/unsubscribe-auth/AACXBMlpMVeIgHXN1frwu7trpUg5ywPFks5vKC78gaJpZM4aYL5J .

dci2112 commented 5 years ago

You’ll need to watch out for some other eccentricited in the deckbox format.

  1. Foiled cards are split out as another row, so we can have multiple rows with the same Card Number and Edition that we need to sum the Count value over.

  2. Some of the edition names don’t match identically to Scryfall. An example being ‘Modern Masters 2015 Edition. I was considering the best way to deal with this subset (gardcoded hash of translations, or regex adjustments when a direct match isn’t found). But I hadn’t come up with a clear solution yet.

jjallaire commented 5 years ago

Addressed here: https://github.com/jjallaire/draftpod/commit/eb53c30298f66506a18ac3752819e2774b778b09