コード例 #1
0
ファイル: Character.py プロジェクト: CMRicketts/dnd2.0
 def set_alignment(self):
     cols = ["lawful", "neutral", "chaotic", "true"]
     rows = ["good", "neutral", "evil"]
     flag = False
     while not flag:
         ch = input("What alignment are you?\n")
         try:
             split = ch.split(" ")
             for i in range(0, 1):
                 if utilities.is_valid_input(
                         split[i].lower(),
                         cols) or utilities.is_valid_input(
                             split[1].lower(), rows):
                     self.alignment = ch
                     if self.alignment.lower() == "neutral neutral":
                         self.alignment = "True Neutral"
                     flag = True
                 else:
                     print(
                         ch +
                         " is not recognized as a valid input. Please try again."
                     )
         except IndexError:
             print(ch +
                   " is not recognized as a valid input. Please try again.")
コード例 #2
0
ファイル: Character.py プロジェクト: CMRicketts/dnd2.0
 def set_background(self):
     count = 1
     while True:
         bg_names = backgrounds.keys()
         if count == 1:
             print("Listing all Backgrounds:")
             for item in bg_names:
                 print(item)
         print(
             "\ninput 'list', 'choose', or 'search' to see all backgrounds, choose a background, or find out more about an inputted background\n"
             +
             "You can also input 'random' to have a background chosen for you at random.\n"
         )
         choice = input("")
         ch = choice.strip()
         if ch == "list":
             print("\nListing all Backgrounds:\n")
             for item in bg_names:
                 print(item)
         if ch == "choose":
             flag = False
             while not flag:
                 bg = input(
                     "Which background do you want to have? input 'exit' to go back and search. This is case-sensitive\n"
                 )
                 if bg.strip().lower() == "exit":
                     flag = True
                 elif utilities.is_valid_input(bg, bg_names):
                     self.background = bg
                     return
                 else:
                     print(bg + " isn't a recognized background.")
         elif utilities.is_valid_input(ch, bg_names):
             self.background = choice.strip()
             return
         elif ch == "search":
             flag = False
             while not flag:
                 bg = input(
                     "Which background do you want to learn more about?\n")
                 if utilities.is_valid_input(bg, bg_names):
                     for item in backgrounds.get(bg):
                         print("\n" + item + ": " +
                               backgrounds.get(bg).get(item) + "\n")
                     import time
                     time.sleep(1)
                     flag = True
                 else:
                     print("That's not valid input. Try again.")
         elif ch == "random":
             self.background = bg_names[r.randrange(0, len(bg_names))]
         else:
             print(ch + " is not recognized as a command. Try again.")
コード例 #3
0
 def append_item(self, opt, item):
     """
     :param opt: the dict
     :param item:
     :return:
     """
     if opt == "proficiency":
         self.proficiencies.append(item)
     elif opt == "feature":
         self.features.append(item)
     elif opt == "skill":
         if utilities.is_valid_input(item, utilities.valid_skills()):
             self.skills.append(item)
         else:
             return False
     elif opt == "resistance":
         self.resistances.append(item)
     elif opt == "advantage":
         self.advantages.append(item)
     elif opt == "disadvantage":
         self.disadvantages.append(item)
     elif opt == "stat":
         utilities.alter_stat(self, item[0], item[1])
     elif opt == "attack":
         self.attack.append(item)
     elif opt == "language":
         self.languages.append(item)
     elif opt == "spells":
         self.add_spell(item, self.level)
     return True
