diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-04 11:30:04 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-04 11:30:04 -0500 |
commit | 6e04dbb1ebb811429bbfdb53bd8c4c079ef63732 (patch) | |
tree | ccda986e1acd9968248d6f499610c7e2677d0152 | |
parent | ef22a8141b80344ef5e1ed6fd12779ecbe04ba58 (diff) | |
download | lingo-randomizer-6e04dbb1ebb811429bbfdb53bd8c4c079ef63732.tar.gz lingo-randomizer-6e04dbb1ebb811429bbfdb53bd8c4c079ef63732.tar.bz2 lingo-randomizer-6e04dbb1ebb811429bbfdb53bd8c4c079ef63732.zip |
Randomize layout of The Steady
-rw-r--r-- | randomizer/doorControl.gd | 18 | ||||
-rw-r--r-- | randomizer/load.gd | 8 | ||||
-rw-r--r-- | randomizer/randomizer.gd | 8 | ||||
-rw-r--r-- | randomizer/settings_screen.gd | 2 | ||||
-rw-r--r-- | randomizer/steady.gd | 78 |
5 files changed, 114 insertions, 0 deletions
diff --git a/randomizer/doorControl.gd b/randomizer/doorControl.gd new file mode 100644 index 0000000..3f70026 --- /dev/null +++ b/randomizer/doorControl.gd | |||
@@ -0,0 +1,18 @@ | |||
1 | extends "res://scripts/doorControl.gd" | ||
2 | |||
3 | |||
4 | func remap(new_panels): | ||
5 | for panel in panels: | ||
6 | get_node(panel).get_node("Viewport/GUI/Panel/TextEdit").disconnect("answer_correct", self, "handle_correct") | ||
7 | get_node(panel).get_node("Viewport/GUI/Panel/TextEdit").disconnect("answer_unsolved", self, "handle_unsolve") | ||
8 | |||
9 | panels = new_panels.duplicate() | ||
10 | |||
11 | if complete_at > 0: | ||
12 | total = complete_at | ||
13 | else: | ||
14 | total = panels.size() | ||
15 | |||
16 | for panel in panels: | ||
17 | get_node(panel).get_node("Viewport/GUI/Panel/TextEdit").connect("answer_correct", self, "handle_correct") | ||
18 | get_node(panel).get_node("Viewport/GUI/Panel/TextEdit").connect("answer_unsolved", self, "handle_unsolve") | ||
diff --git a/randomizer/load.gd b/randomizer/load.gd index aad221f..55e4efc 100644 --- a/randomizer/load.gd +++ b/randomizer/load.gd | |||
@@ -206,6 +206,14 @@ func _load(): | |||
206 | $CountdownPanels.add_child(pilgrim_cdp) | 206 | $CountdownPanels.add_child(pilgrim_cdp) |
207 | pilgrim_real.translation.y = -33 | 207 | pilgrim_real.translation.y = -33 |
208 | 208 | ||
209 | # Remap The Steady's doors. | ||
210 | for door in randomizer.steady._door_mapping.keys(): | ||
211 | get_node("Doors/Rock Room Doors").get_node(door).remap(["../../../Panels/Rock Room/%s" % randomizer.steady._door_mapping[door]]) | ||
212 | |||
213 | for door in get_node("Doors/Rock Room Doors").get_children(): | ||
214 | if !randomizer.steady._door_mapping.has(door.name) and door.name != "Door_hint": | ||
215 | door.remap(["../../../Panels/Countdown Panels/Panel_steady_steady"]) | ||
216 | |||
209 | # Proceed with the rest of the load. | 217 | # Proceed with the rest of the load. |
210 | global._print("Hooked Load End") | 218 | global._print("Hooked Load End") |
211 | ._load() | 219 | ._load() |
diff --git a/randomizer/randomizer.gd b/randomizer/randomizer.gd index 0738cb6..681567d 100644 --- a/randomizer/randomizer.gd +++ b/randomizer/randomizer.gd | |||
@@ -3,8 +3,10 @@ extends Node | |||
3 | const my_version = "0.1.0" | 3 | const my_version = "0.1.0" |
4 | 4 | ||
5 | var SCRIPT_generator | 5 | var SCRIPT_generator |
6 | var SCRIPT_steady | ||
6 | 7 | ||
7 | var generator | 8 | var generator |
9 | var steady | ||
8 | var thread = Thread.new() | 10 | var thread = Thread.new() |
9 | 11 | ||
10 | signal finished_randomizing | 12 | signal finished_randomizing |
@@ -21,6 +23,12 @@ func _thread_func(gen_seed): | |||
21 | generator.connect("generator_status", self, "statusUpdate") | 23 | generator.connect("generator_status", self, "statusUpdate") |
22 | generator.generate(gen_seed) | 24 | generator.generate(gen_seed) |
23 | 25 | ||
26 | var rng = RandomNumberGenerator.new() | ||
27 | rng.seed = generator.gen_seed | ||
28 | |||
29 | steady = SCRIPT_steady.new() | ||
30 | steady.generate(rng) | ||
31 | |||
24 | emit_signal("finished_randomizing") | 32 | emit_signal("finished_randomizing") |
25 | 33 | ||
26 | 34 | ||
diff --git a/randomizer/settings_screen.gd b/randomizer/settings_screen.gd index 842b046..9b3ddeb 100644 --- a/randomizer/settings_screen.gd +++ b/randomizer/settings_screen.gd | |||
@@ -14,6 +14,7 @@ func _ready(): | |||
14 | global.add_child(randomizer_instance) | 14 | global.add_child(randomizer_instance) |
15 | 15 | ||
16 | randomizer_instance.SCRIPT_generator = load("user://maps/randomizer/generator.gd") | 16 | randomizer_instance.SCRIPT_generator = load("user://maps/randomizer/generator.gd") |
17 | randomizer_instance.SCRIPT_steady = load("user://maps/randomizer/steady.gd") | ||
17 | 18 | ||
18 | var generated_puzzles = ResourceLoader.load("user://maps/randomizer/generated_puzzles.gd") | 19 | var generated_puzzles = ResourceLoader.load("user://maps/randomizer/generated_puzzles.gd") |
19 | var generated_puzzles_instance = generated_puzzles.new() | 20 | var generated_puzzles_instance = generated_puzzles.new() |
@@ -26,6 +27,7 @@ func _ready(): | |||
26 | randomizer_instance.add_child(extradata_instance) | 27 | randomizer_instance.add_child(extradata_instance) |
27 | 28 | ||
28 | # Let's also inject any scripts we need to inject now. | 29 | # Let's also inject any scripts we need to inject now. |
30 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/doorControl.gd")) | ||
29 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/load.gd")) | 31 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/load.gd")) |
30 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelEnd.gd")) | 32 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelEnd.gd")) |
31 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelInput.gd")) | 33 | installScriptExtension(ResourceLoader.load("user://maps/randomizer/panelInput.gd")) |
diff --git a/randomizer/steady.gd b/randomizer/steady.gd new file mode 100644 index 0000000..3153e79 --- /dev/null +++ b/randomizer/steady.gd | |||
@@ -0,0 +1,78 @@ | |||
1 | extends Node | ||
2 | |||
3 | const layout = { | ||
4 | "outside": ["Panel_begin_begin",[["Door_3", "carnation"], ["Door_2", "rose"], ["Door_1", "lilac"]]], | ||
5 | "lilac":["Panel_lielack_lilac",[["Door_1","outside"],["Door_5","amethyst"],["Door_vert_1","rose"]]], | ||
6 | "rose":["Panel_soar_rose",[["Door_vert_1","lilac"],["Door_6","ruby"],["Door_vert_2","carnation"],["Door_2","outside"]]], | ||
7 | "carnation":["Panel_incarnation_carnation",[["Door_vert_2","rose"],["Door_7","amber"],["Door_vert_3","sunflower"],["Door_3","outside"]]], | ||
8 | "sunflower":["Panel_sun_sunflower",[["Door_8","topaz"],["Door_vert_3","carnation"],["Door_4","achievement"],["","lime"]]], | ||
9 | "emerald":["Panel_herald_emerald",[["Door_9","lime"],["Door_vert_4","sapphire"],["","lemon"]]], | ||
10 | "sapphire":["Panel_sap_sapphire",[["Door_vert_4","emerald"],["Door_10","blueberry"],["Door_vert_5","amethyst"]]], | ||
11 | "amethyst":["Panel_thistle_amethyst",[["Door_vert_5","sapphire"],["Door_11","plum"],["Door_vert_6","ruby"],["Door_5","lilac"]]], | ||
12 | "ruby":["Panel_bury_ruby",[["Door_vert_6","amethyst"],["Door_12","cherry"],["Door_vert_7","amber"],["Door_6","rose"]]], | ||
13 | "amber":["Panel_antechamber_amber",[["Door_vert_7","ruby"],["Door_13","orange"],["Door_vert_8","topaz"],["Door_7","carnation"]]], | ||
14 | "topaz":["Panel_top_topaz",[["Door_vert_8","amber"],["Door_14","lemon"],["Door_8","sunflower"]]], | ||
15 | "lime":["Panel_limelight_lime",[["Door_vert_9","blueberry"],["Door_9","emerald"]]], | ||
16 | "blueberry":["Panel_blue_blueberry",[["Door_vert_9","lime"],["Door_10","sapphire"],["Door_vert_10","plum"]]], | ||
17 | "plum":["Panel_lump_plum",[["Door_vert_10","blueberry"],["Door_11","amethyst"],["Door_vert_11","cherry"]]], | ||
18 | "cherry":["Panel_hairy_cherry",[["Door_vert_11","plum"],["Door_12","ruby"],["Door_vert_12","orange"]]], | ||
19 | "orange":["Panel_blue_orange",[["Door_vert_12","cherry"],["Door_13","amber"],["Door_vert_13","lemon"]]], | ||
20 | "lemon":["Panel_melon_lemon",[["Door_vert_13","orange"],["Door_14","topaz"]]], | ||
21 | } | ||
22 | |||
23 | var _visited | ||
24 | var _door_mapping | ||
25 | var _flood_boundary | ||
26 | var _panel_boundary | ||
27 | |||
28 | |||
29 | func generate(rng): | ||
30 | _visited = [] | ||
31 | _door_mapping = {} | ||
32 | _flood_boundary = [] | ||
33 | _panel_boundary = [] | ||
34 | |||
35 | enterRoom("outside") | ||
36 | |||
37 | while !_panel_boundary.empty(): | ||
38 | var filtered = [] | ||
39 | for door in _flood_boundary: | ||
40 | if _door_mapping.has(door[1]): | ||
41 | continue | ||
42 | if _visited.size() < 18: | ||
43 | if _visited.has(door[2]): | ||
44 | continue | ||
45 | if _panel_boundary.size() == 1 and door[2] == "achievement": | ||
46 | continue | ||
47 | if _door_mapping.size() == 16 and door[2] == "achievement" and !_visited.has("achievement"): | ||
48 | filtered = [door] | ||
49 | break | ||
50 | filtered.append(door) | ||
51 | |||
52 | var chosen_door = _pickRandom(filtered, rng) | ||
53 | _door_mapping[chosen_door[1]] = _panel_boundary.pop_front() | ||
54 | |||
55 | enterRoom(chosen_door[2]) | ||
56 | _flood_boundary.erase(chosen_door) | ||
57 | |||
58 | |||
59 | func enterRoom(room): | ||
60 | if _visited.has(room): | ||
61 | return | ||
62 | |||
63 | _visited.append(room) | ||
64 | |||
65 | if room == "achievement": | ||
66 | return | ||
67 | |||
68 | _panel_boundary.append(layout[room][0]) | ||
69 | for door in layout[room][1]: | ||
70 | if door[0] == "": | ||
71 | enterRoom(door[1]) | ||
72 | else: | ||
73 | _flood_boundary.append([room, door[0], door[1]]) | ||
74 | |||
75 | |||
76 | func _pickRandom(set, rng): | ||
77 | var id = rng.randi_range(0, set.size() - 1) | ||
78 | return set[id] | ||