diff options
Diffstat (limited to 'src/game_data.cpp')
-rw-r--r-- | src/game_data.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/game_data.cpp b/src/game_data.cpp index a4a441d..7c221e9 100644 --- a/src/game_data.cpp +++ b/src/game_data.cpp | |||
@@ -12,32 +12,6 @@ | |||
12 | 12 | ||
13 | namespace { | 13 | namespace { |
14 | 14 | ||
15 | LingoColor GetColorForString(const std::string &str) { | ||
16 | if (str == "black") { | ||
17 | return LingoColor::kBlack; | ||
18 | } else if (str == "red") { | ||
19 | return LingoColor::kRed; | ||
20 | } else if (str == "blue") { | ||
21 | return LingoColor::kBlue; | ||
22 | } else if (str == "yellow") { | ||
23 | return LingoColor::kYellow; | ||
24 | } else if (str == "orange") { | ||
25 | return LingoColor::kOrange; | ||
26 | } else if (str == "green") { | ||
27 | return LingoColor::kGreen; | ||
28 | } else if (str == "gray") { | ||
29 | return LingoColor::kGray; | ||
30 | } else if (str == "brown") { | ||
31 | return LingoColor::kBrown; | ||
32 | } else if (str == "purple") { | ||
33 | return LingoColor::kPurple; | ||
34 | } else { | ||
35 | TrackerLog(fmt::format("Invalid color: {}", str)); | ||
36 | |||
37 | return LingoColor::kNone; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | struct GameData { | 15 | struct GameData { |
42 | std::vector<Room> rooms_; | 16 | std::vector<Room> rooms_; |
43 | std::vector<Door> doors_; | 17 | std::vector<Door> doors_; |
@@ -84,7 +58,7 @@ struct GameData { | |||
84 | ids_config["special_items"][color_name]) { | 58 | ids_config["special_items"][color_name]) { |
85 | std::string input_name = color_name; | 59 | std::string input_name = color_name; |
86 | input_name[0] = std::tolower(input_name[0]); | 60 | input_name[0] = std::tolower(input_name[0]); |
87 | ap_id_by_color_[GetColorForString(input_name)] = | 61 | ap_id_by_color_[GetLingoColorForString(input_name)] = |
88 | ids_config["special_items"][color_name].as<int>(); | 62 | ids_config["special_items"][color_name].as<int>(); |
89 | } else { | 63 | } else { |
90 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); | 64 | TrackerLog(fmt::format("Missing AP item ID for color {}", color_name)); |
@@ -181,12 +155,12 @@ struct GameData { | |||
181 | 155 | ||
182 | if (panel_it.second["colors"]) { | 156 | if (panel_it.second["colors"]) { |
183 | if (panel_it.second["colors"].IsScalar()) { | 157 | if (panel_it.second["colors"].IsScalar()) { |
184 | panels_[panel_id].colors.push_back(GetColorForString( | 158 | panels_[panel_id].colors.push_back(GetLingoColorForString( |
185 | panel_it.second["colors"].as<std::string>())); | 159 | panel_it.second["colors"].as<std::string>())); |
186 | } else { | 160 | } else { |
187 | for (const auto &color_node : panel_it.second["colors"]) { | 161 | for (const auto &color_node : panel_it.second["colors"]) { |
188 | panels_[panel_id].colors.push_back( | 162 | panels_[panel_id].colors.push_back( |
189 | GetColorForString(color_node.as<std::string>())); | 163 | GetLingoColorForString(color_node.as<std::string>())); |
190 | } | 164 | } |
191 | } | 165 | } |
192 | } | 166 | } |
@@ -1010,3 +984,29 @@ std::optional<int> GD_GetSubwayItemForPainting(const std::string &painting_id) { | |||
1010 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { | 984 | int GD_GetSubwayItemForSunwarp(const SubwaySunwarp &sunwarp) { |
1011 | return GetState().subway_item_by_sunwarp_.at(sunwarp); | 985 | return GetState().subway_item_by_sunwarp_.at(sunwarp); |
1012 | } | 986 | } |
987 | |||
988 | LingoColor GetLingoColorForString(const std::string &str) { | ||
989 | if (str == "black") { | ||
990 | return LingoColor::kBlack; | ||
991 | } else if (str == "red") { | ||
992 | return LingoColor::kRed; | ||
993 | } else if (str == "blue") { | ||
994 | return LingoColor::kBlue; | ||
995 | } else if (str == "yellow") { | ||
996 | return LingoColor::kYellow; | ||
997 | } else if (str == "orange") { | ||
998 | return LingoColor::kOrange; | ||
999 | } else if (str == "green") { | ||
1000 | return LingoColor::kGreen; | ||
1001 | } else if (str == "gray") { | ||
1002 | return LingoColor::kGray; | ||
1003 | } else if (str == "brown") { | ||
1004 | return LingoColor::kBrown; | ||
1005 | } else if (str == "purple") { | ||
1006 | return LingoColor::kPurple; | ||
1007 | } else { | ||
1008 | TrackerLog(fmt::format("Invalid color: {}", str)); | ||
1009 | |||
1010 | return LingoColor::kNone; | ||
1011 | } | ||
1012 | } | ||