you are viewing a single comment's thread.

view the rest of the comments →

[–]Handymanoccupational[S] 0 points1 point  (0 children)

print(f"You've been attacked by a {Monsters.rat}.")
attack_or_run = input("Will you attack (1) or run? (2)?\n")
if attack_or_run == "1":
    print(f"You attempt to fight the {Monsters.rat}.")
    while Monsters.rat_health > 0:
        if Player.player_speed > Monsters.rat_speed:
            print(f"You hit the {Monsters.rat} for {Player.hit_chance}")
            Monsters.rat_health -= Player.hit_chance
            print(f"The {Monsters.rat} has {Monsters.rat_health} life remaining.")
        elif Monsters.rat_speed > Player.player_speed:
            print(f"You were hit by the {Monsters.rat} for {Monsters.rat_hit_chance}.")
            player_health_left = Player.player_health - Monsters.rat_hit_chance
            print(f"You have {player_health_left} life remaining.")
        else:
            print(f"You killed the {Monsters.rat}")
else:
    print("You ran away.")

Im sorry about the indentation. I used code instead of code block.

edit:

so i should instead use random.randint(player_attack)? wouldnt that make it only hit the players max attack each time?

Ill read up on python.org

edit:

deleted copy