python/Tucker/Dungeon game.py
2024-03-17 14:35:17 -04:00

57 lines
3.1 KiB
Python

import os
def load_player_data(player_name, character_name):
player_file = f"{player_name}_{character_name}.txt"
if os.path.exists(player_file):
with open(player_file, 'r') as file:
player_data = file.readlines()
return [data.strip() for data in player_data]
else:
print(f"Player file '{player_file}' not found.")
return None
def save_player_data(player_name, character_name, data):
player_file = f"{player_name}_{character_name}.txt"
with open(player_file, 'w') as file:
for line in data:
file.write(line + '\n')
def create_new_character(player_name):
character_name = input("Enter character name: ")
gamer_tag = input("Please enter your gamer tag: ")
answer = input(f"So your gamer tag is {gamer_tag}? (yes/no) ")
while answer.lower() not in ['yes', 'no']:
print("Sorry, I only accept 'yes' or 'no' as an answer.")
answer = input("Please enter 'yes' or 'no': ")
if answer.lower() == 'no':
gamer_tag = input("Please enter your gamer tag: ")
print(f"Hello {gamer_tag}")
player_race = input("Are you a human, dwarf, or elf? (human/dwarf/elf): ").lower()
player_category = input(f"Is your {player_race} a ranged {player_race} or a close combat {player_race}? (ranged/close combat): ").lower()
if player_category == "close combat":
player_class = input("Are you a barbarian with increased attack power and less intelligence, a warrior with balanced stats, or a rogue with increased intelligence and less attack power? (barbarian/warrior/rogue): ").lower()
if player_class == "barbarian":
weapon_skill = input(f"Will your {gamer_tag} be skilled with axes, swords, or hammers? (axes/swords/hammers): ").lower()
elif player_class == "warrior":
weapon_skill = input(f"Will your {gamer_tag} be skilled with longswords, swords, or daggers? (longswords/swords/daggers): ").lower()
elif player_category == "ranged":
player_class = input(f"Are you an archer with increased intelligence and less attack power or a dead shot with increased attack power and less intelligence? (archer/dead shot): ").lower()
if player_class == "archer":
weapon_skill = input(f"Will your {gamer_tag} be skilled with longbows, throwing daggers, or shortbows? (longbows/throwing daggers/shortbows): ").lower()
elif player_class == "dead shot":
weapon_skill = input(f"Will your {gamer_tag} be skilled with crossbows, slings, or magic bows? (crossbows/slings/magic bows): ").lower()
return [gamer_tag, player_race, player_category, player_class, weapon_skill]
def main():
player_name = input("Enter player name: ")
characters = int(input("How many characters do you want to create?: "))
for i in range(characters):
print(f"Creating character {i + 1}...")
character_data = create_new_character(player_name)
save_player_data(player_name, f"character_{i + 1}", character_data)
# Continue with your story or additional code here
print("You wake up on a shore not remebering anything")
if __name__ == "__main__":
main()