00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CAVEGEN_HPP_INCLUDED
00019 #define CAVEGEN_HPP_INCLUDED
00020
00021 #include "config.hpp"
00022 #include "mapgen.hpp"
00023
00024 #include <set>
00025
00026 class cave_map_generator : public map_generator
00027 {
00028 public:
00029 cave_map_generator(const config* game_config);
00030
00031 bool allow_user_config() const { return true; }
00032
00033 void user_config(display& ) { return; }
00034
00035 std::string name() const { return "cave"; }
00036
00037 std::string create_map(const std::vector<std::string>& args);
00038 config create_scenario(const std::vector<std::string>& args);
00039
00040 private:
00041
00042 struct chamber {
00043 gamemap::location center;
00044 std::set<gamemap::location> locs;
00045 config* items;
00046 };
00047
00048 struct passage {
00049 passage(gamemap::location s, gamemap::location d, const config& c)
00050 : src(s), dst(d), cfg(c)
00051 {}
00052 gamemap::location src, dst;
00053 config cfg;
00054 };
00055
00056 void generate_chambers();
00057 void build_chamber(gamemap::location loc, std::set<gamemap::location>& locs, size_t size, size_t jagged);
00058
00059 void place_chamber(const chamber& c);
00060 void place_items(const chamber& c, config::all_children_iterator i1, config::all_children_iterator i2);
00061
00062 void place_passage(const passage& p);
00063
00064
00065 bool on_board(const gamemap::location& loc) const
00066 {
00067 return loc.x > 0 && loc.y > 0 &&
00068 loc.x < static_cast<long>(width_ - 2) &&
00069 loc.y < static_cast<long>(height_ - 2);
00070 }
00071
00072 void set_terrain(gamemap::location loc, t_translation::t_terrain t);
00073 void place_castle(const std::string& side, gamemap::location loc);
00074
00075 t_translation::t_terrain wall_, clear_, village_, castle_, keep_;
00076 t_translation::t_map map_;
00077 std::map<int, t_translation::coordinate> starting_positions_;
00078
00079 std::map<std::string,size_t> chamber_ids_;
00080 std::vector<chamber> chambers_;
00081 std::vector<passage> passages_;
00082
00083 config res_;
00084 const config* cfg_;
00085 size_t width_, height_, village_density_;
00086
00087
00088
00089 bool flipx_, flipy_;
00090
00091 size_t translate_x(size_t x) const;
00092 size_t translate_y(size_t y) const;
00093 };
00094
00095 #endif