Merge pull request #111 from Berserker66/tweaks_and_fixes
Tweaks and fixes
This commit is contained in:
		
						commit
						10f675a61e
					
				|  | @ -82,10 +82,10 @@ def parse_arguments(argv, no_defaults=False): | ||||||
|                                             20 of them to beat the game.        |                                             20 of them to beat the game.        | ||||||
|                              ''') |                              ''') | ||||||
|     parser.add_argument('--triforce_pieces_available', default=defval(30), |     parser.add_argument('--triforce_pieces_available', default=defval(30), | ||||||
|                         type=lambda value: min(max(int(value), 1), 112), |                         type=lambda value: min(max(int(value), 1), 90), | ||||||
|                         help='''Set Triforce Pieces available in item pool.''') |                         help='''Set Triforce Pieces available in item pool.''') | ||||||
|     parser.add_argument('--triforce_pieces_required', default=defval(20), |     parser.add_argument('--triforce_pieces_required', default=defval(20), | ||||||
|                         type=lambda value: min(max(int(value), 1), 112), |                         type=lambda value: min(max(int(value), 1), 90), | ||||||
|                         help='''Set Triforce Pieces required to win a Triforce Hunt''') |                         help='''Set Triforce Pieces required to win a Triforce Hunt''') | ||||||
|     parser.add_argument('--difficulty', default=defval('normal'), const='normal', nargs='?', |     parser.add_argument('--difficulty', default=defval('normal'), const='normal', nargs='?', | ||||||
|                         choices=['normal', 'hard', 'expert'], |                         choices=['normal', 'hard', 'expert'], | ||||||
|  |  | ||||||
|  | @ -64,8 +64,8 @@ difficulties = { | ||||||
|         progressive_armor_limit = 2, |         progressive_armor_limit = 2, | ||||||
|         progressive_bow_limit = 2, |         progressive_bow_limit = 2, | ||||||
|         progressive_bottle_limit = 4, |         progressive_bottle_limit = 4, | ||||||
|         boss_heart_container_limit = 255, |         boss_heart_container_limit = 10, | ||||||
|         heart_piece_limit = 255, |         heart_piece_limit = 24, | ||||||
|     ), |     ), | ||||||
|     'hard': Difficulty( |     'hard': Difficulty( | ||||||
|         baseitems = normalbaseitems, |         baseitems = normalbaseitems, | ||||||
|  |  | ||||||
							
								
								
									
										52
									
								
								Mystery.py
								
								
								
								
							
							
						
						
									
										52
									
								
								Mystery.py
								
								
								
								
							|  | @ -63,14 +63,14 @@ def main(): | ||||||
|             weights_cache[args.weights] = get_weights(args.weights) |             weights_cache[args.weights] = get_weights(args.weights) | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             raise ValueError(f"File {args.weights} is destroyed. Please fix your yaml.") from e |             raise ValueError(f"File {args.weights} is destroyed. Please fix your yaml.") from e | ||||||
|         print(f"Weights: {args.weights} >> {weights_cache[args.weights]['description']}") |         print(f"Weights: {args.weights} >> {get_choice('description', weights_cache[args.weights], 'No description specified')}") | ||||||
|     if args.meta: |     if args.meta: | ||||||
|         try: |         try: | ||||||
|             weights_cache[args.meta] = get_weights(args.meta) |             weights_cache[args.meta] = get_weights(args.meta) | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             raise ValueError(f"File {args.meta} is destroyed. Please fix your yaml.") from e |             raise ValueError(f"File {args.meta} is destroyed. Please fix your yaml.") from e | ||||||
|         meta_weights = weights_cache[args.meta] |         meta_weights = weights_cache[args.meta] | ||||||
|         print(f"Meta: {args.meta} >> {meta_weights['meta_description']}") |         print(f"Meta: {args.meta} >> {get_choice('meta_description', meta_weights, 'No description specified')}") | ||||||
|         if args.samesettings: |         if args.samesettings: | ||||||
|             raise Exception("Cannot mix --samesettings with --meta") |             raise Exception("Cannot mix --samesettings with --meta") | ||||||
| 
 | 
 | ||||||
|  | @ -80,7 +80,7 @@ def main(): | ||||||
|             try: |             try: | ||||||
|                 if path not in weights_cache: |                 if path not in weights_cache: | ||||||
|                     weights_cache[path] = get_weights(path) |                     weights_cache[path] = get_weights(path) | ||||||
|                 print(f"P{player} Weights: {path} >> {weights_cache[path]['description']}") |                 print(f"P{player} Weights: {path} >> {get_choice('description', weights_cache[path], 'No description specified')}") | ||||||
| 
 | 
 | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e |                 raise ValueError(f"File {path} is destroyed. Please fix your yaml.") from e | ||||||
|  | @ -223,15 +223,17 @@ def convert_to_on_off(value): | ||||||
|     return {True: "on", False: "off"}.get(value, value) |     return {True: "on", False: "off"}.get(value, value) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def get_choice(option, root) -> typing.Any: | def get_choice(option, root, value=None) -> typing.Any: | ||||||
|     if option not in root: |     if option not in root: | ||||||
|         return None |         return value | ||||||
|     if type(root[option]) is not dict: |     if type(root[option]) is not dict: | ||||||
|         return interpret_on_off(root[option]) |         return interpret_on_off(root[option]) | ||||||
|     if not root[option]: |     if not root[option]: | ||||||
|         return None |         return value | ||||||
|     return interpret_on_off( |     if any(root[option].values()): | ||||||
|         random.choices(list(root[option].keys()), weights=list(map(int, root[option].values())))[0]) |         return interpret_on_off( | ||||||
|  |             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.") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def handle_name(name: str): | def handle_name(name: str): | ||||||
|  | @ -257,8 +259,7 @@ def roll_settings(weights): | ||||||
|     ret.logic = {None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', |     ret.logic = {None: 'noglitches', 'none': 'noglitches', 'no_logic': 'nologic', 'overworld_glitches': 'owglitches', | ||||||
|                  'minor_glitches' : 'minorglitches'}[ |                  'minor_glitches' : 'minorglitches'}[ | ||||||
|         glitches_required] |         glitches_required] | ||||||
|     ret.progression_balancing = get_choice('progression_balancing', |     ret.progression_balancing = get_choice('progression_balancing', weights, True) | ||||||
|                                            weights) if 'progression_balancing' in weights else True |  | ||||||
|     # item_placement = get_choice('item_placement') |     # item_placement = get_choice('item_placement') | ||||||
|     # not supported in ER |     # not supported in ER | ||||||
| 
 | 
 | ||||||
|  | @ -270,10 +271,10 @@ def roll_settings(weights): | ||||||
|     elif not dungeon_items: |     elif not dungeon_items: | ||||||
|         dungeon_items = "" |         dungeon_items = "" | ||||||
| 
 | 
 | ||||||
|     ret.mapshuffle = get_choice('map_shuffle', weights) if 'map_shuffle' in weights else 'm' in dungeon_items |     ret.mapshuffle = get_choice('map_shuffle', weights, 'm' in dungeon_items) | ||||||
|     ret.compassshuffle = get_choice('compass_shuffle', weights) if 'compass_shuffle' in weights else 'c' in dungeon_items |     ret.compassshuffle = get_choice('compass_shuffle', weights, 'c' in dungeon_items) | ||||||
|     ret.keyshuffle = get_choice('smallkey_shuffle', weights) if 'smallkey_shuffle' in weights else 's' in dungeon_items |     ret.keyshuffle = get_choice('smallkey_shuffle', weights, 's' in dungeon_items) | ||||||
|     ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights) if 'bigkey_shuffle' in weights else 'b' in dungeon_items |     ret.bigkeyshuffle = get_choice('bigkey_shuffle', weights, 'b' in dungeon_items) | ||||||
| 
 | 
 | ||||||
|     ret.accessibility = get_choice('accessibility', weights) |     ret.accessibility = get_choice('accessibility', weights) | ||||||
| 
 | 
 | ||||||
|  | @ -295,14 +296,11 @@ def roll_settings(weights): | ||||||
| 
 | 
 | ||||||
|     ret.crystals_ganon = get_choice('ganon_open', weights) |     ret.crystals_ganon = get_choice('ganon_open', weights) | ||||||
| 
 | 
 | ||||||
|     ret.triforce_pieces_available = get_choice('triforce_pieces_available', |     ret.triforce_pieces_available = get_choice('triforce_pieces_available', weights, 30) | ||||||
|                                                weights) if "triforce_pieces_available" in weights else 30 |     ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 90) | ||||||
| 
 | 
 | ||||||
|     ret.triforce_pieces_available = min(max(1, int(ret.triforce_pieces_available)), 112) |     ret.triforce_pieces_required = get_choice('triforce_pieces_required', weights, 20) | ||||||
| 
 |     ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 90) | ||||||
