2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  argparse  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  logging  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  random  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  urllib . request  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  urllib . parse  
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  typing  
						 
					
						
							
								
									
										
										
										
											2020-01-25 16:37:29 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  os  
						 
					
						
							
								
									
										
										
										
											2021-03-12 17:43:50 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  collections  import  Counter  
						 
					
						
							
								
									
										
										
										
											2021-03-28 16:52:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  string  
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  ModuleUpdate  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ModuleUpdate . update ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 23:43:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  Utils  
						 
					
						
							
								
									
										
										
										
											2021-07-23 01:57:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . alttp  import  Options  as  LttPOptions  
						 
					
						
							
								
									
										
										
										
											2022-02-14 04:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . generic  import  PlandoConnection  
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  Utils  import  parse_yaml ,  version_tuple ,  __version__ ,  tuplize_version ,  get_options ,  local_path ,  user_path  
						 
					
						
							
								
									
										
										
										
											2020-10-24 05:38:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . alttp . EntranceRandomizer  import  parse_arguments  
						 
					
						
							
								
									
										
										
										
											2021-02-21 20:17:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  Main  import  main  as  ERmain  
						 
					
						
							
								
									
										
										
										
											2021-10-06 11:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  BaseClasses  import  seeddigits ,  get_seed  
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  Options  
						 
					
						
							
								
									
										
										
										
											2021-01-03 14:32:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . alttp  import  Bosses  
						 
					
						
							
								
									
										
										
										
											2021-01-17 06:54:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . alttp . Text  import  TextTable  
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  worlds . AutoWorld  import  AutoWorldRegister  
						 
					
						
							
								
									
										
										
										
											2022-01-06 23:04:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  copy  
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								categories  =  set ( AutoWorldRegister . world_types )  
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 03:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  mystery_argparse ( ) :  
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    options  =  get_options ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    defaults  =  options [ " generator " ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    def  resolve_path ( path :  str ,  resolver :  typing . Callable [ [ str ] ,  str ] )  - >  str : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  path  if  os . path . isabs ( path )  else  resolver ( path ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser  =  argparse . ArgumentParser ( description = " CMD Generation Interface, defaults come from host.yaml. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --weights_file_path ' ,  default = defaults [ " weights_file_path " ] , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        help = ' Path to the weights file to use for rolling game settings, urls are also valid ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --samesettings ' ,  help = ' Rolls settings per weights file rather than per player ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        action = ' store_true ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --player_files_path ' ,  default = resolve_path ( defaults [ " player_files_path " ] ,  user_path ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        help = " Input directory for player files. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --seed ' ,  help = ' Define seed number to generate. ' ,  type = int ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-21 08:15:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --multi ' ,  default = defaults [ " players " ] ,  type = lambda  value :  max ( int ( value ) ,  1 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --spoiler ' ,  type = int ,  default = defaults [ " spoiler " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 05:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --lttp_rom ' ,  default = options [ " lttp_options " ] [ " rom_file " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " Path to the 1.0 JP LttP Baserom. " )   # absolute, relative to cwd or relative to app path 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --sm_rom ' ,  default = options [ " sm_options " ] [ " rom_file " ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " Path to the 1.0 JP SM Baserom. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --enemizercli ' ,  default = resolve_path ( defaults [ " enemizer_path " ] ,  local_path ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --outputpath ' ,  default = resolve_path ( options [ " general_options " ] [ " output_path " ] ,  user_path ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        help = " Path to output folder. Absolute or relative to cwd. " )   # absolute or relative to cwd 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --race ' ,  action = ' store_true ' ,  default = defaults [ " race " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --meta_file_path ' ,  default = defaults [ " meta_file_path " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser . add_argument ( ' --log_level ' ,  default = ' info ' ,  help = ' Sets log level ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-21 08:15:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --yaml_output ' ,  default = 0 ,  type = lambda  value :  max ( int ( value ) ,  0 ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:25:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        help = ' Output rolled mystery results to yaml up to specified number (made for async multiworld) ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser . add_argument ( ' --plando ' ,  default = defaults [ " plando_options " ] , 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        help = ' List of options that can be set manually. Can be combined, for example  " bosses, items " ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    args  =  parser . parse_args ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  os . path . isabs ( args . weights_file_path ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        args . weights_file_path  =  os . path . join ( args . player_files_path ,  args . weights_file_path ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  os . path . isabs ( args . meta_file_path ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        args . meta_file_path  =  os . path . join ( args . player_files_path ,  args . meta_file_path ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    args . plando :  typing . Set [ str ]  =  { arg . strip ( ) . lower ( )  for  arg  in  args . plando . split ( " , " ) } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  args ,  options 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 03:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 06:16:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  get_seed_name ( random_source )  - >  str :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  f " { random_source . randint ( 0 ,  pow ( 10 ,  seeddigits )  -  1 ) } " . zfill ( seeddigits ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-29 03:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-13 17:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  main ( args = None ,  callback = ERmain ) :  
						 
					
						
							
								
									
										
										
										
											2020-06-29 03:59:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  args : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        args ,  options  =  mystery_argparse ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-28 00:24:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    seed  =  get_seed ( args . seed ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    random . seed ( seed ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    seed_name  =  get_seed_name ( random ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-21 02:02:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  args . race : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        random . seed ( )   # reset to time-based random source 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    weights_cache  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  args . weights_file_path  and  os . path . exists ( args . weights_file_path ) : 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            weights_cache [ args . weights_file_path ]  =  read_weights_yaml ( args . weights_file_path ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        except  Exception  as  e : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            raise  ValueError ( f " File  { args . weights_file_path }  is destroyed. Please fix your yaml. " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        print ( f " Weights:  { args . weights_file_path }  >>  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              f " { get_choice ( ' description ' ,  weights_cache [ args . weights_file_path ] ,  ' No description specified ' ) } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  args . meta_file_path  and  os . path . exists ( args . meta_file_path ) : 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            weights_cache [ args . meta_file_path ]  =  read_weights_yaml ( args . meta_file_path ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        except  Exception  as  e : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            raise  ValueError ( f " File  { args . meta_file_path }  is destroyed. Please fix your yaml. " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        meta_weights  =  weights_cache [ args . meta_file_path ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-21 18:09:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        print ( f " Meta:  { args . meta_file_path }  >>  { get_choice ( ' meta_description ' ,  meta_weights ) } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        del ( meta_weights [ " meta_description " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  args . samesettings : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  Exception ( " Cannot mix --samesettings with --meta " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        meta_weights  =  None 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    player_id  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    player_files  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  file  in  os . scandir ( args . player_files_path ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        fname  =  file . name 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 14:42:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  file . is_file ( )  and  os . path . join ( args . player_files_path ,  fname )  not  in  { args . meta_file_path ,  args . weights_file_path } : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            path  =  os . path . join ( args . player_files_path ,  fname ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 02:31:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            try : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                weights_cache [ fname ]  =  read_weights_yaml ( path ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-05 02:31:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            except  Exception  as  e : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                raise  ValueError ( f " File  { fname }  is destroyed. Please fix your yaml. " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                print ( f " P { player_id }  Weights:  { fname }  >>  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                      f " { get_choice ( ' description ' ,  weights_cache [ fname ] ,  ' No description specified ' ) } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                player_files [ player_id ]  =  fname 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                player_id  + =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    args . multi  =  max ( player_id - 1 ,  args . multi ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 04:28:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    print ( f " Generating for  { args . multi }  player { ' s '  if  args . multi  >  1  else  ' ' } ,  { seed_name }  Seed  { seed }  with plando:  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          f " { ' ,  ' . join ( args . plando ) } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  weights_cache : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " No weights found. Provide a general weights file ( { args . weights_file_path } ) or individual player files.  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        f " A mix is also permitted. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs  =  parse_arguments ( [ ' --multi ' ,  str ( args . multi ) ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    erargs . seed  =  seed 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . glitch_triforce  =  options [ " generator " ] [ " glitch_triforce_room " ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 01:32:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . spoiler  =  args . spoiler 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 19:47:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . race  =  args . race 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-12 09:45:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . outputname  =  seed_name 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    erargs . outputpath  =  args . outputpath 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-18 18:54:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Utils . init_logging ( f " Generate_ { seed } " ,  loglevel = args . log_level ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 08:00:11 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . lttp_rom  =  args . lttp_rom 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    erargs . sm_rom  =  args . sm_rom 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . enemizercli  =  args . enemizercli 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    settings_cache  =  { k :  ( roll_settings ( v ,  args . plando )  if  args . samesettings  else  None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                      for  k ,  v  in  weights_cache . items ( ) } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    player_path_cache  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  player  in  range ( 1 ,  args . multi  +  1 ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        player_path_cache [ player ]  =  player_files . get ( player ,  args . weights_file_path ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  meta_weights : 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-21 18:09:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  category_name ,  category_dict  in  meta_weights . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  key  in  category_dict : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                option  =  get_choice ( key ,  category_dict ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  option  is  not  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    for  player ,  path  in  player_path_cache . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  category_name  is  None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            weights_cache [ path ] [ key ]  =  option 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        elif  category_name  not  in  weights_cache [ path ] : 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-06 22:01:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            logging . warning ( f " Meta: Category  { category_name }  is not present in  { path } . " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-21 18:09:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            weights_cache [ path ] [ category_name ] [ key ]  =  option 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-12 17:43:50 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    name_counter  =  Counter ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    erargs . player_settings  =  { } 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  player  in  range ( 1 ,  args . multi  +  1 ) : 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        path  =  player_path_cache [ player ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  path : 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 17:03:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            try : 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                settings  =  settings_cache [ path ]  if  settings_cache [ path ]  else  \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    roll_settings ( weights_cache [ path ] ,  args . plando ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 17:03:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                for  k ,  v  in  vars ( settings ) . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  v  is  not  None : 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            getattr ( erargs ,  k ) [ player ]  =  v 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        except  AttributeError : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            setattr ( erargs ,  k ,  { player :  v } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 09:15:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            raise  Exception ( f " Error setting  { k }  to  { v }  for player  { player } " )  from  e 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                raise  ValueError ( f " File  { path }  is destroyed. Please fix your yaml. " )  from  e 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  RuntimeError ( f ' No weights specified for player  { player } ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 18:08:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  path  ==  args . weights_file_path :   # if name came from the weights file, just use base player name 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 22:11:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            erargs . name [ player ]  =  f " Player { player } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        elif  not  erargs . name [ player ] :   # if name was not specified, generate it from filename 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-13 15:26:21 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            erargs . name [ player ]  =  os . path . splitext ( os . path . split ( path ) [ - 1 ] ) [ 0 ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 16:52:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        erargs . name [ player ]  =  handle_name ( erargs . name [ player ] ,  player ,  name_counter ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-17 06:26:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-26 17:22:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  len ( set ( erargs . name . values ( ) ) )  !=  len ( erargs . name ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 04:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Exception ( f " Names have to be unique. Names:  { Counter ( erargs . name . values ( ) ) } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-26 17:22:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  args . yaml_output : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        import  yaml 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        important  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  option ,  player_settings  in  vars ( erargs ) . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  type ( player_settings )  ==  dict : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 20:19:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  all ( type ( value )  !=  list  for  value  in  player_settings . values ( ) ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-05 08:07:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  len ( player_settings . values ( ) )  >  1 : 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 20:19:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        important [ option ]  =  { player :  value  for  player ,  value  in  player_settings . items ( )  if 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                             player  < =  args . yaml_output } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        logging . debug ( f " No player settings defined for option  ' { option } ' " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  player_settings  !=  " " :   # is not empty name 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    important [ option ]  =  player_settings 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 17:57:20 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    logging . debug ( f " No player settings defined for option  ' { option } ' " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  args . outputpath : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            os . makedirs ( args . outputpath ,  exist_ok = True ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 01:42:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        with  open ( os . path . join ( args . outputpath  if  args . outputpath  else  " . " ,  f " generate_ { seed_name } .yaml " ) ,  " wt " )  as  f : 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            yaml . dump ( important ,  f ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-25 22:40:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    callback ( erargs ,  seed ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  read_weights_yaml ( path ) :  
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    try : 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 08:22:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  urllib . parse . urlparse ( path ) . scheme  in  ( ' https ' ,  ' file ' ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 21:55:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            yaml  =  str ( urllib . request . urlopen ( path ) . read ( ) ,  " utf-8-sig " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-10 06:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            with  open ( path ,  ' rb ' )  as  f : 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 21:55:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                yaml  =  str ( f . read ( ) ,  " utf-8-sig " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    except  Exception  as  e : 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-18 06:03:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Exception ( f " Failed to read weights ( { path } ) " )  from  e 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  parse_yaml ( yaml ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 06:16:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  interpret_on_off ( value )  - >  bool :  
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  { " on " :  True ,  " off " :  False } . get ( value ,  value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-18 06:16:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  convert_to_on_off ( value )  - >  str :  
						 
					
						
							
								
									
										
										
										
											2020-01-20 03:29:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  { True :  " on " ,  False :  " off " } . get ( value ,  value ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-19 23:30:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  get_choice_legacy ( option ,  root ,  value = None )  - >  typing . Any :  
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  option  not  in  root : 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-18 08:51:38 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  value 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 17:03:10 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  type ( root [ option ] )  is  list : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  interpret_on_off ( random . choices ( root [ option ] ) [ 0 ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 09:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  type ( root [ option ] )  is  not  dict : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  interpret_on_off ( root [ option ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  root [ option ] : 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-18 08:51:38 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  value 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-18 19:21:52 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  any ( root [ option ] . values ( ) ) : 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-18 08:48:33 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  interpret_on_off ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            random . choices ( list ( root [ option ] . keys ( ) ) ,  weights = list ( map ( int ,  root [ option ] . values ( ) ) ) ) [ 0 ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-31 13:23:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    raise  RuntimeError ( f " All options specified in  \" { option } \"  are weighted as zero. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  get_choice ( option ,  root ,  value = None )  - >  typing . Any :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  option  not  in  root : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  type ( root [ option ] )  is  list : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  random . choices ( root [ option ] ) [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  type ( root [ option ] )  is  not  dict : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  root [ option ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  not  root [ option ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  value 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  any ( root [ option ] . values ( ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  random . choices ( list ( root [ option ] . keys ( ) ) ,  weights = list ( map ( int ,  root [ option ] . values ( ) ) ) ) [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    raise  RuntimeError ( f " All options specified in  \" { option } \"  are weighted as zero. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 16:52:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								class  SafeDict ( dict ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def  __missing__ ( self ,  key ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  ' { '  +  key  +  ' } ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  handle_name ( name :  str ,  player :  int ,  name_counter :  Counter ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    name_counter [ name ]  + =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    new_name  =  " % " . join ( [ x . replace ( " % number % " ,  " {number} " ) . replace ( " % player % " ,  " {player} " )  for  x  in  name . split ( " %% " ) ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    new_name  =  string . Formatter ( ) . vformat ( new_name ,  ( ) ,  SafeDict ( number = name_counter [ name ] , 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                                                 NUMBER = ( name_counter [ name ]  if  name_counter [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                                                                                   name ]  >  1  else  ' ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-28 16:52:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                                                 player = player , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                                                 PLAYER = ( player  if  player  >  1  else  ' ' ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 09:15:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    new_name  =  new_name . strip ( ) [ : 16 ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 23:08:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  new_name  ==  " Archipelago " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " You cannot name yourself  \" { new_name } \" " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  new_name 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-23 17:06:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-18 07:12:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  prefer_int ( input_data :  str )  - >  typing . Union [ str ,  int ] :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  int ( input_data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    except : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  input_data 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-31 13:23:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								available_boss_names :  typing . Set [ str ]  =  { boss . lower ( )  for  boss  in  Bosses . boss_table  if  boss  not  in  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                         { ' Agahnim ' ,  ' Agahnim2 ' ,  ' Ganon ' } } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 04:36:46 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								available_boss_locations :  typing . Set [ str ]  =  { f " { loc . lower ( ) } { f '   { level } '  if  level  else  ' ' } "  for  loc ,  level  in  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                             Bosses . boss_location_table } 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-31 13:23:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								boss_shuffle_options  =  { None :  ' none ' ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ' none ' :  ' none ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-06 11:12:23 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' basic ' :  ' basic ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' full ' :  ' full ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-06 11:12:23 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' chaos ' :  ' chaos ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' singularity ' :  ' singularity ' 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-31 13:23:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								goals  =  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' ganon ' :  ' ganon ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' crystals ' :  ' crystals ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' bosses ' :  ' bosses ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' pedestal ' :  ' pedestal ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' ganon_pedestal ' :  ' ganonpedestal ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' triforce_hunt ' :  ' triforcehunt ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' local_triforce_hunt ' :  ' localtriforcehunt ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' ganon_triforce_hunt ' :  ' ganontriforcehunt ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' local_ganon_triforce_hunt ' :  ' localganontriforcehunt ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ' ice_rod_hunt ' :  ' icerodhunt ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 15:06:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  roll_percentage ( percentage :  typing . Union [ int ,  float ] )  - >  bool :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    """ Roll a percentage chance. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    percentage  is  expected  to  be  in  range  [ 0 ,  100 ] """ 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  random . random ( )  <  ( float ( percentage )  /  100 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 10:26:02 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  update_weights ( weights :  dict ,  new_weights :  dict ,  type :  str ,  name :  str )  - >  dict :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    logging . debug ( f ' Applying  { new_weights } ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    new_options  =  set ( new_weights )  -  set ( weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    weights . update ( new_weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  new_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  new_option  in  new_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            logging . warning ( f ' { type }  Suboption  " { new_option } "  of  " { name } "  did not  ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            f ' overwrite a root option.  ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            f ' This is probably in error. ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  weights 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  roll_linked_options ( weights :  dict )  - >  dict :  
						 
					
						
							
								
									
										
										
										
											2022-01-06 23:04:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    weights  =  copy . deepcopy ( weights )   # make sure we don't write back to other weights sets in same_settings 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  option_set  in  weights [ " linked_options " ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  " name "  not  in  option_set : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  ValueError ( " One of your linked options does not have a name. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  roll_percentage ( option_set [ " percentage " ] ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logging . debug ( f " Linked option  { option_set [ ' name ' ] }  triggered. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                new_options  =  option_set [ " options " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  category_name ,  category_options  in  new_options . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    currently_targeted_weights  =  weights 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  category_name : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        currently_targeted_weights  =  currently_targeted_weights [ category_name ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    update_weights ( currently_targeted_weights ,  category_options ,  " Linked " ,  option_set [ " name " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logging . debug ( f " linked option  { option_set [ ' name ' ] }  skipped. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  ValueError ( f " Linked option  { option_set [ ' name ' ] }  is destroyed.  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                             f " Please fix your linked option. " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  weights 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 12:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-17 20:53:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  roll_triggers ( weights :  dict ,  triggers :  list )  - >  dict :  
						 
					
						
							
								
									
										
										
										
											2022-01-06 23:04:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    weights  =  copy . deepcopy ( weights )   # make sure we don't write back to other weights sets in same_settings 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-28 02:57:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    weights [ " _Generator_Version " ]  =  Utils . __version__ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-17 20:53:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  i ,  option_set  in  enumerate ( triggers ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            currently_targeted_weights  =  weights 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            category  =  option_set . get ( " option_category " ,  None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  category : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                currently_targeted_weights  =  currently_targeted_weights [ category ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            key  =  get_choice ( " option_name " ,  option_set ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  key  not  in  currently_targeted_weights : 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 13:57:52 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                logging . warning ( f ' Specified option name  { option_set [ " option_name " ] }  did not  ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                f ' match with a root option.  ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                f ' This is probably in error. ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            trigger_result  =  get_choice ( " option_result " ,  option_set ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            result  =  get_choice ( key ,  currently_targeted_weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            currently_targeted_weights [ key ]  =  result 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  result  ==  trigger_result  and  roll_percentage ( get_choice ( " percentage " ,  option_set ,  100 ) ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                for  category_name ,  category_options  in  option_set [ " options " ] . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    currently_targeted_weights  =  weights 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  category_name : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        currently_targeted_weights  =  currently_targeted_weights [ category_name ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    update_weights ( currently_targeted_weights ,  category_options ,  " Triggered " ,  option_set [ " option_name " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-14 02:14:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        except  Exception  as  e : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 14:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            raise  ValueError ( f " Your trigger number  { i  +  1 }  is destroyed.  " 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                             f " Please fix your triggers. " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  weights 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 03:38:49 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								def  get_plando_bosses ( boss_shuffle :  str ,  plando_options :  typing . Set [ str ] )  - >  str :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  boss_shuffle  in  boss_shuffle_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  boss_shuffle_options [ boss_shuffle ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  " bosses "  in  plando_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        options  =  boss_shuffle . lower ( ) . split ( " ; " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        remainder_shuffle  =  " none "   # vanilla 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        bosses  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  boss  in  options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  boss  in  boss_shuffle_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                remainder_shuffle  =  boss_shuffle_options [ boss ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 04:36:46 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            elif  " - "  in  boss : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                loc ,  boss_name  =  boss . split ( " - " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  boss_name  not  in  available_boss_names : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  ValueError ( f " Unknown Boss name  { boss_name } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  loc  not  in  available_boss_locations : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  ValueError ( f " Unknown Boss Location  { loc } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                level  =  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  loc . split ( "   " ) [ - 1 ]  in  { " top " ,  " middle " ,  " bottom " } : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    # split off level 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    loc  =  loc . split ( "   " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    level  =  f "   { loc [ - 1 ] } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    loc  =  "   " . join ( loc [ : - 1 ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                loc  =  loc . title ( ) . replace ( " Of " ,  " of " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  not  Bosses . can_place_boss ( boss_name . title ( ) ,  loc ,  level ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  ValueError ( f " Cannot place  { boss_name }  at  { loc } { level } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                bosses . append ( boss ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            elif  boss  not  in  available_boss_names : 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 03:38:49 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                raise  ValueError ( f " Unknown Boss name or Boss shuffle option  { boss } . " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                bosses . append ( boss ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  " ; " . join ( bosses  +  [ remainder_shuffle ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " Boss Shuffle  { boss_shuffle }  is unknown and boss plando is turned off. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-17 00:17:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  handle_option ( ret :  argparse . Namespace ,  game_weights :  dict ,  option_key :  str ,  option :  type ( Options . Option ) ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  option_key  in  game_weights : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  not  option . supports_weighting : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                player_option  =  option . from_any ( game_weights [ option_key ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                player_option  =  option . from_any ( get_choice ( option_key ,  game_weights ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            setattr ( ret ,  option_key ,  player_option ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        except  Exception  as  e : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  Exception ( f " Error generating option  { option_key }  in  { ret . game } " )  from  e 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        else : 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  hasattr ( player_option ,  " verify " ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                player_option . verify ( AutoWorldRegister . world_types [ ret . game ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-17 00:17:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        setattr ( ret ,  option_key ,  option ( option . default ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  roll_settings ( weights :  dict ,  plando_options :  typing . Set [ str ]  =  frozenset ( ( " bosses " , ) ) ) :  
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  " linked_options "  in  weights : 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        weights  =  roll_linked_options ( weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  " triggers "  in  weights : 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-17 20:53:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        weights  =  roll_triggers ( weights ,  weights [ " triggers " ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-18 23:17:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    requirements  =  weights . get ( " requires " ,  { } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  requirements : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        version  =  requirements . get ( " version " ,  __version__ ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  tuplize_version ( version )  >  version_tuple : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            raise  Exception ( f " Settings reports required version of generator is at least  { version } ,  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            f " however generator is of version  { __version__ } " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        required_plando_options  =  requirements . get ( " plando " ,  " " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  required_plando_options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-19 01:00:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            required_plando_options  =  set ( option . strip ( )  for  option  in  required_plando_options . split ( " , " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            required_plando_options  - =  plando_options 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  required_plando_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  len ( required_plando_options )  ==  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  Exception ( f " Settings reports required plando module  { ' ,  ' . join ( required_plando_options ) } ,  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    f " which is not enabled. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  Exception ( f " Settings reports required plando modules  { ' ,  ' . join ( required_plando_options ) } ,  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    f " which are not enabled. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-18 23:17:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 14:03:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret  =  argparse . Namespace ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-17 00:17:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  option_key  in  Options . per_game_common_options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-28 18:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  option_key  in  weights  and  option_key  not  in  Options . common_options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-17 00:17:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            raise  Exception ( f " Option  { option_key }  has to be in a game ' s section, not on its own. " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 15:10:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . game  =  get_choice ( " game " ,  weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ret . game  not  in  weights : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " No game options for selected game  \" { ret . game } \"  found. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-17 20:53:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-12 13:54:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    world_type  =  AutoWorldRegister . world_types [ ret . game ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 15:10:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    game_weights  =  weights [ ret . game ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 08:24:34 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-17 20:53:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  " triggers "  in  game_weights : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        weights  =  roll_triggers ( weights ,  game_weights [ " triggers " ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        game_weights  =  weights [ ret . game ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ret . name  =  get_choice ( ' name ' ,  weights ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  option_key ,  option  in  Options . common_options . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        setattr ( ret ,  option_key ,  option . from_any ( get_choice ( option_key ,  weights ,  option . default ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-04 16:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ret . game  in  AutoWorldRegister . world_types : 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-17 00:17:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  option_key ,  option  in  world_type . options . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            handle_option ( ret ,  game_weights ,  option_key ,  option ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  option_key ,  option  in  Options . per_game_common_options . items ( ) : 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-04 20:04:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            # skip setting this option if already set from common_options, defaulting to root option 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  not  ( option_key  in  Options . common_options  and  option_key  not  in  game_weights ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                handle_option ( ret ,  game_weights ,  option_key ,  option ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-10 04:28:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  " items "  in  plando_options : 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-20 13:34:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ret . plando_items  =  game_weights . get ( " plando_items " ,  [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-20 15:36:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ret . game  ==  " Minecraft "  or  ret . game  ==  " Ocarina of Time " : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-25 23:32:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            # bad hardcoded behavior to make this work for now 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . plando_connections  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  " connections "  in  plando_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                options  =  game_weights . get ( " plando_connections " ,  [ ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  placement  in  options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  roll_percentage ( get_choice ( " percentage " ,  placement ,  100 ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ret . plando_connections . append ( PlandoConnection ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            get_choice ( " entrance " ,  placement ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            get_choice ( " exit " ,  placement ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-20 15:36:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            get_choice ( " direction " ,  placement ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-25 23:32:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-04 16:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        elif  ret . game  ==  " A Link to the Past " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            roll_alttp_settings ( ret ,  game_weights ,  plando_options ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  Exception ( f " Unsupported game  { ret . game } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 10:14:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  ret 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-06 16:37:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								def  roll_alttp_settings ( ret :  argparse . Namespace ,  weights ,  plando_options ) :  
						 
					
						
							
								
									
										
										
										
											2021-09-01 09:18:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  " dungeon_items "  in  weights  and  get_choice_legacy ( ' dungeon_items ' ,  weights ,  " none " )  !=  " none " : 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-01 17:56:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        raise  Exception ( f " dungeon_items key in A Link to the Past was removed, but is present in these weights as  { get_choice_legacy ( ' dungeon_items ' ,  weights ,  False ) } . " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    glitches_required  =  get_choice_legacy ( ' glitches_required ' ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-07 19:34:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  glitches_required  not  in  [ None ,  ' none ' ,  ' no_logic ' ,  ' overworld_glitches ' ,  ' hybrid_major_glitches ' ,  ' minor_glitches ' ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        logging . warning ( " Only NMG, OWG, HMG and No Logic supported " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        glitches_required  =  ' none ' 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 19:02:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . logic  =  { None :  ' noglitches ' ,  ' none ' :  ' noglitches ' ,  ' no_logic ' :  ' nologic ' ,  ' overworld_glitches ' :  ' owglitches ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-07 01:19:27 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                 ' minor_glitches ' :  ' minorglitches ' ,  ' hybrid_major_glitches ' :  ' hybridglitches ' } [ 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-25 02:24:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        glitches_required ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 19:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . dark_room_logic  =  get_choice_legacy ( " dark_room_logic " ,  weights ,  " lamp " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 23:19:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  ret . dark_room_logic :   # None/False 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 19:51:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . dark_room_logic  =  " none " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ret . dark_room_logic  ==  " sconces " : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ret . dark_room_logic  =  " torches " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ret . dark_room_logic  not  in  { " lamp " ,  " torches " ,  " none " } : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        raise  ValueError ( f " Unknown Dark Room Logic:  \" { ret . dark_room_logic } \" " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    entrance_shuffle  =  get_choice_legacy ( ' entrance_shuffle ' ,  weights ,  ' vanilla ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-24 13:23:42 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  entrance_shuffle . startswith ( ' none- ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ret . shuffle  =  ' vanilla ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ret . shuffle  =  entrance_shuffle  if  entrance_shuffle  !=  ' none '  else  ' vanilla ' 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    goal  =  get_choice_legacy ( ' goals ' ,  weights ,  ' ganon ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ret . goal  =  goals [ goal ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-11 03:23:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-13 17:15:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # TODO consider moving open_pyramid to an automatic variable in the core roller, set to True when 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-13 17:13:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # fast ganon + ganon at hole 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . open_pyramid  =  get_choice_legacy ( ' open_pyramid ' ,  weights ,  ' goal ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    extra_pieces  =  get_choice_legacy ( ' triforce_pieces_mode ' ,  weights ,  ' available ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-17 01:02:54 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . triforce_pieces_required  =  LttPOptions . TriforcePieces . from_any ( get_choice_legacy ( ' triforce_pieces_required ' ,  weights ,  20 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 15:22:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 19:43:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # sum a percentage to required 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  extra_pieces  ==  ' percentage ' : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        percentage  =  max ( 100 ,  float ( get_choice_legacy ( ' triforce_pieces_percentage ' ,  weights ,  150 ) ) )  /  100 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-18 07:12:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . triforce_pieces_available  =  int ( round ( ret . triforce_pieces_required  *  percentage ,  0 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 19:43:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # vanilla mode (specify how many pieces are) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  extra_pieces  ==  ' available ' : 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-04 16:18:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . triforce_pieces_available  =  LttPOptions . TriforcePieces . from_any ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            get_choice_legacy ( ' triforce_pieces_available ' ,  weights ,  30 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 19:43:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # required pieces + fixed extra 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    elif  extra_pieces  ==  ' extra ' : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        extra_pieces  =  max ( 0 ,  int ( get_choice_legacy ( ' triforce_pieces_extra ' ,  weights ,  10 ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 19:43:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . triforce_pieces_available  =  ret . triforce_pieces_required  +  extra_pieces 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # change minimum to required pieces to avoid problems 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-07 23:19:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . triforce_pieces_available  =  min ( max ( ret . triforce_pieces_required ,  int ( ret . triforce_pieces_available ) ) ,  90 ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 20:05:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . shop_shuffle  =  get_choice_legacy ( ' shop_shuffle ' ,  weights ,  ' ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-23 15:03:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  not  ret . shop_shuffle : 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-23 21:38:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . shop_shuffle  =  ' ' 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-23 15:03:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . mode  =  get_choice_legacy ( " mode " ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . difficulty  =  get_choice_legacy ( ' item_pool ' ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . item_functionality  =  get_choice_legacy ( ' item_functionality ' ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    boss_shuffle  =  get_choice_legacy ( ' boss_shuffle ' ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 03:38:49 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . shufflebosses  =  get_plando_bosses ( boss_shuffle ,  plando_options ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-19 22:25:58 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . enemy_damage  =  { None :  ' default ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ' default ' :  ' default ' , 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 22:41:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' shuffled ' :  ' shuffled ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 09:15:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ' random ' :  ' chaos ' ,  # to be removed 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ' chaos ' :  ' chaos ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } [ get_choice_legacy ( ' enemy_damage ' ,  weights ) ] 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . enemy_health  =  get_choice_legacy ( ' enemy_health ' ,  weights ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-04 13:55:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . timer  =  { ' none ' :  False , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                 None :  False , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                 False :  False , 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-02 20:10:56 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                 ' timed ' :  ' timed ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                 ' timed_ohko ' :  ' timed-ohko ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                 ' ohko ' :  ' ohko ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                 ' timed_countdown ' :  ' timed-countdown ' , 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                 ' display ' :  ' display ' } [ get_choice_legacy ( ' timer ' ,  weights ,  False ) ] 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-02 20:10:56 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . countdown_start_time  =  int ( get_choice_legacy ( ' countdown_start_time ' ,  weights ,  10 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ret . red_clock_time  =  int ( get_choice_legacy ( ' red_clock_time ' ,  weights ,  - 2 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ret . blue_clock_time  =  int ( get_choice_legacy ( ' blue_clock_time ' ,  weights ,  2 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ret . green_clock_time  =  int ( get_choice_legacy ( ' green_clock_time ' ,  weights ,  4 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-28 16:20:59 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . dungeon_counters  =  get_choice_legacy ( ' dungeon_counters ' ,  weights ,  ' default ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-12 15:46:32 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . shuffle_prizes  =  get_choice_legacy ( ' shuffle_prizes ' ,  weights ,  " g " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-20 04:35:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . required_medallions  =  [ get_choice_legacy ( " misery_mire_medallion " ,  weights ,  " random " ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                               get_choice_legacy ( " turtle_rock_medallion " ,  weights ,  " random " ) ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-24 21:14:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  index ,  medallion  in  enumerate ( ret . required_medallions ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-14 08:38:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ret . required_medallions [ index ]  =  { " ether " :  " Ether " ,  " quake " :  " Quake " ,  " bombos " :  " Bombos " ,  " random " :  " random " }  \
							 
						 
					
						
							
								
									
										
										
										
											2021-01-24 21:14:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . get ( medallion . lower ( ) ,  None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  not  ret . required_medallions [ index ] : 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-07 03:31:36 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            raise  Exception ( f " unknown Medallion  { medallion }  for  { ' misery mire '  if  index  ==  0  else  ' turtle rock ' } " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-24 21:14:58 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 16:44:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . plando_texts  =  { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  " texts "  in  plando_options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 07:14:31 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        tt  =  TextTable ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        tt . removeUnwantedText ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 16:44:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        options  =  weights . get ( " plando_texts " ,  [ ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  placement  in  options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  roll_percentage ( get_choice_legacy ( " percentage " ,  placement ,  100 ) ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                at  =  str ( get_choice_legacy ( " at " ,  placement ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 07:14:31 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  at  not  in  tt : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    raise  Exception ( f " No text target  \" { at } \"  found. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ret . plando_texts [ at ]  =  str ( get_choice_legacy ( " text " ,  placement ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 16:44:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 22:41:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . plando_connections  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  " connections "  in  plando_options : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        options  =  weights . get ( " plando_connections " ,  [ ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  placement  in  options : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  roll_percentage ( get_choice_legacy ( " percentage " ,  placement ,  100 ) ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 22:41:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ret . plando_connections . append ( PlandoConnection ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    get_choice_legacy ( " entrance " ,  placement ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    get_choice_legacy ( " exit " ,  placement ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    get_choice_legacy ( " direction " ,  placement ,  " both " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 22:41:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 21:15:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . sprite_pool  =  weights . get ( ' sprite_pool ' ,  [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ret . sprite  =  get_choice_legacy ( ' sprite ' ,  weights ,  " Link " ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 21:15:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ' random_sprite_on_event '  in  weights : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        randomoneventweights  =  weights [ ' random_sprite_on_event ' ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  get_choice_legacy ( ' enabled ' ,  randomoneventweights ,  False ) : 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 21:15:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ret . sprite  =  ' randomon ' 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -hit '  if  get_choice_legacy ( ' on_hit ' ,  randomoneventweights ,  True )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -enter '  if  get_choice_legacy ( ' on_enter ' ,  randomoneventweights ,  False )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -exit '  if  get_choice_legacy ( ' on_exit ' ,  randomoneventweights ,  False )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -slash '  if  get_choice_legacy ( ' on_slash ' ,  randomoneventweights ,  False )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -item '  if  get_choice_legacy ( ' on_item ' ,  randomoneventweights ,  False )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  + =  ' -bonk '  if  get_choice_legacy ( ' on_bonk ' ,  randomoneventweights ,  False )  else  ' ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ret . sprite  =  ' randomonall '  if  get_choice_legacy ( ' on_everything ' ,  randomoneventweights ,  False )  else  ret . sprite 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 21:15:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ret . sprite  =  ' randomonnone '  if  ret . sprite  ==  ' randomon '  else  ret . sprite 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-29 20:21:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( not  ret . sprite_pool  or  get_choice_legacy ( ' use_weighted_sprite_pool ' ,  randomoneventweights ,  False ) )  \
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 21:15:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    and  ' sprite '  in  weights :   # Use sprite as a weighted sprite pool, if a sprite pool is not already defined. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  key ,  value  in  weights [ ' sprite ' ] . items ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  key . startswith ( ' random ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ret . sprite_pool  + =  [ ' random ' ]  *  int ( value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    else : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ret . sprite_pool  + =  [ key ]  *  int ( value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-03 14:47:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								if  __name__  ==  ' __main__ ' :  
						 
					
						
							
								
									
										
										
										
											2021-08-02 01:36:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    import  atexit 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-02 04:57:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    confirmation  =  atexit . register ( input ,  " Press enter to close. " ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-16 02:05:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    main ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-02 04:57:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # in case of error-free exit should not need confirmation 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-03 12:50:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    atexit . unregister ( confirmation )