Improve information on selected options in spoiler.
This commit is contained in:
		
							parent
							
								
									9e05284df9
								
							
						
					
					
						commit
						b7a8cedf42
					
				| 
						 | 
					@ -6,7 +6,7 @@ from collections import OrderedDict
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class World(object):
 | 
					class World(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, shuffle, logic, mode, difficulty, goal, algorithm, place_dungeon_items, check_beatable_only, shuffle_ganon):
 | 
					    def __init__(self, shuffle, logic, mode, difficulty, goal, algorithm, place_dungeon_items, check_beatable_only, shuffle_ganon, quickswap):
 | 
				
			||||||
        self.shuffle = shuffle
 | 
					        self.shuffle = shuffle
 | 
				
			||||||
        self.logic = logic
 | 
					        self.logic = logic
 | 
				
			||||||
        self.mode = mode
 | 
					        self.mode = mode
 | 
				
			||||||
| 
						 | 
					@ -46,6 +46,7 @@ class World(object):
 | 
				
			||||||
        self.shuffle_ganon = shuffle_ganon
 | 
					        self.shuffle_ganon = shuffle_ganon
 | 
				
			||||||
        self.fix_gtower_exit = self.shuffle_ganon
 | 
					        self.fix_gtower_exit = self.shuffle_ganon
 | 
				
			||||||
        self.can_access_trock_eyebridge = None
 | 
					        self.can_access_trock_eyebridge = None
 | 
				
			||||||
 | 
					        self.quickswap = quickswap
 | 
				
			||||||
        self.spoiler = Spoiler(self)
 | 
					        self.spoiler = Spoiler(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_region(self, regionname):
 | 
					    def get_region(self, regionname):
 | 
				
			||||||
| 
						 | 
					@ -562,7 +563,11 @@ class Spoiler(object):
 | 
				
			||||||
                         'mode': self.world.mode,
 | 
					                         'mode': self.world.mode,
 | 
				
			||||||
                         'goal': self.world.goal,
 | 
					                         'goal': self.world.goal,
 | 
				
			||||||
                         'shuffle': self.world.shuffle,
 | 
					                         'shuffle': self.world.shuffle,
 | 
				
			||||||
                         'algorithm': self.world.algorithm}
 | 
					                         'algorithm': self.world.algorithm,
 | 
				
			||||||
 | 
					                         'difficulty': self.world.difficulty,
 | 
				
			||||||
 | 
					                         'completeable': not self.world.check_beatable_only,
 | 
				
			||||||
 | 
					                         'dungeonitems': self.world.place_dungeon_items,
 | 
				
			||||||
 | 
					                         'quickswap': self.world.quickswap}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def to_json(self):
 | 
					    def to_json(self):
 | 
				
			||||||
        self.parse_data()
 | 
					        self.parse_data()
 | 
				
			||||||
