def test_resolve_hit():
    test_attack = AttackBuilder(d(10))\
        .prof(3)\
        .amod(3)\
        .adv()\
        .gwm()\
        .attbon(3)\
        .dmgbon(2)\
        .build()
    assert 0.6525 == test_attack.resolve_hit(15)
def test_resolve_turn_attacks():
    damage = TurnBuilder()\
        .attack(AttackBuilder(d(10))
                .prof(3)
                .amod(3)
                .adv()
                .gwm()
                .attbon(3)
                .dmgbon(2), times=2)\
        .attack(AttackBuilder(d(4))
                .prof(3)
                .amod(3)
                .adv()
                .gwm()
                .attbon(3)
                .dmgbon(2))\
        .dmgroll(d(2, 8))\
        .resolve(15)
    damage_stats = damage.stats()
    assert 52.81875000000001 == damage_stats.mean
def test_resolve_attack():
    assert 0.04861111111111111 == AttackBuilder(d(6)).resolve(15).p(6)
def test_resolve_crit_attack():
    assert 1.0000000000000002 == AttackBuilder(d(1))\
        .attbon(-20)\
        .crit(0)\
        .resolve(0)\
        .p(2)
def test_radd():
    assert (1 + d(3)).p(3) == (d(3) + 1).p(3)
def test_lucky_hit():
    test_attack = AttackBuilder(d(1)).adv().lucky().build()
    hit_outcome = test_attack.resolve_hit(15)
    assert 0.10212500000000002 == hit_outcome.p(HitOutcome.CRITICAL_HIT)
def test_scale_probability():
    test_scale = d(5).scale_probability(0.5)
    assert 0.1 == test_scale.p(2)
def test_if():
    if_pmf = pmf.if_(d(5) == 1, d(1), d(1) + d(1))
    assert 0.2 == if_pmf.p(1)
    assert 0.8 == if_pmf.p(2)
def test_union_int():
    test_union = d(2).union(d(2) + d(1))
    assert 1.0 == test_union.p(2)
Exemple #10
0
def test_equal():
    assert 0.25 == (d(4) == d(4)).p(True)
Exemple #11
0
def test_joint_pmf():
    test_joint = pmf.joint([d(2), d(4)])
    assert 0.125 == test_joint.p((1, 2))
Exemple #12
0
def test_greater_or_equal_than():
    assert 0.08000000000000002 == d(5).ge(3).p(2)
    assert 0.27999999999999997 == d(5).ge(3).p(3)
Exemple #13
0
def test_advantage():
    assert 0.28 == d(5).adv().p(4)