alexander-pick / MKMTool

MKMTool ist a helper application I wrote for tinkering around with optimization of sale processes on magiccardmarket.eu and the idea of automisation of some tasks most people wouldn’t be able to get done by pure manpower.
GNU Affero General Public License v3.0
65 stars 15 forks source link

Database Problem #57

Closed alecmestroni closed 3 years ago

alecmestroni commented 3 years ago

Hi, I'm tryng to price my Pokemon collection but the program always import only the MTG database and shows an error of Expansion not found. I have set:

<Games>
    Pokémon;
      <!-- Magic the Gathering; -->
      <!-- World of Warcraft TCG; -->
      <!-- Yugioh; -->
      <!-- The Spoils; -->
      <!-- Force of Will; -->
      <!-- Cardfight!! Vanguard; -->
      <!-- Final Fantasy; -->
      <!-- Weiß Schwarz; -->
      <!-- Dragoborne; -->
      <!-- My Little Pony; -->
      <!-- Dragon Ball Super; -->
    </Games>

The error is in the Expansion Database But its seems to not work. Any help? Thanks

alecmestroni commented 3 years ago

Ok, i found this part in MKMDatabaseManger.cs

// build expansions
                var doc = MKMInteract.RequestHelper.getExpansions("1"); // Only MTG at present
                var node = doc.GetElementsByTagName("expansion");

                using (StreamWriter exp = new StreamWriter(@".\\mkmexpansions.csv"))
                {
                    exp.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\"",
                        ExpansionsFields.ExpansionID, ExpansionsFields.Abbreviation, ExpansionsFields.Name, ExpansionsFields.ReleaseDate));
                    foreach (XmlNode nExpansion in node)
                    {
                        exp.WriteLine("\"" + nExpansion[ExpansionsFields.ExpansionID].InnerText + "\",\"" // put commas around each, in case wizards ever decide to do set with a comma in the name
                            + nExpansion[ExpansionsFields.Abbreviation].InnerText + "\",\"" + nExpansion[ExpansionsFields.Name].InnerText + "\",\""
                            + nExpansion[ExpansionsFields.ReleaseDate].InnerText + "\"");
                    }
                }

I set the Expansion Number on "6" and works really well.

"Magic the Gathering", 1 "World of Warcraft TCG", 2 "Yugioh", 3

"The Spoils", 5 "Pokémon", 6 "Force of Will", 7 "Cardfight!! Vanguard", 8 "Final Fantasy", 9 "Weiß Schwarz", 10 "Dragoborne", 11 "My Little Pony",12 "Dragon Ball Super", 13

I think u can add this info in the Home project

tomasjanak commented 3 years ago

Changing it here to the code of the game will work as long as there is exactly one game you are using MKMTool for and never any other game. A general code that downloads the database for the first allowed game in your config.xml would be this:

var doc = MKMInteract.RequestHelper.getExpansions(MainView.Instance.Config.Games[0].GameID); // Only MTG at present

But the moment you start allowing multiple games in your config or even just running MKMTool with just one game allowed, but a different one each time, the database would have to be reconstructed every time which takes time and API requests. At the very least, the files should be stored under different names for different games (mkmexpansionsMtg.csv, mkmexpansionsPokemon.csv etc.) and then loaded based on which game is allowed right now.

I can add that in the next update. But to make proper support for multiple games at once, more changes would likely be needed and since I am not interested in different games than MtG, I will not do that, someone else would have to.

tomasjanak commented 3 years ago

This should now work in version 0.8.1.0 (commit a23f66388c5c9805f6e4726837f97b52700053ff). Each game's expansion database is now stored in a separate file. When multiple games are allowed, MKMTool loads all relevant files and combines tehm into a single list of all expansions from all games, which could theoretically lead to some problems, see changelog for more info. It should work fine when only one game is allowed in config.