Mystery: rom options can be set in weights file, eg

rom:
  sprite:
    random: 1
    randomonhit: 1
    mog: 1
  disablemusic: off
  quickswap:
    on: 1
    off: 0
  menuspeed:
    normal: 1
    instant: 1
    double: 1
    triple: 1
    quadruple: 1
    half: 1
  heartcolor:
    red: 1
    blue: 1
    green: 1
    yellow: 1
    random: 1
  heartbeep:
    double: 1
    normal: 1
    half: 1
    quarter: 1
    off: 1
  ow_palettes:
    default: 1
    random: 1
    blackout: 1
  uw_palettes:
    default: 1
    random: 1
    blackout: 1
This commit is contained in:
Bonta-kun 2020-01-09 17:46:07 +01:00
parent 240cf2d844
commit 6bafdfafe6
5 changed files with 39 additions and 46 deletions

View File

@ -9,7 +9,7 @@ from Utils import int16_as_bytes
class World(object):
def __init__(self, players, shuffle, logic, mode, swords, difficulty, difficulty_adjustments, timer, progressive, goal, algorithm, accessibility, shuffle_ganon, quickswap, fastmenu, disable_music, retro, custom, customitemarray, hints):
def __init__(self, players, shuffle, logic, mode, swords, difficulty, difficulty_adjustments, timer, progressive, goal, algorithm, accessibility, shuffle_ganon, retro, custom, customitemarray, hints):
self.players = players
self.shuffle = shuffle.copy()
self.logic = logic.copy()
@ -44,9 +44,6 @@ class World(object):
self.accessibility = accessibility.copy()
self.shuffle_ganon = shuffle_ganon
self.fix_gtower_exit = self.shuffle_ganon
self.quickswap = quickswap
self.fastmenu = fastmenu
self.disable_music = disable_music
self.retro = retro.copy()
self.custom = custom
self.customitemarray = customitemarray
@ -1124,8 +1121,6 @@ class Spoiler(object):
outfile.write('Enemy health: %s\n' % self.metadata['enemy_health'])
outfile.write('Enemy damage: %s\n' % self.metadata['enemy_damage'])
outfile.write('Hints: %s\n' % {k: 'Yes' if v else 'No' for k, v in self.metadata['hints'].items()})
outfile.write('L\\R Quickswap enabled: %s\n' % ('Yes' if self.world.quickswap else 'No'))
outfile.write('Menu speed: %s' % self.world.fastmenu)
if self.entrances:
outfile.write('\n\nEntrances:\n\n')
outfile.write('\n'.join(['%s%s %s %s' % ('Player {0}: '.format(entry['player']) if self.world.players >1 else '', entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances.values()]))

View File

@ -288,9 +288,9 @@ def parse_arguments(argv, no_defaults=False):
for name in ['logic', 'mode', 'swords', 'goal', 'difficulty', 'item_functionality',
'shuffle', 'crystals_ganon', 'crystals_gt', 'openpyramid',
'mapshuffle', 'compassshuffle', 'keyshuffle', 'bigkeyshuffle', 'startinventory',
'retro', 'accessibility', 'hints', 'shufflepots', 'beemizer',
'shufflebosses', 'shuffleenemies', 'enemy_health', 'enemy_damage',
'ow_palettes', 'uw_palettes', 'sprite']:
'retro', 'accessibility', 'hints', 'beemizer',
'shufflebosses', 'shuffleenemies', 'enemy_health', 'enemy_damage', 'shufflepots',
'ow_palettes', 'uw_palettes', 'sprite', 'disablemusic', 'quickswap', 'fastmenu', 'heartcolor', 'heartbeep']:
value = getattr(defaults, name) if getattr(playerargs, name) is None else getattr(playerargs, name)
if player == 1:
setattr(ret, name, {1: value})

View File

