diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-02-22 12:18:21 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-02-22 12:18:21 -0500 |
| commit | 386b136fb7d31d6424bd988d1d7c095626ceb393 (patch) | |
| tree | ae3a988b3904056bb32b80a71795a1f81bab8d7f /generator.h | |
| parent | 56abd4ed1d2a2adff01363f31ca2d0c81f3fbf53 (diff) | |
| download | lingo-randomizer-386b136fb7d31d6424bd988d1d7c095626ceb393.tar.gz lingo-randomizer-386b136fb7d31d6424bd988d1d7c095626ceb393.tar.bz2 lingo-randomizer-386b136fb7d31d6424bd988d1d7c095626ceb393.zip | |
Added painting room randomisation
Diffstat (limited to 'generator.h')
| -rw-r--r-- | generator.h | 43 |
1 files changed, 43 insertions, 0 deletions
| diff --git a/generator.h b/generator.h index 7803004..d0333a6 100644 --- a/generator.h +++ b/generator.h | |||
| @@ -118,6 +118,25 @@ private: | |||
| 118 | std::vector<std::vector<std::string>> sets_; | 118 | std::vector<std::vector<std::string>> sets_; |
| 119 | }; | 119 | }; |
| 120 | 120 | ||
| 121 | class Paintings { | ||
| 122 | public: | ||
| 123 | explicit Paintings(std::string filename) { | ||
| 124 | std::ifstream file(filename); | ||
| 125 | std::string line; | ||
| 126 | while (std::getline(file, line)) { | ||
| 127 | auto parts = hatkirby::split<std::vector<std::string>>(line, ","); | ||
| 128 | paintings_.emplace_back(parts[0], parts[1], std::atoi(parts[2].c_str())); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | const std::tuple<std::string, std::string, int>& GetPainting(std::mt19937& rng) const { | ||
| 133 | return paintings_.at(std::uniform_int_distribution<int>(0, paintings_.size()-1)(rng)); | ||
| 134 | } | ||
| 135 | |||
| 136 | private: | ||
| 137 | std::vector<std::tuple<std::string, std::string, int>> paintings_; | ||
| 138 | }; | ||
| 139 | |||
| 121 | class Generator { | 140 | class Generator { |
| 122 | public: | 141 | public: |
| 123 | 142 | ||
| @@ -125,6 +144,7 @@ public: | |||
| 125 | database_ = std::make_unique<verbly::database>("/Users/hatkirby/Dropbox/Programming/verbly-datafiles/d1.3_lingo7"); | 144 | database_ = std::make_unique<verbly::database>("/Users/hatkirby/Dropbox/Programming/verbly-datafiles/d1.3_lingo7"); |
| 126 | wanderlust_ = std::make_unique<Wanderlust>("../wanderlust_words.txt", "../wanderlust_puzzles.txt"); | 145 | wanderlust_ = std::make_unique<Wanderlust>("../wanderlust_words.txt", "../wanderlust_puzzles.txt"); |
| 127 | cross_tower_ = std::make_unique<CrossTower>("../cross_tower.txt"); | 146 | cross_tower_ = std::make_unique<CrossTower>("../cross_tower.txt"); |
| 147 | paintings_ = std::make_unique<Paintings>("../paintings.txt"); | ||
| 128 | } | 148 | } |
| 129 | 149 | ||
| 130 | // Querying | 150 | // Querying |
| @@ -136,6 +156,18 @@ public: | |||
| 136 | return panels_.at(name); | 156 | return panels_.at(name); |
| 137 | } | 157 | } |
| 138 | 158 | ||
| 159 | bool IsNodeRandomized(const std::string& name) const { | ||
| 160 | return replace_nodes_.count(name); | ||
| 161 | } | ||
| 162 | |||
| 163 | const std::tuple<std::string, int>& GetNode(const std::string& name) const { | ||
| 164 | return replace_nodes_.at(name); | ||
| 165 | } | ||
| 166 | |||
| 167 | const std::vector<std::tuple<std::string, std::string>>& GetResources() const { | ||
| 168 | return resources_; | ||
| 169 | } | ||
| 170 | |||
| 139 | // Sets the panel's question and answer to static values. | 171 | // Sets the panel's question and answer to static values. |
| 140 | void GenerateStaticPanel(std::string name, std::string question, std::string answer = ""); | 172 | void GenerateStaticPanel(std::string name, std::string question, std::string answer = ""); |
| 141 | 173 | ||
| @@ -196,6 +228,9 @@ public: | |||
| 196 | std::string west_other_name2, | 228 | std::string west_other_name2, |
| 197 | std::string west_other_name3); | 229 | std::string west_other_name3); |
| 198 | 230 | ||
| 231 | // Generate a painting/panel pair. | ||
| 232 | void GeneratePaintingPuzzle(std::string panel_name, std::string painting_name); | ||
| 233 | |||
| 199 | private: | 234 | private: |
| 200 | 235 | ||
| 201 | verbly::filter MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) const; | 236 | verbly::filter MakeHintFilter(verbly::filter subfilter, Height height, Colour colour, FilterDirection filter_direction) const; |
| @@ -223,12 +258,20 @@ private: | |||
| 223 | std::unique_ptr<verbly::database> database_; | 258 | std::unique_ptr<verbly::database> database_; |
| 224 | std::unique_ptr<Wanderlust> wanderlust_; | 259 | std::unique_ptr<Wanderlust> wanderlust_; |
| 225 | std::unique_ptr<CrossTower> cross_tower_; | 260 | std::unique_ptr<CrossTower> cross_tower_; |
| 261 | std::unique_ptr<Paintings> paintings_; | ||
| 226 | 262 | ||
| 227 | // name, question, answer | 263 | // name, question, answer |
| 228 | std::map<std::string, std::tuple<std::string, std::string>> panels_; | 264 | std::map<std::string, std::tuple<std::string, std::string>> panels_; |
| 229 | 265 | ||
| 266 | // name, resource_path, resource_id (0 if needs import) | ||
| 267 | std::map<std::string, std::tuple<std::string, int>> replace_nodes_; | ||
| 268 | |||
| 269 | // path, type | ||
| 270 | std::vector<std::tuple<std::string, std::string>> resources_; | ||
| 271 | |||
| 230 | std::vector<std::string> reusable_; | 272 | std::vector<std::string> reusable_; |
| 231 | std::map<std::string, std::set<std::string>> pools_; | 273 | std::map<std::string, std::set<std::string>> pools_; |
| 274 | std::set<std::string> used_paintings_; | ||
| 232 | }; | 275 | }; |
| 233 | 276 | ||
| 234 | #endif /* end of include guard: GENERATOR_H_811386CE */ | 277 | #endif /* end of include guard: GENERATOR_H_811386CE */ |
