| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | from BaseClasses import MultiWorld | 
					
						
							| 
									
										
										
										
											2022-10-01 15:24:05 +02:00
										 |  |  | from worlds.AutoWorld import LogicMixin | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  | from .Options import get_option_value | 
					
						
							|  |  |  | from .Items import get_basic_units, defense_ratings, zerg_defense_ratings | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SC2WoLLogic(LogicMixin): | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_common_unit(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return self.has_any(get_basic_units(multiworld, player), player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_air(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |         return self.has_any({'Viking', 'Wraith', 'Banshee', 'Battlecruiser'}, player) or get_option_value(multiworld, player, 'required_tactics') > 0 \ | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |                 and self.has_any({'Hercules', 'Medivac'}, player) and self._sc2wol_has_common_unit(multiworld, player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_air_anti_air(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         return self.has('Viking', player) \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 or self.has_all({'Wraith', 'Advanced Laser Technology (Wraith)'}, player) \ | 
					
						
							|  |  |  |                 or self.has_all({'Battlecruiser', 'ATX Laser Battery (Battlecruiser)'}, player) \ | 
					
						
							|  |  |  |                 or get_option_value(multiworld, player, 'required_tactics') > 0 and self.has_any({'Wraith', 'Valkyrie', 'Battlecruiser'}, player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |     def _sc2wol_has_competent_ground_to_air(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 |  |  |         return self.has('Goliath', player) \ | 
					
						
							|  |  |  |                 or self.has('Marine', player) and self.has_any({'Medic', 'Medivac'}, player) \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 or get_option_value(multiworld, player, 'required_tactics') > 0 and self.has('Cyclone', player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _sc2wol_has_competent_anti_air(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return self._sc2wol_has_competent_ground_to_air(multiworld, player) \ | 
					
						
							| 
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 |  |  |                 or self._sc2wol_has_air_anti_air(multiworld, player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |     def _sc2wol_welcome_to_the_jungle_requirement(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return ( | 
					
						
							|  |  |  |                 self._sc2wol_has_common_unit(multiworld, player) | 
					
						
							|  |  |  |                 and self._sc2wol_has_competent_ground_to_air(multiworld, player) | 
					
						
							|  |  |  |         ) or ( | 
					
						
							|  |  |  |                 get_option_value(multiworld, player, 'required_tactics') > 0 | 
					
						
							|  |  |  |                 and self.has_any({'Marine', 'Vulture'}, player) | 
					
						
							|  |  |  |                 and self._sc2wol_has_air_anti_air(multiworld, player) | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_anti_air(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |         return self.has_any({'Missile Turret', 'Thor', 'War Pigs', 'Spartan Company', "Hel's Angel", 'Battlecruiser', 'Marine', 'Wraith', 'Valkyrie', 'Cyclone'}, player) \ | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |                 or self._sc2wol_has_competent_anti_air(multiworld, player) \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 or get_option_value(multiworld, player, 'required_tactics') > 0 and self.has_any({'Ghost', 'Spectre', 'Widow Mine', 'Liberator'}, player) | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_defense_rating(self, multiworld: MultiWorld, player: int, zerg_enemy: bool, air_enemy: bool = True) -> bool: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         defense_score = sum((defense_ratings[item] for item in defense_ratings if self.has(item, player))) | 
					
						
							|  |  |  |         if self.has_any({'Marine', 'Marauder'}, player) and self.has('Bunker', player): | 
					
						
							|  |  |  |             defense_score += 3 | 
					
						
							| 
									
										
										
										
											2023-04-20 09:13:34 +02:00
										 |  |  |         if self.has_all({'Siege Tank', 'Maelstrom Rounds (Siege Tank)'}, player): | 
					
						
							| 
									
										
										
										
											2023-03-07 08:14:49 -05:00
										 |  |  |             defense_score += 2 | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |         if self.has_all({'Siege Tank', 'Graduating Range (Siege Tank)'}, player): | 
					
						
							|  |  |  |             defense_score += 1 | 
					
						
							|  |  |  |         if self.has_all({'Widow Mine', 'Concealment (Widow Mine)'}, player): | 
					
						
							|  |  |  |             defense_score += 1 | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         if zerg_enemy: | 
					
						
							|  |  |  |             defense_score += sum((zerg_defense_ratings[item] for item in zerg_defense_ratings if self.has(item, player))) | 
					
						
							|  |  |  |             if self.has('Firebat', player) and self.has('Bunker', player): | 
					
						
							|  |  |  |                 defense_score += 2 | 
					
						
							|  |  |  |         if not air_enemy and self.has('Missile Turret', player): | 
					
						
							|  |  |  |             defense_score -= defense_ratings['Missile Turret'] | 
					
						
							|  |  |  |         # Advanced Tactics bumps defense rating requirements down by 2 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |         if get_option_value(multiworld, player, 'required_tactics') > 0: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |             defense_score += 2 | 
					
						
							|  |  |  |         return defense_score | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_competent_comp(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |         return \ | 
					
						
							|  |  |  |                 ( | 
					
						
							|  |  |  |                         ( | 
					
						
							|  |  |  |                                 self.has_any({'Marine', 'Marauder'}, player) and self.has_any({'Medivac', 'Medic'}, player) | 
					
						
							|  |  |  |                                 or self.has_any({'Thor', 'Banshee', 'Siege Tank'}, player) | 
					
						
							|  |  |  |                                 or self.has_all({'Liberator', 'Raid Artillery (Liberator)'}, player) | 
					
						
							|  |  |  |                         ) and self._sc2wol_has_competent_anti_air(multiworld, player) | 
					
						
							|  |  |  |                 ) \ | 
					
						
							|  |  |  |                 or \ | 
					
						
							|  |  |  |                 ( | 
					
						
							|  |  |  |                         self.has('Battlecruiser', player) and self._sc2wol_has_common_unit(multiworld, player) | 
					
						
							|  |  |  |                 ) | 
					
						
							| 
									
										
										
										
											2022-05-20 20:47:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_train_killers(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-04-20 09:13:34 +02:00
										 |  |  |         return ( | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 self.has_any({'Siege Tank', 'Diamondback', 'Marauder', 'Cyclone'}, player) | 
					
						
							| 
									
										
										
										
											2023-04-20 09:13:34 +02:00
										 |  |  |                 or get_option_value(multiworld, player, 'required_tactics') > 0 | 
					
						
							|  |  |  |                 and ( | 
					
						
							|  |  |  |                         self.has_all({'Reaper', "G-4 Clusterbomb"}, player) | 
					
						
							|  |  |  |                         or self.has_all({'Spectre', 'Psionic Lash'}, player) | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                         or self.has_any({'Vulture', 'Liberator'}, player) | 
					
						
							| 
									
										
										
										
											2023-04-20 09:13:34 +02:00
										 |  |  |                 ) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_able_to_rescue(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return self.has_any({'Medivac', 'Hercules', 'Raven', 'Viking'}, player) or get_option_value(multiworld, player, 'required_tactics') > 0 | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_protoss_common_units(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         return self.has_any({'Zealot', 'Immortal', 'Stalker', 'Dark Templar'}, player) \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 or get_option_value(multiworld, player, 'required_tactics') > 0 and self.has('High Templar', player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_protoss_medium_units(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return self._sc2wol_has_protoss_common_units(multiworld, player) and \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                self.has_any({'Stalker', 'Void Ray', 'Carrier'}, player) \ | 
					
						
							|  |  |  |                or get_option_value(multiworld, player, 'required_tactics') > 0 and self.has('Dark Templar', player) | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_beats_protoss_deathball(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |         return (self.has_any({'Banshee', 'Battlecruiser'}, player) or | 
					
						
							|  |  |  |                 self.has_all({'Liberator', 'Raid Artillery (Liberator)'}, player)) \ | 
					
						
							|  |  |  |             and self._sc2wol_has_competent_anti_air(multiworld, player) or \ | 
					
						
							|  |  |  |             self._sc2wol_has_competent_comp(multiworld, player) and self._sc2wol_has_air_anti_air(multiworld, player) | 
					
						
							| 
									
										
										
										
											2022-08-19 13:50:44 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_mm_upgrade(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         return self.has_any({"Combat Shield (Marine)", "Stabilizer Medpacks (Medic)"}, player) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_survives_rip_field(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |         return self.has("Battlecruiser", player) or \ | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |            self._sc2wol_has_air(multiworld, player) and \ | 
					
						
							|  |  |  |            self._sc2wol_has_competent_anti_air(multiworld, player) and \ | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |            self.has("Science Vessel", player) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_has_nukes(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return get_option_value(multiworld, player, 'required_tactics') > 0 and self.has_any({'Ghost', 'Spectre'}, player) | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |     def _sc2wol_can_respond_to_colony_infestations(self, multiworld: MultiWorld, player: int) -> bool: | 
					
						
							|  |  |  |         return self._sc2wol_has_common_unit(multiworld, player) \ | 
					
						
							|  |  |  |             and self._sc2wol_has_competent_anti_air(multiworld, player) \ | 
					
						
							|  |  |  |             and \ | 
					
						
							|  |  |  |                 ( | 
					
						
							|  |  |  |                     self._sc2wol_has_air_anti_air(multiworld, player) or | 
					
						
							|  |  |  |                     self.has_any({'Battlecruiser', 'Valkyrie'}), player | 
					
						
							|  |  |  |                 ) \ | 
					
						
							|  |  |  |             and \ | 
					
						
							|  |  |  |             self._sc2wol_defense_rating(multiworld, player, True) >= 3 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_final_mission_requirements(self, multiworld: MultiWorld, player: int): | 
					
						
							|  |  |  |         beats_kerrigan = self.has_any({'Marine', 'Banshee', 'Ghost'}, player) or get_option_value(multiworld, player, 'required_tactics') > 0 | 
					
						
							|  |  |  |         if get_option_value(multiworld, player, 'all_in_map') == 0: | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |             # Ground | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |             defense_rating = self._sc2wol_defense_rating(multiworld, player, True, False) | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |             if self.has_any({'Battlecruiser', 'Banshee'}, player): | 
					
						
							|  |  |  |                 defense_rating += 3 | 
					
						
							|  |  |  |             return defense_rating >= 12 and beats_kerrigan | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             # Air | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |             defense_rating = self._sc2wol_defense_rating(multiworld, player, True, True) | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |             return defense_rating >= 8 and beats_kerrigan \ | 
					
						
							| 
									
										
										
										
											2023-09-15 02:22:10 +02:00
										 |  |  |                 and self.has_any({'Viking', 'Battlecruiser', 'Valkyrie'}, player) \ | 
					
						
							| 
									
										
										
										
											2022-10-26 06:24:54 -04:00
										 |  |  |                 and self.has_any({'Hive Mind Emulator', 'Psi Disruptor', 'Missile Turret'}, player) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-11 14:46:24 -05:00
										 |  |  |     def _sc2wol_cleared_missions(self, multiworld: MultiWorld, player: int, mission_count: int) -> bool: | 
					
						
							| 
									
										
										
										
											2022-05-18 17:27:38 -04:00
										 |  |  |         return self.has_group("Missions", player, mission_count) |