Badaro / MTGODecklistCache

Cache in JSON format of tournaments posted on MTGO, Manatraders, Melee and Topdeck Websites
34 stars 4 forks source link

Run project #26

Closed j6e closed 1 year ago

j6e commented 1 year ago

Hi!

First congrats on the project, it looks awesome!

I was doing some research on current parsers of decklists and tournament results and stumbled on your project. The format you output is really nice and since I don't want to reinvent the wheel I'd love to use your work. Unfortunately, I have no clue about C#.

I tried to run the project but it gives me an error:

> dotnet run --project .\Tools\MTGODecklistCache.Updater.App\` but it 
C:\Program Files\dotnet\sdk\2.1.503\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(150,5): error NETSDK1045:
El SDK de .NET actual no admite el destino .NET Standard 2.1. 
Use el destino .NET Standard 2.0 u otro inferior, o bien una versión del SDK de .NET que admita .NET Standard 2.1. 
[C:\Users\jonga\Documents\PyProjects\MTGODecklistCache\Tools\MTGODecklistCache.Updater.Common\MTGODecklistCache.Updater.Common.csproj]

Any chance you could help me get the project running? Also, would it be possible to make a Docker image of the app?

Many thanks!

Badaro commented 1 year ago

So, what exactly are you trying to do? :)

1) Do you want to use the tournament data for some analysis?

In this case, you don't need to run this tool at all - I already have a process to run it daily on my machine and commit the new data, so just doing a git-pull daily will keep the /Tournaments folder up-to-date with the latest JSON files.

Running the tool would simply check for new tournaments and not find anything new. :)

2) Do you want to do something using the same JSON model (maybe a parser for another site) so people can mix data from both projects?

In this case, you can check the data model here and ignore the rest of the project, each file is a CacheItem entity. https://github.com/Badaro/MTGODecklistCache/tree/master/Tools/MTGODecklistCache.Updater.Model

If that's your goal I also could write a document detailing the format and a couple things you'd need to be careful about to ensure compatibility (mainly normalization of cards with more than one name like split cards and adventures) and add it to the repository so you don't even have to look at the C# code.

3) Are you trying to run it to debug and learn how I implemented the parsers?

On Windows you can just download the free VS Community, open the project and build and it should work fine. But it looks like you're using a different OS. Is it MacOS or Linux, and which distribution?

I don't have access to a MacOS machine but if it's Linux I can probably boot an image locally and check the steps to get it running. That particular error code seems to indicate you don't have the appropriate SDKs, you can run dotnet --list-sdks and dotnet --list-runtimes and post the results here so I can check what is installed.

Finally, about this:

Also, would it be possible to make a Docker image of the app?

What would you expect to be the output of the docker image? Updating a tournament folder mounted to the container with the new data? Because that's all this tool does.

If that's the case, while I could do it it kinda falls on the same scenario as 1) above - as long as my own automated process to run the and tool update the repository is running you can just do a git-pull and get the same data the tool would download.

j6e commented 1 year ago

Hi,

First thanks for the quick response.

Yes, the final purpose is to use the data for analysis. And honestly, for now, your automatism works fine. But in the future, I'll want to be more flexible and run it kinda live and maybe write the outputs to another destination.

The document detailing the format would be super useful. Now that I look at the parser code more closely, I get most of it (I'm familiar with Java). But your explanations would be really appreciated.

I am on windows but I was using VS Code, not VS community.

Finally, If I run those commands I get:

> dotnet --list-sdks
2.1.503 [C:\Program Files\dotnet\sdk]

> dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Thanks a lot 😊

Badaro commented 1 year ago

If you are on Windows and want to build the tools then I'd definitely recommend installing VS Community since it's free and it should come with the required SDKs.

But you can probably get it to work by installing a newer version of the .Net SDKs. Right now this project requires .Net Core 3.1, but I'll upgrade it to 7.0 soon since 3.1 has reached EOL.

The document detailing the format would be super useful.

I agree, and I created #27 so I don't forget to do this. :)

j6e commented 1 year ago

I got it running! Thanks a lot.

I'm guessing the correct way to run it is:

 dotnet run --project .\Tools\MTGODecklistCache.Updater.App\ .\Tournaments\ .\Tools\MTGODecklistCache.Updater.App\RawData\

and then the validator:

 dotnet run --project .\Tools\MTGODecklistCache.Validator.App\ .\Tournaments\ 

If I understand it correctly, in order to parse the current Pro Tour For example you will need to add the file Rawdata\MtgMelee\WizardsOfTheCoast\2023\02\17\Pro_Tour_Phyrexia.json looking something like this?:

{
  "Name": "Pro Tour Phyrexia",
  "Date": "2023-02-17 00:00:00Z",
  "Uri": "https://mtgmelee.com/Tournament/View/14111"
}

Also, has the tool any problem gathering info from live (not yet finished) tournaments?

Badaro commented 1 year ago

looking something like this?:

That's correct for most tournaments, but when you have a tournament with multiple formats it's a slightly different JSON since you need to specify which deck you want to pick.

Rawdata\MtgMelee\WizardsOfTheCoast\2023\02\17\Pro_Tour_Phyrexia_Pioneer.json

{
  "Name": "Pro Tour Phyrexia (Pioneer)",
  "Date": "2023-02-17 00:00:00Z",
  "Uri": "https://mtgmelee.com/Tournament/View/14111"
  "DeckOffset": 2,
  "ExpectedDecks": 3,
  "FixBehavior": "UseLast"
}

For the PT you probably just want the Pioneer decklists so one file is enough, but for Team tournaments you usually create one JSON file for each format to get all decklists - NerdRageGaming often does Team tournaments, you can check their folder for some examples. Also, I recommend always including the tournament format in the filename for easier searching and filtering.

DeckOffset is 0-based, and FixBehavior is how it handles when the number of decks is less than what is specified in ExpectedDecks, and can be either Skip or UseLast.

You actually chose a bad tournament to start playing with, since as you can see in MtgMelee page the PT decklists look rather messy - as few players have both draft decks, some have only one, and the remaining players only have the Pioneer deck, But fortunately the last one is always the Pioneer one so the tool should handle it correctly with the above settings thanks to FixBehavior=UseLast.

Finally, you only need JSON files for MtgMelee and MagicGG since I manually pick which tournaments from those two sites to import. For MTGO and ManaTraders it automatically downloads everything.

Also, has the tool any problem gathering info from live (not yet finished) tournaments?

Should work if the decklists are public before the tournament is over. A lot of organizers keep them hidden until either Top 8 or the end of the tournament.

Finally, one heads-up: I keep a monthly checklist with the tournaments from MtgMelee I plan on adding to the repository, current one is #25 and it does include the PT. Of course, you're free to play around with the tool and download any tournament you like for your own use, but if you see some interesting big tournament I'm missing I'd appreciate if you mention there so I can add it for others to use.

Badaro commented 1 year ago

FYI: I just checked the code and looks like the default behavior if you don't specify DeckOffset is also to use the last deck, so due to a bit of a lucky coincidence your JSON should still work for the PT. :)

Badaro commented 1 year ago

@j6e since you were able to build and run the tool I'll be closing this, but feel free to comment if you have any other questions.

j6e commented 1 year ago

Yes! Thanks a lot!