Go to the documentation of this file.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 #include "terrain_translation.hpp"
00024
00025 #include <set>
00026
00027 class cave_map_generator : public map_generator
00028 {
00029 public:
00030 cave_map_generator(const config &game_config);
00031
00032 bool allow_user_config() const { return true; }
00033
00034 void user_config(display& ) { return; }
00035
00036 std::string name() const { return "cave"; }
00037
00038 std::string config_name() const;
00039
00040 std::string create_map(const std::vector<std::string>& args);
00041 config create_scenario(const std::vector<std::string>& args);
00042
00043 private:
00044
00045 struct chamber {
00046 chamber() :
00047 center(),
00048 locs(),
00049 items(0)
00050 {
00051 }
00052
00053 map_location center;
00054 std::set<map_location> locs;
00055 const config *items;
00056 };
00057
00058 struct passage {
00059 passage(map_location s, map_location d, const config& c)
00060 : src(s), dst(d), cfg(c)
00061 {}
00062 map_location src, dst;
00063 config cfg;
00064 };
00065
00066 void generate_chambers();
00067 void build_chamber(map_location loc, std::set<map_location>& locs, size_t size, size_t jagged);
00068
00069 void place_chamber(const chamber& c);
00070
00071 void place_passage(const passage& p);
00072
00073 bool on_board(const map_location& loc) const
00074 {
00075 return loc.x >= 0 && loc.y >= 0 && loc.x < width_ && loc.y < height_;
00076 }
00077
00078 void set_terrain(map_location loc, t_translation::t_terrain t);
00079 void place_castle(int starting_position, const map_location &loc);
00080
00081 t_translation::t_terrain wall_, clear_, village_, castle_, keep_;
00082 t_translation::t_map map_;
00083 std::map<int, t_translation::coordinate> starting_positions_;
00084
00085 std::map<std::string,size_t> chamber_ids_;
00086 std::vector<chamber> chambers_;
00087 std::vector<passage> passages_;
00088
00089 config res_;
00090 config cfg_;
00091 int width_, height_, village_density_;
00092
00093
00094
00095 bool flipx_, flipy_;
00096
00097 size_t translate_x(size_t x) const;
00098 size_t translate_y(size_t y) const;
00099 };
00100
00101 #endif