Partially refactor dice.py