I did take a crack at this. I got a very basic version working in the game by including a second while loop within the CentralCorridor class (starts line 138). I was going to spin it off into a function, but by that time I felt I had spent too much time on the exercise and moved on.
I also modified my Lifeform class (line 23) to include “stats” that I envisioned using in the combat loop to judge if an attack was successful and how much damage is done.
Here’s the file, it’s pretty verbose. so apologies for that.
My line of thinking was that combat is a loop, I thought of JRPG turn based combat for inspiration.
while enemy is alive: # i.e health is greater than 0
subtract damage from enemy health
enemy counter attacks
subtract damage from player health
if player is not dead:
get input to see if player still wants to fight or retreat
There probably is a better way to do it, but that’s where I started. Let me know if you have any questions or feedback.