Ejemplo n.º 1
0
def test_dice():
    """The dice() function returns the summarised data from the rolls."""
    with pytest.raises(ValueError):
        opend6.dice(0)
    # One die is a wild die.
    assert opend6.dice(1).is_same(opend6.wild_die)
    # Two dice is wild + regular, and we need to test that addition is correct.
    expected = DRV.weighted_average((
        (DRV({0: 1}), Fraction(1, 6)),
        (d6 + d6.explode().given(lambda x: x != 1), Fraction(5, 6)),
    ))
    _check(
        opend6.dice(2),
        expected,
        single=False,
        totals=d6 + d6.explode(),
        highest=pool(d6, d6).apply(max),
    )
Ejemplo n.º 2
0
def test_more_dice_char(reg, char):
    """Test the char parameter with higher numbers of dice"""
    pips = 2
    expected = opend6.wild_die + pips
    if reg > 0:
        expected += reg @ opend6.regular_die
    if char > 0:
        expected += char @ opend6.character_die
    assert opend6.dice(reg + 1, char=char, pips=pips).is_same(expected)
Ejemplo n.º 3
0
def test_more_dice(reg):
    """
    Test with higher numbers of dice. Three dice is wild + 2 @ regular, etc.
    """
    def remove_highest(values):
        return sum(values) - max(values)

    expected = DRV.weighted_average((
        (pool(d6, count=reg).apply(remove_highest), Fraction(1, 6)),
        (reg @ d6 + d6.explode().given(lambda x: x != 1), Fraction(5, 6)),
    ))
    _check(
        opend6.dice(reg + 1),
        expected,
        single=False,
        totals=reg @ d6 + d6.explode(),
        highest=pool(d6, count=reg + 1).apply(max),
    )
Ejemplo n.º 4
0
def test_dice_char():
    """The char parameter adds dice bought with Character Points"""

    # I don't think the rules explicity say what happens on a botch, if an
    # exploded character die is the highest score rolled. I'm going to assume
    # that the botch cancels the 6.
    def cancel(value):
        return max(value - 6, 0)

    expected = DRV.weighted_average((
        (d6.explode().apply(cancel), Fraction(1, 6)),
        (d6.explode() + d6.explode().given(lambda x: x != 1), Fraction(5, 6)),
    ))
    _check(
        opend6.dice(1, char=1),
        expected,
        single=False,
        totals=2 @ d6.explode(),
        highest=pool(d6, d6).apply(max),
    )
Ejemplo n.º 5
0
def test_total(dice):
    """The total() function just gives you the overall score"""
    assert opend6.total(dice).is_same(opend6.dice(dice).apply(int))