def test_chain_stepper_multi_unstarted(): test_chain = TestChain() stepper = ChainStepper("test", test_chain.step1_to_unstarted) status = stepper.evaluate(State(), set()) assert status == ChainStatus.IN_PROGRESS status = stepper.evaluate(State(), set()) assert status == ChainStatus.UNSTARTED # Should restart status = stepper.evaluate(State(), set()) assert status == ChainStatus.IN_PROGRESS
def test_chain_stepper_multi_progress(): test_chain = TestChain() stepper = ChainStepper("test", test_chain.step1_to_fail) status = stepper.evaluate(State(), set()) assert status == ChainStatus.IN_PROGRESS status = stepper.evaluate(State(), set()) assert status == ChainStatus.FAILED # Should still be failed status = stepper.evaluate(State(), set()) assert status == ChainStatus.FAILED
def test_carry_scepter_to_42( world, level, screen, player_item_set, hh_item_set, expected_status, expected_step_name, ): entity_map = EntityMapBuilder() player = make_player_with_hh_items(entity_map, hh_item_set) game_state = State( world=world, level=level, screen=screen, items=Items(players=(player, )), instance_id_to_pointer=entity_map.build(), ) duat_chain = DuatChain() result = duat_chain.carry_scepter_to_42(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_chain_stepper_single(initial_step_name, expected_status): test_chain = TestChain() initial_step = getattr(test_chain, initial_step_name) stepper = ChainStepper("test", initial_step) status = stepper.evaluate(State(), set()) assert status == expected_status
def carry_bow_to_hundun( world, level, screen, win_state, player_item_set, hh_item_set, waddler_item_set, expected_status, expected_step_name, ): entity_map = EntityMapBuilder() player = make_player_with_hh_items(entity_map, hh_item_set) game_state = State( world=world, level=level, screen=screen, win_state=win_state, waddler_storage=tuple(waddler_item_set), items=Items(players=(player, )), instance_id_to_pointer=entity_map.build(), ) co_chain = CosmicOceanChain() result = co_chain.carry_bow_to_hundun(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_collect_tablet(world, item_set, expected_status, expected_step_name): fake_chain = MinimalCommonChain() game_state = State(world=world) result = fake_chain.collect_tablet(game_state, item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_win_via_hundun_or_co(win_state, expected_status, expected_step_name): game_state = State(win_state=win_state) fake_chain = MinimalCommonChain() result = fake_chain.win_via_hundun_or_co(game_state, set()) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_visit_world44_theme(world, level, theme, expected_status, expected_step_name): fake_chain = MinimalCommonChain() game_state = State(world=world, level=level, theme=theme) result = fake_chain.visit_world44_theme(game_state, set()) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_collect_excalibur(world, level, player_item_set, expected_status, expected_step_name): abzu_chain = AbzuChain() game_state = State(world=world, level=level) result = abzu_chain.collect_excalibur(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_win_via_co(win_state, expected_status, expected_step_name): game_state = State(win_state=win_state) player_item_set = set() co_chain = CosmicOceanChain() result = co_chain.win_via_co(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_collect_bow(world, player_item_set, expected_status, expected_step_name): game_state = State(world=world) co_chain = CosmicOceanChain() result = co_chain.collect_bow(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_millionaire_clone_gun_wo_bow(item_set, cosmic_status, expected_clone_gun_wo_cosmic, expected_millionaire): run_state = RunState() run_state.cosmic_stepper = FakeStepper(cosmic_status) run_state.update_millionaire(State(), Inventory(), item_set) assert run_state.clone_gun_wo_cosmic == expected_clone_gun_wo_cosmic is_millionaire = Label.MILLIONAIRE in run_state.run_label._set assert is_millionaire == expected_millionaire
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
def test_collect_eggplant_crown(world, level, player_item_set, expected_status, expected_step_name): game_state = State( world=world, level=level, ) eggy_chain = EggplantChain() result = eggy_chain.collect_eggplant_crown(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_keep_ankh(world, level, player, player_item_set, expected_status, expected_step_name): game_state = State( world=world, level=level, items=Items(players=(player, )), ) duat_chain = DuatChain() result = duat_chain.keep_ankh(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_visit_city_of_gold(world, level, theme, player_item_set, expected_status, expected_step_name): game_state = State( world=world, level=level, theme=theme, ) duat_chain = DuatChain() result = duat_chain.visit_city_of_gold(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_visit_eggplant_world(world, level, theme, expected_status, expected_step_name): game_state = State( world=world, level=level, theme=theme, ) player_item_set = set() eggy_chain = EggplantChain() result = eggy_chain.visit_eggplant_world(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_collect_eggplant_item(world, screen, player_item_set, hh_item_set, expected_status, expected_step_name): entity_map = EntityMapBuilder() player = make_player_with_hh_items(entity_map, hh_item_set) game_state = State( world=world, screen=screen, items=Items(players=(player, )), instance_id_to_pointer=entity_map.build(), ) eggy_chain = EggplantChain() result = eggy_chain.collect_eggplant(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_collect_eggplant_skip(): entity_map = EntityMapBuilder() player = make_player_with_hh_type(entity_map, EntityType.CHAR_EGGPLANT_CHILD) game_state = State( world=5, items=Items(players=(player, )), instance_id_to_pointer=entity_map.build(), ) player_item_set = set() eggy_chain = EggplantChain() result = eggy_chain.collect_eggplant(game_state, player_item_set) assert result.status == ChainStatus.IN_PROGRESS assert result.next_step.__name__ == "guide_eggplant_child_to_71"
def test_guide_eggplant_child_to_71(world, level, screen, hh_type, expected_status, expected_step_name): entity_map = EntityMapBuilder() player = make_player_with_hh_type(entity_map, hh_type) game_state = State( world=world, level=level, screen=screen, items=Items(players=(player, )), instance_id_to_pointer=entity_map.build(), ) player_item_set = set() eggy_chain = EggplantChain() result = eggy_chain.guide_eggplant_child_to_71(game_state, player_item_set) assert result.status == expected_status if expected_status.in_progress: assert result.next_step.__name__ == expected_step_name
def test_update_terminus( world, win_state, final_death, had_ankh, sunken_status, eggplant_status, cosmic_status, expected_terminus, ): run_state = RunState() run_state.final_death = final_death run_state.had_ankh = had_ankh run_state.sunken_chain_status = sunken_status run_state.eggplant_stepper = FakeStepper(eggplant_status) run_state.cosmic_stepper = FakeStepper(cosmic_status) game_state = State(world=world, win_state=win_state) run_state.update_terminus(game_state) assert run_state.run_label._terminus == expected_terminus
def test_millionaire_( money_shop_total, win_state, money, collected_money_total, clone_gun_wo_bow, expected_millionaire, ): run_state = RunState() run_state.clone_gun_wo_cosmic = clone_gun_wo_bow if clone_gun_wo_bow: # This would have been added on a previous update run_state.run_label.add(Label.MILLIONAIRE) game_state = State(money_shop_total=money_shop_total, win_state=win_state) inventory = Inventory(money=money, collected_money_total=collected_money_total) item_set = set() run_state.update_millionaire(game_state, inventory, item_set) is_millionaire = Label.MILLIONAIRE in run_state.run_label._set assert is_millionaire == expected_millionaire
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