implement glitch_boots as a proper CLI option

This commit is contained in:
Fabian Dill 2020-04-16 11:02:16 +02:00
parent 30ae9487d4
commit 31d3b7ce84
5 changed files with 20 additions and 35 deletions

View File

@ -111,6 +111,7 @@ class World(object):
set_player_attr('treasure_hunt_count', 0)
set_player_attr('clock_mode', False)
set_player_attr('can_take_damage', True)
set_player_attr('glitch_boots', True)
def get_name_string_for_object(self, obj) -> str:
return obj.name if self.players == 1 else f'{obj.name} ({self.get_player_names(obj.player)})'

View File

@ -292,12 +292,15 @@ def parse_arguments(argv, no_defaults=False):
parser.add_argument('--create_diff', default=defval(False), action='store_true', help='''\
create a binary patch file from which the randomized rom can be recreated using MultiClient.
Does not work with jsonout.''')
parser.add_argument('--disable_glitch_boots', default=defval(False), action='store_true', help='''\
turns off starting with Pegasus Boots in glitched modes.''')
if multiargs.multi:
for player in range(1, multiargs.multi + 1):
parser.add_argument(f'--p{player}', default=defval(''), help=argparse.SUPPRESS)
ret = parser.parse_args(argv)
ret.glitch_boots = not ret.disable_glitch_boots
if ret.timer == "none":
ret.timer = False
if ret.dungeon_counters == 'on':
@ -319,7 +322,7 @@ def parse_arguments(argv, no_defaults=False):
'shufflebosses', 'shuffleenemies', 'enemy_health', 'enemy_damage', 'shufflepots',
'ow_palettes', 'uw_palettes', 'sprite', 'disablemusic', 'quickswap', 'fastmenu', 'heartcolor',
'heartbeep',
'remote_items', 'progressive', 'extendedmsu', 'dungeon_counters']:
'remote_items', 'progressive', 'extendedmsu', 'dungeon_counters', 'glitch_boots']:
value = getattr(defaults, name) if getattr(playerargs, name) is None else getattr(playerargs, name)
if player == 1:
setattr(ret, name, {1: value})

View File

@ -189,9 +189,7 @@ def generate_itempool(world, player):
world.rupoor_cost = min(world.customitemarray[69], 9999)
else:
(pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon,
lamps_needed_for_dark_rooms) = get_pool_core(world.progressive[player], world.shuffle[player],
world.difficulty[player], world.timer[player], world.goal[player],
world.mode[player], world.swords[player], world.retro[player], world.logic[player])
lamps_needed_for_dark_rooms) = get_pool_core(world, player)
for item in precollected_items:
world.push_precollected(ItemFactory(item, player))
@ -392,7 +390,17 @@ def set_up_shops(world, player):
rss.locked = True
def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, swords, retro, logic):
def get_pool_core(world, player: int):
progressive = world.progressive[player]
shuffle = world.shuffle[player]
difficulty = world.difficulty[player]
timer = world.timer[player]
goal = world.goal[player]
mode = world.mode[player]
swords = world.swords[player]
retro = world.retro[player]
logic = world.logic[player]
pool = []
placed_items = {}
precollected_items = []
@ -410,7 +418,7 @@ def get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, swords, r
return random.choice([True, False]) if progressive == 'random' else progressive == 'on'
# provide boots to major glitch dependent seeds
if logic in ['owglitches', 'nologic']:
if logic in {'owglitches', 'nologic'} and world.glitch_boots[player]:
precollected_items.append('Pegasus Boots')
pool.remove('Pegasus Boots')
pool.extend(['Rupees (20)'])
@ -674,31 +682,5 @@ def make_custom_item_pool(progressive, shuffle, difficulty, timer, goal, mode, s
return (pool, placed_items, precollected_items, clock_mode, treasure_hunt_count, treasure_hunt_icon, lamps_needed_for_dark_rooms)
# A quick test to ensure all combinations generate the correct amount of items.
def test():
for difficulty in ['normal', 'hard', 'expert']:
for goal in ['ganon', 'triforcehunt', 'pedestal']:
for timer in [False, 'display', 'timed', 'timed-ohko', 'ohko', 'timed-countdown']:
for mode in ['open', 'standard', 'inverted']:
for swords in ['random', 'assured', 'swordless', 'vanilla']:
for progressive in ['on', 'off']:
for shuffle in ['full', 'insanity_legacy']:
for retro in [True, False]:
for logic in ['noglitches', 'owglitches']:
out = get_pool_core(progressive, shuffle, difficulty, timer, goal, mode, swords,
retro, logic)
count = len(out[0]) + len(out[1])
correct_count = total_items_to_place
if goal == 'pedestal' and swords != 'vanilla':
# pedestal goals generate one extra item
correct_count += 1
if retro:
correct_count += 28
try:
assert count == correct_count, "expected {0} items but found {1} items for {2}".format(correct_count, count, (progressive, shuffle, difficulty, timer, goal, mode, swords, retro))
except AssertionError as e:
print(e)
if __name__ == '__main__':
test()

View File

@ -59,6 +59,7 @@ def main(args, seed=None):
world.progressive = args.progressive.copy()
world.dungeon_counters = args.dungeon_counters.copy()
world.extendedmsu = args.extendedmsu.copy()
world.glitch_boots = args.glitch_boots.copy()
world.rom_seeds = {player: random.randint(0, 999999999) for player in range(1, world.players + 1)}

View File

@ -282,9 +282,7 @@ def roll_settings(weights):
startitems.append(item)
elif itemvalue:
startitems.append(item)
glitch_boots = get_choice('glitch_boots', weights) if 'glitch_boots' in weights else True
if ret.logic != 'noglitches' and 'Pegasus Boots' not in startitems and glitch_boots:
startitems.append('Pegasus Boots')
ret.glitch_boots = get_choice('glitch_boots', weights) if 'glitch_boots' in weights else True
ret.startinventory = ','.join(startitems)
ret.remote_items = get_choice('remote_items', weights) if 'remote_items' in weights else False