Hello, forum members!
I’ve doing a drill-down for ex.43, and Zed suggested to add a simple battle system in game.
So I thought to do following:
- Added another elif to the room that guides player to another class(scene):
class CentralCorridor(Scene):
...
elif action == "fight":
print(dedent("""
You take off your shirt and prepare to fight him.
"""))
return 'fight_scene'
- Added new scene with following code:
class FightScene(Scene):
def enter(self):
alien_hp = 10
player_hp = 10
round = 1
print(dedent("""
You've decided to fight that alien.
You have no weapon, so he throws away his blaster. Bare knuckles vs. raw power...
"""))
print(dedent("""You are trying to hit him, and every time he will fight back"""))
input()
while alien_hp > 0 and player_hp > 0:
print(f"\nRound {round}")
print(f"Player:{player_hp}\tAlien:{alien_hp}")
input()
player_hit = randint(1,3)
print(f"You hit Alien and his HP is decreased by {player_hit}")
alien_hp -= player_hit
input()
alien_hit = randint(1,3)
print(f"Alien hits you and your HP is decreased by {alien_hit}")
player_hp -= alien_hit
input()
round += 1
if player_hp <= 0:
return 'death'
else:
print("You won in a fierce fight and now going to move forward")
input()
return 'laser_weapon_armory'
Any suggestions how to make it more simple and / or better?
Thank you in advance!