diff --git a/worlds/portal2/LocationNames.py b/worlds/portal2/LocationNames.py new file mode 100644 index 00000000000..761b4b4e31a --- /dev/null +++ b/worlds/portal2/LocationNames.py @@ -0,0 +1,96 @@ +# map completion checks +container_ride_completion = "Container Ride Completion" +portal_carousel_completion = "Portal Carousel Completion" +portal_gun_completion = "Portal Gun Completion" +smooth_jazz_completion = "Smooth Jazz Completion" +cube_momentum_completion = "Cube Momentum Completion" +future_starter_completion = "Future Starter Completion" +secret_panel_completion = "Secret Panel Completion" +wake_up_completion = "Wake Up Completion" +incinerator_completion = "Incinerator Completion" +laser_intro_completion = "Laser Intro Completion" +laser_stairs_completion = "Laser Stairs Completion" +dual_lasers_completion = "Dual Lasers Completion" +laser_over_goo_completion = "Laser Over Goo Completion" +catapult_intro_completion = "Catapult Intro Completion" +trust_fling_completion = "Trust Fling Completion" +pit_flings_completion = "Pit Flings Completion" +fizzler_intro_completion = "Fizzler Intro Completion" +ceiling_catapult_completion = "Ceiling Catapult Completion" +ricochet_completion = "Ricochet Completion" +bridge_intro_completion = "Bridge Intro Completion" +bridge_the_gap_completion = "Bridge the Gap Completion" +turret_intro_completion = "Turret Intro Completion" +laser_relays_completion = "Laser Relays Completion" +turret_blocker_completion = "Turret Blocker Completion" +laser_vs_turret_completion = "Laser Vs. Turret Completion" +pull_the_rug_completion = "Pull The Rug Completion" +column_blocker_completion = "Column Blocker Completion" +laser_chaining_completion = "Laser Chaining Completion" +triple_laser_completion = "Triple Laser Completion" +jailbreak_completion = "Jailbreak Completion" +escape_completion = "Escape Completion" +turret_factory_completion = "Turret Factory Completion" +turret_sabotage_completion = "Turret Sabotage Completion" +neurotoxin_sabotage_completion = "Neurotoxin Sabotage Completion" +core_completion = "Core Completion" +underground_completion = "Underground Completion" +cave_johnson_completion = "Cave Johnson Completion" +repulsion_intro_completion = "Repulsion Intro Completion" +bomb_flings_completion = "Bomb Flings Completion" +crazy_box_completion = "Crazy Box Completion" +potatos_completion = "PotatOS Completion" +propulsion_intro_completion = "Propulsion Intro Completion" +propulsion_flings_completion = "Propulsion Flings Completion" +conversion_intro_completion = "Conversion Intro Completion" +three_gels_completion = "Three Gels Completion" +test_completion = "Test Completion" +funnel_intro_completion = "Funnel Intro Completion" +ceiling_button_completion = "Ceiling Button Completion" +wall_button_completion = "Wall Button Completion" +polarity_completion = "Polarity Completion" +funnel_catch_completion = "Funnel Catch Completion" +stop_the_box_completion = "Stop The Box Completion" +laser_catapult_completion = "Laser Catapult Completion" +laser_platform_completion = "Laser Platform Completion" +propulsion_catch_completion = "Propulsion Catch Completion" +repulsion_polarity_completion = "Repulsion Polarity Completion" +finale_1_completion = "Finale 1 Completion" +finale_2_completion = "Finale 2 Completion" +finale_3_completion = "Finale 3 Completion" +finale_4_completion = "Finale 4 Completion" + +# optional checks +tube_ride_completion = "Tube Ride Completion" +long_fall_completion = "Long Fall Completion" + +# wheatley monitors +wheatley_monitor_1_funnel_intro = "Wheatley Monitor 1 (Funnel Intro)" +wheatley_monitor_2_ceiling_button = "Wheatley Monitor 2 (Ceiling Button)" +wheatley_monitor_3_wall_button = "Wheatley Monitor 3 (Wall Button)" +wheatley_monitor_4_polarity = "Wheatley Monitor 4 (Polarity)" +wheatley_monitor_5_funnel_catch = "Wheatley Monitor 5 (Funnel Catch)" +wheatley_monitor_6_funnel_catch = "Wheatley Monitor 6 (Funnel Catch)" +wheatley_monitor_7_stop_the_box = "Wheatley Monitor 7 (Stop The Box)" +wheatley_monitor_8_laser_catapult = "Wheatley Monitor 8 (Laser Catapult)" +wheatley_monitor_9_laser_platform = "Wheatley Monitor 9 (Laser Platform)" +wheatley_monitor_10_propulsion_catch = "Wheatley Monitor 10 (Propulsion Catch)" +wheatley_monitor_11_repulsion_polarity = "Wheatley Monitor 11 (Repulsion Polarity)" +wheatley_monitor_12_finale_3 = "Wheatley Monitor 12 (Finale 3)" + +# ratman dens +ratman_den_1_smooth_jazz = "Ratman Den 1 (Smooth Jazz)" +ratman_den_2_dual_lasers = "Ratman Den 2 (Dual Lasers)" +ratman_den_3_trust_fling = "Ratman Den 3 (Trust Fling)" +ratman_den_4_bridge_intro = "Ratman Den 4 (Bridge Intro)" +ratman_den_5_bridge_the_gap = "Ratman Den 5 (Bridge the Gap)" +ratman_den_6_laser_vs_turret = "Ratman Den 6 (Laser Vs. Turret)" +ratman_den_7_pull_the_rug = "Ratman Den 7 (Pull The Rug)" + +# vitrified doors +vitrified_door_1_cave_johnson = "Vitrified Door 1 (Cave Johnson)" +vitrified_door_2_cave_johnson = "Vitrified Door 2 (Cave Johnson)" +vitrified_door_3_cave_johnson = "Vitrified Door 3 (Cave Johnson)" +vitrified_door_4_potatos = "Vitrified Door 4 (PotatOS)" +vitrified_door_5_potatos = "Vitrified Door 5 (PotatOS)" +vitrified_door_6_potatos = "Vitrified Door 6 (PotatOS)" diff --git a/worlds/portal2/Locations.py b/worlds/portal2/Locations.py index 43b68f4c79c..137d832cfa9 100644 --- a/worlds/portal2/Locations.py +++ b/worlds/portal2/Locations.py @@ -3,6 +3,7 @@ from attr import dataclass from BaseClasses import Location from .ItemNames import * +from .LocationNames import * portal_2_base_id = 98275000 offset_index = 0 @@ -34,93 +35,93 @@ class Portal2Location(Location): map_complete_table: dict[str, Portal2LocationData] = { # Chapter 1 - "Container Ride Completion": Portal2LocationData("sp_a1_intro1", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), - "Portal Carousel Completion": Portal2LocationData("sp_a1_intro2", LocationType.MAP_COMPLETION, [button, weighted_cube, floor_button], 1), - "Portal Gun Completion": Portal2LocationData("sp_a1_intro3", LocationType.MAP_COMPLETION, [], 1), - "Smooth Jazz Completion": Portal2LocationData("sp_a1_intro4", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), - "Cube Momentum Completion": Portal2LocationData("sp_a1_intro5", LocationType.MAP_COMPLETION, [button, weighted_cube, floor_button], 1), - "Future Starter Completion": Portal2LocationData("sp_a1_intro6", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), - "Secret Panel Completion": Portal2LocationData("sp_a1_intro7", LocationType.MAP_COMPLETION, [], 1), - "Wake Up Completion": Portal2LocationData("sp_a1_wakeup", LocationType.MAP_COMPLETION, [], 1), - "Incinerator Completion": Portal2LocationData("sp_a2_intro", LocationType.MAP_COMPLETION, [portal_gun_2], 1), + container_ride_completion: Portal2LocationData("sp_a1_intro1", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), + portal_carousel_completion: Portal2LocationData("sp_a1_intro2", LocationType.MAP_COMPLETION, [button, weighted_cube, floor_button], 1), + portal_gun_completion: Portal2LocationData("sp_a1_intro3", LocationType.MAP_COMPLETION, [], 1), + smooth_jazz_completion: Portal2LocationData("sp_a1_intro4", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), + cube_momentum_completion: Portal2LocationData("sp_a1_intro5", LocationType.MAP_COMPLETION, [button, weighted_cube, floor_button], 1), + future_starter_completion: Portal2LocationData("sp_a1_intro6", LocationType.MAP_COMPLETION, [weighted_cube, floor_button], 1), + secret_panel_completion: Portal2LocationData("sp_a1_intro7", LocationType.MAP_COMPLETION, [], 1), + wake_up_completion: Portal2LocationData("sp_a1_wakeup", LocationType.MAP_COMPLETION, [], 1), + incinerator_completion: Portal2LocationData("sp_a2_intro", LocationType.MAP_COMPLETION, [portal_gun_2], 1), # Chapter 2 - "Laser Intro Completion": Portal2LocationData("sp_a2_laser_intro", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher], 2), - "Laser Stairs Completion": Portal2LocationData("sp_a2_laser_stairs", LocationType.MAP_COMPLETION, [portal_gun_2, reflection_cube, floor_button, laser, laser_catcher], 2), - "Dual Lasers Completion": Portal2LocationData("sp_a2_dual_lasers", LocationType.MAP_COMPLETION, [portal_gun_2, reflection_cube, laser, laser_catcher], 2), - "Laser Over Goo Completion": Portal2LocationData("sp_a2_laser_over_goo", LocationType.MAP_COMPLETION, [button, floor_button, weighted_cube, portal_gun_2, laser, laser_catcher], 2), - "Catapult Intro Completion": Portal2LocationData("sp_a2_catapult_intro", LocationType.MAP_COMPLETION, [faith_plate, button, weighted_cube, floor_button], 2), - "Trust Fling Completion": Portal2LocationData("sp_a2_trust_fling", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, button, weighted_cube, floor_button], 2), - "Pit Flings Completion": Portal2LocationData("sp_a2_pit_flings", LocationType.MAP_COMPLETION, [portal_gun_2, weighted_cube, laser, laser_catcher, floor_button], 2), - "Fizzler Intro Completion": Portal2LocationData("sp_a2_fizzler_intro", LocationType.MAP_COMPLETION, [portal_gun_2, laser, reflection_cube, laser_catcher, button], 2), + laser_intro_completion: Portal2LocationData("sp_a2_laser_intro", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher], 2), + laser_stairs_completion: Portal2LocationData("sp_a2_laser_stairs", LocationType.MAP_COMPLETION, [portal_gun_2, reflection_cube, floor_button, laser, laser_catcher], 2), + dual_lasers_completion: Portal2LocationData("sp_a2_dual_lasers", LocationType.MAP_COMPLETION, [portal_gun_2, reflection_cube, laser, laser_catcher], 2), + laser_over_goo_completion: Portal2LocationData("sp_a2_laser_over_goo", LocationType.MAP_COMPLETION, [button, floor_button, weighted_cube, portal_gun_2, laser, laser_catcher], 2), + catapult_intro_completion: Portal2LocationData("sp_a2_catapult_intro", LocationType.MAP_COMPLETION, [faith_plate, button, weighted_cube, floor_button], 2), + trust_fling_completion: Portal2LocationData("sp_a2_trust_fling", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, button, weighted_cube, floor_button], 2), + pit_flings_completion: Portal2LocationData("sp_a2_pit_flings", LocationType.MAP_COMPLETION, [portal_gun_2, weighted_cube, laser, laser_catcher, floor_button], 2), + fizzler_intro_completion: Portal2LocationData("sp_a2_fizzler_intro", LocationType.MAP_COMPLETION, [portal_gun_2, laser, reflection_cube, laser_catcher, button], 2), # Chapter 3 - "Ceiling Catapult Completion": Portal2LocationData("sp_a2_sphere_peek", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, button, reflection_cube, laser, laser_catcher], 3), - "Ricochet Completion": Portal2LocationData("sp_a2_ricochet", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, weighted_cube, laser, laser_catcher, reflection_cube, floor_button, button], 3), - "Bridge Intro Completion": Portal2LocationData("sp_a2_bridge_intro", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, floor_button, button, weighted_cube], 3), - "Bridge the Gap Completion": Portal2LocationData("sp_a2_bridge_the_gap", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, floor_button, button, weighted_cube], 3), - "Turret Intro Completion": Portal2LocationData("sp_a2_turret_intro", LocationType.MAP_COMPLETION, [portal_gun_2, weighted_cube, floor_button, turrets], 3), - "Laser Relays Completion": Portal2LocationData("sp_a2_laser_relays", LocationType.MAP_COMPLETION, [portal_gun_2, laser, reflection_cube, laser_relays], 3), - "Turret Blocker Completion": Portal2LocationData("sp_a2_turret_blocker", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, faith_plate, floor_button, weighted_cube], 3), - "Laser Vs. Turret Completion": Portal2LocationData("sp_a2_laser_vs_turret", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, weighted_cube, reflection_cube, floor_button], 3), - "Pull The Rug Completion": Portal2LocationData("sp_a2_pull_the_rug", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, weighted_cube, floor_button, laser, laser_catcher], 3), + ceiling_catapult_completion: Portal2LocationData("sp_a2_sphere_peek", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, button, reflection_cube, laser, laser_catcher], 3), + ricochet_completion: Portal2LocationData("sp_a2_ricochet", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, weighted_cube, laser, laser_catcher, reflection_cube, floor_button, button], 3), + bridge_intro_completion: Portal2LocationData("sp_a2_bridge_intro", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, floor_button, button, weighted_cube], 3), + bridge_the_gap_completion: Portal2LocationData("sp_a2_bridge_the_gap", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, floor_button, button, weighted_cube], 3), + turret_intro_completion: Portal2LocationData("sp_a2_turret_intro", LocationType.MAP_COMPLETION, [portal_gun_2, weighted_cube, floor_button, turrets], 3), + laser_relays_completion: Portal2LocationData("sp_a2_laser_relays", LocationType.MAP_COMPLETION, [portal_gun_2, laser, reflection_cube, laser_relays], 3), + turret_blocker_completion: Portal2LocationData("sp_a2_turret_blocker", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, faith_plate, floor_button, weighted_cube], 3), + laser_vs_turret_completion: Portal2LocationData("sp_a2_laser_vs_turret", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, weighted_cube, reflection_cube, floor_button], 3), + pull_the_rug_completion: Portal2LocationData("sp_a2_pull_the_rug", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, weighted_cube, floor_button, laser, laser_catcher], 3), # Chapter 4 - "Column Blocker Completion": Portal2LocationData("sp_a2_column_blocker", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, laser, laser_catcher, laser_relays, button, reflection_cube, faith_plate], 4), - "Laser Chaining Completion": Portal2LocationData("sp_a2_laser_chaining", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, laser_relays, reflection_cube, faith_plate], 4), - "Triple Laser Completion": Portal2LocationData("sp_a2_triple_laser", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, reflection_cube], 4), - "Jailbreak Completion": Portal2LocationData("sp_a2_bts1", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, button, weighted_cube], 4), - "Escape Completion": Portal2LocationData("sp_a2_bts2", LocationType.MAP_COMPLETION, [portal_gun_2, turrets], 4), + column_blocker_completion: Portal2LocationData("sp_a2_column_blocker", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, laser, laser_catcher, laser_relays, button, reflection_cube, faith_plate], 4), + laser_chaining_completion: Portal2LocationData("sp_a2_laser_chaining", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, laser_relays, reflection_cube, faith_plate], 4), + triple_laser_completion: Portal2LocationData("sp_a2_triple_laser", LocationType.MAP_COMPLETION, [portal_gun_2, laser, laser_catcher, reflection_cube], 4), + jailbreak_completion: Portal2LocationData("sp_a2_bts1", LocationType.MAP_COMPLETION, [portal_gun_2, bridge, button, weighted_cube], 4), + escape_completion: Portal2LocationData("sp_a2_bts2", LocationType.MAP_COMPLETION, [portal_gun_2, turrets], 4), # Chapter 5 - "Turret Factory Completion": Portal2LocationData("sp_a2_bts3", LocationType.MAP_COMPLETION, [portal_gun_2], 5), - "Turret Sabotage Completion": Portal2LocationData("sp_a2_bts4", LocationType.MAP_COMPLETION, [portal_gun_2, turrets], 5), - "Neurotoxin Sabotage Completion": Portal2LocationData("sp_a2_bts5", LocationType.MAP_COMPLETION, [portal_gun_2, laser], 5), - "Core Completion": Portal2LocationData("sp_a2_core", LocationType.MAP_COMPLETION, [portal_gun_2, button, turrets], 5), + turret_factory_completion: Portal2LocationData("sp_a2_bts3", LocationType.MAP_COMPLETION, [portal_gun_2], 5), + turret_sabotage_completion: Portal2LocationData("sp_a2_bts4", LocationType.MAP_COMPLETION, [portal_gun_2, turrets], 5), + neurotoxin_sabotage_completion: Portal2LocationData("sp_a2_bts5", LocationType.MAP_COMPLETION, [portal_gun_2, laser], 5), + core_completion: Portal2LocationData("sp_a2_core", LocationType.MAP_COMPLETION, [portal_gun_2, button, turrets], 5), # Chapter 6 - "Underground Completion": Portal2LocationData("sp_a3_01", LocationType.MAP_COMPLETION, [portal_gun_2], 6), - "Cave Johnson Completion": Portal2LocationData("sp_a3_03", LocationType.MAP_COMPLETION, [portal_gun_2], 6), - "Repulsion Intro Completion": Portal2LocationData("sp_a3_jump_intro", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, old_button, old_floor_button, antique_cube], 6), - "Bomb Flings Completion": Portal2LocationData("sp_a3_bomb_flings", LocationType.MAP_COMPLETION, [portal_gun_2, old_button, blue_gel], 6), - "Crazy Box Completion": Portal2LocationData("sp_a3_crazy_box", LocationType.MAP_COMPLETION, [portal_gun_2, old_button, blue_gel, antique_cube, old_floor_button], 6), - "PotatOS Completion": Portal2LocationData("sp_a3_transition01", LocationType.MAP_COMPLETION, [portal_gun_2, potatos], 6), + underground_completion: Portal2LocationData("sp_a3_01", LocationType.MAP_COMPLETION, [portal_gun_2], 6), + cave_johnson_completion: Portal2LocationData("sp_a3_03", LocationType.MAP_COMPLETION, [portal_gun_2], 6), + repulsion_intro_completion: Portal2LocationData("sp_a3_jump_intro", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, old_button, old_floor_button, antique_cube], 6), + bomb_flings_completion: Portal2LocationData("sp_a3_bomb_flings", LocationType.MAP_COMPLETION, [portal_gun_2, old_button, blue_gel], 6), + crazy_box_completion: Portal2LocationData("sp_a3_crazy_box", LocationType.MAP_COMPLETION, [portal_gun_2, old_button, blue_gel, antique_cube, old_floor_button], 6), + potatos_completion: Portal2LocationData("sp_a3_transition01", LocationType.MAP_COMPLETION, [portal_gun_2, potatos], 6), # Chapter 7 - "Propulsion Intro Completion": Portal2LocationData("sp_a3_speed_ramp", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, antique_cube, old_floor_button, old_button], 7), - "Propulsion Flings Completion": Portal2LocationData("sp_a3_speed_flings", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, antique_cube, old_floor_button], 7), - "Conversion Intro Completion": Portal2LocationData("sp_a3_portal_intro", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, white_gel], 7), - "Three Gels Completion": Portal2LocationData("sp_a3_end", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, white_gel], 7), + propulsion_intro_completion: Portal2LocationData("sp_a3_speed_ramp", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, antique_cube, old_floor_button, old_button], 7), + propulsion_flings_completion: Portal2LocationData("sp_a3_speed_flings", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, antique_cube, old_floor_button], 7), + conversion_intro_completion: Portal2LocationData("sp_a3_portal_intro", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, white_gel], 7), + three_gels_completion: Portal2LocationData("sp_a3_end", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, orange_gel, white_gel], 7), # Chapter 8 - "Test Completion": Portal2LocationData("sp_a4_intro", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, button], 8), - "Funnel Intro Completion": Portal2LocationData("sp_a4_tb_intro", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button], 8), - "Ceiling Button Completion": Portal2LocationData("sp_a4_tb_trust_drop", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button], 8), - "Wall Button Completion": Portal2LocationData("sp_a4_tb_wall_button", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button, faith_plate], 8), - "Polarity Completion": Portal2LocationData("sp_a4_tb_polarity", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button], 8), - "Funnel Catch Completion": Portal2LocationData("sp_a4_tb_catch", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button, faith_plate], 8), - "Stop The Box Completion": Portal2LocationData("sp_a4_stop_the_box", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, button, faith_plate, bridge], 8), - "Laser Catapult Completion": Portal2LocationData("sp_a4_laser_catapult", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, faith_plate, reflection_cube, laser, laser_catcher, funnel], 8), - "Laser Platform Completion": Portal2LocationData("sp_a4_laser_platform", LocationType.MAP_COMPLETION, [portal_gun_2, button, reflection_cube, laser, laser_catcher, funnel], 8), - "Propulsion Catch Completion": Portal2LocationData("sp_a4_speed_tb_catch", LocationType.MAP_COMPLETION, [portal_gun_2, floor_button, funnel, button, frankenturret, orange_gel], 8), - "Repulsion Polarity Completion": Portal2LocationData("sp_a4_jump_polarity", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, white_gel, funnel, floor_button, button], 8), + test_completion: Portal2LocationData("sp_a4_intro", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, button], 8), + funnel_intro_completion: Portal2LocationData("sp_a4_tb_intro", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button], 8), + ceiling_button_completion: Portal2LocationData("sp_a4_tb_trust_drop", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button], 8), + wall_button_completion: Portal2LocationData("sp_a4_tb_wall_button", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button, faith_plate], 8), + polarity_completion: Portal2LocationData("sp_a4_tb_polarity", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button], 8), + funnel_catch_completion: Portal2LocationData("sp_a4_tb_catch", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, frankenturret, floor_button, button, faith_plate], 8), + stop_the_box_completion: Portal2LocationData("sp_a4_stop_the_box", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, button, faith_plate, bridge], 8), + laser_catapult_completion: Portal2LocationData("sp_a4_laser_catapult", LocationType.MAP_COMPLETION, [portal_gun_2, frankenturret, floor_button, faith_plate, reflection_cube, laser, laser_catcher, funnel], 8), + laser_platform_completion: Portal2LocationData("sp_a4_laser_platform", LocationType.MAP_COMPLETION, [portal_gun_2, button, reflection_cube, laser, laser_catcher, funnel], 8), + propulsion_catch_completion: Portal2LocationData("sp_a4_speed_tb_catch", LocationType.MAP_COMPLETION, [portal_gun_2, floor_button, funnel, button, frankenturret, orange_gel], 8), + repulsion_polarity_completion: Portal2LocationData("sp_a4_jump_polarity", LocationType.MAP_COMPLETION, [portal_gun_2, blue_gel, white_gel, funnel, floor_button, button], 8), # Chapter 9 - "Finale 1 Completion": Portal2LocationData("sp_a4_finale1", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, funnel, white_gel], 9), - "Finale 2 Completion": Portal2LocationData("sp_a4_finale2", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, blue_gel, floor_button, turrets], 9), - "Finale 3 Completion": Portal2LocationData("sp_a4_finale3", LocationType.MAP_COMPLETION, [portal_gun_2, orange_gel, white_gel, funnel], 9), - "Finale 4 Completion": Portal2LocationData("sp_a4_finale4", LocationType.MAP_COMPLETION, [portal_gun_2, potatos, blue_gel, orange_gel, white_gel, adventure_core, space_core, fact_core], 9), + finale_1_completion: Portal2LocationData("sp_a4_finale1", LocationType.MAP_COMPLETION, [portal_gun_2, faith_plate, funnel, white_gel], 9), + finale_2_completion: Portal2LocationData("sp_a4_finale2", LocationType.MAP_COMPLETION, [portal_gun_2, funnel, blue_gel, floor_button, turrets], 9), + finale_3_completion: Portal2LocationData("sp_a4_finale3", LocationType.MAP_COMPLETION, [portal_gun_2, orange_gel, white_gel, funnel], 9), + finale_4_completion: Portal2LocationData("sp_a4_finale4", LocationType.MAP_COMPLETION, [portal_gun_2, potatos, blue_gel, orange_gel, white_gel, adventure_core, space_core, fact_core], 9), } # Optional Checks cutscene_completion_table: dict[str, Portal2LocationData] = { - "Tube Ride Completion": Portal2LocationData("sp_a2_bts6", LocationType.CUTSCENE_COMPLETION, [], 5), - "Long Fall Completion": Portal2LocationData("sp_a3_00", LocationType.CUTSCENE_COMPLETION, [], 6), + tube_ride_completion: Portal2LocationData("sp_a2_bts6", LocationType.CUTSCENE_COMPLETION, [], 5), + long_fall_completion: Portal2LocationData("sp_a3_00", LocationType.CUTSCENE_COMPLETION, [], 6), } maps_in_chapters: dict[str, list[str]] = { - "Chapter 1": ["Container Ride Completion", "Portal Carousel Completion", "Portal Gun Completion", "Smooth Jazz Completion", "Cube Momentum Completion", "Future Starter Completion", "Secret Panel Completion", "Wake Up Completion", "Incinerator Completion"], - "Chapter 2": ["Laser Intro Completion", "Laser Stairs Completion", "Dual Lasers Completion", "Laser Over Goo Completion", "Catapult Intro Completion", "Trust Fling Completion", "Pit Flings Completion", "Fizzler Intro Completion"], - "Chapter 3": ["Ceiling Catapult Completion", "Ricochet Completion", "Bridge Intro Completion", "Bridge the Gap Completion", "Turret Intro Completion", "Laser Relays Completion", "Turret Blocker Completion", "Laser Vs. Turret Completion", "Pull The Rug Completion"], - "Chapter 4": ["Column Blocker Completion", "Laser Chaining Completion", "Triple Laser Completion", "Jailbreak Completion", "Escape Completion"], - "Chapter 5": ["Turret Factory Completion", "Turret Sabotage Completion", "Neurotoxin Sabotage Completion", "Core Completion", "Tube Ride Completion"], - "Chapter 6": ["Long Fall Completion","Underground Completion", "Cave Johnson Completion", "Repulsion Intro Completion", "Bomb Flings Completion", "Crazy Box Completion", "PotatOS Completion"], - "Chapter 7": ["Propulsion Intro Completion", "Propulsion Flings Completion", "Conversion Intro Completion", "Three Gels Completion"], - "Chapter 8": ["Test Completion", "Funnel Intro Completion", "Ceiling Button Completion", "Wall Button Completion", "Polarity Completion", "Funnel Catch Completion", "Stop The Box Completion", "Laser Catapult Completion", "Laser Platform Completion", "Propulsion Catch Completion", "Repulsion Polarity Completion"], - "Chapter 9": ["Finale 1 Completion", "Finale 2 Completion", "Finale 3 Completion", "Finale 4 Completion"] + "Chapter 1": [container_ride_completion, portal_carousel_completion, portal_gun_completion, smooth_jazz_completion, cube_momentum_completion, future_starter_completion, secret_panel_completion, wake_up_completion, incinerator_completion], + "Chapter 2": [laser_intro_completion, laser_stairs_completion, dual_lasers_completion, laser_over_goo_completion, catapult_intro_completion, trust_fling_completion, pit_flings_completion, fizzler_intro_completion], + "Chapter 3": [ceiling_catapult_completion, ricochet_completion, bridge_intro_completion, bridge_the_gap_completion, turret_intro_completion, laser_relays_completion, turret_blocker_completion, laser_vs_turret_completion, pull_the_rug_completion], + "Chapter 4": [column_blocker_completion, laser_chaining_completion, triple_laser_completion, jailbreak_completion, escape_completion], + "Chapter 5": [turret_factory_completion, turret_sabotage_completion, neurotoxin_sabotage_completion, core_completion, tube_ride_completion], + "Chapter 6": [long_fall_completion, underground_completion, cave_johnson_completion, repulsion_intro_completion, bomb_flings_completion, crazy_box_completion, potatos_completion], + "Chapter 7": [propulsion_intro_completion, propulsion_flings_completion, conversion_intro_completion, three_gels_completion], + "Chapter 8": [test_completion, funnel_intro_completion, ceiling_button_completion, wall_button_completion, polarity_completion, funnel_catch_completion, stop_the_box_completion, laser_catapult_completion, laser_platform_completion, propulsion_catch_completion, repulsion_polarity_completion], + "Chapter 9": [finale_1_completion, finale_2_completion, finale_3_completion, finale_4_completion] } @@ -145,18 +146,18 @@ class Portal2Location(Location): achievements_table: dict[str, Portal2LocationData] = {} wheatley_monitor_table: dict[str, Portal2LocationData] = { - "Wheatley Monitor 1": Portal2LocationData("sp_a4_tb_intro", LocationType.WHEATLY_MONITOR, [portal_gun_2, funnel, frankenturret]), - "Wheatley Monitor 2": Portal2LocationData("sp_a4_tb_trust_drop", LocationType.WHEATLY_MONITOR, [portal_gun_2, button, funnel, frankenturret]), - "Wheatley Monitor 3": Portal2LocationData("sp_a4_tb_wall_button", LocationType.WHEATLY_MONITOR, [portal_gun_2]), - "Wheatley Monitor 4": Portal2LocationData("sp_a4_tb_polarity", LocationType.WHEATLY_MONITOR, [turrets]), - "Wheatley Monitor 5": Portal2LocationData("sp_a4_tb_catch 1", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, funnel, faith_plate, button]), #monitor1 - "Wheatley Monitor 6": Portal2LocationData("sp_a4_tb_catch 2", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, funnel, faith_plate, button]), #monitor2 - "Wheatley Monitor 7": Portal2LocationData("sp_a4_stop_the_box", LocationType.WHEATLY_MONITOR, [faith_plate]), - "Wheatley Monitor 8": Portal2LocationData("sp_a4_laser_catapult", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, faith_plate, funnel, reflection_cube, laser, laser_catcher]), - "Wheatley Monitor 9": Portal2LocationData("sp_a4_laser_platform", LocationType.WHEATLY_MONITOR, [portal_gun_2, laser, laser_catcher, reflection_cube, button]), - "Wheatley Monitor 10": Portal2LocationData("sp_a4_speed_tb_catch", LocationType.WHEATLY_MONITOR, [portal_gun_2]), - "Wheatley Monitor 11": Portal2LocationData("sp_a4_jump_polarity", LocationType.WHEATLY_MONITOR, [portal_gun_2, blue_gel, white_gel, funnel, turrets, floor_button, button]), - "Wheatley Monitor 12": Portal2LocationData("sp_a4_finale3", LocationType.WHEATLY_MONITOR, [portal_gun_2, white_gel]), + wheatley_monitor_1_funnel_intro: Portal2LocationData("sp_a4_tb_intro", LocationType.WHEATLY_MONITOR, [portal_gun_2, funnel, frankenturret]), + wheatley_monitor_2_ceiling_button: Portal2LocationData("sp_a4_tb_trust_drop", LocationType.WHEATLY_MONITOR, [portal_gun_2, button, funnel, frankenturret]), + wheatley_monitor_3_wall_button: Portal2LocationData("sp_a4_tb_wall_button", LocationType.WHEATLY_MONITOR, [portal_gun_2]), + wheatley_monitor_4_polarity: Portal2LocationData("sp_a4_tb_polarity", LocationType.WHEATLY_MONITOR, [turrets]), + wheatley_monitor_5_funnel_catch: Portal2LocationData("sp_a4_tb_catch 1", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, funnel, faith_plate, button]), #monitor1 + wheatley_monitor_6_funnel_catch: Portal2LocationData("sp_a4_tb_catch 2", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, funnel, faith_plate, button]), #monitor2 + wheatley_monitor_7_stop_the_box: Portal2LocationData("sp_a4_stop_the_box", LocationType.WHEATLY_MONITOR, [faith_plate]), + wheatley_monitor_8_laser_catapult: Portal2LocationData("sp_a4_laser_catapult", LocationType.WHEATLY_MONITOR, [portal_gun_2, frankenturret, faith_plate, funnel, reflection_cube, laser, laser_catcher]), + wheatley_monitor_9_laser_platform: Portal2LocationData("sp_a4_laser_platform", LocationType.WHEATLY_MONITOR, [portal_gun_2, laser, laser_catcher, reflection_cube, button]), + wheatley_monitor_10_propulsion_catch: Portal2LocationData("sp_a4_speed_tb_catch", LocationType.WHEATLY_MONITOR, [portal_gun_2]), + wheatley_monitor_11_repulsion_polarity: Portal2LocationData("sp_a4_jump_polarity", LocationType.WHEATLY_MONITOR, [portal_gun_2, blue_gel, white_gel, funnel, turrets, floor_button, button]), + wheatley_monitor_12_finale_3: Portal2LocationData("sp_a4_finale3", LocationType.WHEATLY_MONITOR, [portal_gun_2, white_gel]), } # Note: these are the names used in game to identify the monitors @@ -172,29 +173,29 @@ class Portal2Location(Location): item_maps_to_item_location : dict[str, str] = {value.map_name:key for key, value in item_location_table.items()} ratman_den_locations_table: dict[str, Portal2LocationData] = { - "Ratman Den 1": Portal2LocationData("sp_a1_intro4", LocationType.RATMAN_DEN, [weighted_cube, floor_button]), - "Ratman Den 2": Portal2LocationData("sp_a2_dual_lasers", LocationType.RATMAN_DEN), - "Ratman Den 3": Portal2LocationData("sp_a2_trust_fling", LocationType.RATMAN_DEN, [portal_gun_2, faith_plate]), - "Ratman Den 4": Portal2LocationData("sp_a2_bridge_intro", LocationType.RATMAN_DEN), - "Ratman Den 5": Portal2LocationData("sp_a2_bridge_the_gap", LocationType.RATMAN_DEN, [portal_gun_2, bridge]), - "Ratman Den 6": Portal2LocationData("sp_a2_laser_vs_turret", LocationType.RATMAN_DEN, [portal_gun_2, laser, floor_button, reflection_cube]), - "Ratman Den 7": Portal2LocationData("sp_a2_pull_the_rug", LocationType.RATMAN_DEN, [portal_gun_2, bridge]) + ratman_den_1_smooth_jazz: Portal2LocationData("sp_a1_intro4", LocationType.RATMAN_DEN, [weighted_cube, floor_button]), + ratman_den_2_dual_lasers: Portal2LocationData("sp_a2_dual_lasers", LocationType.RATMAN_DEN), + ratman_den_3_trust_fling: Portal2LocationData("sp_a2_trust_fling", LocationType.RATMAN_DEN, [portal_gun_2, faith_plate]), + ratman_den_4_bridge_intro: Portal2LocationData("sp_a2_bridge_intro", LocationType.RATMAN_DEN), + ratman_den_5_bridge_the_gap: Portal2LocationData("sp_a2_bridge_the_gap", LocationType.RATMAN_DEN, [portal_gun_2, bridge]), + ratman_den_6_laser_vs_turret: Portal2LocationData("sp_a2_laser_vs_turret", LocationType.RATMAN_DEN, [portal_gun_2, laser, floor_button, reflection_cube]), + ratman_den_7_pull_the_rug: Portal2LocationData("sp_a2_pull_the_rug", LocationType.RATMAN_DEN, [portal_gun_2, bridge]) } ratman_map_to_ratman_den: dict[str, str] = {value.map_name: key for key, value in ratman_den_locations_table.items()} vitrified_door_locations_table: dict[str, Portal2LocationData] = { - "Vitrified Door 1": Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), - "Vitrified Door 2": Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), - "Vitrified Door 3": Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), - "Vitrified Door 4": Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), - "Vitrified Door 5": Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), - "Vitrified Door 6": Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_1_cave_johnson: Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_2_cave_johnson: Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_3_cave_johnson: Portal2LocationData("sp_a3_03", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_4_potatos: Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_5_potatos: Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), + vitrified_door_6_potatos: Portal2LocationData("sp_a3_transition01", LocationType.OTHER, [portal_gun_2], 6), } vitrified_map_to_vitrified_door: dict[str, list[str]] = { - "sp_a3_03": ["Vitrified Door 1", "Vitrified Door 2", "Vitrified Door 3"], - "sp_a3_transition01": ["Vitrified Door 4", "Vitrified Door 5", "Vitrified Door 6"] + "sp_a3_03": [vitrified_door_1_cave_johnson, vitrified_door_2_cave_johnson, vitrified_door_3_cave_johnson], + "sp_a3_transition01": [vitrified_door_4_potatos, vitrified_door_5_potatos, vitrified_door_6_potatos] } all_locations_table: dict[str, Portal2LocationData] = map_complete_table.copy() @@ -221,87 +222,87 @@ class Portal2Location(Location): # Alternate logic for speedrunners speedrun_logic_table: dict[str, list[str]] = { # Chapter 1 - "Portal Carousel Completion": [button, floor_button], - "Smooth Jazz Completion": [floor_button], - "Cube Momentum Completion": [floor_button], - "Future Starter Completion": [floor_button], - "Incinerator Completion": [weighted_cube], + portal_carousel_completion: [button, floor_button], + smooth_jazz_completion: [floor_button], + cube_momentum_completion: [floor_button], + future_starter_completion: [floor_button], + incinerator_completion: [weighted_cube], # Chapter 2 - "Laser Intro Completion": [portal_gun_2], - "Laser Stairs Completion": [portal_gun_2, floor_button], - "Dual Lasers Completion": [portal_gun_2, laser, laser_catcher], - "Laser Over Goo Completion": [portal_gun_2, floor_button], - "Catapult Intro Completion": [portal_gun_2, floor_button], - "Trust Fling Completion": [portal_gun_2, faith_plate, floor_button], - "Pit Flings Completion": [portal_gun_2], - "Fizzler Intro Completion": [portal_gun_2, laser, laser_catcher], + laser_intro_completion: [portal_gun_2], + laser_stairs_completion: [portal_gun_2, floor_button], + dual_lasers_completion: [portal_gun_2, laser, laser_catcher], + laser_over_goo_completion: [portal_gun_2, floor_button], + catapult_intro_completion: [portal_gun_2, floor_button], + trust_fling_completion: [portal_gun_2, faith_plate, floor_button], + pit_flings_completion: [portal_gun_2], + fizzler_intro_completion: [portal_gun_2, laser, laser_catcher], # Chapter 3 - "Ricochet Completion": [portal_gun_2, weighted_cube, floor_button], - "Bridge Intro Completion": [portal_gun_2, floor_button], - "Bridge the Gap Completion": [weighted_cube, button, floor_button], - "Turret Intro Completion": [floor_button], - "Laser Relays Completion": [laser_relays, laser, reflection_cube], - "Turret Blocker Completion": [floor_button], - "Laser Vs. Turret Completion": [portal_gun_2], - "Pull The Rug Completion": [floor_button, weighted_cube, bridge, portal_gun_2], + ricochet_completion: [portal_gun_2, weighted_cube, floor_button], + bridge_intro_completion: [portal_gun_2, floor_button], + bridge_the_gap_completion: [weighted_cube, button, floor_button], + turret_intro_completion: [floor_button], + laser_relays_completion: [laser_relays, laser, reflection_cube], + turret_blocker_completion: [floor_button], + laser_vs_turret_completion: [portal_gun_2], + pull_the_rug_completion: [floor_button, weighted_cube, bridge, portal_gun_2], # Chapter 4 - "Column Blocker Completion": [portal_gun_2], - "Laser Chaining Completion": [reflection_cube, laser, laser_relays], - "Triple Laser Completion": [reflection_cube, portal_gun_2], - "Jailbreak Completion": [portal_gun_2, button, weighted_cube], - "Escape Completion": [], + column_blocker_completion: [portal_gun_2], + laser_chaining_completion: [reflection_cube, laser, laser_relays], + triple_laser_completion: [reflection_cube, portal_gun_2], + jailbreak_completion: [portal_gun_2, button, weighted_cube], + escape_completion: [], # Chapter 5 - "Turret Sabotage Completion": [portal_gun_2], - "Neurotoxin Sabotage Completion": [portal_gun_2], - "Core Completion": [turrets], + turret_sabotage_completion: [portal_gun_2], + neurotoxin_sabotage_completion: [portal_gun_2], + core_completion: [turrets], # Chapter 6 - "Repulsion Intro Completion": [blue_gel, old_floor_button, portal_gun_2], - "Bomb Flings Completion": [portal_gun_2, blue_gel, old_button], - "Crazy Box Completion": [portal_gun_2, old_floor_button], + repulsion_intro_completion: [blue_gel, old_floor_button, portal_gun_2], + bomb_flings_completion: [portal_gun_2, blue_gel, old_button], + crazy_box_completion: [portal_gun_2, old_floor_button], # Chapter 7 - "Propulsion Intro Completion": [portal_gun_2], - "Propulsion Flings Completion": [portal_gun_2, blue_gel], - "Conversion Intro Completion": [portal_gun_2], - "Three Gels Completion": [portal_gun_2, blue_gel], + propulsion_intro_completion: [portal_gun_2], + propulsion_flings_completion: [portal_gun_2, blue_gel], + conversion_intro_completion: [portal_gun_2], + three_gels_completion: [portal_gun_2, blue_gel], # Chapter 8 - "Funnel Intro Completion": [floor_button, funnel], - "Ceiling Button Completion": [floor_button, frankenturret, button, portal_gun_2], - "Wall Button Completion": [floor_button, funnel, portal_gun_2], - "Polarity Completion": [portal_gun_2, funnel], - "Funnel Catch Completion": [portal_gun_2], - "Stop The Box Completion": [floor_button, portal_gun_2], - "Laser Catapult Completion": [portal_gun_2], - "Laser Platform Completion": [portal_gun_2, funnel], - "Propulsion Catch Completion": [floor_button, funnel], - "Repulsion Polarity Completion": [turrets, button, blue_gel], + funnel_intro_completion: [floor_button, funnel], + ceiling_button_completion: [floor_button, frankenturret, button, portal_gun_2], + wall_button_completion: [floor_button, funnel, portal_gun_2], + polarity_completion: [portal_gun_2, funnel], + funnel_catch_completion: [portal_gun_2], + stop_the_box_completion: [floor_button, portal_gun_2], + laser_catapult_completion: [portal_gun_2], + laser_platform_completion: [portal_gun_2, funnel], + propulsion_catch_completion: [floor_button, funnel], + repulsion_polarity_completion: [turrets, button, blue_gel], # Chapter 9 - "Finale 1 Completion": [portal_gun_2, frankenturret, faith_plate], - "Finale 2 Completion": [portal_gun_2], - "Finale 3 Completion": [portal_gun_2, funnel], - "Finale 4 Completion": [portal_gun_2, potatos, white_gel, adventure_core, space_core, fact_core], + finale_1_completion: [portal_gun_2, frankenturret, faith_plate], + finale_2_completion: [portal_gun_2], + finale_3_completion: [portal_gun_2, funnel], + finale_4_completion: [portal_gun_2, potatos, white_gel, adventure_core, space_core, fact_core], } sub_locations_in_maps: dict[str, list[str]] = { - "Portal Gun Completion": [portal_gun_1], - "Incinerator Completion": [portal_gun_2], - "PotatOS Completion": [potatos, "Vitrified Door 4", "Vitrified Door 5", "Vitrified Door 6"], - "Funnel Intro Completion": ["Wheatley Monitor 1"], - "Ceiling Button Completion": ["Wheatley Monitor 2"], - "Wall Button Completion": ["Wheatley Monitor 3"], - "Polarity Completion": ["Wheatley Monitor 4"], - "Funnel Catch Completion": ["Wheatley Monitor 5", "Wheatley Monitor 6"], - "Stop The Box Completion": ["Wheatley Monitor 7"], - "Laser Catapult Completion": ["Wheatley Monitor 8"], - "Laser Platform Completion": ["Wheatley Monitor 9"], - "Propulsion Catch Completion": ["Wheatley Monitor 10"], - "Repulsion Polarity Completion": ["Wheatley Monitor 11"], - "Finale 3 Completion": ["Wheatley Monitor 12"], - "Smooth Jazz Completion": ["Ratman Den 1"], - "Dual Lasers Completion": ["Ratman Den 2"], - "Trust Fling Completion": ["Ratman Den 3"], - "Bridge Intro Completion": ["Ratman Den 4"], - "Bridge the Gap Completion": ["Ratman Den 5"], - "Laser Vs. Turret Completion": ["Ratman Den 6"], - "Pull The Rug Completion": ["Ratman Den 7"], - "Cave Johnson Completion": ["Vitrified Door 1", "Vitrified Door 2", "Vitrified Door 3"], + portal_gun_completion: [portal_gun_1], + incinerator_completion: [portal_gun_2], + potatos_completion: [potatos, vitrified_door_4_potatos, vitrified_door_5_potatos, vitrified_door_6_potatos], + funnel_intro_completion: [wheatley_monitor_1_funnel_intro], + ceiling_button_completion: [wheatley_monitor_2_ceiling_button], + wall_button_completion: [wheatley_monitor_3_wall_button], + polarity_completion: [wheatley_monitor_4_polarity], + funnel_catch_completion: [wheatley_monitor_5_funnel_catch, wheatley_monitor_6_funnel_catch], + stop_the_box_completion: [wheatley_monitor_7_stop_the_box], + laser_catapult_completion: [wheatley_monitor_8_laser_catapult], + laser_platform_completion: [wheatley_monitor_9_laser_platform], + propulsion_catch_completion: [wheatley_monitor_10_propulsion_catch], + repulsion_polarity_completion: [wheatley_monitor_11_repulsion_polarity], + finale_3_completion: [wheatley_monitor_12_finale_3], + smooth_jazz_completion: [ratman_den_1_smooth_jazz], + dual_lasers_completion: [ratman_den_2_dual_lasers], + trust_fling_completion: [ratman_den_3_trust_fling], + bridge_intro_completion: [ratman_den_4_bridge_intro], + bridge_the_gap_completion: [ratman_den_5_bridge_the_gap], + laser_vs_turret_completion: [ratman_den_6_laser_vs_turret], + pull_the_rug_completion: [ratman_den_7_pull_the_rug], + cave_johnson_completion: [vitrified_door_1_cave_johnson, vitrified_door_2_cave_johnson, vitrified_door_3_cave_johnson], } diff --git a/worlds/portal2/archipelago.json b/worlds/portal2/archipelago.json index 678c4945733..5053d4a887e 100644 --- a/worlds/portal2/archipelago.json +++ b/worlds/portal2/archipelago.json @@ -2,5 +2,5 @@ "game": "Portal 2", "authors": [ "GlassToadstool" ], "minimum_ap_version": "0.6.5", - "world_version": "0.7.3" + "world_version": "0.8.0" } \ No newline at end of file diff --git a/worlds/portal2/client/P2Context.py b/worlds/portal2/client/P2Context.py new file mode 100644 index 00000000000..d879b9b7de3 --- /dev/null +++ b/worlds/portal2/client/P2Context.py @@ -0,0 +1,380 @@ +tracker_loaded = False +try: + from worlds.tracker.TrackerClient import ( + TrackerGameContext as CommonContext, + TrackerCommandProcessor as ClientCommandProcessor, + ) + + tracker_loaded = True +except ModuleNotFoundError: + from CommonClient import CommonContext, ClientCommandProcessor +import asyncio +import logging + +from Utils import async_start +from kvui import GameManager, ScrollBox +from kivy.metrics import dp +from kivy.uix.behaviors import ButtonBehavior +from kivymd.uix.boxlayout import MDBoxLayout +from kivymd.uix.gridlayout import MDGridLayout +from kivymd.uix.button import MDButton, MDButtonText, MDIconButton +from kivymd.uix.label import MDLabel + +from .. import Portal2World + +HOST = "localhost" +PORT = int(Portal2World.settings.default_portal2_port) + +logger = logging.getLogger("Portal2Client") + + +async def send_instant_command(command: str): + try: + _, writer = await asyncio.open_connection(HOST, PORT) + writer.write((command + "\n").encode()) + await writer.drain() + writer.close() + await writer.wait_closed() + except: + logger.error(f"Connection to portal 2 failed for instant command") + + +class P2ClientCommandProcessor(ClientCommandProcessor): + + def __init__(self, context: "P2CommonContext"): + super().__init__(context) + + +class MapInfo(MDGridLayout): + + def __init__(self, map_data: dict): + super().__init__(rows=2, cols=1) + self.map_data = map_data + self.build() + + def build(self): + chapter_info_string = f"{self.map_data["title"]}\n\nRequired Items:\n" + + if self.map_data["required_items"]: + chapter_info_string += ", ".join(self.map_data["required_items"]) + else: + chapter_info_string += "All required items acquired" + + chapter_info_string += "\n\n" + + if self.map_data["sub_locations"]: + chapter_info_string += "Sub locations:\n" + sub_locations_incomplete = [ + name + for name, complete in self.map_data["sub_locations"].items() + if not complete + ] + if sub_locations_incomplete: + chapter_info_string += ", ".join(sub_locations_incomplete) + else: + chapter_info_string += "All sublocations completed" + + self.chapter_info = MDLabel(text=chapter_info_string) + + if self.map_data["disabled"]: + self.play_map_button = MDButton( + MDButtonText(text="Map not yet available"), disabled=True + ) + else: + self.play_map_button = MDButton( + MDButtonText(text="Play Map"), on_release=lambda btn: self.play_map() + ) + + # Add all these to the layout + self.add_widget(self.chapter_info) + self.add_widget(self.play_map_button) + + def play_map(self): + """ + Send map command to the game to load the selected map + """ + + async_start( + send_instant_command(f"{self.map_data['command']}"), "send_map_command" + ) + + +class SelectableButton(ButtonBehavior, MDBoxLayout): + def __init__(self, name_text: str, count_text: str, on_release): + self.name = name_text + super().__init__( + orientation="horizontal", + padding=[dp(12), dp(8)], + spacing=dp(8), + size_hint_y=None, + height=dp(40), + width=dp(220), + size_hint_x=None, + md_bg_color=[1, 1, 1, 0.12], + radius=dp(6), + ) + + self.name_label = MDLabel( + text=name_text, + width=dp(150), + size_hint_x=None, + halign="left" + ) + self.count_label = MDLabel( + text=count_text, + halign="right", + ) + + self.add_widget(self.name_label) + self.add_widget(self.count_label) + + if on_release is not None: + self.bind(on_release=on_release) + + + def select(self): + self.md_bg_color = [1, 1, 1, 0.3] + + def deselect(self): + self.md_bg_color=[1, 1, 1, 0.12] + + +class ChapterButton(SelectableButton): + + def __init__(self, chapter_name: str, chapter_maps: list, on_release): + self.chapter_name = chapter_name + self.chapter_maps = chapter_maps + finished_checks, total_checks = self.calculate_completeness() + + super().__init__(self.chapter_name, f"{finished_checks}/{total_checks}", on_release) + + + def calculate_completeness(self) -> tuple: + total_checks = 0 + finished_checks = 0 + for map in self.chapter_maps: + total_checks += map["total_locations"] + finished_checks += map["finished_locations"] + + return finished_checks, total_checks + + def update_title(self, chapter_maps: list): + self.chapter_maps = chapter_maps + finished_checks, total_checks = self.calculate_completeness() + self.count_label.text = f"{finished_checks}/{total_checks}" + + +class MenuLayout(MDGridLayout): + + def __init__(self): + super().__init__(rows=1, cols=3, padding=[40, 10], spacing=dp(10)) + self.menu_info = {} + self.selected_chapter_btn: ChapterButton = None + self.selected_map_btn: SelectableButton = None + self.map_area = None + self.map_info = None + self.is_open_world = False + self.return_to_menu = False + self.chapter_buttons: list[ChapterButton] = [] + self.map_buttons: list[SelectableButton] = [] + self.built = False + + def update_menu(self, menu_data: dict[str, list], map_finished: bool = False): + """ + - Set the map data + - Update the menu + """ + self.menu_info = menu_data + + self.refresh_chapter_titles() + + if self.map_area and self.selected_chapter_btn: + self.select_chapter(self.selected_chapter_btn.name, self.selected_chapter_btn) + + if self.selected_map_btn: + if not self.return_to_menu and map_finished: + # Try to select next map in chapter + current_chapter = next((m for m in self.map_buttons if m.name == self.selected_map_btn.name), None) + if current_chapter: + index = self.map_buttons.index(current_chapter) + if index + 1 < len(self.map_buttons): + self.select_map(self.map_buttons[index+1].name, self.map_buttons[index+1]) + else: + self.select_map(self.selected_map_btn.name) + + def refresh_chapter_titles(self): + for cb in self.chapter_buttons: + cb.update_title(self.menu_info[cb.chapter_name]) + + def set_open_world(self): + self.is_open_world = True + + def build(self): + """ + - List of chapter buttons on the left side + - Add a dynamic list of map buttons on the right side of the grid that updates based on the selected chapter + """ + + if self.built: + return + + self.built = True + + if self.menu_info is None: + raise Exception( + "Menu data not set. Call update_menu() once before build()." + ) + + self.clear_widgets() + self.chapter_area = ScrollBox() + self.chapter_area.layout.orientation = "vertical" + self.chapter_area.layout.spacing = dp(3) + self.chapter_area.scroll_type = ["bars"] + self.chapter_area.do_scroll_x = False + self.add_widget(self.chapter_area) + + self.map_area = ScrollBox() + self.map_area.layout.orientation = "vertical" + self.map_area.layout.spacing = dp(3) + self.map_area.scroll_type = ["bars"] + self.map_area.do_scroll_x = False + self.add_widget(self.map_area) + + for chapter_name, maps in self.menu_info.items(): + chapter_button = ChapterButton( + chapter_name, + maps, + lambda btn, chapter=chapter_name: self.select_chapter(chapter, btn), + ) + self.chapter_buttons.append(chapter_button) + self.chapter_area.layout.add_widget(chapter_button) + + menu_toggle_box = MDGridLayout( + cols=2, + row_default_height=40, + row_force_default=True, + padding=dp(10), + md_bg_color=[1, 1, 1, 0.1], + width=dp(220), + size_hint_x=None, + height=dp(60), + size_hint_y=None, + radius=dp(10), + ) + self.auto_next_map_button = MDIconButton( + icon="checkbox-blank-outline", on_release=self.toggle_switch + ) + button_label = MDLabel(text="Return to menu on map finish: ") + menu_toggle_box.add_widget(button_label) + menu_toggle_box.add_widget(self.auto_next_map_button) + self.chapter_area.layout.add_widget(menu_toggle_box) + + def select_chapter(self, chapter_name: str, btn: ChapterButton = None): + """ + - Remove the old map buttons + - Add the list of new map buttons + """ + + if self.selected_chapter_btn: + self.selected_chapter_btn.deselect() + + if btn: + self.selected_chapter_btn = btn + self.selected_chapter_btn.select() + + if self.map_area is None: + raise Exception( + "Map area not initialized. Call build() before select_chapter()." + ) + + + for child in self.map_area.layout.children[:]: + self.map_area.layout.remove_widget(child) + + if not self.menu_info: + no_maps_label = MDLabel(text="No maps available for this chapter") + self.map_area.layout.add_widget(no_maps_label) + return + + self.map_buttons = [] + map_data = self.menu_info[chapter_name] + disable_map = False + for map in map_data: + map_button = SelectableButton( + map['title'], + f"{map["finished_locations"]}/{map["total_locations"]}", + on_release=lambda btn, _map_name=map["title"]: self.select_map( + _map_name, btn + ), + ) + self.map_buttons.append(map_button) + self.map_area.layout.add_widget(map_button) + map["disabled"] = disable_map + if not self.is_open_world: + disable_map = not map["completed"] + + def select_map(self, map_name: str, btn: SelectableButton = None): + """ + - Handle the selection of a map button + - Send map command to the game to load the selected map + """ + + if self.selected_map_btn: + self.selected_map_btn.deselect() + + if btn: + self.selected_map_btn = btn + else: + possible_buttons = [btn for btn in self.map_buttons if btn.name == map_name] + if len(possible_buttons) > 0: + self.selected_map_btn = possible_buttons[0] + + self.selected_map_btn.select() + + + maps = self.menu_info[self.selected_chapter_btn.chapter_name] + map_data = next((map for map in maps if map["title"] == map_name), None) + + if not map_data: + print(f"Map '{map_name}' not found in chapter '{self.selected_chapter_btn.chapter_name}'") + return + + # Replace the map info area + if self.map_info: + self.remove_widget(self.map_info) + + self.map_info = MapInfo(map_data) + self.add_widget(self.map_info) + + def toggle_switch(self, instance): + self.return_to_menu = not self.return_to_menu + if self.return_to_menu: + self.auto_next_map_button.icon = "checkbox-outline" + else: + self.auto_next_map_button.icon = "checkbox-blank-outline" + + +class P2GameManager(GameManager): + + def build(self): + container = super().build() + + game_menu = self.add_client_tab("Maps", MenuLayout()) + self.log_panels["Maps"] = game_menu.content + + return container + + +class P2CommonContext(CommonContext): + + def make_gui(self) -> "type[kvui.GameManager]": + ui = super().make_gui() + + class TextManager(ui, P2GameManager): + base_title = "Portal 2 Text Client" + icon = r"worlds/portal2/data/Portalpelago.png" + + return TextManager + + def get_menu(self) -> "MenuLayout": + return self.ui.log_panels["Maps"] diff --git a/worlds/portal2/client/Portal2Client.py b/worlds/portal2/client/Portal2Client.py index eddc04d688d..e8ce59819fd 100644 --- a/worlds/portal2/client/Portal2Client.py +++ b/worlds/portal2/client/Portal2Client.py @@ -5,19 +5,14 @@ import time import typing -tracker_loaded = False -try: - from worlds.tracker.TrackerClient import TrackerGameContext as CommonContext, TrackerCommandProcessor as ClientCommandProcessor - tracker_loaded = True -except ModuleNotFoundError: - from CommonClient import CommonContext, ClientCommandProcessor +from .P2Context import MenuLayout, P2CommonContext as CommonContext, P2ClientCommandProcessor as ClientCommandProcessor, tracker_loaded, HOST, PORT, send_instant_command from CommonClient import server_loop, logger, gui_enabled from NetUtils import ClientStatus, NetworkItem from Utils import async_start, init_logging from ..mod_helpers.ItemHandling import add_ratman_commands, handle_item, handle_map_start, handle_trap, portal_gun_upgrade_not_inplace, potatos_not_inplace -from ..mod_helpers.MapMenu import Menu +from ..mod_helpers.MapMenu import GameMapMenu from .DeathMessages import get_death_message from ..Locations import location_names_to_map_codes, map_codes_to_location_names, wheatley_maps_to_monitor_names, all_locations_table, wheatley_monitor_table, ratman_den_locations_table from .. import Portal2World @@ -36,7 +31,7 @@ def _cmd_check_connection(self): def _cmd_command(self, *command): """Sends a command to the game. Should not be used unless you get softlocked""" - self.ctx.command_queue.append(' '.join(command) + "\n") + async_start(send_instant_command(' '.join(command)), "send_command") def _cmd_deathlink(self): """Toggles death link for this client""" @@ -74,13 +69,7 @@ def _cmd_needed(self, *location_name): f"{"All items acquired" if not requirements_not_collected else "Still needed: \n" + ", ".join(requirements_not_collected)}") break self.output(message) - - def _cmd_ping(self): - async def player_in_map(compro): - is_in_map = await compro.ctx.is_player_in_map() - compro.output("pong" if is_in_map else "no pong recieved from server") - loop = asyncio.get_event_loop() - loop.create_task(player_in_map(self)) + class Portal2Context(CommonContext): command_processor = Portal2CommandProcessor @@ -90,9 +79,6 @@ class Portal2Context(CommonContext): tags = {"AP"} items_handling = 0b111 # receive all items for /received - HOST = "localhost" - PORT = int(Portal2World.settings.default_portal2_port) - death_link_active = False goal_map_code = "" @@ -106,7 +92,8 @@ class Portal2Context(CommonContext): location_name_to_id: dict[str, int] = None - menu: Menu = None + game_map_menu: GameMapMenu = None + client_map_menu: MenuLayout = None def alert_game_connection(self): if self.check_game_connection(): @@ -120,15 +107,19 @@ def create_level_begin_command(self): def update_menu(self, location_id: int = None): menu_file = Portal2World.settings.menu_file + check_completed = False if location_id is not None: - self.menu.complete_check(location_id) + check_completed = self.game_map_menu.complete_check(location_id) # Write the menu to that file with open(menu_file, "w", encoding='utf-8') as f: - f.write(str(self.menu)) + f.write(str(self.game_map_menu)) + + self.client_map_menu.update_menu(self.game_map_menu.get_menu_info(), type(check_completed) == str) + return check_completed def refresh_menu(self): for location_id in self.checked_locations: - self.menu.complete_check(location_id) + self.game_map_menu.complete_check(location_id) self.update_menu() def add_to_in_game_message_queue(self, message: str, color_string: str = None) -> None: @@ -139,7 +130,7 @@ async def p2_message_listener(self): try: while True: try: - reader, writer = await asyncio.open_connection(self.HOST, self.PORT) + reader, writer = await asyncio.open_connection(HOST, PORT) except ConnectionRefusedError: self.listener_active = False await asyncio.sleep(self.current_reconnect_delay) @@ -178,7 +169,7 @@ async def p2_command_sender(self): try: while True: try: - _, writer = await asyncio.open_connection(self.HOST, self.PORT) + _, writer = await asyncio.open_connection(HOST, PORT) except ConnectionRefusedError: self.sender_active = False await asyncio.sleep(self.current_reconnect_delay) @@ -232,20 +223,24 @@ async def p2_command_sender(self): async def is_player_in_map(self): try: - reader, writer = await asyncio.open_connection(self.HOST, self.PORT) + reader, writer = await asyncio.open_connection(HOST, PORT) ping = 'script printl("Pong")\n' writer.write(ping.encode()) await writer.drain() data = await asyncio.wait_for(reader.read(1000), timeout=0.5) pong = data.decode(errors="ignore").replace("\'", "").split('\r\n') - writer.close() - await writer.wait_closed() if pong and pong[0] == "Pong": return True return False + except asyncio.CancelledError: + logger.info("Game pinger closed from cancellation") + raise except: return False + finally: + writer.close() + await writer.wait_closed() async def handle_message(self, message: str): if message.startswith("map_name:"): @@ -258,13 +253,19 @@ async def handle_message(self, message: str): # For map complete checks elif message.startswith("map_complete:"): done_map = message.split(':', 1)[1] - if done_map == self.goal_map_code: - await self.handle_goal_completion() map_id = self.map_code_to_location_id(done_map) if map_id: await self.check_locations([map_id]) - self.update_menu(map_id) + next_map = self.update_menu(map_id) + + if done_map == self.goal_map_code: + await self.handle_goal_completion() + else: + if not self.client_map_menu.return_to_menu and type(next_map) == str: + await send_instant_command(f"changelevel {next_map}") + else: + await send_instant_command("disconnect;startupmenu force") # All other checks # Item checks e.g. portal gun upgrade, potatos @@ -365,27 +366,30 @@ def handle_slot_data(self, slot_data: dict): if "chapter_dict" in slot_data: if "logic_difficulty" in slot_data: - self.menu = Menu(slot_data["chapter_dict"], self, logic_difficulty=slot_data["logic_difficulty"]) + self.game_map_menu = GameMapMenu(slot_data["chapter_dict"], self, logic_difficulty=slot_data["logic_difficulty"]) else: - self.menu = Menu(slot_data["chapter_dict"], self) + self.game_map_menu = GameMapMenu(slot_data["chapter_dict"], self) + else: raise Exception("chapter_dict not found in slot data") if "game_mode" in slot_data: - self.menu.is_open_world = slot_data["game_mode"] == GameModeOption.OPEN_WORLD + if slot_data["game_mode"] == GameModeOption.OPEN_WORLD: + self.game_map_menu.is_open_world = True + self.get_menu().set_open_world() if "wheatley_monitors" in slot_data: if slot_data["wheatley_monitors"]: - self.menu.has_wheatley_monitors = True + self.game_map_menu.has_wheatley_monitors = True if "ratman_dens" in slot_data: if slot_data["ratman_dens"]: add_ratman_commands() - self.menu.has_ratman_dens = True + self.game_map_menu.has_ratman_dens = True if "vitrified_doors" in slot_data: if slot_data["vitrified_doors"]: - self.menu.has_vitrified_doors = True + self.game_map_menu.has_vitrified_doors = True # Don't remove the portal gun upgrade after pickup if "portal_gun_upgrade_inplace" not in slot_data: @@ -395,8 +399,11 @@ def handle_slot_data(self, slot_data: dict): if "potatos_inplace" not in slot_data: potatos_not_inplace() - self.menu.generate_menu() + self.game_map_menu.generate_menu() + if not self.client_map_menu: + self.client_map_menu = self.get_menu() self.refresh_menu() + self.client_map_menu.build() def on_package(self, cmd, args): super().on_package(cmd, args) @@ -463,14 +470,7 @@ def update_item_remove_commands(self): self.item_remove_commands = temp_commands - def make_gui(self): - from kvui import GameManager - ui = super().make_gui() - ui.base_title = "Portal 2 Text Client" - ui.icon = r"worlds/portal2/data/Portalpelago.png" - - return ui - + async def shutdown(self): self.server_address = "" self.username = None diff --git a/worlds/portal2/mod_helpers/ItemHandling.py b/worlds/portal2/mod_helpers/ItemHandling.py index cfe17512b53..0c1ff6ac245 100644 --- a/worlds/portal2/mod_helpers/ItemHandling.py +++ b/worlds/portal2/mod_helpers/ItemHandling.py @@ -3,6 +3,7 @@ from ..ItemNames import motion_blur_trap, fizzle_portal_trap, butter_fingers_trap from .Gels import * from ..Locations import wheatley_monitor_table, LocationType +from ..LocationNames import * # Constants DELETE_CUBE = ItemTag.CUBE | ItemTag.DELETE @@ -157,17 +158,17 @@ def potatos_not_inplace(): def portal_gun_upgrade_not_inplace(): global map_specific_commands - map_specific_commands.append(MapCommand("sp_a2_intro", portal_gun_2, ["script InciniratorDisablePortalGun()\n"])) + map_specific_commands.append(MapCommand("sp_a2_intro", portal_gun_2, ["script IncineratorDisablePortalGun()\n"])) # Option based commands ratman_den_commands: list[MapCommand] = [ - MapCommand("sp_a1_intro4", None, ['script CreateAPButton("Ratman Den 1", Vector(847, -703, 320-65), Vector(0,-90,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_dual_lasers", None, ['script CreateAPButton("Ratman Den 2", Vector(438, -636, 827-65), Vector(0,135,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_trust_fling", None, ['script CreateAPButton("Ratman Den 3", Vector(2045, 82, 254-65), Vector(0,-135,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_bridge_intro", None, ['script CreateAPButton("Ratman Den 4", Vector(612, -618, 64-65), Vector(0,-135,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_bridge_the_gap", None, ['script CreateAPButton("Ratman Den 5", Vector(-128, -270, 1756-65), Vector(0,90,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_laser_vs_turret", None, ['script CreateAPButton("Ratman Den 6", Vector(850, -720, 222-65), Vector(0,180,0), 0.8)\n'], LocationType.RATMAN_DEN), - MapCommand("sp_a2_pull_the_rug", None, ['script CreateAPButton("Ratman Den 7", Vector(63, -1158, 550-65), Vector(0,45,0), 0.8)\n'], LocationType.RATMAN_DEN) + MapCommand("sp_a1_intro4", None, [f'script CreateAPButton("{ratman_den_1_smooth_jazz}", Vector(847, -703, 320-65), Vector(0,-90,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_dual_lasers", None, [f'script CreateAPButton("{ratman_den_2_dual_lasers}", Vector(438, -636, 827-65), Vector(0,135,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_trust_fling", None, [f'script CreateAPButton("{ratman_den_3_trust_fling}", Vector(2045, 82, 254-65), Vector(0,-135,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_bridge_intro", None, [f'script CreateAPButton("{ratman_den_4_bridge_intro}", Vector(612, -618, 64-65), Vector(0,-135,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_bridge_the_gap", None, [f'script CreateAPButton("{ratman_den_5_bridge_the_gap}", Vector(-128, -270, 1756-65), Vector(0,90,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_laser_vs_turret", None, [f'script CreateAPButton("{ratman_den_6_laser_vs_turret}", Vector(850, -720, 222-65), Vector(0,180,0), 0.8)\n'], LocationType.RATMAN_DEN), + MapCommand("sp_a2_pull_the_rug", None, [f'script CreateAPButton("{ratman_den_7_pull_the_rug}", Vector(63, -1158, 550-65), Vector(0,45,0), 0.8)\n'], LocationType.RATMAN_DEN) ] def add_ratman_commands(): diff --git a/worlds/portal2/mod_helpers/MapMenu.py b/worlds/portal2/mod_helpers/MapMenu.py index 30b845ab2ba..8144722ae43 100644 --- a/worlds/portal2/mod_helpers/MapMenu.py +++ b/worlds/portal2/mod_helpers/MapMenu.py @@ -94,6 +94,7 @@ class MapMenuElement(MenuElement): def __init__(self, parent, chapter_number, map_number, title, map_code, location_id, required_items, pic): self.location_id = location_id self.required_items = required_items + self.map_code = map_code self.sub_location_completion = get_sub_locations( title, parent.parent.has_wheatley_monitors, parent.parent.has_ratman_dens, parent.parent.has_vitrified_doors ) @@ -101,6 +102,7 @@ def __init__(self, parent, chapter_number, map_number, title, map_code, location new_title = title.removesuffix(" Completion") super().__init__(parent, f"chapter {chapter_number}.{map_number}", new_title, subtitle, f"map {map_code}", pic) self.info_text = indicator_characters["map"] + parse_sub_locations(self.sub_location_completion) + self.total_locations = len(self.sub_location_completion) + 1 def refresh_title(self, blocked: bool = False): self.info_text = indicator_characters["completed"] if self.completed else indicator_characters["map"] @@ -131,15 +133,27 @@ def get_string(self, previous_completed: bool): text = text + self.next_map.get_string(self.completed) return text - - def complete_map(self, map_id: int) -> bool: + + def get_chapter_info(self): + info = { + "completed": self.completed, + "sub_locations": self.sub_location_completion, + "required_items": [item for item in self.required_items if item in self.parent.parent.client.item_list], + "location_id": self.location_id, + "title": self.title[2:], + "command": self.command, + "total_locations": self.total_locations, + "finished_locations": (1 if self.completed else 0) + len([name for name, complete in self.sub_location_completion.items() if complete]) + } + return info + + def complete_map(self, map_id: int) -> str | bool: if self.location_id == map_id: - if self.completed: - return True self.completed = True self.refresh_title() if self.next_map: self.next_map.command = self.next_map.command.replace("command_deactivated", "command") + return self.next_map.map_code return True else: if self.next_map: @@ -151,14 +165,21 @@ def complete_sub_location_check(self, sub_location: str): if sub_location in self.sub_location_completion: self.sub_location_completion[sub_location] = True self.refresh_title() + return True elif self.next_map: - self.next_map.complete_sub_location_check(sub_location) + return self.next_map.complete_sub_location_check(sub_location) + return False + + def complete_check(self, location_id: int) -> str | bool: + map_complete = self.complete_map(location_id) + if map_complete: + return map_complete + + location_name = self.parent.parent.client.location_names.lookup_in_game(location_id) + if "Complete" not in location_name: + return self.complete_sub_location_check(location_name) + return False - def complete_check(self, location_id: int): - if not self.complete_map(location_id): - location_name = self.parent.parent.client.location_names.lookup_in_game(location_id) - if "Complete" not in location_name: - self.complete_sub_location_check(location_name) blank_map_element = lambda parent, chapter_number: MapMenuElement(parent, chapter_number, 0, "No Maps In This Chapter", "", -1, [], "") @@ -237,12 +258,26 @@ def complete_sub_location_check(self, sub_location: str): if self.first_map: self.first_map.complete_sub_location_check(sub_location) - def complete_check(self, location_id: int): + def complete_check(self, location_id: int) -> str | bool: if self.first_map: - self.first_map.complete_check(location_id) - - -class Menu: + return self.first_map.complete_check(location_id) + return False + + def get_chapter_info(self): + maps = [] + current_map = self.first_map + while current_map: + maps.append(current_map.get_chapter_info()) + current_map = current_map.next_map + + info = { + "chapter_name": self.title, + "maps": maps + } + return info + + +class GameMapMenu: chapters: list[ChapterMenuElement] = [] def __init__( @@ -267,6 +302,8 @@ def __init__( self.chapter_dict = chapter_dict def generate_menu(self): + if self.chapters: + return for chapter_number, map_names in self.chapter_dict.items(): self.chapters.append(ChapterMenuElement(self, chapter_number, map_names)) @@ -281,6 +318,17 @@ def complete_sub_location_check(self, sub_location: str): for chapter in self.chapters: chapter.complete_sub_location_check(sub_location) - def complete_check(self, location_id: int): + def complete_check(self, location_id: int) -> str | bool: + for chapter in self.chapters: + found_check = chapter.complete_check(location_id) + if found_check: + return found_check + return False + + def get_menu_info(self) -> dict[str, list]: + menu_info = {} for chapter in self.chapters: - chapter.complete_check(location_id) + chapter_info = chapter.get_chapter_info() + menu_info[chapter_info["chapter_name"]] = chapter_info["maps"] + return menu_info + \ No newline at end of file diff --git a/worlds/portal2/test/test_base_menu.py b/worlds/portal2/test/test_base_menu.py index 78dafaf737e..565c6809e96 100644 --- a/worlds/portal2/test/test_base_menu.py +++ b/worlds/portal2/test/test_base_menu.py @@ -2,7 +2,7 @@ from .bases import Portal2TestBase from ..Options import GameModeOption -from ..mod_helpers.MapMenu import Menu +from ..mod_helpers.MapMenu import GameMapMenu from ..Locations import all_locations_table class FakeClient: @@ -28,7 +28,7 @@ def test_menu_generation(self) -> None: slot_data = self.world.fill_slot_data() - menu = Menu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"]) + menu = GameMapMenu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"]) menu.generate_menu() # Check menu is generated where the first map of each chapter says "command" and the rest say "command_deactivated" menu_string = str(menu) @@ -36,7 +36,7 @@ def test_menu_generation(self) -> None: self.assertEqual(menu_string.count('"command"'), 18) def test_menu_no_maps(self) -> None: - menu = Menu({1: [], 2: [], 3: []}, self.client) + menu = GameMapMenu({1: [], 2: [], 3: []}, self.client) menu.generate_menu() menu_string = str(menu) # Check menu is generated where the first map of each chapter says "No Maps In This Chapter" diff --git a/worlds/portal2/test/test_menu_additional_checks.py b/worlds/portal2/test/test_menu_additional_checks.py index 314f4ff1350..c143b37c6ad 100644 --- a/worlds/portal2/test/test_menu_additional_checks.py +++ b/worlds/portal2/test/test_menu_additional_checks.py @@ -3,7 +3,7 @@ from .test_base_menu import FakeClient from .bases import Portal2TestBase from ..Options import GameModeOption -from ..mod_helpers.MapMenu import Menu +from ..mod_helpers.MapMenu import GameMapMenu from ..ItemNames import portal_gun_1, portal_gun_2, potatos from ..mod_helpers.MapMenu import indicator_characters @@ -29,7 +29,7 @@ def test_title_generation(self) -> None: slot_data = self.world.fill_slot_data() - menu = Menu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"], vitrified_doors=slot_data["vitrified_doors"]) + menu = GameMapMenu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"], vitrified_doors=slot_data["vitrified_doors"]) menu.generate_menu() menu_string = str(menu) # Find map that includes Wheatley Monitors in the title and check it is correct @@ -51,7 +51,7 @@ def test_sub_location_completion(self) -> None: slot_data = self.world.fill_slot_data() - menu = Menu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"]) + menu = GameMapMenu(slot_data["chapter_dict"], self.client, is_open_world=slot_data["game_mode"] == GameModeOption.OPEN_WORLD, logic_difficulty=slot_data["logic_difficulty"], wheatley_monitors=slot_data["wheatley_monitors"], ratman_dens=slot_data["ratman_dens"]) menu.generate_menu() # Complete a map with a sub location and check the title updates menu.complete_map(slot_data["location_name_to_id"]["Portal Gun Completion"])