forked from 2dos/DK64-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShuffleWarps.py
45 lines (40 loc) · 1.85 KB
/
ShuffleWarps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Randomizes Bananaports."""
import random
import js
from randomizer.Enums.Warps import Warps
from randomizer.Lists.Warps import BananaportVanilla
from randomizer.Lists.MapsAndExits import Maps
def getShuffleMaps():
"""Produce list of maps which contain a bananaport swap."""
lst = []
for x in BananaportVanilla.values():
if x.map_id not in lst:
lst.append(x.map_id)
return lst
def ShuffleWarps(bananaport_replacements, human_ports):
"""Shuffles warps between themselves."""
map_list = getShuffleMaps()
for warp_map in map_list:
shufflable_warps = []
# Generate list of shufflable warp types (Warp 1, Warp 2 etc.)
for warp in BananaportVanilla.values():
if warp.map_id == warp_map and not warp.locked:
shufflable_warps.append(warp.vanilla_warp)
random.shuffle(shufflable_warps)
shuffle_index = 0
# Apply shuffle
for warp in BananaportVanilla.keys():
if BananaportVanilla[warp].map_id == warp_map and not BananaportVanilla[warp].locked:
BananaportVanilla[warp].setNewWarp(shufflable_warps[shuffle_index])
shuffle_index += 1
# Write to spoiler and create array of replacements
pad_list = []
pad_temp_list = [[], [], [], [], []]
for warp in BananaportVanilla.values():
if warp.map_id == warp_map and not warp.locked:
pad_temp_list[warp.new_warp].append(warp.obj_id_vanilla)
human_ports[warp.name] = "Warp " + str(warp.new_warp + 1)
for warp_index in range(len(pad_temp_list)):
if len(pad_temp_list[warp_index]) > 0:
pad_list.append({"warp_index": warp_index, "warp_ids": pad_temp_list[warp_index].copy()})
bananaport_replacements.append({"containing_map": warp_map, "pads": pad_list.copy()})