RillingDev / yugioh-deck-tool

A tool to share and edit decks, view deck prices, and much more.
https://ygoprodeck.com/card-database/deck-prices/
Apache License 2.0
48 stars 9 forks source link

Submitting decks to ygoprodeck.com #107

Closed RillingDev closed 2 years ago

RillingDev commented 3 years ago

Implement a mechanism to export(or similar) decks to the deck upload API on ygoprodeck.com.

AlanOC91 commented 3 years ago

At the moment there is a button on the deck builder that does this but it would be great if it could be "baked" into the deck builder UI properly.

We can go about this in a few ways:

Fastest Method:

Have a button that calls the submitDeck() function when used. This is the function I am currently using to submit the deck to the deck upload page.

Deep Dive Method:

The current design requires an API endpoint to be called. This endpoint creates a .ydk deck on a server folder which is then used in a URL query string when passed to the deck upload page.

The endpoint is: https://ygoprodeck.com/api/deckbuilderupload.php It accepts the following parameters: main, extra and side. You can pass comma separated IDs to each of these endpoints.

Here is a URL example of a regular (40 main, 15 extra, 15 side) Deck: https://ygoprodeck.com/api/deckbuilderupload.php?main=14181608,55794644,55794644,55794644,91345518,91345518,91345518,97750534,97750534,87209160,31533704,31533704,38730226,38730226,38730226,64734921,36539330,36539330,36539330,54772065,54772065,91123920,91123920,91123920,50810455,50810455,14816857,25908748,25908748,25908748,55154048,97570038,84731222,313513,51097887,86379342,86379342,86379342,40975243,40975243&extra=59642500,39402797,67926903,67926903,67926903,62070231,30100551,40424929,40424929,99726621,52331012,26847978,23689428,8602351,8602351&side=97750534,87209160,28573958,64734921,64734921,50810455,76614003,91188343,14816857,99726621,52331012,26847978,33057951,51097887,40975243

Here is the response from this API: {"url":"https://ygoprodeck.com/send-us-a-deck/?deckurl=https://goprodeck.com/YGOPRO_Decks/deck-builder-deck/zHIuMUawrf1605710541.ydk"}

This is the URL that the user is then re-directed to which allows them to upload that deck from the deck builder page.

Authentication:

This can be handled purely by the WordPress PHP function is_user_logged_in(). The can be used to validate if the user is logged into the website or not.

I currently have this functionality up and running on the current decktool page template including the submitDeck() function.

RillingDev commented 2 years ago

-> with the new JS API to get the deck contents, I feel like this is something that can be implemented externally