walkerb, Read a post last night asking about making a python class use different code for different things. It was in the context of a game, so extending the ability of the class with different objects.
It interested me so I thought I'd play with the idea this lunchtime.
Here we have a player object (apologies to Steve Jackson / Ian Livingston for appropriating their combat system) with name, skill, stamina and the weapon and armor they have.
The weapons and armor are defined in different classes as functions representing the damage they do, or absorb.
They are passed into the player object by assigning them.
Then battle commences...
Fun little lunchtime code illustrating the power of object oriented code.
https://github.com/nakedmcse/PyRPGCombat/blob/main/PyRPGCombat.py
Add comment