Coding 2024-09-05
Well, I've worked out how to avoid template pattern stuff. The new design I'm working towards as a result is... a thing. There are a few bits that I'm missing and I need to sketch out how they should work.
Here's the idea of the new design:
- There are a few "internal" dice types, which all accept a scaling factor. (I am not at all confident that Mypy will accept how I have implemented this.)
- These are collected into a "pool", in a PBag, along with an integer offset.
- The pool can be rolled, but this does not produce a final numerical result. Instead, it produces a mapping from the number rolled on each die, to a bag of the dice that rolled that number.
- This should be sufficient for stuff like the obvious choice of summing everything up (simply scale by the length of the bag), as well as more involved means of scoring or determining an outcome, as well as allowing for intermediate processing steps like exploding dice or dropping or doubling extreme entries.
What I need to figure out now is the proper way to handle "pipelining" this stuff, as well as the "basic" case of "please just sum up these dice, crazy software design person".
I'll think about that overnight and see what I come up with.
Good night.