Thinking back on all of the refactoring I've been doing, I realized that a bunch of it wasn't really getting me closer to having serialization work nicely. I therefore exercised a tiny bit of restraint and shifted focus towards addressing any issues I identified that would directly complicate serialization. I wrote up everything I saw as an issue inline, and fixed a few of the issues, but not yet all of them.
The serialization issues I identified fit into two general categories:
- The type of an attribute would, if serialized directly, pull in data that exists elsewhere in the intended serialized structure, which would copy the state. But, if just the unique state gets serialized, then it's impossible to deserialize the object without access to information that the deserializer cannot express the need for. The solution to these issues was to rewrite the type to work with just the unique state, and rely on the consumers to provide the wider context.
- The type of an attribute would, if serialized, preserve information from the source code of the current run. For example, if I stored some of the messages associated with an item on the associated component, then it would be very inconvenient to make sure the messages had any changes made to the source in future versions. My solution to this was to store the message directly on the class or function that handles the item's behavior.
I believe I solved every instance I found of the first issue, but the second issue is somewhat more involved to solve, so I only fixed some of it. The big issues remaining are the "Fighter" and "Display" components. My basic inclination right now is to make a set of baseline things, and have ways of modifying them by nesting them inside other data structures.
I just put together the groundwork for that, which was pretty easy. Actually adapting the rest of the code to use it is more effort, which I'll put off until tomorrow. Tomorrow, I'll wire those in, and figure out how I want to handle colors, because I know I want to do something different than how I'm currently handling them. Really excited to redo the core turn logic, but that's not a priority. I'll let myself work on that when it looks like the code is ready for serialization.
I've put off finishing this post too long. Good night.