Beispiel #1
0
def test_add_inv_item__new_slot__partial_stack__last_letter_unoccupied(vials5):
    pi = PlayerInventory(10)
    vials5.add_comp(letter=LetterComponent('z'))
    pi.add_inv_item(vials5, 2)
    result = pi.item_dict['z']
    assert result.name == "healing vial"
    assert result.stackable.size == 2
Beispiel #2
0
def test_add_inv_item__new_slot__full_stack__last_letter_occupied(
        dagger, vials5):
    pi = PlayerInventory(10)
    vials5.add_comp(letter=LetterComponent('a'))
    pi.add_inv_item(dagger)
    pi.add_inv_item(vials5)
    assert pi.item_dict['a'] == dagger
    assert pi.item_dict['b'] == vials5  # rolls to next available letter
Beispiel #3
0
def test_rm_inv_item__stackable__removed_partial_stack__letter_remains(vials5):
    pi = PlayerInventory(10)
    pi.add_inv_item(vials5)
    pi.rm_inv_item(vials5, 2)
    assert not pi.is_empty()
    assert vials5 in pi.entities
    assert "a" in pi.item_dict
Beispiel #4
0
def test_add_inv_item__new_slot__nonstackable__last_letter_occupied(
        dagger, plunger):
    pi = PlayerInventory(10)
    plunger.add_comp(letter=LetterComponent('a'))
    pi.add_inv_item(dagger)
    pi.add_inv_item(plunger)
    assert pi.item_dict['a'] == dagger
    assert pi.item_dict['b'] == plunger  # rolls to next available letter
Beispiel #5
0
def test_add_inv_item__new_slot__partial_stack__last_letter_occupied(
        dagger, vials5):
    pi = PlayerInventory(10)
    vials5.add_comp(letter=LetterComponent('a'))
    pi.add_inv_item(dagger)
    pi.add_inv_item(vials5, 2)
    result = pi.item_dict['b']  # rolls to next available letter
    assert result.name == "healing vial"
    assert result.stackable.size == 2
Beispiel #6
0
    def __init__(self):
        super().__init__(
            name="player",
            player=True,  # Let's us work with the player component around the game.
            char="@",
            color=(255, 255, 255),
            ai=None,
            equipment=Equipment(),
            fighter=Fighter(max_hp=30, base_ac=10),
            offense=OffenseComponent(Attack('punch', [2])),
            attributes=Attributes(base_strength=5),

            # Original inventory capacity is 267 because we have 26 lowercase letters plus $
            inventory=PlayerInventory(capacity=27),

            level=Level(level_up_base=20, difficulty=0),
            energy=EnergyComponent(refill=12),
            regeneration=Regeneration(),

            light=LightComponent(radius=1),
        )
Beispiel #7
0
def test_init__first_inv_letter_is_a():
    pi = PlayerInventory(10)
    assert pi.current_letter == 'a'
Beispiel #8
0
def test_init__requires_item_components():
    pi = PlayerInventory(10)
    assert pi.required_comp == "item"
Beispiel #9
0
def test_init__capacity():
    pi = PlayerInventory(10)
    assert pi.capacity == 10
Beispiel #10
0
def test_add_inv_item__added_to_stackable__full_capacity_returns_letter(
        dagger):
    pi = PlayerInventory(1)
    pi.add_inv_item(dagger)
    assert pi.add_inv_item(dagger) == "a"
Beispiel #11
0
def test_rm_inv_item__item_dne__returns_None(dagger):
    pi = PlayerInventory(10)
    result = pi.rm_inv_item(dagger)
    assert result is None
Beispiel #12
0
def test_add_inv_item__adding_money_full_capacity_returns_True(money):
    pi = PlayerInventory(1)
    pi.add_inv_item(money)
    assert pi.add_inv_item(money) == "$"
Beispiel #13
0
def test_add_inv_item__added_to_stackable__no_new_letter(dagger):
    pi = PlayerInventory(10)
    pi.add_inv_item(dagger)
    pi.add_inv_item(dagger)
    assert pi.item_dict == {"a": dagger}
