| 
									
										
										
										
											2022-02-04 21:34:39 +01:00
										 |  |  | import typing | 
					
						
							| 
									
										
										
										
											2022-03-12 22:05:54 +01:00
										 |  |  | import os, json | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | from .Items import item_table, V6Item | 
					
						
							|  |  |  | from .Locations import location_table, V6Location | 
					
						
							|  |  |  | from .Options import v6_options | 
					
						
							| 
									
										
										
										
											2022-02-04 21:34:39 +01:00
										 |  |  | from .Rules import set_rules | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | from .Regions import create_regions | 
					
						
							|  |  |  | from BaseClasses import Region, RegionType, Entrance, Item, MultiWorld | 
					
						
							|  |  |  | from ..AutoWorld import World | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | client_version = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class V6World(World): | 
					
						
							|  |  |  |     """ 
 | 
					
						
							|  |  |  |      VVVVVV is a platform game all about exploring one simple mechanical idea - what if you reversed gravity instead of jumping? | 
					
						
							|  |  |  |     """ #Lifted from Store Page
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     game: str = "VVVVVV" | 
					
						
							|  |  |  |     topology_present = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     item_name_to_id = item_table | 
					
						
							|  |  |  |     location_name_to_id = location_table | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     data_version = 1 | 
					
						
							|  |  |  |     forced_auto_forfeit = False | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 21:34:39 +01:00
										 |  |  |     area_connections: typing.Dict[int, int] | 
					
						
							| 
									
										
										
										
											2022-02-05 16:53:43 +01:00
										 |  |  |     area_cost_map: typing.Dict[int,int] | 
					
						
							| 
									
										
										
										
											2022-02-04 21:22:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 22:56:54 +01:00
										 |  |  |     music_map: typing.Dict[int,int] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  |     options = v6_options | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_regions(self): | 
					
						
							|  |  |  |         create_regions(self.world,self.player) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def set_rules(self): | 
					
						
							| 
									
										
										
										
											2022-02-04 21:22:26 +01:00
										 |  |  |         self.area_connections = {} | 
					
						
							| 
									
										
										
										
											2022-02-05 16:53:43 +01:00
										 |  |  |         self.area_cost_map = {} | 
					
						
							|  |  |  |         set_rules(self.world, self.player, self.area_connections, self.area_cost_map) | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							| 
									
										
										
										
											2022-01-25 23:17:22 +01:00
										 |  |  |         return V6Item(name, True, item_table[name], self.player) | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def generate_basic(self): | 
					
						
							| 
									
										
										
										
											2022-02-05 16:53:43 +01:00
										 |  |  |         trinkets = [self.create_item("Trinket " + str(i+1).zfill(2)) for i in range(0,20)] | 
					
						
							|  |  |  |         self.world.itempool += trinkets | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 22:56:54 +01:00
										 |  |  |         musiclist_o = [1,2,3,4,9,12] | 
					
						
							|  |  |  |         musiclist_s = musiclist_o.copy() | 
					
						
							|  |  |  |         if self.world.MusicRandomizer[self.player].value: | 
					
						
							|  |  |  |             self.world.random.shuffle(musiclist_s) | 
					
						
							|  |  |  |         self.music_map = dict(zip(musiclist_o, musiclist_s)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  |     def fill_slot_data(self): | 
					
						
							|  |  |  |         return { | 
					
						
							| 
									
										
										
										
											2022-02-04 22:56:54 +01:00
										 |  |  |             "MusicRando": self.music_map, | 
					
						
							| 
									
										
										
										
											2022-02-04 21:22:26 +01:00
										 |  |  |             "AreaRando": self.area_connections, | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  |             "DoorCost": self.world.DoorCost[self.player].value, | 
					
						
							| 
									
										
										
										
											2022-02-05 16:53:43 +01:00
										 |  |  |             "AreaCostRando": self.area_cost_map, | 
					
						
							| 
									
										
										
										
											2022-01-21 22:42:11 +01:00
										 |  |  |             "DeathLink": self.world.DeathLink[self.player].value, | 
					
						
							|  |  |  |             "DeathLink_Amnesty": self.world.DeathLinkAmnesty[self.player].value | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-03-12 22:05:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def generate_output(self, output_directory: str): | 
					
						
							|  |  |  |         if self.world.players != 1: | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  |         data = { | 
					
						
							|  |  |  |             "slot_data": self.fill_slot_data(), | 
					
						
							| 
									
										
										
										
											2022-04-14 13:55:42 +02:00
										 |  |  |             "location_to_item": {self.location_name_to_id[i.name] : item_table[i.item.name] for i in self.world.get_locations()}, | 
					
						
							| 
									
										
										
										
											2022-03-12 22:05:54 +01:00
										 |  |  |             "data_package": { | 
					
						
							|  |  |  |                 "data": { | 
					
						
							|  |  |  |                     "games": { | 
					
						
							|  |  |  |                         self.game: { | 
					
						
							|  |  |  |                             "item_name_to_id": self.item_name_to_id, | 
					
						
							|  |  |  |                             "location_name_to_id": self.location_name_to_id | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-04-02 22:47:42 -05:00
										 |  |  |         filename = f"AP_{self.world.seed_name}_P{self.player}_{self.world.get_file_safe_player_name(self.player)}.apv6" | 
					
						
							| 
									
										
										
										
											2022-03-12 22:05:54 +01:00
										 |  |  |         with open(os.path.join(output_directory, filename), 'w') as f: | 
					
						
							|  |  |  |             json.dump(data, f) |