Moved OW shuffle group reorganization to separate function for readability
This commit is contained in:
@@ -41,166 +41,7 @@ def link_overworld(world, player):
|
|||||||
|
|
||||||
trimmed_groups = remove_reserved(world, OWEdgeGroups, connected_edges, player)
|
trimmed_groups = remove_reserved(world, OWEdgeGroups, connected_edges, player)
|
||||||
|
|
||||||
if world.owShuffle[player] == 'full':
|
groups = reorganize_groups(world, trimmed_groups, player)
|
||||||
#predefined shuffle groups get reorganized here
|
|
||||||
if world.owKeepSimilar[player]:
|
|
||||||
if world.mode[player] == 'standard':
|
|
||||||
#tuple stays (A,B,C,D,_,F)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, _, count) = group
|
|
||||||
new_grouping[(std, region, axis, terrain, count)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, _, count) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain, count)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(std, region, axis, terrain, count)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
#tuple goes to (_,B,C,D,_,F)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, _, count) = group
|
|
||||||
new_grouping[(region, axis, terrain, count)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, _, count) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, count)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(region, axis, terrain, count)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
if world.mode[player] == 'standard':
|
|
||||||
#tuple stays (A,B,C,D,_,_)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, _, _) = group
|
|
||||||
new_grouping[(std, region, axis, terrain)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, _, _) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
forward_edges = [[i] for l in forward_edges for i in l]
|
|
||||||
back_edges = [[i] for l in back_edges for i in l]
|
|
||||||
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(std, region, axis, terrain)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
#tuple goes to (_,B,C,D,_,_)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, _, _) = group
|
|
||||||
new_grouping[(region, axis, terrain)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, _, _) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
forward_edges = [[i] for l in forward_edges for i in l]
|
|
||||||
back_edges = [[i] for l in back_edges for i in l]
|
|
||||||
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(region, axis, terrain)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
elif world.owShuffle[player] == 'parallel':
|
|
||||||
#predefined shuffle groups get reorganized here
|
|
||||||
if world.owKeepSimilar[player]:
|
|
||||||
if world.mode[player] == 'standard':
|
|
||||||
#tuple stays (A,B,C,D,E,F)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
groups = list(grouping.values())
|
|
||||||
else:
|
|
||||||
#tuple goes to (_,B,C,D,E,F)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, parallel, count) = group
|
|
||||||
new_grouping[(region, axis, terrain, parallel, count)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, parallel, count) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, parallel, count)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(region, axis, terrain, parallel, count)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
if world.mode[player] == 'standard':
|
|
||||||
#tuple stays (A,B,C,D,E,_)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, parallel, _) = group
|
|
||||||
new_grouping[(std, region, axis, terrain, parallel)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(std, region, axis, terrain, parallel, _) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
forward_edges = [[i] for l in forward_edges for i in l]
|
|
||||||
back_edges = [[i] for l in back_edges for i in l]
|
|
||||||
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain, parallel)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(std, region, axis, terrain, parallel)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
#tuple goes to (_,B,C,D,E,_)
|
|
||||||
for grouping in (trimmed_groups, None):
|
|
||||||
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
|
||||||
new_grouping = {}
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, parallel, _) = group
|
|
||||||
new_grouping[(region, axis, terrain, parallel)] = ([], [])
|
|
||||||
|
|
||||||
for group in grouping.keys():
|
|
||||||
(_, region, axis, terrain, parallel, _) = group
|
|
||||||
(forward_edges, back_edges) = grouping[group]
|
|
||||||
forward_edges = [[i] for l in forward_edges for i in l]
|
|
||||||
back_edges = [[i] for l in back_edges for i in l]
|
|
||||||
|
|
||||||
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, parallel)]
|
|
||||||
exist_forward_edges.extend(forward_edges)
|
|
||||||
exist_back_edges.extend(back_edges)
|
|
||||||
new_grouping[(region, axis, terrain, parallel)] = (exist_forward_edges, exist_back_edges)
|
|
||||||
|
|
||||||
groups = list(new_grouping.values())
|
|
||||||
else:
|
|
||||||
raise NotImplementedError('Shuffling not supported yet')
|
|
||||||
|
|
||||||
#all shuffling occurs here
|
#all shuffling occurs here
|
||||||
random.shuffle(groups)
|
random.shuffle(groups)
|
||||||
@@ -286,6 +127,168 @@ def remove_reserved(world, groupedlist, connected_edges, player):
|
|||||||
|
|
||||||
return new_grouping
|
return new_grouping
|
||||||
|
|
||||||
|
def reorganize_groups(world, groups, player):
|
||||||
|
if world.owShuffle[player] == 'full':
|
||||||
|
#predefined shuffle groups get reorganized here
|
||||||
|
if world.owKeepSimilar[player]:
|
||||||
|
if world.mode[player] == 'standard':
|
||||||
|
#tuple stays (A,B,C,D,_,F)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, _, count) = group
|
||||||
|
new_grouping[(std, region, axis, terrain, count)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, _, count) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain, count)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(std, region, axis, terrain, count)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
#tuple goes to (_,B,C,D,_,F)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, _, count) = group
|
||||||
|
new_grouping[(region, axis, terrain, count)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, _, count) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, count)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(region, axis, terrain, count)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
if world.mode[player] == 'standard':
|
||||||
|
#tuple stays (A,B,C,D,_,_)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, _, _) = group
|
||||||
|
new_grouping[(std, region, axis, terrain)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, _, _) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
forward_edges = [[i] for l in forward_edges for i in l]
|
||||||
|
back_edges = [[i] for l in back_edges for i in l]
|
||||||
|
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(std, region, axis, terrain)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
#tuple goes to (_,B,C,D,_,_)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, _, _) = group
|
||||||
|
new_grouping[(region, axis, terrain)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, _, _) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
forward_edges = [[i] for l in forward_edges for i in l]
|
||||||
|
back_edges = [[i] for l in back_edges for i in l]
|
||||||
|
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(region, axis, terrain)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
elif world.owShuffle[player] == 'parallel':
|
||||||
|
#predefined shuffle groups get reorganized here
|
||||||
|
if world.owKeepSimilar[player]:
|
||||||
|
if world.mode[player] == 'standard':
|
||||||
|
#tuple stays (A,B,C,D,E,F)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
return list(grouping.values())
|
||||||
|
else:
|
||||||
|
#tuple goes to (_,B,C,D,E,F)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, parallel, count) = group
|
||||||
|
new_grouping[(region, axis, terrain, parallel, count)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, parallel, count) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, parallel, count)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(region, axis, terrain, parallel, count)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
if world.mode[player] == 'standard':
|
||||||
|
#tuple stays (A,B,C,D,E,_)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, parallel, _) = group
|
||||||
|
new_grouping[(std, region, axis, terrain, parallel)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(std, region, axis, terrain, parallel, _) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
forward_edges = [[i] for l in forward_edges for i in l]
|
||||||
|
back_edges = [[i] for l in back_edges for i in l]
|
||||||
|
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(std, region, axis, terrain, parallel)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(std, region, axis, terrain, parallel)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
#tuple goes to (_,B,C,D,E,_)
|
||||||
|
for grouping in (groups, None):
|
||||||
|
if grouping is not None: #TODO: Figure out why ^ has to be a tuple for this to work
|
||||||
|
new_grouping = {}
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, parallel, _) = group
|
||||||
|
new_grouping[(region, axis, terrain, parallel)] = ([], [])
|
||||||
|
|
||||||
|
for group in grouping.keys():
|
||||||
|
(_, region, axis, terrain, parallel, _) = group
|
||||||
|
(forward_edges, back_edges) = grouping[group]
|
||||||
|
forward_edges = [[i] for l in forward_edges for i in l]
|
||||||
|
back_edges = [[i] for l in back_edges for i in l]
|
||||||
|
|
||||||
|
(exist_forward_edges, exist_back_edges) = new_grouping[(region, axis, terrain, parallel)]
|
||||||
|
exist_forward_edges.extend(forward_edges)
|
||||||
|
exist_back_edges.extend(back_edges)
|
||||||
|
new_grouping[(region, axis, terrain, parallel)] = (exist_forward_edges, exist_back_edges)
|
||||||
|
|
||||||
|
return list(new_grouping.values())
|
||||||
|
else:
|
||||||
|
raise NotImplementedError('Shuffling not supported yet')
|
||||||
|
|
||||||
test_connections = [
|
test_connections = [
|
||||||
#('Links House ES', 'Octoballoon WS'),
|
#('Links House ES', 'Octoballoon WS'),
|
||||||
#('Links House NE', 'Lost Woods Pass SW')
|
#('Links House NE', 'Lost Woods Pass SW')
|
||||||
|
|||||||
Reference in New Issue
Block a user