Open Twmabysjzna opened 1 year ago
Local "Monster"
import random
def encounter_monster(): monsters = ["Goblin", "Orc", "Troll", "Werewolf"] monster = random.choice(monsters) print(f"A wild {monster} appears!")
action = input("Do you want to [F]ight or [R]un? ").lower()
if action == "f":
if random.random() < 0.5: # 50% chance of winning
print(f"You defeated the {monster}!")
else:
print(f"The {monster} defeated you. Game over!")
elif action == "r":
print("You managed to escape.")
else:
print("Invalid choice. Please select 'F' to fight or 'R' to run.")
def main(): print("Welcome to the Local Monster Game!") print("You're exploring your town and encounter various monsters.")
while True:
encounter_monster()
play_again = input("Do you want to play again? (yes/no) ").lower()
if play_again != "yes":
print("Thanks for playing!")
break
if name == "main": main()
class Kingdom: def init(self, name, ruler, main_city, resources): self.name = name self.ruler = ruler self.main_city = main_city self.resources = resources
def describe(self):
print(f"Welcome to the Kingdom of {self.name}!")
print(f"Ruled by {self.ruler}, this kingdom is centered around the city of {self.main_city}.")
print(f"The kingdom is known for its abundant {', '.join(self.resources)}.")
kingdom = Kingdom( name="Eldoria", ruler="Queen Isabella", main_city="Eldorium", resources=["rich farmlands", "sparkling rivers", "dense forests"] )
kingdom.describe() Run code () Run () Run code () Run fly ()
.gradle /build/ !src//build/
gradle-app.setting
!gradle-wrapper.jar
!gradle-wrapper.properties
.gradletasknamecache
.project
.classpath
/build/
.gradle /Build/
import random
def encounter_monster(): monsters = ["Goblin", "Orc", "Troll", "Werewolf"] monster = random.choice(monsters) print(f"A wild {monster} appears!")
def main(): print("Welcome to the Local Monster Game!") print("You're exploring your town and encounter various monsters.")
if name == "main": main()