DotP Universal Generator
Posted: 04 Jul 2014, 09:54
Thefiremind's DotP Universal Generator
CLARIFICATION FOR NEW USERS: This tool won't give you the full working card, unless you are searching for a "vanilla" card (no abilities). The code that makes the abilities work still needs to be added. That's what modders do... if there were a program that can automatically generate a fully working card, we would all build any deck in the blink of an eye, but that's not possible.
Executable Changelog:
Plugins Changelog:
What is this all about?
This is mostly a modders' community, so I thought: why not making a moddable card generator? And here it is! It supports plugins written in Python so that it can fetch information from different sites and produce XML files for different DotP versions.
How to install it
Download the ZIP file with the binaries and extract it to a folder of your choice, then download the ZIP file with the IronPython DLLs and extract it to the same folder. It requires .NET Framework 4.5.
In case someone wants to meddle with the source, note that the "python" directory isn't included in the ZIP file with the sources: you'll need to take it from the binaries. Moreover, if you don't install the IronPython extensions for your Visual Studio, you'll also need the 4 additional DLLs from the second ZIP file, which aren't referenced in the project because the IronPython extensions take care of that.
Basic usage
Run the executable and you'll face a window like this:
The input plugin takes care of reading the card information from a site. I included one for Gatherer and one for magiccards.info, use the one you prefer (maybe if a card gets badly formatted text from one you can try with the other one rather than editing the XML file manually). You need to enter the name or the Multiverse ID of a card in the text box. Note that, if you enter a Multiverse ID with the magiccards plugin, it will need to ask Gatherer anyway because you can't search Multiverse IDs outside of Gatherer (this is relevant if Gatherer is down for maintenance).
The output plugin gets the information from the input plugin and generates a string with XML file contents. The program will ask you where to save the file, but that doesn't happen inside the plugin. You need to enter a personal prefix for your card IDs (or just uncheck the option, but I don't recommend it).
The so-called "other" plugin (sorry, couldn't think of a better name ) is a way to allow a certain degree of expandability: it receives both the card information from the input plugin and the XML string from the output plugin, and it generates a string that will be shown in the upper-right box. I included a dummy plugin that just writes the Gatherer link for the card, but in the future I might code a plugin that writes a link to MagicVille in order to search for pictures (the only reason I haven't done this already is because MagicVille doesn't seem to allow exact terms search, which would make things so much easier).
So, once you selected the plugins and entered the required information, click on Run and wait for the program to do its... Magic. If something wrong happens, you'll probably see a red entry in the log (the lower-right box): if that's the case, answer to this topic and let me know what happened and what the red entry says (I think the errors are generated in the OS's language, so please provide a translation if it's not English or Italian ).
Batch processing
First and foremost, thanks to Xander9009 for giving me the idea of implementing a batch processing mode!
In the Tools menu you can find a "Batch processing" command: it will allow you to let the program work on a list of cards automatically. First, open Notepad and make a list of terms (names or IDs) for the cards you want to generate, one term per line. Save the text file wherever you want. Now click on "Batch processing", select the text file you just saved, and a directory where you want the XML files to be saved. Batch started! Just wait for it to finish. Note that batch processing has some minor limitations due to me not having thought about implementing it from the start: it won't provide any error report, and the "other" plugin won't show anything (but it will be run anyway, so I suggest you to always choose the Gatherer one which does almost nothing, so the batch will take less time). On the bright side, I made it so that the program will spawn a thread for each card (up to a maximum of 8, you can change the value in the Settings.xml file that will be produced after the first run, if you want), so the batch processing will have a nice parallelism.
How to make a new plugin
I may write some more details in the future, but for now, just know that there are 3 mandatory functions to include: Info, Purpose and Get. Look at the existing plugins for examples.
Possible questions
Known bugs
Links
Choose the link you prefer. It appears that Chrome doesn't like Mega, but Firefox downloads it just fine (or you can use JDownloader).
Binaries:
Other people's plugins
Feel free to post your own plugins by replying to this topic: I'll add a link for each one in this section.
CLARIFICATION FOR NEW USERS: This tool won't give you the full working card, unless you are searching for a "vanilla" card (no abilities). The code that makes the abilities work still needs to be added. That's what modders do... if there were a program that can automatically generate a fully working card, we would all build any deck in the blink of an eye, but that's not possible.
Executable Changelog:
- Version 1.0.0.0: Initial version.
Plugins Changelog:
- [DotP2014Output] Version 1.2: It now generates also Chinese text, so it's ready for DotP2015 as well.
- [GathererInput] Version 1.4: It now handles flavor text from Gatherer again.
- [GathererInput] Version 1.3, [MagiccardsInput] Version 1.2: Card title uses "graceful quotes", enhanced ability auto-splitting where the site's formatting fails.
- [GathererInput] Version 1.2: It now understands both "Portuguese (Brazil)" and "Portuguese" in the language pages.
- [DotP2014Output] Version 1.1: Fixed rarity attribute.
[GathererInput] Version 1.1: Trimmed white spaces around flavor text.
[MagiccardsInput] Version 1.1: Removed some debugging leftovers. - [All plugins] Version 1.0: Initial version.
What is this all about?
This is mostly a modders' community, so I thought: why not making a moddable card generator? And here it is! It supports plugins written in Python so that it can fetch information from different sites and produce XML files for different DotP versions.
How to install it
Download the ZIP file with the binaries and extract it to a folder of your choice, then download the ZIP file with the IronPython DLLs and extract it to the same folder. It requires .NET Framework 4.5.
In case someone wants to meddle with the source, note that the "python" directory isn't included in the ZIP file with the sources: you'll need to take it from the binaries. Moreover, if you don't install the IronPython extensions for your Visual Studio, you'll also need the 4 additional DLLs from the second ZIP file, which aren't referenced in the project because the IronPython extensions take care of that.
Basic usage
Run the executable and you'll face a window like this:
The input plugin takes care of reading the card information from a site. I included one for Gatherer and one for magiccards.info, use the one you prefer (maybe if a card gets badly formatted text from one you can try with the other one rather than editing the XML file manually). You need to enter the name or the Multiverse ID of a card in the text box. Note that, if you enter a Multiverse ID with the magiccards plugin, it will need to ask Gatherer anyway because you can't search Multiverse IDs outside of Gatherer (this is relevant if Gatherer is down for maintenance).
The output plugin gets the information from the input plugin and generates a string with XML file contents. The program will ask you where to save the file, but that doesn't happen inside the plugin. You need to enter a personal prefix for your card IDs (or just uncheck the option, but I don't recommend it).
The so-called "other" plugin (sorry, couldn't think of a better name ) is a way to allow a certain degree of expandability: it receives both the card information from the input plugin and the XML string from the output plugin, and it generates a string that will be shown in the upper-right box. I included a dummy plugin that just writes the Gatherer link for the card, but in the future I might code a plugin that writes a link to MagicVille in order to search for pictures (the only reason I haven't done this already is because MagicVille doesn't seem to allow exact terms search, which would make things so much easier).
So, once you selected the plugins and entered the required information, click on Run and wait for the program to do its... Magic. If something wrong happens, you'll probably see a red entry in the log (the lower-right box): if that's the case, answer to this topic and let me know what happened and what the red entry says (I think the errors are generated in the OS's language, so please provide a translation if it's not English or Italian ).
Batch processing
First and foremost, thanks to Xander9009 for giving me the idea of implementing a batch processing mode!
In the Tools menu you can find a "Batch processing" command: it will allow you to let the program work on a list of cards automatically. First, open Notepad and make a list of terms (names or IDs) for the cards you want to generate, one term per line. Save the text file wherever you want. Now click on "Batch processing", select the text file you just saved, and a directory where you want the XML files to be saved. Batch started! Just wait for it to finish. Note that batch processing has some minor limitations due to me not having thought about implementing it from the start: it won't provide any error report, and the "other" plugin won't show anything (but it will be run anyway, so I suggest you to always choose the Gatherer one which does almost nothing, so the batch will take less time). On the bright side, I made it so that the program will spawn a thread for each card (up to a maximum of 8, you can change the value in the Settings.xml file that will be produced after the first run, if you want), so the batch processing will have a nice parallelism.
How to make a new plugin
I may write some more details in the future, but for now, just know that there are 3 mandatory functions to include: Info, Purpose and Get. Look at the existing plugins for examples.
Possible questions
- Q: Why didn't you use Lua instead of Python? I just learned to code cards, do I have to learn yet another scripting language?
A: Well, nobody forces you to mod this program... :wink: I chose Python because its extensions for Visual Studio seemed the most robust, and I don't regret the choice, because Python revealed itself very capable at manipulating strings, which is the most important thing here. - Q: What is the purpose of the "Test" commands in the Tools menu?
A: If a plugin includes a Test function, using a Test command will run that function and redirect all the print outputs to the upper-right box (where the "other" plugin usually writes). They are useful if you want to test a plugin alone. If you don't plan to mod this program, you won't need them. - Q: Will you make output plugins for DotP2012 and 2013?
A: Never say never... but I don't plan on making them right now. If someone else wants to make them, I'll be glad to add them. By the way, you can use the DotP2014 plugin for DotP2015 as well, nothing really important concerning my auto-generation has changed. - Q: Why isn't the intermediate Card object coded in Python as well?
A: Because that would defeat the whole purpose of having compatible input and output plugins: if everyone started to make their own Card object, input and output plugins coded by different people might not be compatible. - Q: Why don't you generate the XML as a C# XmlDocument?
A: Because it's easier to auto-generate abilities (where possible) if I make an XML string by stitching pieces together. - Q: Why haven't you coded <something> in a better performing way?
A: I started to code in C# not really long ago, and I can say the same for Python, so if you know a better way to code <something>, please don't hesitate to show me!
Known bugs
- I wouldn't call this a bug because it depends on the information source, anyway the program can't separate abilities that are written on the same line (it can sometimes, but only under very specific circumstances). And I'm not even talking about comma-separated keywords: separating those is out of question, I thought many times of a way to do that which works for all languages and does it exactly as it's supposed to, but with no result.
- When making Auras, the "Enchant creature" part could be labeled as ACTIVATED_ABILITY. Since it just needs to be corrected manually, I consider this a very low priority bug and I won't fix it anytime soon. You can use Xander9009's plugin which has it fixed already.
Links
Choose the link you prefer. It appears that Chrome doesn't like Mega, but Firefox downloads it just fine (or you can use JDownloader).
Binaries:
- Code: Select all
https://mega.nz/#!rK5k2a5b!BhGcoybK0bh-CSA2WaxyIOtvFEGgcNKcPo6ziCmCn0w
http://www81.zippyshare.com/v/Prz6BMFd/file.html
- Code: Select all
https://mega.nz/#!7PoGXChD!HoeB9rSHCK51vq-ojHO2KPJOVrB8bYU9oj-_ZlRQE5w
http://www81.zippyshare.com/v/8XHtK7jf/file.html
- Code: Select all
https://mega.nz/#!vGoUyYxT!Weju2kE7QSGuWSGQkS44pCvvyMEYD-jFkb_NesIBrCM
http://www44.zippyshare.com/v/TYeJIk66/file.html
Other people's plugins
Feel free to post your own plugins by replying to this topic: I'll add a link for each one in this section.