| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  | from BaseClasses import Item, MultiWorld, Region, Location, Entrance | 
					
						
							|  |  |  | from .Items import item_table | 
					
						
							|  |  |  | from .Rules import set_rules | 
					
						
							|  |  |  | from ..AutoWorld import World | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ArchipIDLEWorld(World): | 
					
						
							| 
									
										
										
										
											2022-03-13 23:44:30 -04:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     An idle game which sends a check every thirty seconds, up to one hundred checks. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  |     game = "ArchipIDLE" | 
					
						
							|  |  |  |     topology_present = False | 
					
						
							|  |  |  |     data_version = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     item_name_to_id = {} | 
					
						
							|  |  |  |     start_id = 9000 | 
					
						
							|  |  |  |     for item in item_table: | 
					
						
							|  |  |  |         item_name_to_id[item] = start_id | 
					
						
							|  |  |  |         start_id += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     location_name_to_id = {} | 
					
						
							|  |  |  |     start_id = 9000 | 
					
						
							| 
									
										
										
										
											2022-03-13 14:37:56 -04:00
										 |  |  |     for i in range(1, 101): | 
					
						
							| 
									
										
										
										
											2022-03-13 22:56:46 -04:00
										 |  |  |         location_name_to_id[f"IDLE for {int(i / 2)} minutes {30 if (i % 2) > 0 else 0} seconds"] = start_id | 
					
						
							| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  |         start_id += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def generate_basic(self): | 
					
						
							|  |  |  |         item_table_copy = list(item_table) | 
					
						
							|  |  |  |         self.world.random.shuffle(item_table_copy) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         item_pool = [] | 
					
						
							| 
									
										
										
										
											2022-03-13 14:37:56 -04:00
										 |  |  |         for i in range(100): | 
					
						
							| 
									
										
										
										
											2022-03-13 15:31:27 -04:00
										 |  |  |             item = Item( | 
					
						
							| 
									
										
										
										
											2022-03-13 20:39:13 -04:00
										 |  |  |                 item_table_copy[i], | 
					
						
							|  |  |  |                 i < 20, | 
					
						
							|  |  |  |                 self.item_name_to_id[item_table_copy[i]], | 
					
						
							| 
									
										
										
										
											2022-03-13 15:31:27 -04:00
										 |  |  |                 self.player | 
					
						
							|  |  |  |             ) | 
					
						
							| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  |             item.game = 'ArchipIDLE' | 
					
						
							|  |  |  |             item_pool.append(item) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-13 20:44:08 -04:00
										 |  |  |         self.world.itempool += item_pool | 
					
						
							| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def set_rules(self): | 
					
						
							|  |  |  |         set_rules(self.world, self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							| 
									
										
										
										
											2022-03-13 20:39:13 -04:00
										 |  |  |         return Item(name, True, self.item_name_to_id[name], self.player) | 
					
						
							| 
									
										
										
										
											2022-03-13 04:04:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_regions(self): | 
					
						
							|  |  |  |         self.world.regions += [ | 
					
						
							|  |  |  |             create_region(self.world, self.player, 'Menu', None, ['Entrance to IDLE Zone']), | 
					
						
							|  |  |  |             create_region(self.world, self.player, 'IDLE Zone', self.location_name_to_id) | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # link up our region with the entrance we just made | 
					
						
							|  |  |  |         self.world.get_entrance('Entrance to IDLE Zone', self.player)\ | 
					
						
							|  |  |  |             .connect(self.world.get_region('IDLE Zone', self.player)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None): | 
					
						
							|  |  |  |     region = Region(name, None, name, player) | 
					
						
							|  |  |  |     region.world = world | 
					
						
							|  |  |  |     if locations: | 
					
						
							|  |  |  |         for location_name in locations.keys(): | 
					
						
							|  |  |  |             location = ArchipIDLELocation(player, location_name, locations[location_name], region) | 
					
						
							|  |  |  |             region.locations.append(location) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if exits: | 
					
						
							|  |  |  |         for _exit in exits: | 
					
						
							|  |  |  |             region.exits.append(Entrance(player, _exit, region)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return region | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ArchipIDLELocation(Location): | 
					
						
							|  |  |  |     game: str = "ArchipIDLE" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self, player: int, name: str, address=None, parent=None): | 
					
						
							|  |  |  |         super(ArchipIDLELocation, self).__init__(player, name, address, parent) |