コード例 #4
0
 def set_arch(self, arch_choice, char):
     arch = {}
     if arch_choice == "glamour":
         arch['feature'] = [[0, "Mantle of Inspiration"],
                            [0, "Enthralling Performance"],
                            [5, "Mantle of Majesty"],
                            [13, "Unbreakable Majesty"]]
     elif arch_choice == "lore":
         all_skills = list(
             set(utilities.valid_skills()) - set(char.race.skills) -
             set(self.skills))
         utilities.set_skills(self, 3, all_skills)
         arch['feature'] = [[2, "Cutting Words"],
                            [5, "Additional Magic Secrets"],
                            [13, "Peerless Skill"]]
     elif arch_choice == "satire":
         arch['proficiency'] = [[0, "Thieves' tools"]]
         arch['skill'] = [[0, "sleight of hand"]]
         all_skills = list(
             set(utilities.valid_skills()) - set(char.race.skills) -
             set(self.skills))
         utilities.set_skills(self, 1, all_skills)
         arch['feature'] = [[0, "Tumbling Fool"], [5, "Fool's Insight"],
                            [13, "Fool's Luck"]]
         arch['spells'] = [[[5, "two"], ["Detect Thoughts"]]]
     elif arch_choice == "sword":
         arch['proficiency'] = [[0, ["medium armor", "scimitar"]]]
         opts = ["dueling", "two weapon"]
         print(
             "College of Swords: Which fighting style do you want to join? They're listed below"
         )
         print("dueling")
         print("two weapon")
         style = input("")
         arch['feature'] = [[0, "Blade Flourish"], [5, "Extra Attack"],
                            [13, "Master's Flourish"]]
         flag = True
         while flag:
             if utilities.is_valid_input(style, opts):
                 if style == "dueling":
                     print("dueling\n\n")
                     arch['feature'].append([0, ["Dueling (Bard)"]])
                 else:
                     print("other archetype\n\n")
                     arch['feature'].append(
                         [0, ["Two-Weapon Fighting (Bard)"]])
                 flag = False
     elif arch_choice == "valor":
         arch['proficiency'] = [[0, ["medium armor"]], [0, ["shields"]],
                                [0, ["martial weapons"]]]
         arch['feature'] = [[0, "Combat Inspiration"], [5, "Extra Attack"],
                            [13, "Battle Magic"]]
     else:
         arch_choice = "whisper"
         arch['feature'] = [[0, ["Psychic Blades", "Words of Terror"]],
                            [5, ["Mantle of Whispers"]],
                            [13, ["Shadow Lore"]]]
     self.level_arch(arch)
コード例 #5
0
 def init_archetype(self, opts):
     """
     sets archetype string for character from options given
     :param opts: list of strings, options of archetypes to choose from
     :return: string of option chosen for the class to invoke the function that relates to that archetype
     """
     flag = True
     while flag:
         print(
             "\nWhich archetype do you want to join? Your choices are listed below\n"
         )
         for item in opts:
             print(item)
         choice = input("\n")
         if utilities.is_valid_input(choice,
                                     opts) or utilities.is_valid_input(
                                         choice.capitalize(), opts):
             self.archetype = choice.capitalize()
             return choice
         else:
             print(choice + " is not in the list below. Try again")
コード例 #6
0
 def set_expertise(self, char, amt):
     for i in range(0, int(amt)):
         flag = False
         while not flag:
             skills = set(char.race.skills).union(set(self.skills)) - set(
                 self.expert_skills)
             pot_skills = list(skills)
             print(
                 "Which skill do you want to double your proficiency bonus for?\n"
                 "Your known and valid skills are listed below")
             print("Choice: " + str(i + 1) + "/" + str(amt))
             for item in pot_skills:
                 print(item)
             ch = input("")
             if utilities.is_valid_input(ch, pot_skills):
                 self.expert_skills.append(ch)
                 flag = True
コード例 #7
0
ファイル: sorcerer.py プロジェクト: CMRicketts/dnd2.0
 def set_metamagic(self):
     flag = False
     opts = {
         "Careful Spell", "Distant Spell", "Empowered Spell",
         "Extended Spell", "Heightened Spell", "Quickened Spell",
         "Subtle Spell", "Twinned Spell"
     } - set(self.metamagic_features)
     print(
         "Metamagic: Which feature do you want? Your options are printed below"
     )
     for item in opts:
         print(item)
     while not flag:
         ch = input("")
         if utilities.is_valid_input(ch, opts):
             self.metamagic_features.append(ch)
             flag = True
         else:
             print(ch + " is an invalid input. Try again.")