@ -33,7 +33,7 @@ def main(args, seed=None):
start = time.process_time()
# initialize the world
world = World(args.multi, args.shuffle, args.logic, args.mode, args.swords, args.difficulty, args.item_functionality, args.timer, args.progressive, args.goal, args.algorithm, args.accessibility, args.shuffleganon, args.quickswap, args.fastmenu, args.disablemusic, args.retro, args.custom, args.customitemarray, args.hints)
world = World(args.multi, args.shuffle, args.logic, args.mode, args.swords, args.difficulty, args.item_functionality, args.timer, args.progressive, args.goal, args.algorithm, args.accessibility, args.shuffleganon, args.retro, args.custom, args.customitemarray, args.hints)
logger = logging.getLogger('')
if seed is None:
random.seed(None)
@ -172,7 +172,7 @@ def main(args, seed=None):
for addr, values in get_race_rom_patches(rom).items():
rom.write_bytes(int(addr), values)
apply_rom_settings(rom, args.heartbeep, args.heartcolor, world.quickswap, world.fastmenu, world.disable_music, args.sprite[player], args.ow_palettes[player], args.uw_palettes[player], player_names)
apply_rom_settings(rom, args.heartbeep[player], args.heartcolor[player], args.quickswap[player], args.fastmenu[player], args.disablemusic[player], args.sprite[player], args.ow_palettes[player], args.uw_palettes[player], player_names)
mcsb_name = ''
if all([world.mapshuffle[player], world.compassshuffle[player], world.keyshuffle[player], world.bigkeyshuffle[player]]):
@ -219,7 +219,7 @@ def main(args, seed=None):
def copy_world(world):
# ToDo: Not good yet
ret = World(world.players, world.shuffle, world.logic, world.mode, world.swords, world.difficulty, world.difficulty_adjustments, world.timer, world.progressive, world.goal, world.algorithm, world.accessibility, world.shuffle_ganon, world.quickswap, world.fastmenu, world.disable_music, world.retro, world.custom, world.customitemarray, world.hints)
ret = World(world.players, world.shuffle, world.logic, world.mode, world.swords, world.difficulty, world.difficulty_adjustments, world.timer, world.progressive, world.goal, world.algorithm, world.accessibility, world.shuffle_ganon, world.retro, world.custom, world.customitemarray, world.hints)
ret.required_medallions = world.required_medallions.copy()
ret.swamp_patch_required = world.swamp_patch_required.copy()
ret.ganon_at_pyramid = world.ganon_at_pyramid.copy()

View File

