Exemplo n.º 1
0
def test_class_feature_levels():
    true_class_feature_levels = util.import_yaml_file('content/class_feature_levels.yaml')
    class_features = util.import_yaml_file('content/class_features.yaml')
    for class_feature_name in class_features:
        print(class_feature_name)
        class_feature = AbilityLeveler(class_feature_name, class_features[class_feature_name])
        assert_equal(class_feature.level('class feature'), true_class_feature_levels[class_feature_name])
Exemplo n.º 2
0
    def from_sample_creature(cls, sample_name, **kwargs):
        if cls.sample_creatures is None:
            cls.sample_creatures = util.import_yaml_file('content/sample_creatures.yaml')
            # also add monsters, which are stored separately
            cls.sample_creatures.update(util.import_yaml_file('content/monsters.yaml'))

        try:
            sample_properties = cls.sample_creatures[sample_name].copy()
        except KeyError:
            raise Exception(
                "Error: Unable to recognize sample creature '{0}'".format(
                    sample_name
                )
            )

        # enforce underscores instead of spaces
        for key in sample_properties:
            python_key = key.replace(' ', '_')
            if key != python_key:
                sample_properties[python_key] = sample_properties.pop(key)

        for key, value in kwargs.items():
            if value is not None:
                sample_properties[key] = value

        # use a monster leveler to automatically determine level
        if sample_properties.get('level') is None:
            leveler = MonsterLeveler.from_monster_name(sample_name)
            sample_properties['level'] = int(round(leveler.level()))

        return cls(
            name=sample_name,
            properties=sample_properties
        )
Exemplo n.º 3
0
    def from_sample_creature(cls, sample_name, **kwargs):
        if cls.sample_creatures is None:
            cls.sample_creatures = util.import_yaml_file(
                'content/sample_creatures.yaml')
            # also add monsters, which are stored separately
            cls.sample_creatures.update(
                util.import_yaml_file('content/monsters.yaml'))

        try:
            sample_properties = cls.sample_creatures[sample_name].copy()
        except KeyError:
            raise Exception(
                "Error: Unable to recognize sample creature '{0}'".format(
                    sample_name))

        # enforce underscores instead of spaces
        for key in sample_properties:
            python_key = key.replace(' ', '_')
            if key != python_key:
                sample_properties[python_key] = sample_properties.pop(key)

        for key, value in kwargs.items():
            if value is not None:
                sample_properties[key] = value

        # use a monster leveler to automatically determine level
        if sample_properties.get('level') is None:
            leveler = MonsterLeveler.from_monster_name(sample_name)
            sample_properties['level'] = int(round(leveler.level()))

        return cls(name=sample_name, properties=sample_properties)
Exemplo n.º 4
0
def test_spell_levels():
    true_spell_levels = util.import_yaml_file('content/spell_levels.yaml')
    spells = util.import_yaml_file('content/spells.yaml')
    for spell_name in spells:
        print(spell_name)
        spell = AbilityLeveler(spell_name, spells[spell_name])
        assert_equal(spell.level('spell'), true_spell_levels[spell_name])
Exemplo n.º 5
0
def test_monster_levels():
    true_monster_levels = util.import_yaml_file('content/monster_levels.yaml')
    monsters = util.import_yaml_file('content/monsters.yaml')
    for monster_name in sorted(monsters.keys()):
        print(monster_name)
        monster = MonsterLeveler(monster_name, monsters[monster_name])
        assert_equal(monster.level(), true_monster_levels[monster_name])
Exemplo n.º 6
0
def test_spell_levels():
    true_spell_levels = util.import_yaml_file('content/spell_levels.yaml')
    spells = util.import_yaml_file('content/spells.yaml')
    for spell_name in spells:
        print(spell_name)
        spell = AbilityLeveler(spell_name, spells[spell_name])
        assert_equal(spell.level('spell'), true_spell_levels[spell_name])
Exemplo n.º 7
0
def test_class_feature_levels():
    true_class_feature_levels = util.import_yaml_file(
        'content/class_feature_levels.yaml')
    class_features = util.import_yaml_file('content/class_features.yaml')
    for class_feature_name in class_features:
        print(class_feature_name)
        class_feature = AbilityLeveler(class_feature_name,
                                       class_features[class_feature_name])
        assert_equal(class_feature.level('class feature'),
                     true_class_feature_levels[class_feature_name])
Exemplo n.º 8
0
def main(args):
    data = util.import_yaml_file('content/monsters.yaml')
    monster_levels = calculate_monster_levels(data)
    for monster_name in sorted(monster_levels.keys()):
        print("{}: {}".format(
            monster_name,
            monster_levels[monster_name]
        ))