|     ret.triforce_pieces_required = get_choice('triforce_pieces_required', |  | ||||||
|                                               weights) if "triforce_pieces_required" in weights else 20 |  | ||||||
|     ret.triforce_pieces_required = min(max(1, int(ret.triforce_pieces_required)), 112) |  | ||||||
| 
 | 
 | ||||||
|     ret.mode = get_choice('world_state', weights) |     ret.mode = get_choice('world_state', weights) | ||||||
|     if ret.mode == 'retro': |     if ret.mode == 'retro': | ||||||
|  | @ -341,7 +339,7 @@ def roll_settings(weights): | ||||||
| 
 | 
 | ||||||
|     ret.shufflepots = get_choice('pot_shuffle', weights) |     ret.shufflepots = get_choice('pot_shuffle', weights) | ||||||
| 
 | 
 | ||||||
|     ret.beemizer = int(get_choice('beemizer', weights)) if 'beemizer' in weights else 0 |     ret.beemizer = int(get_choice('beemizer', weights, 0)) | ||||||
| 
 | 
 | ||||||
|     ret.timer = {'none': False, |     ret.timer = {'none': False, | ||||||
|                  None: False, |                  None: False, | ||||||
|  | @ -350,11 +348,11 @@ def roll_settings(weights): | ||||||
|                  'timed_ohko': 'timed-ohko', |                  'timed_ohko': 'timed-ohko', | ||||||
|                  'ohko': 'ohko', |                  'ohko': 'ohko', | ||||||
|                  'timed_countdown': 'timed-countdown', |                  'timed_countdown': 'timed-countdown', | ||||||
|                  'display': 'display'}[get_choice('timer', weights)] if 'timer' in weights.keys() else False |                  'display': 'display'}[get_choice('timer', weights, False)] | ||||||
| 
 | 
 | ||||||
