botbowl
botbowl copied to clipboard
Fixed dice should be stored in Game object
Currently the fixed dice are stored with a singleton pattern, namely the class itself (see code below). If fixed dice are used with multiple game objects at the same time there is a risk that a fixed dice for one game is consumed by another game. That behavior will not crash the execution and but can lead to very subtle bugs.
I propose we move information about the stored fixed rolls to the game object itself. I'm happy to write the PR if you agree.
class BBDie(Die, Immutable):
value: BBDieResult
FixedRolls = []
@staticmethod
def fix(value):
if type(value) == BBDieResult:
BBDie.FixedRolls.append(value)
else:
raise ValueError("Fixed result of BBDie must be a BBDieResult")
Yeah, great idea.
Curious to see how you will implement it :)