Yeah, I already have a CompendiumEntry class which does 95% of the work and then a CompendiumNPC and CompendiumPower subclass which just add on a little specialist functionality where needed. Same with Token and NPCToken/PCToken (oh, just realised I have inconsistent naming convensions there - the Compendium classes all start Compendium and the Token classes don't - as an aside, what is the better convention?)jfrazierjr wrote:Glad you noted this. One thing to think about is breaking components down into nouns and each noun becomes it's own class. For example, in your entry above, when you look at the compendium there are Creatures, classes(player classes that is), powers, etc. But each of those are an instance of a CompendiumEntry, so CompendiumEntry(or something like that) would be an interface or more likely in this case class or partially abstract class that the other classes extend.
There are some common things about compendium items that you should not have to reimplement in each of your subclasses...Name comes to mind...
I'm much happier with the way all the object interact now after a little refactoring. I'm sure there is stuff that could be better designed - I'm more than happy if people want to critique my design!! I shouldn't get too defensive I don't think.
On the progress front today I have refactored, commented up and documented all the classes as I said. I've also added formatting code to the HTML output of the powers so they look much better now.
I improved my HTML parser as well adding a little RegExp function to get integers from strings that include an int plus potentially a bunch of spurious characters. That means I can now read "AC 14;" and parse out 14 for AC. I can read "Will 16 (but see also Blah power)" and parse out 16 for Will. I threw Gwenneth the Vampire at the parser after those changes and it nailed all her stats first time! Well chuffed.
I'm currently not picking up resistances and vulnerabilities, alignment, attributes, skills, equipment, saving throws, action points and all sorts of other stuff so there is more work to do, although a lot of these I'll be ignoring for now anyway as I don't need them.
I think my next important job is to parse out the last stats that I do need and then start added the stats into the token as properties.
When that is done I want to parse the monster HTML for attack and damage strings and replace them with MACRO link calls - so I can call macros to roll attacks and damage by clicking on the links on the HTML output - I have this facility with James' HTML parser and it's great so I want to replicate it on my HTML frame.
At that stage I think the monsters might be usable in a game!
Blakey