How to use the dungeonsheets.character.Character function in dungeonsheets

To help you get started, we’ve selected a few dungeonsheets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github canismarko / dungeon-sheets / tests / test_stats.py View on Github external
def test_setter(self):
        """Verify that this class works as a data descriptor."""
        # Set up a dummy class
        class MyCharacter(character.Character):
            stat = stats.Ability()
        char = MyCharacter()
        # Check that the stat works as expected once set
        char.stat = 15
        self.assertEqual(char.stat.value, 15)
        self.assertEqual(char.stat.modifier, 2)
github canismarko / dungeon-sheets / tests / test_character.py View on Github external
def test_wield_shield(self):
        char = Character(dexterity=16)
        char.wield_shield('shield')
        self.assertTrue(isinstance(char.shield, Shield), msg=char.shield)
        # Now make sure the armor class is correct
        self.assertEqual(char.armor_class, 15)
        # Try passing an Armor object directly
        char.wield_shield(Shield)
        self.assertEqual(char.armor_class, 15)
github canismarko / dungeon-sheets / tests / test_character.py View on Github external
def test_speed(self):
        # Check that the speed pulls from the character's race
        char = Character(race='lightfoot halfling')
        self.assertEqual(char.speed, '25')
        # Check that a character with no race defaults to 30 feet
        char = Character()
        char.race = None
        self.assertEqual(char.speed, '30')
github canismarko / dungeon-sheets / tests / test_character.py View on Github external
def test_speed(self):
        # Check that the speed pulls from the character's race
        char = Character(race='lightfoot halfling')
        self.assertEqual(char.speed, '25')
        # Check that a character with no race defaults to 30 feet
        char = Character()
        char.race = None
        self.assertEqual(char.speed, '30')
github canismarko / dungeon-sheets / dungeonsheets / character.py View on Github external
char_props = {}
    for prop_name in dir(module):
        if prop_name[0:2] != '__':
            char_props[prop_name] = getattr(module, prop_name)
    return char_props


# Add backwards compatability for tests
class Artificer(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Artificer']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Barbarian(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Barbarian']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Bard(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Bard']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Cleric(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Cleric']
github canismarko / dungeon-sheets / dungeonsheets / character.py View on Github external
class Sorceror(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Sorceror']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Warlock(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Warlock']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Wizard(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Wizard']
        attrs['levels'] = [level]
        super().__init__(**attrs)
github canismarko / dungeon-sheets / dungeonsheets / character.py View on Github external
class Cleric(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Cleric']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Druid(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Druid']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Fighter(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Fighter']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Monk(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Monk']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Paladin(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Paladin']
github canismarko / dungeon-sheets / dungeonsheets / create_character.py View on Github external
def onStart(self):
        self.character = character.Character()
        self.character.class_list = []
        self.addForm("MAIN", BasicInfoForm, name="Basic Info:", formid='MAIN')
        self.addForm("RACE", RaceForm, name="Select your character's race:",
                     formid='RACE')
        self.addForm("CLASS1", CharacterClassForm, name="Select your character's primary class:",
                     formid='CLASS1')
        self.addForm("BACKGROUND", BackgroundForm, name="Choose background:",
                     formid='BACKGROUND')
        self.addForm("ALIGNMENT", AlignmentForm,
                     name="Select your character's alignment:",
                     formid='ALIGNMENT')
        self.addForm("ABILITIES", AbilityScoreForm,
                     name="Choose ability scores:", formid='ABILITIES')
        self.addForm("SKILLS", SkillForm, name="Choose skill proficiencies",
                     formid='SKILLS')
        self.addForm("WEAPONS", WeaponForm, name="Choose weapons",
github canismarko / dungeon-sheets / dungeonsheets / character.py View on Github external
def load(cls, character_file):
        # Create a character from the character definition
        char_props = read_character_file(character_file)
        classes = char_props.get('classes', [])
        # backwards compatability
        if (len(classes) == 0) and ('character_class' in char_props):
            char_props['classes'] = [char_props.pop('character_class').lower().capitalize()]
            char_props['levels'] = [str(char_props.pop('level'))]
        # Create the character with loaded properties
        char = Character(**char_props)
        return char
github canismarko / dungeon-sheets / dungeonsheets / character.py View on Github external
# Add backwards compatability for tests
class Artificer(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Artificer']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Barbarian(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Barbarian']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Bard(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Bard']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Cleric(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Cleric']
        attrs['levels'] = [level]
        super().__init__(**attrs)


class Druid(Character):
    def __init__(self, level=1, **attrs):
        attrs['classes'] = ['Druid']