importrandomimporttimeplayer_level=1player_health=100player_attack=10player_defense=0player_gold=0armor="None"blade="None"poison_potions=0healing_potions=0hunger=100enemy_types={"Goblin":{"health":50,"attack":20},"Skeleton":{"health":80,"attack":15},"Zombie":{"health":120,"attack":25},}coin_toss_attack={"power":50,"boost_turns":2,}armor_options={"Leather Armor":{"defense":5},"Iron Armor":{"defense":10},"Steel Armor":{"defense":15},}blade_options={"Iron Blade":{"attack":10},"Steel Blade":{"attack":20},"Legendary Blade":{"attack":30},}whileTrue:print("1. Explore")print("2. Stats")print("3. Inventory")print("4. Exit")choice=input("Enter your choice: ")time.sleep(1)ifchoice=="1":encounter=random.choice(["Nothing","Monster","Treasure","Boss"])ifencounter=="Nothing":ifplayer_health<100:player_health+=random.randint(5,10)print("Caught your breath. Regenerated some health.")time.sleep(1)else:print("Nothing interesting here.")time.sleep(1)ifhunger<100:hunger+=random.randint(2,5)print("Found some mushrooms. Satisfied your hunger.")time.sleep(1)elifencounter=="Monster":enemy_type=random.choice(list(enemy_types.keys()))enemy_health=enemy_types[enemy_type]["health"]+player_level*20enemy_attack=enemy_types[enemy_type]["attack"]+player_level*5print("A wild "+enemy_type+" appears! (Health: "+str(enemy_health)+", Attack: "+str(enemy_attack)+")")time.sleep(1)whileplayer_health>0andenemy_health>0:print("1. Attack")print("2. Flee")print("3. Coin Toss Attack")battle_choice=input("Enter your choice: ")time.sleep(1)ifbattle_choice=="1":enemy_health-=player_attackprint("You attack the "+enemy_type+"!")time.sleep(1)ifenemy_health>0:player_health-=enemy_attackprint("The "+enemy_type+" attacks you!")time.sleep(1)elifbattle_choice=="2":ifrandom.randint(1,10)<=5:print("You successfully flee!")time.sleep(1)breakelse:print("You failed to flee. The "+enemy_type+" attacks!")time.sleep(1)player_health-=enemy_attackelifbattle_choice=="3":coin_toss_result=random.choice(["Head","Tail"])print("Coin toss result:",coin_toss_result)time.sleep(1)ifcoin_toss_result=="Head":player_health-=coin_toss_attack["power"]print("Coin toss failed! Endured a powerful attack.")time.sleep(1)else:player_attack+=coin_toss_attack["power"]print("Coin toss succeeded! Escaped the attack and gained a boost for the next attack.")time.sleep(1)else:print("Invalid choice. Try again.")time.sleep(1)ifplayer_health<=0:print("Defeated by the "+enemy_type+". Game over!")breakelse:gold_earned=random.randint(10,20)player_gold+=gold_earnedprint("Defeated the "+enemy_type+"! Found "+str(gold_earned)+" gold.")time.sleep(1)ifplayer_gold>=100:print("Enough gold to improve stats at the shop.")time.sleep(1)elifencounter=="Treasure":gold_found=random.randint(5,10)player_gold+=gold_foundprint("Found treasure! Gained "+str(gold_found)+" gold.")time.sleep(1)ifhunger<100:hunger+=random.randint(5,10)print("Found some meat. Satisfied your hunger.")time.sleep(1)elifencounter=="Boss":boss_type=random.choice(["Demon Lord","Ancient Dragon","Lich King"])boss_health=(player_level*100)+random.randint(50,100)boss_attack=(player_level*20)+random.randint(10,20)print("You encounter a mighty "+boss_type+"! (Health: "+str(boss_health)+", Attack: "+str(boss_attack)+")")time.sleep(1)whileplayer_health>0andboss_health>0:print("1. Attack")print("2. Coin Toss Attack")battle_choice=input("Enter your choice: ")time.sleep(1)ifbattle_choice=="1":boss_health-=player_attackprint("You attack the "+boss_type+"!")time.sleep(1)ifboss_health>0:player_health-=boss_attackprint("The "+boss_type+" attacks you!")time.sleep(1)elifbattle_choice=="2":coin_toss_result=random.choice(["Head","Tail"])print("Coin toss result:",coin_toss_result)time.sleep(1)ifcoin_toss_result=="Head":player_health-=coin_toss_attack["power"]print("Coin toss failed! Endured a powerful attack.")time.sleep(1)else:player_attack+=coin_toss_attack["power"]print("Coin toss succeeded! Escaped the attack and gained a boost for the next attack.")time.sleep(1)else:print("Invalid choice. Try again.")time.sleep(1)ifplayer_health<=0:print("Defeated by the "+boss_type+". Game over!")breakelse:gold_earned=random.randint(50,100)player_gold+=gold_earnedprint("Defeated the "+boss_type+"! Found "+str(gold_earned)+" gold.")time.sleep(1)ifplayer_gold>=100:print("Enough gold to improve stats at the shop.")time.sleep(1)ifhunger>0:hunger-=random.randint(1,3)ifhunger<=0:print("You are starving! Lose health.")player_health-=random.randint(5,10)time.sleep(1)elifchoice=="2":print("Player Stats:")print("Level:",player_level)print("Health:",player_health)print("Attack:",player_attack)print("Defense:",player_defense)print("Gold:",player_gold)print("Armor:",armor)print("Blade:",blade)time.sleep(1)elifchoice=="3":print("1. Use Poison Potion")print("2. Use Healing Potion")print("3. Equip Armor")print("4. Equip Blade")print("5. Leave Inventory")inventory_choice=input("Enter your choice: ")time.sleep(1)ifinventory_choice=="1":ifpoison_potions>0:player_attack+=10poison_potions-=1print("Used a Poison Potion. Attack increased!")time.sleep(1)else:print("No Poison Potions available.")time.sleep(1)elifinventory_choice=="2":ifhealing_potions>0:player_health+=20healing_potions-=1print("Used a Healing Potion. Health increased!")time.sleep(1)else:print("No Healing Potions available.")time.sleep(1)elifinventory_choice=="3":print("Available Armor Options:")fori,optioninenumerate(armor_options.keys()):print(str(i+1)+". "+option)equip_choice=input("Enter the number of the armor you want to equip: ")time.sleep(1)ifequip_choice.isdigit()andint(equip_choice)inrange(1,len(armor_options)+1):armor=list(armor_options.keys())[int(equip_choice)-1]player_defense=armor_options[armor]["defense"]print("Equipped "+armor+". Defense increased!")time.sleep(1)else:print("Invalid choice. Try again.")time.sleep(1)elifinventory_choice=="4":print("Available Blade Options:")fori,optioninenumerate(blade_options.keys()):print(str(i+1)+". "+option)equip_choice=input("Enter the number of the blade you want to equip: ")time.sleep(1)ifequip_choice.isdigit()andint(equip_choice)inrange(1,len(blade_options)+1):blade=list(blade_options.keys())[int(equip_choice)-1]player_attack=blade_options[blade]["attack"]print("Equipped "+blade+". Attack increased!")time.sleep(1)else:print("Invalid choice. Try again.")time.sleep(1)elifinventory_choice=="5":print("Leaving inventory.")time.sleep(1)else:print("Invalid choice. Try again.")time.sleep(1)elifchoice=="4":print("Exiting the game.")breakelse:print("Invalid choice. Try again.")time.sleep(1)
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.