2021-08-29 14:02:02 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from BaseClasses import MultiWorld
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-15 23:52:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from worlds.generic.Rules import set_rule, add_rule
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def set_rules(world: MultiWorld, player: int) -> None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    total_locations = world.total_locations[player].value  # total locations for current player
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    event_location_step = 25  # set an event location at these locations for "spheres"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    divisions = total_locations // event_location_step
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    total_revivals = world.worlds[player].total_revivals  # pulling this info we calculated in generate_basic
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if divisions:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for i in range(1, divisions):  # since divisions is the floor of total_locations / 25
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            event_loc = world.get_location(f"Pickup{i * event_location_step}", player)
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            set_rule(event_loc,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     lambda state, i=i: state.can_reach(f"ItemPickup{i * event_location_step - 1}", "Location", player))
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for n in range(i * event_location_step, (i + 1) * event_location_step):  # we want to create a rule for each of the 25 locations per division
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if n == i * event_location_step:
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    set_rule(world.get_location(f"ItemPickup{n}", player),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                             lambda state, event_item=event_loc.item.name: state.has(event_item, player))
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    set_rule(world.get_location(f"ItemPickup{n}", player),
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                             lambda state, n=n: state.can_reach(f"ItemPickup{n - 1}", "Location", player))
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for i in range(divisions * event_location_step, total_locations+1):
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            set_rule(world.get_location(f"ItemPickup{i}", player),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     lambda state, i=i: state.can_reach(f"ItemPickup{i - 1}", "Location", player))
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    set_rule(world.get_location("Victory", player),
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             lambda state: state.can_reach(f"ItemPickup{total_locations}", "Location", player))
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if total_revivals or world.start_with_revive[player].value:
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        add_rule(world.get_location("Victory", player),
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-20 18:09:35 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 lambda state: state.has("Dio's Best Friend", player,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                         total_revivals + world.start_with_revive[player]))
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-12 08:00:11 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    world.completion_condition[player] = lambda state: state.has("Victory", player)
							 |