#ifndef GAME_DATA_H_9C42AC51 #define GAME_DATA_H_9C42AC51 #include #include #include #include enum class LingoColor { kNone, kBlack, kRed, kBlue, kYellow, kGreen, kOrange, kPurple, kBrown, kGray }; struct Panel { int id; int room; std::string name; std::vector colors; std::vector required_rooms; std::vector required_doors; bool check = false; bool exclude_reduce = false; }; struct Door { int room; std::string name; std::string location_name; std::string item_name; std::string group_name; bool skip_location = false; bool skip_item = false; std::vector panels; bool exclude_reduce = true; }; struct Exit { int destination_room; std::optional door; }; struct Room { std::string name; std::vector exits; }; struct Location { std::string name; std::string ap_location_name; int room; std::vector panels; }; struct MapArea { int id; std::string name; std::vector locations; int map_x; int map_y; }; class GameData { public: GameData(); const std::vector& GetMapAreas() const { return map_areas_; } const MapArea& GetMapArea(int id) const { return map_areas_.at(id); } int GetRoomByName(const std::string& name) const { return room_by_id_.at(name); } const Room& GetRoom(int room_id) const { return rooms_.at(room_id); } const std::vector& GetDoors() const { return doors_; } const Door& GetDoor(int door_id) const { return doors_.at(door_id); } const Panel& GetPanel(int panel_id) const { return panels_.at(panel_id); } private: int AddOrGetRoom(std::string room); int AddOrGetDoor(std::string room, std::string door); int AddOrGetPanel(std::string room, std::string panel); int AddOrGetArea(std::string area); std::vector rooms_; std::vector doors_; std::vector panels_; std::vector map_areas_; std::map room_by_id_; std::map door_by_id_; std::map panel_by_id_; std::map area_by_id_; }; const GameData& GetGameData(); #endif /* end of include guard: GAME_DATA_H_9C42AC51 */ action='/lingo2-archipelago/log/apworld/client/panel.gd'>
blob: 2cef28e69e9ea099cb2abd6770fec51342a1af14 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
extends "res://scripts/nodes/panel.gd"

var panel_logic = null
var symbol_solvable = true

var black = load("res://assets/materials/black.material")


func _ready():
	super._ready()

	var node_path = String(
		get_tree().get_root().get_node("scene").get_path_to(self).get_concatenated_names()
	)

	var gamedata = global.get_node("Gamedata")
	var panel_id = gamedata.get_panel_for_map_node_path(global.map, node_path)
	if panel_id != null:
		var ap = global.get_node("Archipelago")
		if ap.shuffle_symbols:
			if global.map == "the_entry" and node_path == "Panels/Entry/front_1":
				clue = "i"
				symbol = ""

				setField("clue", clue)
				setField("symbol", symbol)

		panel_logic = gamedata.objects.get_panels()[panel_id]
		checkSymbolSolvable()

		if not symbol_solvable:
			get_tree().get_root().get_node("scene/player").evaluate_solvability.connect(
				evaluateSolvability
			)


func checkSymbolSolvable():
	var old_solvable = symbol_solvable
	symbol_solvable = true

	if panel_logic == null:
		# There's no logic for this panel.
		return

	var ap = global.get_node("Archipelago")
	if not ap.shuffle_symbols:
		# Symbols aren't item-locked.
		return

	var gamedata = global.get_node("Gamedata")
	for symbol in panel_logic.get_symbols():
		var item_name = gamedata.kSYMBOL_ITEMS.get(symbol)
		var item_id = gamedata.objects.get_special_ids()[item_name]
		if ap.client.getItemAmount(item_id) < 1:
			symbol_solvable = false
			break

	if symbol_solvable != old_solvable:
		if symbol_solvable:
			setField("clue", clue)
			setField("symbol", symbol)
			setField("answer", answer)
		else:
			quad_mesh.surface_set_material(0, black)
			get_node("Hinge/clue").text = "missing"
			get_node("Hinge/answer").text = "symbols"


func checkSolvable(key):
	checkSymbolSolvable()
	if not symbol_solvable:
		return false

	return super.checkSolvable(key)


func evaluateSolvability():
	checkSolvable("")


func passedInput(key, skip_focus_check = false):
	if not symbol_solvable:
		return

	super.passedInput(key, skip_focus_check)


func focus():
	if not symbol_solvable:
		has_focus = false
		return

	super.focus()


func unfocus():
	if not symbol_solvable:
		has_focus = false
		return

	super.unfocus()