|     ret.dungeon_counters = get_choice('dungeon_counters', weights) if 'dungeon_counters' in weights else 'default' |     ret.dungeon_counters = get_choice('dungeon_counters', weights, 'default') | ||||||
| 
 | 
 | ||||||
|     ret.progressive = convert_to_on_off(get_choice('progressive', weights)) if "progressive" in weights else 'on' |     ret.progressive = convert_to_on_off(get_choice('progressive', weights, 'on')) | ||||||
|     inventoryweights = weights.get('startinventory', {}) |     inventoryweights = weights.get('startinventory', {}) | ||||||
|     startitems = [] |     startitems = [] | ||||||
|     for item in inventoryweights.keys(): |     for item in inventoryweights.keys(): | ||||||
|  | @ -368,9 +366,9 @@ def roll_settings(weights): | ||||||
|             startitems.append(item) |             startitems.append(item) | ||||||
|     ret.startinventory = ','.join(startitems) |     ret.startinventory = ','.join(startitems) | ||||||
| 
 | 
 | ||||||
|     ret.glitch_boots = get_choice('glitch_boots', weights) if 'glitch_boots' in weights else True |     ret.glitch_boots = get_choice('glitch_boots', weights, True) | ||||||
| 
 | 
 | ||||||
|     ret.remote_items = get_choice('remote_items', weights) if 'remote_items' in weights else False |     ret.remote_items = get_choice('remote_items', weights, False) | ||||||
| 
 | 
 | ||||||
|     if "l" in dungeon_items: |     if "l" in dungeon_items: | ||||||
|         ret.local_items = {"Small Keys", "Big Keys"} |         ret.local_items = {"Small Keys", "Big Keys"} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue