Corrected last bugs in character creation. Now fully complete.
This commit is contained in:
120
function_list.py
120
function_list.py
@@ -13,11 +13,16 @@ def wait():
|
|||||||
|
|
||||||
def startGame():
|
def startGame():
|
||||||
print("Welcome stranger, to the world of Kanjin!.")
|
print("Welcome stranger, to the world of Kanjin!.")
|
||||||
|
# Loop for initial choice: Create or Pre-generated
|
||||||
|
while True:
|
||||||
start = input("Would you like to create your own character or use pre-generated stats?"
|
start = input("Would you like to create your own character or use pre-generated stats?"
|
||||||
"\n 1) Create a new character\n 2) Pre-generated\n >> ")
|
"\n 1) Create a new character\n 2) Pre-generated\n >> ")
|
||||||
while True:
|
|
||||||
if start in ("1", "Create"):
|
if start in ("1", "Create"):
|
||||||
while True: # Global check to see if Name, Age, and Gender are correct
|
# --- Character Basic Info (Name, Gender, Age) ---
|
||||||
|
name, gender, age = None, None, None # Initialize
|
||||||
|
# Loop until basic info is confirmed
|
||||||
|
while True:
|
||||||
# Name
|
# Name
|
||||||
name = input('What is your name?\n >> ').title()
|
name = input('What is your name?\n >> ').title()
|
||||||
while len(name) < 2:
|
while len(name) < 2:
|
||||||
@@ -25,7 +30,7 @@ def startGame():
|
|||||||
# Gender
|
# Gender
|
||||||
while True:
|
while True:
|
||||||
gender_select = input("What is your gender?\n"
|
gender_select = input("What is your gender?\n"
|
||||||
"1) Male\n2) Female\n3) Other\n >> ")
|
"1) Male\n2) Female\n3) Other\n >> ").lower()
|
||||||
if gender_select not in ("male", "female", "other", "1", "2", "3"):
|
if gender_select not in ("male", "female", "other", "1", "2", "3"):
|
||||||
print("Sorry I didn't recognise that gender. Please try again.")
|
print("Sorry I didn't recognise that gender. Please try again.")
|
||||||
continue
|
continue
|
||||||
@@ -46,26 +51,23 @@ def startGame():
|
|||||||
print("Sorry I didn't recognise that age. Please type in a whole number.")
|
print("Sorry I didn't recognise that age. Please type in a whole number.")
|
||||||
continue
|
continue
|
||||||
# Double check responses
|
# Double check responses
|
||||||
correct = input(f"Hello, {name}. You are a {age} year old {gender}.\nIs this correct? Y/N\n >> ")
|
correct = input(f"Hello, {name}.\nYou are a {age} year old {gender.lower()}.\nIs this correct? Y/N\n >> ")
|
||||||
if correct in ['y', 'yes']:
|
if correct.lower() in ['y', 'yes']:
|
||||||
break
|
break # Exit basic info confirmation loop
|
||||||
elif correct in ['n', 'no']:
|
elif correct.lower() in ['n', 'no']:
|
||||||
continue
|
continue # Restart basic info input
|
||||||
else:
|
else:
|
||||||
print("Sorry, I didn't catch that.\n")
|
print("Sorry, I didn't catch that. Please try again.\n")
|
||||||
correct = input(f"You are a {age} year old {gender}. \nIs this correct? Y/N\n >> ")
|
|
||||||
if correct in ['y', 'yes']:
|
|
||||||
break
|
|
||||||
elif correct in ['n', 'no']:
|
|
||||||
continue
|
continue
|
||||||
break
|
|
||||||
|
|
||||||
|
# --- Race and Job Selection ---
|
||||||
race = None
|
race = None
|
||||||
job = None
|
job = None
|
||||||
|
# Loop until Race and Job are confirmed
|
||||||
while True: # Global check to see if Race and Job are correct
|
while True:
|
||||||
# Race
|
# Race Selection
|
||||||
selected_race_obj = None
|
selected_race_obj = None
|
||||||
|
# Loop for selecting and viewing race
|
||||||
while True:
|
while True:
|
||||||
race_choice = input("Please select a race to learn more about it:\n"
|
race_choice = input("Please select a race to learn more about it:\n"
|
||||||
"1) Elf\n2) Dwarf\n3) Human\n >> ").title()
|
"1) Elf\n2) Dwarf\n3) Human\n >> ").title()
|
||||||
@@ -81,19 +83,23 @@ def startGame():
|
|||||||
|
|
||||||
if selected_race_obj:
|
if selected_race_obj:
|
||||||
print(f"\n--- {selected_race_obj.name} ---")
|
print(f"\n--- {selected_race_obj.name} ---")
|
||||||
print(selected_race_obj.__repr__()) # Use the __repr__ to get full description and traits
|
print(selected_race_obj.__repr__())
|
||||||
print('Would you like to proceed with this race or view another?')
|
print('Would you like to proceed with this race or view another?')
|
||||||
proceed = input('1) Proceed\n2) View another race\n >> ')
|
proceed = input('1) Proceed\n2) View another race\n >> ')
|
||||||
if proceed in ('1', 'proceed'):
|
if proceed.lower() in ('1', 'proceed'):
|
||||||
race = selected_race_obj
|
race = selected_race_obj # Assign race object
|
||||||
break
|
break # Exit race selection loop
|
||||||
elif proceed in ('2', 'view', 'view another', 'view another race'):
|
elif proceed.lower() in ('2', 'view', 'view another', 'view another race'):
|
||||||
race = None
|
continue # Restart race selection
|
||||||
|
else:
|
||||||
|
print("Sorry, I didn't catch that. Please try again.\n")
|
||||||
continue
|
continue
|
||||||
# Job
|
|
||||||
|
# Job Selection
|
||||||
selected_job_obj = None
|
selected_job_obj = None
|
||||||
|
# Loop for selecting and viewing job
|
||||||
while True:
|
while True:
|
||||||
job_choice = input("Please select a race to learn more about it:\n"
|
job_choice = input("Please select a job to learn more about it:\n"
|
||||||
"1) Barbarian\n2) Cleric\n3) Wizard\n >> ").title()
|
"1) Barbarian\n2) Cleric\n3) Wizard\n >> ").title()
|
||||||
if job_choice in ['Barbarian', '1']:
|
if job_choice in ['Barbarian', '1']:
|
||||||
selected_job_obj = Barbarian
|
selected_job_obj = Barbarian
|
||||||
@@ -107,30 +113,35 @@ def startGame():
|
|||||||
|
|
||||||
if selected_job_obj:
|
if selected_job_obj:
|
||||||
print(f"\n--- {selected_job_obj.name} ---")
|
print(f"\n--- {selected_job_obj.name} ---")
|
||||||
print(selected_job_obj.__repr__()) # Use the __repr__ to get full description and traits
|
print(selected_job_obj.__repr__())
|
||||||
|
|
||||||
print('Would you like to proceed with this job or view another?')
|
print('Would you like to proceed with this job or view another?')
|
||||||
proceed = input('1) Proceed\n2) View another job\n >> ')
|
proceed = input('1) Proceed\n2) View another job\n >> ')
|
||||||
if proceed in ('1', 'proceed'):
|
if proceed.lower() in ('1', 'proceed'):
|
||||||
job = selected_job_obj # Store the string name
|
job = selected_job_obj # Assign job object
|
||||||
break
|
break # Exit job selection loop
|
||||||
elif proceed in ('2', 'view', 'view another', 'view another job'):
|
elif proceed.lower() in ('2', 'view', 'view another', 'view another job'):
|
||||||
job = None
|
continue # Restart job selection
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
print("Sorry, I didn't catch that. Please try again.\n")
|
print("Sorry, I didn't catch that. Please try again.\n")
|
||||||
|
continue
|
||||||
|
|
||||||
# Final check
|
# Final confirmation for both Race and Job
|
||||||
while True:
|
while True:
|
||||||
correct = input(f"{name}, you are a {race.name_adjective} {job.name}.\nIs this correct? Y/N\n >> ")
|
# This safeguard should ideally not be hit if inner loops work correctly
|
||||||
if correct in ['y', 'yes']:
|
if race is None or job is None:
|
||||||
|
print("Error: Race or Job not selected. Restarting Race/Job selection.")
|
||||||
|
break # Break out of this inner loop to restart the outer race/job loop
|
||||||
|
correct = input(f"\n{name}, you are a {race.name_adjective} {job.name}.\nIs this correct? Y/N\n >> ")
|
||||||
|
if correct.lower() in ['y', 'yes']:
|
||||||
|
return name, gender, age, race, job # All confirmed, return values
|
||||||
|
elif correct.lower() in ['n', 'no']:
|
||||||
|
# If not correct, break this loop to re-enter race/job selection
|
||||||
break
|
break
|
||||||
elif correct in ['n', 'no']:
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
print("Sorry, I didn't catch that. Please try again.\n")
|
print("Sorry, I didn't catch that. Please try again.\n")
|
||||||
continue
|
continue
|
||||||
return name, gender, age, race, job
|
|
||||||
elif start in ("2", "pre-generated"):
|
elif start in ("2", "pre-generated"):
|
||||||
print("Please be prepared to enter a name, gender, age, race, and class, from those available in the game."
|
print("Please be prepared to enter a name, gender, age, race, and class, from those available in the game."
|
||||||
"\nIf you are unsure what the options are, please go back and create a new character.")
|
"\nIf you are unsure what the options are, please go back and create a new character.")
|
||||||
@@ -139,19 +150,40 @@ def startGame():
|
|||||||
name = input("Name: ")
|
name = input("Name: ")
|
||||||
gender = input("Gender: ")
|
gender = input("Gender: ")
|
||||||
age = int(input("Age: "))
|
age = int(input("Age: "))
|
||||||
race = input("Race: ")
|
race_str = input("Race (Elf, Dwarf, Human): ")
|
||||||
job = input("Job: ")
|
job_str = input("Job (Barbarian, Cleric, Wizard): ")
|
||||||
return name, gender, age, race, job # Return and exit function
|
|
||||||
|
# Map string inputs to actual Race/Job objects for consistency
|
||||||
|
race_map = {'elf': Elf, 'dwarf': Dwarf, 'human': Human}
|
||||||
|
job_map = {'barbarian': Barbarian, 'cleric': Cleric, 'wizard': Wizard}
|
||||||
|
|
||||||
|
actual_race = race_map.get(race_str.lower())
|
||||||
|
actual_job = job_map.get(job_str.lower())
|
||||||
|
|
||||||
|
if actual_race and actual_job:
|
||||||
|
return name, gender, age, actual_race, actual_job
|
||||||
|
else:
|
||||||
|
print("Invalid race or job entered for pre-generated character. Please try again.")
|
||||||
|
# Force restart to character creation choice by setting 'start' to '1'
|
||||||
|
# and then continue the outermost loop.
|
||||||
|
start = "1"
|
||||||
|
continue
|
||||||
elif create in ("n", "no"):
|
elif create in ("n", "no"):
|
||||||
# If 'n', continue the outer while True loop to re-prompt the initial choice.
|
# If 'n', re-prompt the initial choice.
|
||||||
|
start = input("Would you like to create your own character or use pre-generated stats?"
|
||||||
|
"\n 1) Create a new character\n 2) Pre-generated\n >> ")
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
print("Invalid input. Please enter Y or N.")
|
print("Invalid input. Please enter Y or N.")
|
||||||
# If invalid, continue the outer while True loop to re-prompt the initial choice.
|
# If invalid, re-prompt the initial choice.
|
||||||
|
start = input("Would you like to create your own character or use pre-generated stats?"
|
||||||
|
"\n 1) Create a new character\n 2) Pre-generated\n >> ")
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
print("Invalid input. Please select '1' or '2'.")
|
print("Invalid input. Please select '1' or '2'.")
|
||||||
# Continue the outer while True loop to re-prompt the initial choice.
|
# Re-prompt the initial choice.
|
||||||
|
start = input("Would you like to create your own character or use pre-generated stats?"
|
||||||
|
"\n 1) Create a new character\n 2) Pre-generated\n >> ")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def query_equip(player: Player):
|
def query_equip(player: Player):
|
||||||
|
|||||||
19
main.py
19
main.py
@@ -247,25 +247,8 @@ def main_game_loop():
|
|||||||
# Character Creation
|
# Character Creation
|
||||||
name, gender, age, race, job = startGame()
|
name, gender, age, race, job = startGame()
|
||||||
|
|
||||||
# Instantiate Race and Job objects based on user's choice
|
|
||||||
selected_race = None
|
|
||||||
if race == "Elf":
|
|
||||||
selected_race = Elf
|
|
||||||
elif race == "Dwarf":
|
|
||||||
selected_race = Dwarf
|
|
||||||
elif race == "Human":
|
|
||||||
selected_race = Human
|
|
||||||
|
|
||||||
selected_job = None
|
|
||||||
if job == "Barbarian":
|
|
||||||
selected_job = Barbarian
|
|
||||||
elif job == "Cleric":
|
|
||||||
selected_job = Cleric
|
|
||||||
elif job == "Wizard":
|
|
||||||
selected_job = Wizard
|
|
||||||
|
|
||||||
# Create player instance
|
# Create player instance
|
||||||
player = Player(name, gender, age, selected_race, selected_job)
|
player = Player(name, gender, age, race, job)
|
||||||
game_engine.set_player(player) # Set the player in the game engine
|
game_engine.set_player(player) # Set the player in the game engine
|
||||||
|
|
||||||
# Display initial character summary
|
# Display initial character summary
|
||||||
|
|||||||
57
player.py
57
player.py
@@ -141,13 +141,15 @@ class Inventory:
|
|||||||
.replace('RightRing', 'Right Ring'))
|
.replace('RightRing', 'Right Ring'))
|
||||||
return str(slot_val) # Fallback for unexpected types
|
return str(slot_val) # Fallback for unexpected types
|
||||||
|
|
||||||
def add_item(self, item, count=1):
|
def add_item(self, item, count=1, silent=False):
|
||||||
"""Adds an item to the inventory."""
|
"""Adds an item to the inventory."""
|
||||||
if item in self.items:
|
if item in self.items:
|
||||||
self.items[item]["Count"] += count
|
self.items[item]["Count"] += count
|
||||||
|
if not silent:
|
||||||
print(f"Added {count} more {item.name}. Total: {self.items[item]['Count']}.")
|
print(f"Added {count} more {item.name}. Total: {self.items[item]['Count']}.")
|
||||||
else:
|
else:
|
||||||
self.items[item] = {"Count": count, "object": item.itemType}
|
self.items[item] = {"Count": count, "object": item.itemType}
|
||||||
|
if not silent:
|
||||||
print(f"Added {count} {item.name} to inventory.")
|
print(f"Added {count} {item.name} to inventory.")
|
||||||
|
|
||||||
def remove_item(self, item, count=1):
|
def remove_item(self, item, count=1):
|
||||||
@@ -168,7 +170,7 @@ class Inventory:
|
|||||||
|
|
||||||
def current_inventory(self):
|
def current_inventory(self):
|
||||||
"""Prints a list of items in your backpack that aren't equipped to your person."""
|
"""Prints a list of items in your backpack that aren't equipped to your person."""
|
||||||
print(f'In your rucksack you have:')
|
print(f'You are currently carrying:')
|
||||||
found_un_equipped = False
|
found_un_equipped = False
|
||||||
for item_obj, item_data in self.items.items():
|
for item_obj, item_data in self.items.items():
|
||||||
# Check if the item is in the backpack AND not currently equipped in any slot
|
# Check if the item is in the backpack AND not currently equipped in any slot
|
||||||
@@ -182,7 +184,7 @@ class Inventory:
|
|||||||
|
|
||||||
def current_equipment(self):
|
def current_equipment(self):
|
||||||
"""Prints a list of items that you have equipped in your slots."""
|
"""Prints a list of items that you have equipped in your slots."""
|
||||||
print(f'You are currently wearing:')
|
print(f'You have equipped:')
|
||||||
equipment_found = False
|
equipment_found = False
|
||||||
for slot, equipment in self.equipped_items.items():
|
for slot, equipment in self.equipped_items.items():
|
||||||
if equipment is not None and slot != Slots.Attunement: # Don't print the attunement counter
|
if equipment is not None and slot != Slots.Attunement: # Don't print the attunement counter
|
||||||
@@ -209,72 +211,79 @@ class Inventory:
|
|||||||
print(f"Attunement slots used: {self.equipped_items[Slots.Attunement]}/3")
|
print(f"Attunement slots used: {self.equipped_items[Slots.Attunement]}/3")
|
||||||
|
|
||||||
|
|
||||||
def equip_item(self, item_obj, slot: Slots):
|
def equip_item(self, item_obj, slot: Slots, silent=False):
|
||||||
"""Equips an item to a specific slot."""
|
"""Equips an item to a specific slot."""
|
||||||
if item_obj not in self.items or self.items[item_obj]["Count"] == 0:
|
if item_obj not in self.items or self.items[item_obj]["Count"] == 0:
|
||||||
|
if not silent:
|
||||||
print(f"You don't have {item_obj.name} to equip.")
|
print(f"You don't have {item_obj.name} to equip.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check attunement limits before equipping (moved up for early exit)
|
# Check attunement limits before equipping (moved up for early exit)
|
||||||
if item_obj.attunement and self.equipped_items[Slots.Attunement] >= 3:
|
if item_obj.attunement and self.equipped_items[Slots.Attunement] >= 3:
|
||||||
|
if not silent:
|
||||||
print(f"You cannot equip {item_obj.name}. You have reached your attunement limit (3/3).")
|
print(f"You cannot equip {item_obj.name}. You have reached your attunement limit (3/3).")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Handle unequipping existing item in the target slot first
|
# Handle unequipping existing item in the target slot first
|
||||||
if self.equipped_items[slot] is not None:
|
if self.equipped_items[slot] is not None:
|
||||||
self.unequip_item(slot)
|
self.unequip_item(slot) # This will print its own unequip message
|
||||||
|
|
||||||
# Now, handle equipping based on item type and specific properties
|
# Now, handle equipping based on item type and specific properties
|
||||||
if item_obj.itemType == ItemType.Weapon:
|
if item_obj.itemType == ItemType.Weapon:
|
||||||
if item_obj.slot == Slots.TwoHanded:
|
if item_obj.slot == Slots.TwoHanded:
|
||||||
# If equipping a two-handed weapon, unequip anything in main/off-hand
|
# If equipping a two-handed weapon, unequip anything in main/off-hand
|
||||||
if self.equipped_items[Slots.MainHand] is not None:
|
if self.equipped_items[Slots.MainHand] is not None:
|
||||||
self.unequip_item(Slots.MainHand)
|
self.unequip_item(Slots.MainHand, silent=True) # Silent unequip
|
||||||
if self.equipped_items[Slots.OffHand] is not None:
|
if self.equipped_items[Slots.OffHand] is not None:
|
||||||
self.unequip_item(Slots.OffHand)
|
self.unequip_item(Slots.OffHand, silent=True) # Silent unequip
|
||||||
self.equipped_items[Slots.TwoHanded] = item_obj
|
self.equipped_items[Slots.TwoHanded] = item_obj
|
||||||
|
if not silent:
|
||||||
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(Slots.TwoHanded)}.")
|
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(Slots.TwoHanded)}.")
|
||||||
elif item_obj.versatile:
|
elif item_obj.versatile:
|
||||||
# If equipping a versatile weapon, it goes in MainHand, and potentially affects OffHand
|
# If equipping a versatile weapon, it goes in MainHand, and potentially affects OffHand
|
||||||
if self.equipped_items[Slots.TwoHanded] is not None:
|
if self.equipped_items[Slots.TwoHanded] is not None:
|
||||||
self.unequip_item(Slots.TwoHanded) # Unequip two-handed if present
|
self.unequip_item(Slots.TwoHanded, silent=True) # Unequip two-handed if present silently
|
||||||
self.equipped_items[Slots.MainHand] = item_obj
|
self.equipped_items[Slots.MainHand] = item_obj
|
||||||
# A versatile weapon can be used two-handed, implying it might occupy the off-hand conceptually
|
if not silent:
|
||||||
# For simplicity, we'll just equip it to MainHand here. If you want it to occupy off-hand,
|
|
||||||
# you'd need more complex logic for 1H vs 2H use.
|
|
||||||
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(Slots.MainHand)}.")
|
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(Slots.MainHand)}.")
|
||||||
else: # Standard one-handed weapon (or other weapon types not specifically handled above)
|
else: # Standard one-handed weapon (or other weapon types not specifically handled above)
|
||||||
self.equipped_items[slot] = item_obj # Equip to the specified slot (MainHand or OffHand)
|
self.equipped_items[slot] = item_obj # Equip to the specified slot (MainHand or OffHand)
|
||||||
|
if not silent:
|
||||||
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
||||||
elif item_obj.itemType == ItemType.Armor:
|
elif item_obj.itemType == ItemType.Armor:
|
||||||
# For armor, ensure the target slot is appropriate for armor (e.g., Chest, Helm)
|
# For armor, ensure the target slot is appropriate for armor (e.g., Chest, Helm)
|
||||||
# The Armor class now has a 'slot' attribute, so we can use that for validation/assignment
|
# The Armor class now has a 'slot' attribute, so we can use that for validation/assignment
|
||||||
if item_obj.slot == slot: # Ensure the item's intended slot matches the target slot
|
if item_obj.slot == slot: # Ensure the item's intended slot matches the target slot
|
||||||
self.equipped_items[slot] = item_obj
|
self.equipped_items[slot] = item_obj
|
||||||
|
if not silent:
|
||||||
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
||||||
else:
|
else:
|
||||||
# Corrected this line to use _get_slot_display_name for both slot and item_obj.slot
|
if not silent:
|
||||||
print(f"Cannot equip {item_obj.name} to {self._get_slot_display_name(slot)}. It belongs in the {self._get_slot_display_name(item_obj.slot)} slot.")
|
print(f"Cannot equip {item_obj.name} to {self._get_slot_display_name(slot)}. It belongs in the {self._get_slot_display_name(item_obj.slot)} slot.")
|
||||||
return # Exit if slot mismatch
|
return # Exit if slot mismatch
|
||||||
elif item_obj.itemType == ItemType.Item:
|
elif item_obj.itemType == ItemType.Item:
|
||||||
# For general items (rings, cloaks, etc.), equip to the specified slot
|
# For general items (rings, cloaks, etc.), equip to the specified slot
|
||||||
self.equipped_items[slot] = item_obj
|
self.equipped_items[slot] = item_obj
|
||||||
|
if not silent:
|
||||||
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
print(f"Equipped {item_obj.name} to {self._get_slot_display_name(slot)}.")
|
||||||
else:
|
else:
|
||||||
|
if not silent:
|
||||||
print(f"Cannot equip {item_obj.name}. Unknown item type or invalid slot for this item.")
|
print(f"Cannot equip {item_obj.name}. Unknown item type or invalid slot for this item.")
|
||||||
return # Exit if item type is not recognized for equipping
|
return # Exit if item type is not recognized for equipping
|
||||||
|
|
||||||
self.update_attunement() # Update attunement after successful equip
|
self.update_attunement() # Update attunement after successful equip
|
||||||
|
|
||||||
|
|
||||||
def unequip_item(self, slot: Slots):
|
def unequip_item(self, slot: Slots, silent=False):
|
||||||
"""Unequips an item from a specific slot."""
|
"""Unequips an item from a specific slot."""
|
||||||
if self.equipped_items[slot] is not None:
|
if self.equipped_items[slot] is not None:
|
||||||
unequipped_item = self.equipped_items[slot]
|
unequipped_item = self.equipped_items[slot]
|
||||||
self.equipped_items[slot] = None
|
self.equipped_items[slot] = None
|
||||||
|
if not silent:
|
||||||
print(f"Unequipped {unequipped_item.name} from {self._get_slot_display_name(slot)}.") # Use helper function
|
print(f"Unequipped {unequipped_item.name} from {self._get_slot_display_name(slot)}.") # Use helper function
|
||||||
self.update_attunement()
|
self.update_attunement()
|
||||||
else:
|
else:
|
||||||
|
if not silent:
|
||||||
print(f"Nothing is equipped in {self._get_slot_display_name(slot)}.") # Use helper function
|
print(f"Nothing is equipped in {self._get_slot_display_name(slot)}.") # Use helper function
|
||||||
|
|
||||||
def update_attunement(self):
|
def update_attunement(self):
|
||||||
@@ -418,12 +427,12 @@ class Player:
|
|||||||
"Wisdom": 0,
|
"Wisdom": 0,
|
||||||
"Charisma": 0}
|
"Charisma": 0}
|
||||||
|
|
||||||
# Initial items and equipment
|
# Initial items and equipment (now with silent=True)
|
||||||
self.inventory.add_item(rock, 1)
|
self.inventory.add_item(rock, 1, silent=True)
|
||||||
self.inventory.add_item(tornRags, 1)
|
self.inventory.add_item(tornRags, 1, silent=True)
|
||||||
# Equip initial items (using the inventory's equip method)
|
# Equip initial items (using the inventory's equip method)
|
||||||
self.inventory.equip_item(rock, Slots.MainHand)
|
self.inventory.equip_item(rock, Slots.MainHand, silent=True)
|
||||||
self.inventory.equip_item(tornRags, Slots.Chest)
|
self.inventory.equip_item(tornRags, Slots.Chest, silent=True)
|
||||||
|
|
||||||
|
|
||||||
def getModifier(self):
|
def getModifier(self):
|
||||||
@@ -537,7 +546,7 @@ class Player:
|
|||||||
|
|
||||||
def current_stats(self):
|
def current_stats(self):
|
||||||
"""Prints a display of the user's current statistics."""
|
"""Prints a display of the user's current statistics."""
|
||||||
print("Your current stats are:")
|
print(f'\nYour current stats are:')
|
||||||
print(f'Hit Points: {self.currentHP}/{self.maxHP}')
|
print(f'Hit Points: {self.currentHP}/{self.maxHP}')
|
||||||
print(f'Strength: {self.stats["Strength"]} ({self.mods["Strength"]:+})')
|
print(f'Strength: {self.stats["Strength"]} ({self.mods["Strength"]:+})')
|
||||||
print(f'Dexterity: {self.stats["Dexterity"]} ({self.mods["Dexterity"]:+})')
|
print(f'Dexterity: {self.stats["Dexterity"]} ({self.mods["Dexterity"]:+})')
|
||||||
@@ -606,9 +615,9 @@ class Player:
|
|||||||
stats.append(str(val))
|
stats.append(str(val))
|
||||||
rolls = [] # Reset for next roll
|
rolls = [] # Reset for next roll
|
||||||
|
|
||||||
print(f"Please assign a stat to a selected attribute by entering the number then the attribute.\n"
|
print(f"\nPlease assign a stat to a selected attribute by entering the number then the attribute.\n"
|
||||||
f"For example, '10 strength' or '10 str' will assign 10 to your strength, if you have a 10 available.\n\n"
|
f"For example: '10 strength' or '10 str' will assign 10 to your strength, if you have a 10 available.\n\n"
|
||||||
f"Your rolled stats are:\n {', '.join(stats)}\n\n"
|
f"Your rolled stats are:\n {', '.join(stats)}\n"
|
||||||
f"Your attributes are:\n {', '.join(attributes)}\n")
|
f"Your attributes are:\n {', '.join(attributes)}\n")
|
||||||
|
|
||||||
current_attributes = list(attributes)
|
current_attributes = list(attributes)
|
||||||
@@ -642,7 +651,7 @@ class Player:
|
|||||||
else:
|
else:
|
||||||
print("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.")
|
print("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.")
|
||||||
|
|
||||||
print(f"Your current stats are:\n"
|
print(f'\nYour current stats are:\n'
|
||||||
f'Strength: {self.stats["Strength"]}\n'
|
f'Strength: {self.stats["Strength"]}\n'
|
||||||
f'Dexterity: {self.stats["Dexterity"]}\n'
|
f'Dexterity: {self.stats["Dexterity"]}\n'
|
||||||
f'Constitution: {self.stats["Constitution"]}\n'
|
f'Constitution: {self.stats["Constitution"]}\n'
|
||||||
@@ -651,7 +660,7 @@ class Player:
|
|||||||
f'Charisma: {self.stats["Charisma"]}\n')
|
f'Charisma: {self.stats["Charisma"]}\n')
|
||||||
|
|
||||||
select = input("Are you happy with this selection? Y/N?\n"
|
select = input("Are you happy with this selection? Y/N?\n"
|
||||||
"WARNING: If you select 'N', your dice will be randomly rolled again. Proceed?\n"
|
" WARNING: If you select 'N', your dice will be randomly rolled again. Proceed?\n"
|
||||||
" >> ").lower()
|
" >> ").lower()
|
||||||
if select == "n":
|
if select == "n":
|
||||||
continue # Loop back to re-roll and re-allocate
|
continue # Loop back to re-roll and re-allocate
|
||||||
|
|||||||
Reference in New Issue
Block a user