From 531898b0fef9f81e82ad5d5f38d2c627a0c10e56 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 2 May 2023 00:48:03 -0400 Subject: Use Google's style guide --- game_data.cpp | 73 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'game_data.cpp') diff --git a/game_data.cpp b/game_data.cpp index db574d3..0ae5468 100644 --- a/game_data.cpp +++ b/game_data.cpp @@ -1,9 +1,10 @@ #include "game_data.h" #include -#include #include +#include + LingoColor GetColorForString(const std::string &str) { if (str == "black") { return LingoColor::kBlack; @@ -33,7 +34,7 @@ GameData::GameData() { YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml"); YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml"); - rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu + rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu for (const auto &room_it : lingo_config) { int room_id = AddOrGetRoom(room_it.first.as()); @@ -44,49 +45,49 @@ GameData::GameData() { Room &from_room_obj = rooms_[from_room_id]; switch (entrance_it.second.Type()) { - case YAML::NodeType::Scalar: { - // This is just "true". - from_room_obj.exits.push_back({.destination_room = room_id}); - break; - } - case YAML::NodeType::Map: { - Exit exit_obj; - exit_obj.destination_room = room_id; - - if (entrance_it.second["door"]) { - std::string door_room = room_obj.name; - if (entrance_it.second["room"]) { - door_room = entrance_it.second["room"].as(); - } - exit_obj.door = AddOrGetDoor( - door_room, entrance_it.second["door"].as()); + case YAML::NodeType::Scalar: { + // This is just "true". + from_room_obj.exits.push_back({.destination_room = room_id}); + break; } - - from_room_obj.exits.push_back(exit_obj); - break; - } - case YAML::NodeType::Sequence: { - for (const auto &option : entrance_it.second) { + case YAML::NodeType::Map: { Exit exit_obj; exit_obj.destination_room = room_id; - std::string door_room = room_obj.name; - if (option["room"]) { - door_room = option["room"].as(); + if (entrance_it.second["door"]) { + std::string door_room = room_obj.name; + if (entrance_it.second["room"]) { + door_room = entrance_it.second["room"].as(); + } + exit_obj.door = AddOrGetDoor( + door_room, entrance_it.second["door"].as()); } - exit_obj.door = - AddOrGetDoor(door_room, option["door"].as()); from_room_obj.exits.push_back(exit_obj); + break; } + case YAML::NodeType::Sequence: { + for (const auto &option : entrance_it.second) { + Exit exit_obj; + exit_obj.destination_room = room_id; + + std::string door_room = room_obj.name; + if (option["room"]) { + door_room = option["room"].as(); + } + exit_obj.door = + AddOrGetDoor(door_room, option["door"].as()); - break; - } - default: { - // This shouldn't happen. - std::cout << "Error reading game data: " << entrance_it << std::endl; - break; - } + from_room_obj.exits.push_back(exit_obj); + } + + break; + } + default: { + // This shouldn't happen. + std::cout << "Error reading game data: " << entrance_it << std::endl; + break; + } } } -- cgit 1.4.1