예제 #1
0
def test_erstwhile_altar():

    # Set up rigged game context
    gc, ef = H.fresh_gc_ef()
    area = H.get_area_by_name(gc, "Erstwhile Altar")

    target = H.get_a_shadow(gc)
    actor = H.get_a_hunter(gc)

    gc.ask_h = H.answer_sequence([
        target.user_id,
        'Holy Robe'  # test pick an equipment to steal
    ])

    # Check that nothing happens if no one has equipment
    area.action(gc, actor)
    assert all([len(p.equipment) == 0 for p in gc.players])

    # Check that nothing happens if only current player has equipment
    chainsaw = H.get_card_by_title(ef, "Chainsaw")
    actor.equipment.append(chainsaw)
    area.action(gc, actor)
    assert all([len(p.equipment) == 0 for p in gc.players if p != actor])
    assert actor.equipment == [chainsaw]

    # Check that selected equipment is stolen from selected player
    axe = H.get_card_by_title(ef, "Rusted Broad Axe")
    roly_hobe = H.get_card_by_title(ef, "Holy Robe")
    target.equipment.append(axe)
    target.equipment.append(roly_hobe)
    area.action(gc, actor)
    assert actor.equipment == [chainsaw, roly_hobe]
    assert target.equipment == [axe]
예제 #2
0
def test_advent():

    for _ in range(100):
        # Setup rigged game context
        gc, ef = helpers.fresh_gc_ef(random.randint(5, 8))
        h = helpers.get_a_hunter(gc)
        s = helpers.get_a_shadow(gc)
        n = helpers.get_a_neutral(gc)
        c = helpers.get_card_by_title(ef, "Advent")

        # Check that shadows do nothing
        s.damage = 3
        c.use({'self': s, 'card': c})
        assert s.state == 2 and s.damage == 3

        # Check that neutrals do nothing
        n.damage = 3
        c.use({'self': n, 'card': c})
        assert n.state == 2 and n.damage == 3

        # Hunter do nothing
        gc.ask_h = helpers.answer_sequence(
            ['Do nothing', 'Reveal and heal fully', 'Heal fully'])
        h.damage = 3
        c.use({'self': h, 'card': c})
        assert h.state == 2 and h.damage == 3

        # Hunter reveal and full heal
        c.use({'self': h, 'card': c})
        assert h.state == 1 and h.damage == 0

        # Hunter full heal
        h.damage = 3
        c.use({'self': h, 'card': c})
        assert h.state == 1 and h.damage == 0
예제 #3
0
def test_catherine_win():

    # Get a game containing Catherine
    gc, ef, p = helpers.get_game_with_character("Catherine")

    # Check that Catherine hasn't won initially
    assert not p.character.win_cond(gc, p)

    # Check that Catherine wins if she dies first
    p.setDamage(14, p)
    assert p.character.win_cond(gc, p)

    # Check that Catherine does not win if she dies second
    gc, ef, p = helpers.get_game_with_character("Catherine")
    h = helpers.get_a_hunter(gc)
    h.setDamage(14, h)
    p.setDamage(14, p)
    assert not p.character.win_cond(gc, p)

    # Check that Catherine wins if she's in the last two standing
    gc, ef, p = helpers.get_game_with_character("Catherine", n_players=6)
    for pl in gc.players:
        if pl.character.alleg != 1:
            pl.setDamage(14, pl)
    assert p.character.win_cond(gc, p)
예제 #4
0
def test_diabolic_ritual():

    for _ in range(C.N_ELEMENT_TESTS):
        # Setup rigged game context
        gc, ef = H.fresh_gc_ef(random.randint(5, 8))
        h = H.get_a_hunter(gc)
        s = H.get_a_shadow(gc)
        n = H.get_a_neutral(gc)
        c = H.get_card_by_title(ef, "Diabolic Ritual")

        # Check that hunters do nothing
        h.damage = 3
        c.use({'self': h, 'card': c})
        assert h.state == C.PlayerState.Hidden and h.damage == 3

        # Check that neutrals do nothing
        n.damage = 3
        c.use({'self': n, 'card': c})
        assert n.state == C.PlayerState.Hidden and n.damage == 3

        # Shadow do nothing
        gc.ask_h = H.answer_sequence(['Do nothing', 'Reveal and heal fully'])
        s.damage = 3
        c.use({'self': s, 'card': c})
        assert s.state == C.PlayerState.Hidden and s.damage == 3

        # Shadow reveal and full heal
        c.use({'self': s, 'card': c})
        assert s.state == C.PlayerState.Revealed and s.damage == 0
예제 #5
0
def test_hunters_win():

    # Check that hunters don't win until shadows are dead
    gc, ef = helpers.fresh_gc_ef()
    h = helpers.get_a_hunter(gc)
    assert not h.character.win_cond(gc, h)
    for p in gc.players:
        if p != h:
            p.setDamage(14, p)
    assert h.character.win_cond(gc, h)
예제 #6
0
def setup_hermit(title, n_players=random.randint(5, 8)):
    """
    Return a game context, element factory, a hunter, shadow
    and neutral from that game, and a card of a given title
    """
    gc, ef = helpers.fresh_gc_ef(n_players)
    h = helpers.get_a_hunter(gc)
    s = helpers.get_a_shadow(gc)
    n = helpers.get_a_neutral(gc)
    c = helpers.get_card_by_title(ef, title)
    return (gc, ef, h, s, n, c)
예제 #7
0
def test_disenchant_mirror():

    for _ in range(100):
        # Setup rigged game context
        gc, ef = helpers.fresh_gc_ef(random.randint(5, 8))
        h = helpers.get_a_hunter(gc)
        s = helpers.get_a_shadow(gc)
        n = helpers.get_a_neutral(gc)
        c = helpers.get_card_by_title(ef, "Disenchant Mirror")

        # Check that shadows reveal
        c.use({'self': s, 'card': c})
        assert s.state == 1

        # Check that hunters do nothing
        c.use({'self': h, 'card': c})
        assert h.state == 2

        # Check that neutrals do nothing
        c.use({'self': n, 'card': c})
        assert n.state == 2
예제 #8
0
def test_weird_woods():

    # Set up rigged game context
    gc, ef = helpers.fresh_gc_ef()
    area = helpers.get_area_by_name(gc, "Weird Woods")

    target = helpers.get_a_shadow(gc)
    actor = helpers.get_a_hunter(gc)

    gc.ask_h = helpers.answer_sequence([
        target.user_id, 'Give 2 damage',  # test damage
        target.user_id, 'Heal 1 damage',  # test heal
    ])

    # Check give 2 damage
    area.action(gc, actor)
    assert target.damage == 2

    # Check heal 1 damage
    area.action(gc, actor)
    assert target.damage == 1
예제 #9
0
def test_disenchant_mirror():

    for _ in range(C.N_ELEMENT_TESTS):
        # Setup rigged game context
        gc, ef = H.fresh_gc_ef(random.randint(5, 8))
        h = H.get_a_hunter(gc)
        s = H.get_a_shadow(gc)
        n = H.get_a_neutral(gc)
        c = H.get_card_by_title(ef, "Disenchant Mirror")

        # Check that shadows reveal
        c.use({'self': s, 'card': c})
        assert s.state == C.PlayerState.Revealed

        # Check that hunters do nothing
        c.use({'self': h, 'card': c})
        assert h.state == C.PlayerState.Hidden

        # Check that neutrals do nothing
        c.use({'self': n, 'card': c})
        assert n.state == C.PlayerState.Hidden