From 08ffb400114029569b4043b4f4c5a3f2af9b37b8 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 3 May 2023 17:25:41 -0400 Subject: Added progressive items --- game_data.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'game_data.cpp') diff --git a/game_data.cpp b/game_data.cpp index 2f8f505..9b31f89 100644 --- a/game_data.cpp +++ b/game_data.cpp @@ -235,7 +235,7 @@ GameData::GameData() { } if (room_it.second["paintings"]) { - for (const auto& painting : room_it.second["paintings"]) { + for (const auto &painting : room_it.second["paintings"]) { std::string painting_id = painting["id"].as(); room_by_painting_[painting_id] = room_id; @@ -250,14 +250,36 @@ GameData::GameData() { } painting_exit.door = AddOrGetDoor( - rd_room, - painting["required_door"]["door"].as()); + rd_room, painting["required_door"]["door"].as()); } room_obj.paintings.push_back(painting_exit); } } } + + if (room_it.second["progression"]) { + for (const auto &progression_it : room_it.second["progression"]) { + std::string progressive_item_name = + progression_it.first.as(); + + int index = 1; + for (const auto &stage : progression_it.second) { + int door_id = -1; + + if (stage.IsScalar()) { + door_id = AddOrGetDoor(room_obj.name, stage.as()); + } else { + door_id = AddOrGetDoor(stage["room"].as(), + stage["door"].as()); + } + + doors_[door_id].progressives.push_back( + {.item_name = progressive_item_name, .quantity = index}); + index++; + } + } + } } map_areas_.reserve(areas_config.size()); @@ -341,10 +363,7 @@ int GameData::AddOrGetDoor(std::string room, std::string door) { if (!door_by_id_.count(full_name)) { door_by_id_[full_name] = doors_.size(); - doors_.push_back({ - .room = AddOrGetRoom(room), - .name = door - }); + doors_.push_back({.room = AddOrGetRoom(room), .name = door}); } return door_by_id_[full_name]; -- cgit 1.4.1