structure plando for Minecraft
This commit is contained in:
parent
08bf993146
commit
82cd51f5f4
11
Mystery.py
11
Mystery.py
|
@ -564,6 +564,17 @@ def roll_settings(weights: dict, plando_options: typing.Set[str] = frozenset(("b
|
||||||
setattr(ret, option_name, option.from_any(get_choice(option_name, weights)))
|
setattr(ret, option_name, option.from_any(get_choice(option_name, weights)))
|
||||||
else:
|
else:
|
||||||
setattr(ret, option_name, option(option.default))
|
setattr(ret, option_name, option(option.default))
|
||||||
|
# bad hardcoded behavior to make this work for now
|
||||||
|
ret.plando_connections = []
|
||||||
|
if "connections" in plando_options:
|
||||||
|
options = weights.get("plando_connections", [])
|
||||||
|
for placement in options:
|
||||||
|
if roll_percentage(get_choice("percentage", placement, 100)):
|
||||||
|
ret.plando_connections.append(PlandoConnection(
|
||||||
|
get_choice("entrance", placement),
|
||||||
|
get_choice("exit", placement),
|
||||||
|
get_choice("direction", placement, "both")
|
||||||
|
))
|
||||||
else:
|
else:
|
||||||
raise Exception(f"Unsupported game {ret.game}")
|
raise Exception(f"Unsupported game {ret.game}")
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -38,12 +38,25 @@ def link_minecraft_structures(world: MultiWorld, player: int):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def set_pair(exit, struct):
|
def set_pair(exit, struct):
|
||||||
|
try:
|
||||||
|
assert exit in exits
|
||||||
|
assert struct in structs
|
||||||
|
except AssertionError as e:
|
||||||
|
raise Exception(f"Invalid connection: {exit} => {struct} for player {player}")
|
||||||
pairs[exit] = struct
|
pairs[exit] = struct
|
||||||
exits.remove(exit)
|
exits.remove(exit)
|
||||||
structs.remove(struct)
|
structs.remove(struct)
|
||||||
|
|
||||||
# Plando stuff. Remove any utilized exits/structs from the lists.
|
# Plando stuff. Remove any utilized exits/structs from the lists.
|
||||||
# Raise error if trying to put Nether Fortress in the End.
|
# Raise error if trying to put Nether Fortress in the End.
|
||||||
|
if world.plando_connections[player]:
|
||||||
|
for connection in world.plando_connections[player]:
|
||||||
|
try:
|
||||||
|
if connection.entrance == 'The End Structure' and connection.exit == 'Nether Fortress':
|
||||||
|
raise Exception(f"Cannot place Nether Fortress in the End for player {player}")
|
||||||
|
set_pair(connection.entrance, connection.exit)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f"Could not connect using {connection}") from e
|
||||||
|
|
||||||
if world.shuffle_structures[player]:
|
if world.shuffle_structures[player]:
|
||||||
# Can't put Nether Fortress in the End
|
# Can't put Nether Fortress in the End
|
||||||
|
@ -51,7 +64,7 @@ def link_minecraft_structures(world: MultiWorld, player: int):
|
||||||
try:
|
try:
|
||||||
end_struct = world.random.choice([s for s in structs if s != 'Nether Fortress'])
|
end_struct = world.random.choice([s for s in structs if s != 'Nether Fortress'])
|
||||||
set_pair('The End Structure', end_struct)
|
set_pair('The End Structure', end_struct)
|
||||||
except IndexError as e:
|
except IndexError as e: # should only happen if structs is emptied by plando
|
||||||
raise Exception(f"Plando forced Nether Fortress in the End for player {player}") from e
|
raise Exception(f"Plando forced Nether Fortress in the End for player {player}") from e
|
||||||
world.random.shuffle(structs)
|
world.random.shuffle(structs)
|
||||||
for exit, struct in zip(exits[:], structs[:]):
|
for exit, struct in zip(exits[:], structs[:]):
|
||||||
|
|
Loading…
Reference in New Issue