Fix copy world.

This commit is contained in:
compiling
2020-10-31 10:05:28 +11:00
parent 171b9430c8
commit ef294ab0d3
5 changed files with 23 additions and 35 deletions

View File

@@ -83,9 +83,12 @@ class World(object):
self.spoiler = Spoiler(self) self.spoiler = Spoiler(self)
self.lamps_needed_for_dark_rooms = 1 self.lamps_needed_for_dark_rooms = 1
def intialize_regions(self): def initialize_regions(self, regions=None):
for region in self.regions: for region in regions if regions else self.regions:
region.world = self region.world = self
self._region_cache[(region.name, region.player)] = region
for exit in region.exits:
self._entrance_cache[(exit.name, exit.player)] = exit
def get_region(self, regionname, player): def get_region(self, regionname, player):
if isinstance(regionname, Region): if isinstance(regionname, Region):

1
Gui.py
View File

@@ -405,6 +405,7 @@ def guiMain(args=None):
guiargs.sprite = sprite guiargs.sprite = sprite
guiargs.skip_playthrough = False guiargs.skip_playthrough = False
guiargs.outputpath = None guiargs.outputpath = None
guiargs.securerandom = False
try: try:
if guiargs.count is not None: if guiargs.count is not None:
seed = guiargs.seed seed = guiargs.seed

View File

@@ -323,7 +323,7 @@ def create_inverted_regions(world, player):
shop.add_inventory(0, 'Bomb Upgrade (+5)', 100, 7) shop.add_inventory(0, 'Bomb Upgrade (+5)', 100, 7)
if not world.retro: if not world.retro:
shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7) shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7)
world.intialize_regions() world.initialize_regions()
def create_lw_region(player, name, locations=None, exits=None): def create_lw_region(player, name, locations=None, exits=None):
return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits) return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits)

44
Main.py
View File

