#Battle against an A.I
import random
player = {"name": "", "attack": 10, "heal": 16, "health": 100}
monster = {"name": "NemesisDNA", "attack": 12, "health": 100}
game_running = True
player_won = False
monster_won = False
new_round = True
name = input("What is your name?")
player["name"] = name
def enemy_turn():
print(monster["name"], "'s turn")
monster["attack"] = random.randint(10, 13)
player["health"] = player["health"] - monster["attack"]
print(monster["name"], " dealt ", monster["attack"], " damage and ", player["name"], " has ",
player["health"], " health left!")
while game_running:
new_round = True
player = {"name": name, "attack": 10, "heal": 16, "health": 100}
monster = {"name": "NemesisDNA", "attack": 12, "health": 100}
player_won = False
monster_won = False
while new_round:
print("Please select action")
print("1) Attack")
print("2) Heal")
action = input("")
if action == "1":
player["attack"] = random.randint(9, 11)
monster["health"] = monster["health"] - player["attack"]
print(player["name"], " dealt ", player["attack"], " damage and ", monster["name"], " has ",
monster["health"], " health left!")
if monster["health"] <= 0:
player_won = True
new_round = False
print(player["name"], " wins!!!")
else:
enemy_turn()
if player["health"] <= 0:
player["health"] = 0
player_won = True
new_round = False
print(monster["name"], " wins!!!")
elif action == "2":
player["heal"] = random.randint(10, player["heal"])
player["health"] = player["health"] + player["heal"]
if player["health"] > 100:
player["health"] = 100
print(player["name"], " healed " , player["heal"], " health!")
enemy_turn()
if player["health"] <= 0:
player["health"] = 0
player_won = True
new_round = False
print(monster["name"], " wins!!!")
else:
print(monster["name"], " has ", monster["health"], " left.")
else:
print("-Invalid input-")
if not new_round:
restart = input("Do you want to play again? Y/N: ")
if restart == "Y":
new_round = True
game_running = True
else:
game_running = False