@ -88,7 +88,8 @@ def main():
if path:
settings = settings_cache[path] if settings_cache[path] else roll_settings(weights_cache[path])
for k, v in vars(settings).items():
getattr(erargs, k)[player] = v
if v is not None:
getattr(erargs, k)[player] = v
else:
raise RuntimeError(f'No weights specified for player {player}')
@ -113,7 +114,7 @@ def get_weights(path):
def roll_settings(weights):
def get_choice(option, root=weights):
if option not in weights:
if option not in root:
return None
if type(root[option]) is not dict:
return root[option]
@ -138,73 +139,59 @@ def roll_settings(weights):
ret.keyshuffle = get_choice('smallkey_shuffle') == 'on' if 'smallkey_shuffle' in weights else dungeon_items in ['mcs', 'full']
ret.bigkeyshuffle = get_choice('bigkey_shuffle') == 'on' if 'bigkey_shuffle' in weights else dungeon_items in ['full']
accessibility = get_choice('accessibility')
ret.accessibility = accessibility
ret.accessibility = get_choice('accessibility')
entrance_shuffle = get_choice('entrance_shuffle')
ret.shuffle = entrance_shuffle if entrance_shuffle != 'none' else 'vanilla'
goals = get_choice('goals')
ret.goal = {'ganon': 'ganon',
'fast_ganon': 'crystals',
'dungeons': 'dungeons',
'pedestal': 'pedestal',
'triforce-hunt': 'triforcehunt'
}[goals]
ret.openpyramid = goals == 'fast_ganon'
}[get_choice('goals')]
ret.openpyramid = ret.goal == 'fast_ganon'
tower_open = get_choice('tower_open')
ret.crystals_gt = tower_open
ret.crystals_gt = get_choice('tower_open')
ganon_open = get_choice('ganon_open')
ret.crystals_ganon = ganon_open
ret.crystals_ganon = get_choice('ganon_open')
world_state = get_choice('world_state')
ret.mode = world_state
if world_state == 'retro':
ret.mode = get_choice('world_state')
if ret.mode == 'retro':
ret.mode = 'open'
ret.retro = True
hints = get_choice('hints')
ret.hints = hints == 'on'
ret.hints = get_choice('hints') == 'on'
weapons = get_choice('weapons')
ret.swords = {'randomized': 'random',
'assured': 'assured',
'vanilla': 'vanilla',
'swordless': 'swordless'
}[weapons]
}[get_choice('weapons')]
item_pool = get_choice('item_pool')
ret.difficulty = item_pool
ret.difficulty = get_choice('item_pool')
item_functionality = get_choice('item_functionality')
ret.item_functionality = item_functionality
ret.item_functionality = get_choice('item_functionality')
boss_shuffle = get_choice('boss_shuffle')
ret.shufflebosses = {'none': 'none',
'simple': 'basic',
'full': 'normal',
'random': 'chaos'
}[boss_shuffle]
}[get_choice('boss_shuffle')]
enemy_shuffle = get_choice('enemy_shuffle')
ret.shuffleenemies = {'none': 'none',
'shuffled': 'shuffled',
'random': 'chaos'
}[enemy_shuffle]
}[get_choice('enemy_shuffle')]
enemy_damage = get_choice('enemy_damage')
ret.enemy_damage = {'default': 'default',
'shuffled': 'shuffled',
'random': 'chaos'
}[enemy_damage]
}[get_choice('enemy_damage')]
enemy_health = get_choice('enemy_health')
ret.enemy_health = enemy_health
ret.enemy_health = get_choice('enemy_health')
pot_shuffle = get_choice('pot_shuffle')
ret.shufflepots = pot_shuffle == 'on'
ret.shufflepots = get_choice('pot_shuffle') == 'on'
ret.beemizer = int(get_choice('beemizer')) if 'beemizer' in weights else 0
@ -215,6 +202,17 @@ def roll_settings(weights):
startitems.append(item)
ret.startinventory = ','.join(startitems)
if 'rom' in weights:
romweights = weights['rom']
ret.sprite = get_choice('sprite', romweights)
ret.disablemusic = get_choice('disablemusic', romweights) == 'on'
ret.quickswap = get_choice('quickswap', romweights) == 'on'
ret.fastmenu = get_choice('menuspeed', romweights)
ret.heartcolor = get_choice('heartcolor', romweights)
ret.heartbeep = get_choice('heartbeep', romweights)
ret.ow_palettes = get_choice('ow_palettes', romweights)
ret.uw_palettes = get_choice('uw_palettes', romweights)
return ret
if __name__ == '__main__':

View File

@ -23,7 +23,7 @@ def main(args):
start_time = time.process_time()
# initialize the world
world = World(1, 'vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, args.quickswap, args.fastmenu, args.disablemusic, False, False, False, None, False)
world = World(1, 'vanilla', 'noglitches', 'standard', 'normal', 'none', 'on', 'ganon', 'freshness', False, False, False, False, False, False, None, False)
logger = logging.getLogger('')
hasher = hashlib.md5()
@ -71,7 +71,7 @@ def main(args):
rom = LocalRom(args.rom)
patch_rom(world, 1, rom, False)
apply_rom_settings(rom, args.heartbeep, args.heartcolor, world.quickswap, world.fastmenu, world.disable_music, args.sprite, args.ow_palettes, args.uw_palettes)
apply_rom_settings(rom, args.heartbeep, args.heartcolor, args.quickswap, args.fastmenu, args.disablemusic, args.sprite, args.ow_palettes, args.uw_palettes)
for textname, texttype, text in text_patches:
if texttype == 'text':