Example #1
0
def test_ice_caves(level_started, theme, world_start, level_start,
                   expected_ice_caves):
    game_state = State(theme=theme,
                       world_start=world_start,
                       level_start=level_start)

    run_state = RunState()
    run_state.level_started = level_started
    run_state.update_ice_caves(game_state)

    is_ice_caves = Label.ICE_CAVES_SHORTCUT in run_state.run_label._set
    assert is_ice_caves == expected_ice_caves
Example #2
0
def test_on_level_start_state(
    world,
    theme,
    ropes,
    prev_health,
    expected_level_start_ropes,
    expected_health,
    expected_no,
):
    run_state = RunState()
    run_state.level_started = True
    run_state.health = prev_health

    run_state.update_on_level_start(world, theme, ropes)

    assert run_state.level_start_ropes == expected_level_start_ropes
    assert run_state.health == expected_health

    is_no = Label.NO in run_state.run_label._set
    assert is_no == expected_no
Example #3
0
def test_new_entities(screen, level_started, entity_types,
                      expected_entity_types):
    run_state = RunState()
    run_state.level_started = level_started

    fake_entity_db = {}
    for entity_type in entity_types:
        if entity_type not in fake_entity_db:
            fake_entity_db[entity_type] = EntityDBEntry(id=entity_type)

    entity_map = EntityMapBuilder()
    run_state.prev_next_uid = entity_map.next_uid
    entity_map.add_trivial_entities(entity_types)

    game_state = State(
        screen=screen,
        next_entity_uid=entity_map.next_uid,
        instance_id_to_pointer=entity_map.build(),
    )
    run_state.update_new_entities(game_state)

    got_types = [e.value.type.id for e in run_state.new_entities]
    assert got_types == expected_entity_types