예제 #1
0
def test_soft_requirements():
    attributes = Attributes()
    fighter = classes.fighter
    attributes.strength = 13
    assert fighter.requirements.possible(attributes)
    attributes.strength = 0
    assert not fighter.requirements.possible(attributes)
    attributes.dexterity = 13
    assert fighter.requirements.possible(attributes)
예제 #2
0
def test_character_skill_roll():
    character = (Character.builder().attributes(
        Attributes(16, 20, 16, 4, 8, 12)).race(races.goliath).classes([
            classes.barbarian(level=12)
        ]).proficiencies([Skill.athletics, Skill.intimidation,
                          Skill.nature]).hitpoints(HitPoints(100)).build())
    proficiency = Level(12).proficiency
    mod = character.modifiers
    for _ in range(100):
        assert (1 + mod.strength + proficiency <= character.roll(
            Skill.athletics) <= 20 + mod.strength + proficiency)
        assert 1 + mod.wisdom <= character.roll(
            Skill.insight) <= 20 + mod.wisdom
        assert (1 + mod.intelligence + proficiency <= character.roll(
            Skill.nature) <= 20 + mod.intelligence + proficiency)
예제 #3
0
def test_character_builder_designer():
    character = (
        Character.builder()
        .attributes(Attributes(13, 13, 13, 13, 13, 13))
        .race(races.human)
        .classes([classes.rogue(level=3), classes.fighter(level=7)])
        .proficiencies([])
        .hitpoints(HitPoints(100))
        .build()
    )
    with pytest.raises(AttributeError, match="object has no attribute 'build'"):
        Character.builder().build()
    assert character.attributes.strength == 14
    assert character.modifiers.strength == 2
    assert character.race == races.human
    assert character.level == Level(10)
    assert classes.rogue(level=6) not in character.classes
    assert classes.rogue(level=3) in character.classes
    assert classes.fighter(level=7) in character.classes
    assert classes.paladin(level=7) not in character.classes
    assert classes.fighter(level=6) not in character.classes
예제 #4
0
def test_addition():
    a1 = Attributes()
    a2 = Attributes(strength=1)
    assert 1 == (a1 + a2).strength
예제 #5
0
def test_simple_hard_requirements():
    attributes = Attributes()
    clss = classes.barbarian
    assert not clss.requirements.possible(attributes)
    attributes.strength = 13
    assert clss.requirements.possible(attributes)
예제 #6
0
def test_wizard_ranger():
    attributes = Attributes(12, 16, 15, 12, 14, 12)
    assert not classes.wizard.requirements.possible(attributes)
    assert classes.ranger.requirements.possible(attributes)
예제 #7
0
def test_level_one_hitpoints():
    modifiers = Attributes.random().modifiers()
    for clss in classes.all_classes:
        assert HitPoints(modifiers.constitution +
                         clss.hit_die) == HitPoints.random([clss], modifiers)
예제 #8
0
def test_multiclassing_hitpoints():
    modifiers = Attributes.random(5, 2).modifiers()
    multi_class = [classes.paladin(level=10), classes.sorcerer(level=6)]
    min_hp = HitPoints.min(multi_class, modifiers)
    max_hp = HitPoints.max(multi_class, modifiers)
    assert min_hp <= HitPoints.random(multi_class, modifiers) <= max_hp
예제 #9
0
def test_random_level_hitpoints():
    modifiers = Attributes.random().modifiers()
    for clss in classes.all_classes:
        clss.level = random.randint(1, 20)
        assert (HitPoints.min([clss], modifiers) <= HitPoints.random(
            [clss], modifiers) <= HitPoints.max([clss], modifiers))