I finally got a little bit of time again to work on HamQuest, and so I picked up where I left off, namely, the “load game” functionality.
Note to self: stop being so clever with things.
Most of my objects wound up tightly coupled, which is fine in a smallish project like this, but for the saving and loading aspects, this has been disastrous.
For example, I have a class called “CountedCollection”, which is a generic that requires a type of thing that will be “counted”. Really, this is just a wrapped up dictionary. It is so that I can count things like how many swords a room or a player has.
The ToXml function was easy. blah.ToString() to send out the counted type.
The FromXml function… not so easy. CountedCollection doesn’t necessarily count enumerated types, so the Enum.Parse function cannot be used. I might instead be counting various string values.
So, I now have to pass a delegate to the FromXml function in order to enable conversion from string. Durp.
Quickly, this code base is turning into a slightly steaming pile of goofy code.
But, if and when there is a HamQuest II, I will avoid some of these mistakes.