Exemplo n.º 9
0
def main(args):
    if args['items']:
        abilities = util.import_yaml_file('content/magic_items.yaml')
        ability_type = 'magic item'
    elif args['rituals']:
        abilities = util.import_yaml_file('content/rituals.yaml')
        ability_type = 'spell'
    elif args['spells']:
        abilities = util.import_yaml_file('content/spells.yaml')
        ability_type = 'spell'
    elif args['class']:
        abilities = util.import_yaml_file('content/class_features.yaml')
        ability_type = 'class feature'
    else:
        raise Exception("I don't know what ability data to use")

    ability_levels = calculate_ability_levels(abilities, ability_type)
    for ability_name in sorted(ability_levels.keys()):
        print("{}: {}".format(ability_name, ability_levels[ability_name]))
Exemplo n.º 10
0
def main(args):
    if args['items']:
        abilities = util.import_yaml_file('content/magic_items.yaml')
        ability_type = 'magic item'
    elif args['rituals']:
        abilities = util.import_yaml_file('content/rituals.yaml')
        ability_type = 'spell'
    elif args['spells']:
        abilities = util.import_yaml_file('content/spells.yaml')
        ability_type = 'spell'
    elif args['class']:
        abilities = util.import_yaml_file('content/class_features.yaml')
        ability_type = 'class feature'
    else:
        raise Exception("I don't know what ability data to use")

    ability_levels = calculate_ability_levels(abilities, ability_type)
    for ability_name in sorted(ability_levels.keys()):
        print("{}: {}".format(
            ability_name,
            ability_levels[ability_name]
        ))
Exemplo n.º 11
0
 def from_monster_name(cls, name):
     """Generate a leveler from only the name of a monster"""
     if cls.monsters is None:
         cls.monsters = util.import_yaml_file('content/monsters.yaml')
     return cls(name, cls.monsters[name])
Exemplo n.º 12
0
def main(args):
    data = util.import_yaml_file('content/monsters.yaml')
    monster_levels = calculate_monster_levels(data)
    for monster_name in sorted(monster_levels.keys()):
        print("{}: {}".format(monster_name, monster_levels[monster_name]))
Exemplo n.º 13
0
from docopt import docopt
from rise_gen.ability import Ability
from rise_gen.leveler import Leveler
import rise_gen.util as util

doc = """
Usage:
    monster_leveler [options]

Options:
    -h, --help      Show this screen and exit
    -v, --verbose   Show more output
"""

RAW_MODIFIERS = util.import_yaml_file('content/monster_modifiers.yaml')


class MonsterLeveler(Leveler):

    monsters = None

    def _attributes_modifier(self):
        """We don't care about the names - just the values"""
        modifier = 0
        for name in self.attributes:
            attribute_value = self.attributes[name]
            if isinstance(attribute_value, str):
                modifier += RAW_MODIFIERS['attributes'][attribute_value]
            elif isinstance(attribute_value, int):
                pass
Exemplo n.º 14
0
doc = """
Usage:
    ability_leveler class [options]
    ability_leveler items [options]
    ability_leveler rituals [options]
    ability_leveler spells [options]
    ability_leveler (-h | --help)

Options:
    -a, --ability <ability>  Only show information for the given ability
    -h, --help               Show this screen and exit
    -v, --verbose            Show more output
"""

RAW_MODIFIERS = util.import_yaml_file('content/ability_modifiers.yaml')


def is_close(x, y, threshold=1):
    """Test whether x is within <threshold> of y

    Args:
        x (int)
        y (int)
        threshold (int)

    Yields:
        bool
    """
    return abs(x - y) <= threshold
Exemplo n.º 15
0
doc = """
Usage:
    ability_leveler class [options]
    ability_leveler items [options]
    ability_leveler rituals [options]
    ability_leveler spells [options]
    ability_leveler (-h | --help)

Options:
    -a, --ability <ability>  Only show information for the given ability
    -h, --help               Show this screen and exit
    -v, --verbose            Show more output
"""

RAW_MODIFIERS = util.import_yaml_file('content/ability_modifiers.yaml')

def is_close(x, y, threshold=1):
    """Test whether x is within <threshold> of y

    Args:
        x (int)
        y (int)
        threshold (int)

    Yields:
        bool
    """
    return abs(x - y) <= threshold

Exemplo n.º 16
0
 def from_monster_name(cls, name):
     """Generate a leveler from only the name of a monster"""
     if cls.monsters is None:
         cls.monsters = util.import_yaml_file('content/monsters.yaml')
     return cls(name, cls.monsters[name])
Exemplo n.º 17
0
from docopt import docopt
from rise_gen.ability import Ability
from rise_gen.leveler import Leveler
import rise_gen.util as util

doc = """
Usage:
    monster_leveler [options]

Options:
    -h, --help      Show this screen and exit
    -v, --verbose   Show more output
"""

RAW_MODIFIERS = util.import_yaml_file('content/monster_modifiers.yaml')

class MonsterLeveler(Leveler):

    monsters = None

    def _attributes_modifier(self):
        """We don't care about the names - just the values"""
        modifier = 0
        for name in self.attributes:
            attribute_value = self.attributes[name]
            if isinstance(attribute_value, str):
                modifier += RAW_MODIFIERS['attributes'][attribute_value]
            elif isinstance(attribute_value, int):
                pass
            elif attribute_value is None: