matthewjwhite / crystal-skull

:skull: Highly-configurable, telnet-compatible, text-based RPG
MIT License
0 stars 0 forks source link

Combine common code b/w Monster and User #14

Closed matthewjwhite closed 4 years ago

matthewjwhite commented 4 years ago

Using **kwargs, we can easily pass all the parameters to the User constructor in a dictionary without requiring the constructor to contain parameters for the values that both it and Entity need. Whatever User needs will not be in the **kwargs passed to Entity, so Entity only gets the leftovers.

As part of these changes, I've also made it so that User is instantiated directly using the DB document, as well as the Monster being instantiated directly using the values from the YAML. This requires that User/Monster/Entity member names match DB/YAML field names, though transform functions could easily be created later on to switch between what the YAML/DB needs and what the code needs. For the time being, the simplicity is nice as I'm adding new fields, etc., though the negatives are clear with an approach like this. It should not be something that stays indefinitely.