| 
						 | 
					@ -578,7 +583,14 @@ class Spoiler(object):
 | 
				
			||||||
        self.parse_data()
 | 
					        self.parse_data()
 | 
				
			||||||
        with open(filename, 'w') as outfile:
 | 
					        with open(filename, 'w') as outfile:
 | 
				
			||||||
            outfile.write('ALttP Entrance Randomizer Version %s  -  Seed: %s\n\n' % (self.metadata['version'], self.metadata['seed']))
 | 
					            outfile.write('ALttP Entrance Randomizer Version %s  -  Seed: %s\n\n' % (self.metadata['version'], self.metadata['seed']))
 | 
				
			||||||
            outfile.write('Logic: %s  Mode: %s  Goal: %s  Entrance Shuffle: %s  Filling Algorithm: %s' % (self.metadata['logic'], self.metadata['mode'], self.metadata['goal'], self.metadata['shuffle'], self.metadata['algorithm']))
 | 
					            outfile.write('Logic:                           %s\n' % self.metadata['logic'])
 | 
				
			||||||
 | 
					            outfile.write('Mode:                            %s\n' % self.metadata['mode'])
 | 
				
			||||||
 | 
					            outfile.write('Goal:                            %s\n' % self.metadata['goal'])
 | 
				
			||||||
 | 
					            outfile.write('Entrance Shuffle:                %s\n' % self.metadata['shuffle'])
 | 
				
			||||||
 | 
					            outfile.write('Filling Algorithm:               %s\n' % self.metadata['algorithm'])
 | 
				
			||||||
 | 
					            outfile.write('All Locations Accessible:        %s\n' % ('Yes' if self.metadata['completeable'] else 'No, some locations may be unreachable'))
 | 
				
			||||||
 | 
					            outfile.write('Maps and Compasses in Dungeons:  %s\n' % ('Yes' if self.metadata['dungeonitems'] else 'No'))
 | 
				
			||||||
 | 
					            outfile.write('L\\R Quickswap enabled:           %s' % ('Yes' if self.metadata['quickswap'] else 'No'))
 | 
				
			||||||
            if self.entrances:
 | 
					            if self.entrances:
 | 
				
			||||||
                outfile.write('\n\nEntrances:\n\n')
 | 
					                outfile.write('\n\nEntrances:\n\n')
 | 
				
			||||||
                outfile.write('\n'.join(['%s %s %s' % (entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances]))
 | 
					                outfile.write('\n'.join(['%s %s %s' % (entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances]))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6
									
								
								Main.py
								
								
								
								
							
							
						
						
									
										6
									
								
								Main.py
								
								
								
								
							| 
						 | 
					@ -27,7 +27,7 @@ def main(args, seed=None):
 | 
				
			||||||
    start = time.clock()
 | 
					    start = time.clock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # initialize the world
 | 
					    # initialize the world
 | 
				
			||||||
    world = World(args.shuffle, args.logic, args.mode, args.difficulty, args.goal, args.algorithm, not args.nodungeonitems, args.beatableonly, args.shuffleganon)
 | 
					    world = World(args.shuffle, args.logic, args.mode, args.difficulty, args.goal, args.algorithm, not args.nodungeonitems, args.beatableonly, args.shuffleganon, args.quickswap)
 | 
				
			||||||
    logger = logging.getLogger('')
 | 
					    logger = logging.getLogger('')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if seed is None:
 | 
					    if seed is None:
 | 
				
			||||||
| 
						 | 
					@ -88,7 +88,7 @@ def main(args, seed=None):
 | 
				
			||||||
            rom = JsonRom()
 | 
					            rom = JsonRom()
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            rom = LocalRom(args.rom)
 | 
					            rom = LocalRom(args.rom)
 | 
				
			||||||
        patch_rom(world, rom, bytearray(logic_hash), args.quickswap, args.heartbeep, sprite)
 | 
					        patch_rom(world, rom, bytearray(logic_hash), args.heartbeep, sprite)
 | 
				
			||||||
        if args.jsonout:
 | 
					        if args.jsonout:
 | 
				
			||||||
            print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()}))
 | 
					            print(json.dumps({'patch': rom.patches, 'spoiler': world.spoiler.to_json()}))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