Beispiel #14
0
def test_rm_letter__letter_in_item_dict__returns_item(dagger):
    pi = PlayerInventory(10)
    pi.add_inv_item(dagger)
    assert pi.rm_letter('a') == dagger
Beispiel #15
0
def test_rm_letter__letter_not_in_item_dict__returns_False(dagger):
    pi = PlayerInventory(10)
    pi.add_inv_item(dagger)
    assert pi.rm_letter('b') is None
Beispiel #16
0
def test_find_next_letter__first_letter_is_a():
    pi = PlayerInventory(10)
    assert pi.find_next_letter() == 'a'
Beispiel #17
0
def test_find_next_letter__abd__next_is_c():
    pi = PlayerInventory(10)
    pi.item_dict = {'a': 1, 'b': 2, 'd': 4}
    assert pi.find_next_letter() == 'c'
Beispiel #18
0
def test_rm_inv_item__nonstackable__pops_letter(plunger):
    pi = PlayerInventory(10)
    pi.add_inv_item(plunger)
    pi.rm_inv_item(plunger)
    assert "a" not in pi.item_dict
    assert plunger not in pi.entities
Beispiel #19
0
def test_add_inv_item__new_slot__nonstackable__new_letter(plunger):
    pi = PlayerInventory(10)
    pi.add_inv_item(plunger)
    assert pi.item_dict['a'] == plunger
Beispiel #20
0
def test_rm_inv_item__stackable__removed_full_stack__pops_letter(vials5):
    pi = PlayerInventory(10)
    pi.add_inv_item(vials5)
    pi.rm_inv_item(vials5)
    assert pi.is_empty()
    assert vials5 not in pi.entities
Beispiel #21
0
def test_add_inv_item__adding_money_uses_dollar_sign(money):
    pi = PlayerInventory(10)
    assert pi.add_inv_item(money) == "$"
Beispiel #22
0
def test_add_inv_item__new_slot__nonstackable__last_letter_unoccupied(plunger):
    pi = PlayerInventory(10)
    plunger.add_comp(letter=LetterComponent('z'))
    pi.add_inv_item(plunger)
    assert pi.item_dict['z'] == plunger
Beispiel #23
0
def test_add_inv_item__adding_money_size_unchanged(money):
    pi = PlayerInventory(10)
    pi.add_inv_item(money)
    expected = len(pi)
    pi.add_inv_item(money)
    assert len(pi) == expected
Beispiel #24
0
def test_sorted_dict__multiple_items():
    pi = PlayerInventory(10)
    pi.add_inv_item(factory.make("dagger"))
    pi.add_inv_item(factory.make("leather vest"))
    pi.add_inv_item(factory.make("bulletproof vest"))
    pi.add_inv_item(factory.make("healing vial"))
    result = pi.sorted_dict()
    assert result == {
        '/': ['a'],
        '[': ['b', 'c'],
        '!': ['d'],
    }
Beispiel #25
0
def test_add_inv_item__added_to_stackable__size_unchanged(dagger):
    pi = PlayerInventory(10)
    pi.add_inv_item(dagger)
    expected = len(pi)
    pi.add_inv_item(dagger)
    assert len(pi) == expected
Beispiel #26
0
def test_init__is_Component():
    pi = PlayerInventory(10)
    assert isinstance(pi, Component)
Beispiel #27
0
def test_add_inv_item__added_to_stackable__returns_letter(dagger):
    pi = PlayerInventory(10)
    assert pi.add_inv_item(dagger) == "a"
    assert pi.add_inv_item(dagger) == "a"
Beispiel #28
0
def test_init__is_EntityManager():
    pi = PlayerInventory(10)
    assert isinstance(pi, EntityManager)
Beispiel #29
0
def test_sorted_dict__one_item(dagger):
    pi = PlayerInventory(10)
    pi.add_inv_item(dagger)
    result = pi.sorted_dict()
    assert result == {'/': ['a']}
Beispiel #30
0
def test_add_inv_item__new_slot__nonstackable__full_capacity_raises_Impossible(
        dagger, plunger):
    pi = PlayerInventory(1)
    pi.add_inv_item(dagger)
    with pytest.raises(exceptions.Impossible):
        pi.add_inv_item(plunger)