| 
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 |  |  | from BaseClasses import MultiWorld | 
					
						
							| 
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 |  |  | from ..generic.Rules import set_rule, add_rule | 
					
						
							| 
									
										
										
										
											2021-08-29 14:02:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def set_rules(world: MultiWorld, player: int): | 
					
						
							| 
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 |  |  |     total_locations = world.total_locations[player]  # total locations for current player | 
					
						
							|  |  |  |     event_location_step = 25  # set an event location at these locations for "spheres" | 
					
						
							|  |  |  |     divisions = total_locations // event_location_step | 
					
						
							| 
									
										
										
										
											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-03-27 14:08:03 -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: | 
					
						
							|  |  |  |                     set_rule(world.get_location(f"ItemPickup{n}", player), lambda state, event_item=event_loc.item.name: state.has(event_item, player)) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     set_rule(world.get_location(f"ItemPickup{n}", player), | 
					
						
							|  |  |  |                              lambda state, n = n: state.can_reach(f"ItemPickup{n - 1}", 'Location', player)) | 
					
						
							|  |  |  |         for i in range(divisions * event_location_step, total_locations+1): | 
					
						
							|  |  |  |             set_rule(world.get_location(f"ItemPickup{i}", player), lambda state, i=i: state.can_reach(f"ItemPickup{i - 1}", "Location", player)) | 
					
						
							| 
									
										
										
										
											2021-09-26 20:56:04 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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)) | 
					
						
							|  |  |  |     if world.total_revivals[player] or world.start_with_revive[player]: | 
					
						
							| 
									
										
										
										
											2022-03-27 14:08:03 -05:00
										 |  |  |         total_revivals = world.total_revivals[player] * world.total_locations[player] // 100 | 
					
						
							| 
									
										
										
										
											2022-03-23 16:22:31 -05:00
										 |  |  |         add_rule(world.get_location("Victory", player), | 
					
						
							| 
									
										
										
										
											2022-03-27 14:08:03 -05:00
										 |  |  |                  lambda state: state.has("Dio's Best Friend", player, total_revivals + world.start_with_revive[player].value)) | 
					
						
							| 
									
										
										
										
											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) |