@@ -8,6 +8,7 @@ import RaceRandom as random
import time import time
from BaseClasses import World, CollectionState, Item, Region, Location, Shop from BaseClasses import World, CollectionState, Item, Region, Location, Shop
from Items import ItemFactory
from Regions import create_regions, mark_light_world_regions from Regions import create_regions, mark_light_world_regions
from InvertedRegions import create_inverted_regions, mark_dark_world_regions from InvertedRegions import create_inverted_regions, mark_dark_world_regions
from EntranceShuffle import link_entrances, link_inverted_entrances from EntranceShuffle import link_entrances, link_inverted_entrances
@@ -215,51 +216,35 @@ def copy_dynamic_regions_and_locations(world, ret):
def copy_world(world): def copy_world(world):
# ToDo: Not good yet # 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.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.place_dungeon_items, world.accessibility, world.shuffle_ganon, world.quickswap, world.fastmenu, world.disable_music, world.keysanity, world.retro, world.custom, world.customitemarray, world.boss_shuffle, world.hints)
ret.teams = world.teams
ret.player_names = copy.deepcopy(world.player_names)
ret.remote_items = world.remote_items.copy()
ret.required_medallions = world.required_medallions.copy() ret.required_medallions = world.required_medallions.copy()
ret.swamp_patch_required = world.swamp_patch_required.copy() ret.swamp_patch_required = world.swamp_patch_required.copy()
ret.ganon_at_pyramid = world.ganon_at_pyramid.copy() ret.ganon_at_pyramid = world.ganon_at_pyramid.copy()
ret.powder_patch_required = world.powder_patch_required.copy() ret.powder_patch_required = world.powder_patch_required.copy()
ret.ganonstower_vanilla = world.ganonstower_vanilla.copy() ret.ganonstower_vanilla = world.ganonstower_vanilla.copy()
ret.treasure_hunt_count = world.treasure_hunt_count.copy() ret.treasure_hunt_count = world.treasure_hunt_count
ret.treasure_hunt_icon = world.treasure_hunt_icon.copy() ret.treasure_hunt_icon = world.treasure_hunt_icon
ret.sewer_light_cone = world.sewer_light_cone.copy() ret.sewer_light_cone = world.sewer_light_cone
ret.light_world_light_cone = world.light_world_light_cone ret.light_world_light_cone = world.light_world_light_cone
ret.dark_world_light_cone = world.dark_world_light_cone ret.dark_world_light_cone = world.dark_world_light_cone
ret.seed = world.seed ret.seed = world.seed
ret.can_access_trock_eyebridge = world.can_access_trock_eyebridge.copy() ret.can_access_trock_eyebridge = world.can_access_trock_eyebridge
ret.can_access_trock_front = world.can_access_trock_front.copy() ret.can_access_trock_front = world.can_access_trock_front
ret.can_access_trock_big_chest = world.can_access_trock_big_chest.copy() ret.can_access_trock_big_chest = world.can_access_trock_big_chest
ret.can_access_trock_middle = world.can_access_trock_middle.copy() ret.can_access_trock_middle = world.can_access_trock_middle
ret.can_take_damage = world.can_take_damage ret.can_take_damage = world.can_take_damage
ret.difficulty_requirements = world.difficulty_requirements.copy() ret.difficulty_requirements = world.difficulty_requirements
ret.fix_fake_world = world.fix_fake_world.copy() ret.fix_fake_world = world.fix_fake_world
ret.lamps_needed_for_dark_rooms = world.lamps_needed_for_dark_rooms ret.lamps_needed_for_dark_rooms = world.lamps_needed_for_dark_rooms
ret.mapshuffle = world.mapshuffle.copy() ret.crystals_needed_for_ganon = world.crystals_needed_for_ganon
ret.compassshuffle = world.compassshuffle.copy() ret.crystals_needed_for_gt = world.crystals_needed_for_gt
ret.keyshuffle = world.keyshuffle.copy() ret.boss_shuffle = world.boss_shuffle
ret.bigkeyshuffle = world.bigkeyshuffle.copy()
ret.crystals_needed_for_ganon = world.crystals_needed_for_ganon.copy()
ret.crystals_needed_for_gt = world.crystals_needed_for_gt.copy()
ret.open_pyramid = world.open_pyramid.copy()
ret.boss_shuffle = world.boss_shuffle.copy()
ret.enemy_shuffle = world.enemy_shuffle.copy()
ret.enemy_health = world.enemy_health.copy()
ret.enemy_damage = world.enemy_damage.copy()
ret.beemizer = world.beemizer.copy()
ret.timer = world.timer.copy()
ret.shufflepots = world.shufflepots.copy()
ret.extendedmsu = world.extendedmsu.copy()
for player in range(1, world.players + 1): for player in range(1, world.players + 1):
if world.mode[player] != 'inverted': if world.mode[player] != 'inverted':
create_regions(ret, player) create_regions(ret, player)
else: else:
create_inverted_regions(ret, player) create_inverted_regions(ret, player)
create_shops(ret, player)
create_dungeons(ret, player) create_dungeons(ret, player)
copy_dynamic_regions_and_locations(world, ret) copy_dynamic_regions_and_locations(world, ret)
@@ -308,7 +293,6 @@ def copy_world(world):
for player in range(1, world.players + 1): for player in range(1, world.players + 1):
set_rules(ret, player) set_rules(ret, player)
return ret return ret

View File

@@ -313,7 +313,7 @@ def create_regions(world, player):
shop.add_inventory(0, 'Bomb Upgrade (+5)', 100, 7) shop.add_inventory(0, 'Bomb Upgrade (+5)', 100, 7)
if not world.retro: if not world.retro:
shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7) shop.add_inventory(1, 'Arrow Upgrade (+5)', 100, 7)
world.intialize_regions() world.initialize_regions()
def create_lw_region(player, name, locations=None, exits=None): def create_lw_region(player, name, locations=None, exits=None):
return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits) return _create_region(player, name, RegionType.LightWorld, 'Light World', locations, exits)