Advertisement
Kalidor_Vorlich

Code Refactor Help

Dec 30th, 2024
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. from utilities import *
  2.  
  3. class Job:
  4.  
  5.     def __init__(self, name, description, hp, mp,spell_list,ability_list):
  6.         self.name = name
  7.         self.description = description
  8.         self.hp = hp
  9.         self.mp = mp
  10.         self.spell_list = spell_list
  11.         self.ability_list = ability_list
  12.  
  13.  
  14.  
  15. whm = Job("White Mage", "Healer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  16. blm = Job("Black Mage", "Elemental damage dealer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  17. rdm = Job("Red Mage", "Elemental damage dealer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  18. war = Job("Warrior", "Elemental damage dealer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  19. thf = Job("Thief", "Elemental damage dealer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  20. mnk = Job("Monk", "Elemental damage dealer", 7, 8,["cure", "Dia"],["Dual Wield","Run"])
  21.  
  22. job_list = [whm, blm, rdm, war, thf, mnk]  
  23.  
  24. def select_mainjob():
  25.     print("What Main Job are you?")
  26.     # Display numbered choices
  27.     for index, i in enumerate(job_list, start=1):
  28.         print(f"{index}. {i.name}")    
  29.     # Get and validate user choice
  30.     selected_index = get_valid_choice(job_list)  
  31.     selected_choice = job_list[selected_index - 1] # minus 1 to get actual index position
  32.     return selected_choice
  33.  
  34.  
  35. def select_supportjob(mainjob):
  36.     print("What Support Job are you?")
  37.     # Display numbered choices, excluding the main job
  38.     valid_jobs = [job for job in job_list if job != mainjob]
  39.     for index, i in enumerate(valid_jobs, start=1):
  40.         print(f"{index}. {i.name}")
  41.     # Get and validate user choice
  42.     selected_index = get_valid_choice(valid_jobs)
  43.     selected_choice = valid_jobs[selected_index - 1]  # minus 1 to get actual index position
  44.     return selected_choice
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement