Ejemplo n.º 1
0
def test_automatic_pickup():
    system = PickUpSystem()
    pickupper_components = {"pickupper": Pickupper(mode="auto")}
    inventory_components = {}
    actions = {}
    position_components = PositionDict({
        "pickupper": Position(x=0, y=0),
        "item": Position(x=0, y=0)
    })
    pickup_components = {"item": VanishPickup(kind="vanish")}
    score_components = {}
    removed_entities = system.pick_up_items(
        pickupper_components, actions, position_components,
        pickup_components, score_components, inventory_components)
    assert removed_entities == set(["item"])
Ejemplo n.º 2
0
def test_score_pickup_only_vanish_if_no_score():
    system = PickUpSystem()
    pickupper_components = {"pickupper": Pickupper(mode="action")}
    inventory_components = {}
    actions = {"pickupper": PickUp()}
    position_components = PositionDict({
        "pickupper": Position(x=0, y=0),
        "item": Position(x=0, y=0)
    })
    pickup_components = {"item": ScorePickup(kind="addScore", score=1)}
    score_components = {}
    removed_entities = system.pick_up_items(
        pickupper_components, actions, position_components,
        pickup_components, score_components, inventory_components)
    assert removed_entities == set(["item"])
    assert score_components == {}
Ejemplo n.º 3
0
def test_pickup_item():
    system = PickUpSystem()
    pickupper_components = {"pickupper": Pickupper(mode="action")}
    inventory_components = {"pickupper": Inventory()}
    actions = {"pickupper": PickUp()}
    position_components = PositionDict({
        "pickupper": Position(x=0, y=0),
        "item": Position(x=0, y=0)
    })
    pickup_components = {"item": ItemPickup(kind="item")}
    score_components = {}
    removed_entities = system.pick_up_items(
        pickupper_components, actions, position_components,
        pickup_components, score_components, inventory_components)
    assert inventory_components["pickupper"] == Inventory(items=["item"])
    assert "item" not in position_components
    assert removed_entities == set()