MirUlr / dsa_calculator

Some classes for handling the 3d20 test of the the german pen and paper system in a streamlined way.
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Refactoring Twinkle: More refined subclasses #3

Open MirUlr opened 3 years ago

MirUlr commented 3 years ago

It could be beneficial for the overall code quality to consider Twinkle as somewhat like a abstract class and derive the several roles in seperate classes. There must be checked in which way the concept of an abstract class is available in python.

MirUlr commented 3 years ago

The concept of abstarct classes is provided in python via the module abstract base class, see docs or this tutorial.

The generell difference between wizard, priest, etc. is the naming of certain concepts, like the used (energy-)source. Therefore a tangible consequence is the complex handling of german grammar as output. Right now this is handled via Twinkle's method __twinkle_stuff_term (see here). This is working, but a more sophisticated version could spare some clumsy atricle concatenations.

The refactoring of Twinkle as abstract base class may be appropriate. Each method, wich handles spell-likes could be decorated as @abstractmethod and arguments for the specific terms. Derived subclasses would implement these abstract methods by calling the supermethods with the corresponding terms. Nevertheless these adaptation would have little effect on current features, but the resulting classes could be more expanded in a more elegant way.