| 
						 | 
					@ -520,7 +520,7 @@ def generate_itempool(world):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def copy_world(world):
 | 
					def copy_world(world):
 | 
				
			||||||
    # ToDo: Not good yet
 | 
					    # ToDo: Not good yet
 | 
				
			||||||
    ret = World(world.shuffle, world.logic, world.mode, world.difficulty, world.goal, world.algorithm, world.place_dungeon_items, world.check_beatable_only, world.shuffle_ganon)
 | 
					    ret = World(world.shuffle, world.logic, world.mode, world.difficulty, world.goal, world.algorithm, world.place_dungeon_items, world.check_beatable_only, world.shuffle_ganon, world.quickswap)
 | 
				
			||||||
    ret.required_medallions = list(world.required_medallions)
 | 
					    ret.required_medallions = list(world.required_medallions)
 | 
				
			||||||
    ret.swamp_patch_required = world.swamp_patch_required
 | 
					    ret.swamp_patch_required = world.swamp_patch_required
 | 
				
			||||||
    ret.ganon_at_pyramid = world.ganon_at_pyramid
 | 
					    ret.ganon_at_pyramid = world.ganon_at_pyramid
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ def main(args, seed=None):
 | 
				
			||||||
    start = time.clock()
 | 
					    start = time.clock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # initialize the world
 | 
					    # initialize the world
 | 
				
			||||||
    world = World('vanilla', 'noglitches', 'standard', 'normal', 'ganon', 'freshness', False, False, False)
 | 
					    world = World('vanilla', 'noglitches', 'standard', 'normal', 'ganon', 'freshness', False, False, False, args.quickswap)
 | 
				
			||||||
    logger = logging.getLogger('')
 | 
					    logger = logging.getLogger('')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hasher = hashlib.md5()
 | 
					    hasher = hashlib.md5()
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ def main(args, seed=None):
 | 
				
			||||||
        sprite = None
 | 
					        sprite = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rom = LocalRom(args.rom)
 | 
					    rom = LocalRom(args.rom)
 | 
				
			||||||
    patch_rom(world, rom, logic_hash, args.quickswap, args.heartbeep, sprite)
 | 
					    patch_rom(world, rom, logic_hash, args.heartbeep, sprite)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for textname, texttype, text in text_patches:
 | 
					    for textname, texttype, text in text_patches:
 | 
				
			||||||
        if texttype == 'text':
 | 
					        if texttype == 'text':
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								Rom.py
								
								
								
								
							
							
						
						
									
										4
									
								
								Rom.py
								
								
								
								
							| 
						 | 
					@ -73,7 +73,7 @@ class LocalRom(object):
 | 
				
			||||||
        self.write_bytes(0x7FDC, [inv & 0xFF, (inv >> 8) & 0xFF, crc & 0xFF, (crc >> 8) & 0xFF])
 | 
					        self.write_bytes(0x7FDC, [inv & 0xFF, (inv >> 8) & 0xFF, crc & 0xFF, (crc >> 8) & 0xFF])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def patch_rom(world, rom, hashtable, quickswap=False, beep='normal', sprite=None):
 | 
					def patch_rom(world, rom, hashtable, beep='normal', sprite=None):
 | 
				
			||||||
    # patch items
 | 
					    # patch items
 | 
				
			||||||
    for location in world.get_locations():
 | 
					    for location in world.get_locations():
 | 
				
			||||||
        itemid = location.item.code if location.item is not None else 0x5A
 | 
					        itemid = location.item.code if location.item is not None else 0x5A
 | 
				
			||||||
| 
						 | 
					@ -346,7 +346,7 @@ def patch_rom(world, rom, hashtable, quickswap=False, beep='normal', sprite=None
 | 
				
			||||||
        # todo fix screen scrolling
 | 
					        # todo fix screen scrolling
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # enable quick item swapping with L and R (ported by Amazing Ampharos)
 | 
					    # enable quick item swapping with L and R (ported by Amazing Ampharos)
 | 
				
			||||||
    if quickswap:
 | 
					    if world.quickswap:
 | 
				
			||||||
        rom.write_bytes(0x107fb, [0x22, 0x50, 0xFF, 0x1F])
 | 
					        rom.write_bytes(0x107fb, [0x22, 0x50, 0xFF, 0x1F])
 | 
				
			||||||
        rom.write_bytes(0x12451, [0x22, 0x50, 0xFF, 0x1F])
 | 
					        rom.write_bytes(0x12451, [0x22, 0x50, 0xFF, 0x1F])
 | 
				
			||||||
        rom.write_bytes(0xfff50, [0x20, 0x58, 0xFF, 0xA5, 0xF6, 0x29, 0x40, 0x6B, 0xA5, 0xF6, 0x89, 0x10, 0xF0, 0x03, 0x4C, 0x69,
 | 
					        rom.write_bytes(0xfff50, [0x20, 0x58, 0xFF, 0xA5, 0xF6, 0x29, 0x40, 0x6B, 0xA5, 0xF6, 0x89, 0x10, 0xF0, 0x03, 0x4C, 0x69,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue