From 62f06090014aee90231eb90da36d5ae1b65171a3 Mon Sep 17 00:00:00 2001
From: Star Rauchenberger <fefferburbia@gmail.com>
Date: Sun, 30 Jul 2023 15:56:23 -0400
Subject: Added LEVEL 2 victory condition

---
 Archipelago/client.gd |  6 +++++-
 Archipelago/load.gd   | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

(limited to 'Archipelago')

diff --git a/Archipelago/client.gd b/Archipelago/client.gd
index feeda7e..a816c42 100644
--- a/Archipelago/client.gd
+++ b/Archipelago/client.gd
@@ -43,6 +43,7 @@ const progressive_items = {
 
 const kTHE_END = 0
 const kTHE_MASTER = 1
+const kLEVEL_2 = 2
 
 const kNO_PANEL_SHUFFLE = 0
 const kREARRANGE_PANELS = 1
@@ -81,12 +82,13 @@ var _paintings = {}
 var _paintings_mapping = {}
 var _localdata_file = ""
 var _death_link = false
-var _victory_condition = 0  # THE END, THE MASTER
+var _victory_condition = 0  # THE END, THE MASTER, LEVEL 2
 var _door_shuffle = false
 var _color_shuffle = false
 var _panel_shuffle = 0  # none, rearrange
 var _painting_shuffle = false
 var _mastery_achievements = 21
+var _level_2_requirement = 223
 var _slot_seed = 0
 
 var _map_loaded = false
@@ -267,6 +269,8 @@ func _on_data():
 				_paintings_mapping = _slot_data["painting_entrance_to_exit"]
 			if _slot_data.has("mastery_achievements"):
 				_mastery_achievements = _slot_data["mastery_achievements"]
+			if _slot_data.has("level_2_requirement"):
+				_level_2_requirement = _slot_data["level_2_requirement"]
 
 			_localdata_file = "user://archipelago_data/%s_%d" % [_seed, _slot]
 			var ap_file = File.new()
diff --git a/Archipelago/load.gd b/Archipelago/load.gd
index bb14fea..0157395 100644
--- a/Archipelago/load.gd
+++ b/Archipelago/load.gd
@@ -87,6 +87,10 @@ func _load():
 	get_node("CountdownPanels").add_child(new_master_cdp)
 	old_master_cdp.queue_free()
 
+	# Configure AN OTHER WAY.
+	var another_cdp = get_node("CountdownPanels/CountdownPanel_level2_0")
+	another_cdp.maxlength = (apclient._level_2_requirement - 1)
+
 	# This is the best time to create the location nodes, since the map is now
 	# loaded but the panels haven't been solved from the save file yet.
 	var panels_parent = self.get_node("Panels")
@@ -238,6 +242,8 @@ func _load():
 		victory_condition = "the end"
 	elif apclient._victory_condition == apclient.kTHE_MASTER:
 		victory_condition = "the master"
+	elif apclient._victory_condition == apclient.kLEVEL_2:
+		victory_condition = "level 2"
 
 	set_static_panel("Entry Room/Panel_this_this", victory_condition)
 	set_static_panel("Entry Room/Panel_hidden_hidden", "hewwo")
@@ -366,11 +372,16 @@ func _load():
 		apclient.connect("evaluate_solvability", script_instance, "evaluate_solvability")
 
 	# Hook up the goal panel.
-	if apclient._victory_condition == 1:
+	if apclient._victory_condition == apclient.kTHE_MASTER:
 		var the_master = self.get_node("Panels/Countdown Panels/Panel_master_master")
 		the_master.get_node("Viewport/GUI/Panel/TextEdit").connect(
 			"answer_correct", apclient, "completedGoal"
 		)
+	elif apclient._victory_condition == apclient.kLEVEL_2:
+		var level_2 = self.get_node("Decorations/EndPanel/Panel_level_2")
+		level_2.get_node("Viewport/GUI/Panel/TextEdit").connect(
+			"answer_correct", apclient, "completedGoal"
+		)
 	else:
 		var the_end = self.get_node("Decorations/EndPanel/Panel_end_end")
 		the_end.get_node("Viewport/GUI/Panel/TextEdit").connect(
-- 
cgit 1.4.1