コード例 #1
0
 def calc_hp_first_lvl(self):
     """"
         Updates hit points of character for first level, based on hit die of class and constitution
         modifier. Does not take into account other bonuses.
     """
     self.hit_points = self.dnd_class.hit_dice + get_modifier(
         self.attributes["Constitution"])
コード例 #2
0
    def __init__(self, name: str, gen_type: int, stats=None):
        """
        Initializes the character
            @:param name: a string to be the name of the character
            @:param gen_type: an int to describe the type of generation wanted
                1: 4d6 drop lowest
                2: 3d6
                3: 3d6 re-roll lower than 7 (8?)
                4: pick all 6
                5: re-roll if not 3 < bonus < 7 (cf utilities.py generate_abilities)
            @:param stats: an array of stats, only there when gen_type is 4
            Computes derived attributes such as Base Saving Throws
        """
        super().__init__()

        self.name = name
        self.attributes = generate_attributes(gen_type, stats)
        self.race = None
        self.dnd_class = None
        self.background = None
        self.size = 'Medium'
        self.speed = {"walking": 30}
        self.saving_throws = {
            "Strength": get_modifier(self.attributes["Strength"]),
            "Dexterity": get_modifier(self.attributes["Dexterity"]),
            "Constitution": get_modifier(self.attributes["Constitution"]),
            "Intelligence": get_modifier(self.attributes["Intelligence"]),
            "Wisdom": get_modifier(self.attributes["Wisdom"]),
            "Charisma": get_modifier(self.attributes["Charisma"]),
        }
        self.proficient_saving_throws = []
        self.languages = {"Common"}
        self.skill_proficiencies = set([])
        self.tool_proficiencies = set([])
        self.armor_proficiencies = set([])
        self.weapon_proficiencies = set([])
        self.age = 0
        self.vision = []
        # starting proficiency bonus is always 2
        self.proficiency_bonus = 2
        self.alignment = ""
        self.cantrips = set([])
        self.spells = set([])
        self.prepared_spell_number = 0
        self.level_one_slots = 0
        self.level_two_slots = 0
        self.level_three_slots = 0
        self.level_four_slots = 0
        self.level_five_slots = 0
        self.level_six_slots = 0
        self.personality_traits = []
        self.ideals = []
        self.bonds = []
        self.flaws = []
        self.equipment = []
        self.features = []
        self.hit_points = 0
        self.level = 1
コード例 #3
0
 def update_saving_throws(self):
     self.saving_throws = {
         "Strength": get_modifier(self.attributes["Strength"]),
         "Dexterity": get_modifier(self.attributes["Dexterity"]),
         "Constitution": get_modifier(self.attributes["Constitution"]),
         "Intelligence": get_modifier(self.attributes["Intelligence"]),
         "Wisdom": get_modifier(self.attributes["Wisdom"]),
         "Charisma": get_modifier(self.attributes["Charisma"]),
     }
コード例 #4
0
    def __init__(self, name, gen_type, stats=None):
        super().__init__()

        self.name = name
        self.attributes = generate_attributes(gen_type, stats)
        self.race = None
        self.dnd_class = None
        self.background = None
        self.size = 'Medium'
        self.speed = {
            "walking": 30
        }
        self.saving_throws = {
            "Strength": get_modifier(self.attributes["Strength"]),
            "Dexterity": get_modifier(self.attributes["Dexterity"]),
            "Constitution": get_modifier(self.attributes["Constitution"]),
            "Intelligence": get_modifier(self.attributes["Intelligence"]),
            "Wisdom": get_modifier(self.attributes["Wisdom"]),
            "Charisma": get_modifier(self.attributes["Charisma"]),
        }
        self.proficient_saving_throws = []
        self.languages = {"Common"}
        self.skill_proficiencies = set([])
        self.tool_proficiencies = set([])
        self.armor_proficiencies = set([])
        self.weapon_proficiencies = set([])
        self.age = 0
        self.vision = []
        # starting proficiency bonus is always 2
        self.proficiency_bonus = 2
        self.alignment = ""
        self.cantrips = set([])
        self.spells = set([])
        self.prepared_spell_number = 0
        self.level_one_slots = 0
        self.level_two_slots = 0
        self.level_three_slots = 0
        self.level_four_slots = 0
        self.level_five_slots = 0
        self.level_six_slots = 0
        self.personality_traits = []
        self.ideals = []
        self.bonds = []
        self.flaws = []
        self.equipment = []
        self.features = []
        self.hit_points = 0
        self.level = 1
コード例 #5
0
def cli_display(character):
    """Displays the character chosen in stdout through prints"""
    print("Name: " + character.name)
    print("Hit Points: " + str(character.hit_points))
    print("Race: " + character.race.name)
    print("Class: " + character.dnd_class.name)
    print("Background: " + character.background)
    print("Alignment: " + character.alignment)
    print("Size: " + character.size)
    print("Age: " + str(character.age))
    print("Vision: " + ", ".join(character.vision))

    # Todo: change this into a function for attributes str result (like saving throws)
    print("Attributes:\n\tStrength: " + str(character.attributes["Strength"]) +
          "(" + str(get_modifier(character.attributes["Strength"])) + ")" +
          "\n\tDexterity: " + str(character.attributes["Dexterity"]) + "(" +
          str(get_modifier(character.attributes["Dexterity"])) + ")" +
          "\n\tConstitution: " + str(character.attributes["Constitution"]) +
          "(" + str(get_modifier(character.attributes["Constitution"])) + ")" +
          "\n\tIntelligence: " + str(character.attributes["Intelligence"]) +
          "(" + str(get_modifier(character.attributes["Intelligence"])) + ")" +
          "\n\tWisdom: " + str(character.attributes["Wisdom"]) + "(" +
          str(get_modifier(character.attributes["Wisdom"])) + ")" +
          "\n\tCharisma: " + str(character.attributes["Charisma"]) + "(" +
          str(get_modifier(character.attributes["Charisma"])) + ")")

    print("Saving Throws: " + character.saving_throws_to_str())
    print("Saving Throws Proficiencies: " +
          ", ".join(character.proficient_saving_throws))
    language_string = "Languages: " + ", ".join(character.languages)
    print(language_string)
    skill_proficiency_string = "Skill proficiencies: " + ", ".join(
        character.skill_proficiencies)
    print(skill_proficiency_string)
    if len(character.tool_proficiencies) > 0:
        tool_proficiency_string = "Tool proficiencies: " + ", ".join(
            character.tool_proficiencies)
        print(tool_proficiency_string)
    if len(character.armor_proficiencies) > 0:
        armor_proficiency_string = "Armor proficiencies: " + ", ".join(
            character.armor_proficiencies)
        print(armor_proficiency_string)
    if len(character.weapon_proficiencies) > 0:
        weapon_proficiency_string = "Weapon proficiencies: " + ", ".join(
            character.weapon_proficiencies)
        print(weapon_proficiency_string)
    print(character.race.racial_traits_to_string())
    if len(character.cantrips) > 0:
        print("Known Cantrips: ")
        known_cantrips = "\t" + ", ".join(character.cantrips)
        print(known_cantrips)
    if len(character.spells) > 0:
        print("Known Spells: ")
        known_spells = "\t" + ", ".join(character.spells)
        print(known_spells)

    print("Class Features: ")
    print(character.dnd_class.class_features_to_string())

    print("Personality traits: " + ", ".join(character.personality_traits))
    print("Bonds: " + ", ".join(character.bonds))
    print("Flaws: " + ", ".join(character.flaws))
    print("Ideals: " + ", ".join(character.ideals))
    print("Equipment:")
    print(character.equipment_to_string())