Exemple #1
0
    def _transform_attack(attack) -> Attack:
        desc = html_to_md(attack['desc'])

        if attack['saveDc'] is not None and attack['saveStat'] is not None:
            stat = constants.STAT_ABBREVIATIONS[attack['saveStat'] - 1]
            for_half = desc and 'half' in desc

            the_attack = automation.Save(stat,
                                         fail=[automation.Damage("{damage}")],
                                         success=[] if not for_half else
                                         [automation.Damage("{damage}/2")],
                                         dc=str(attack['saveDc']))

            # attack, then save
            if attack['toHit'] is not None:
                the_attack = automation.Attack(hit=[the_attack],
                                               attackBonus=str(
                                                   attack['toHit']),
                                               miss=[])

            # target and damage meta
            target = automation.Target('each', [the_attack])
            damage_roll = automation.Roll(attack['damage'] or '0', 'damage')
            effects = [damage_roll, target]
            # description text
            if desc:
                effects.append(automation.Text(desc))

            return Attack(attack['name'], automation.Automation(effects))
        else:
            return Attack.new(attack['name'], attack['toHit'], attack['damage']
                              or '0', desc)
Exemple #2
0
async def test_save_strs(dc):
    save = automation.Save(stat='str', fail=[], success=[], dc=dc)
    result = save.build_str(DEFAULT_CASTER, DEFAULT_EVALUATOR)
    log.info(f"Save str: ({dc=!r}) -> {result}")
    assert result
Exemple #3
0
def test_save_strs(dc):
    save = automation.Save(stat='str', fail=[], success=[], dc=dc)
    assert save.build_str(DEFAULT_CASTER, DEFAULT_EVALUATOR)