dnd-tools icon indicating copy to clipboard operation
dnd-tools copied to clipboard

Code cleanup

Open lodenrogue opened this issue 7 years ago • 4 comments

How about abstracting some of these features into their own python file? Maybe (suggestion) using some object oriented programming features like polymorphism to simplify all those if, else statements?

lodenrogue avatar Jul 24 '18 22:07 lodenrogue

Thanks for the input! I am not familiar with polymorphism or (admittedly) other object oriented features, but will look into them. If you're willing, you're more than willing to do so yourself and make a pull request.

I am aware of the verbose nature of the program; particularly if additional libraries and source material continue to be added. A major stumbling block is that the program is made to install directly to a Linux binary and I am not (yet) knowledgeable as to how to make things other than the main script install. Though, taking a quick look at my PKGBUILD it doesn't appear too complicated, it will just take some experimenting to figure out.

savagezen avatar Jul 25 '18 20:07 savagezen

I don't know what you are doing to turn it into a linux binary, but would that still work if the python script references a config file for the tables? ex all the loot tables could be a json or something that you load in and then expand?

raithwind avatar Nov 12 '18 11:11 raithwind

I've had some time to think about this and, yes, it is possible. My concern previously was that implementing library files would break cross-platform compatibility (e.g. Linux wouldn't use the reference files but would install them and vice-versa for Windows).

However, the library files could be made (JSON or just a file containing a python dictionary / list) for different sources or content categories (weapons, items, art, etc...) or source books. Windows should read it fine as long as the python script in the source reads (imports) them correctly.

The job, then of installing those libraries on Linux doesn't have to fall on this script, but can easily be done by the PKGBUILD which packages the source for (Arch) Linux installation. Other distributions would have to use a more manual process, but the commands would all be referenced in the PKGBUILD.

savagezen avatar Nov 13 '18 14:11 savagezen

That sounds reasonable, and the inclusion of the os module would mean that you could have the files stored in a subdirectory and us os to handle the cross platform compatibility of reading from the subdir?

raithwind avatar Nov 13 '18 15:11 raithwind