From 386b136fb7d31d6424bd988d1d7c095626ceb393 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 22 Feb 2023 12:18:21 -0500 Subject: Added painting room randomisation --- generator.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'generator.h') diff --git a/generator.h b/generator.h index 7803004..d0333a6 100644 --- a/generator.h +++ b/generator.h @@ -118,6 +118,25 @@ private: std::vector> sets_; }; +class Paintings { +public: + explicit Paintings(std::string filename) { + std::ifstream file(filename); + std::string line; + while (std::getline(file, line)) { + auto parts = hatkirby::split>(line, ","); + paintings_.emplace_back(parts[0], parts[1], std::atoi(parts[2].c_str())); + } + } + + const std::tuple& GetPainting(std::mt19937& rng) const { + return paintings_.at(std::uniform_int_distribution(0, paintings_.size()-1)(rng)); + } + +private: + std::vector> paintings_; +}; + class Generator { public: @@ -125,6 +144,7 @@ public: database_ = std::make_unique("/Users/hatkirby/Dropbox/Programming/verbly-datafiles/d1.3_lingo7"); wanderlust_ = std::make_unique("../wanderlust_words.txt", "../wanderlust_puzzles.txt"); cross_tower_ = std::make_unique("../cross_tower.txt"); + paintings_ = std::make_unique("../paintings.txt"); } // Querying @@ -136,6 +156,18 @@ public: return panels_.at(name); } + bool IsNodeRandomized(const std::string& name) const { + return replace_nodes_.count(name); + } + + const std::tuple& GetNode(const std::string& name) const { + return replace_nodes_.at(name); + } + + const std::vector>& GetResources() const { + return resources_; + } + // Sets the panel's question and answer to static values. void GenerateStaticPanel(std::string name, std::string question, std::string answer = ""); @@ -196,6 +228,9 @@ public: std::string west_other_name2, std::string west_other_name3); + // Generate a painting/panel pair. + void GeneratePaintingPuzzle(std::string panel_name, std::string painting_name); + private: verbly::filter MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) const; @@ -223,12 +258,20 @@ private: std::unique_ptr database_; std::unique_ptr wanderlust_; std::unique_ptr cross_tower_; + std::unique_ptr paintings_; // name, question, answer std::map> panels_; + // name, resource_path, resource_id (0 if needs import) + std::map> replace_nodes_; + + // path, type + std::vector> resources_; + std::vector reusable_; std::map> pools_; + std::set used_paintings_; }; #endif /* end of include guard: GENERATOR_H_811386CE */ -- cgit 1.4.1