Coding 2024-09-04
All right, I've tossed together some classes that should handle things. Let's review and update my goals from last time:
- Get cattrs to successfully process the TOML file I wrote.
- SVG output.
- Review confusing planets
- Stretch goal for now: overhaul my thrown-together dice implementation for superior testability and logging
The main thing I anticipate to be funky with cattrs is that I want to turn nested maps into a single map with tuple keys. This seems like it should be possible, but there's no reason for it to be out-of-the-box behavior. Every other part of the process should be straightforward
Concerns for the SVG output include:
- How to balance ease of hex shaping with sensible coordinates
- Applying a shear transform to the coordinates to compensate for what the X coordinate does to the Y coordinate
As far as the stretch goal, here's what I want to improve on...
- Right now, each die simply calls random.randint to produce its results.
- There is no indication that a die was rolled.
- There is no indication of any die's results.
- There is no indication of why a die was rolled.
- I want nicer string representations for the different types of dice.
Tossing out some ideas for using context variables to address this:
- The roll methods should take a reason argument.
- There should be a callback that all roll methods call that records the reason.
- The behavior of this callback should be customizable via a context variable.
- The Dice compound type should suppress reason noting in sub-calls, and pass the reason through unchanged.
- There should be a callback that all roll methods call that records the result.
- This should be similarly customizable, but there doesn't need to be any normal code making use of the customization.
- There should also be customization for the randomness source, in a similar fashion.
Some of this could be testable via mocking, but, eh, I'd rather put in the effort to make this work, than try to have mocking happen to work.
The other thing I need to consider is the level of template pattern usage I'm currently considering. It feels okay to me, but my not-quite-gut reaction is that I'm likely to reconsider this later.
I'll have to sleep on this and see what I think.
Good night.