race.hpp

Go to the documentation of this file.
00001 /* $Id: race.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef RACE_HPP_INCLUDED
00017 #define RACE_HPP_INCLUDED
00018 
00019 #include "config.hpp"
00020 #include "serialization/string_utils.hpp"
00021 
00022 namespace rand_rng {
00023     class simple_rng;
00024 } // namespace rand_rng
00025 
00026 
00027 typedef std::map<wide_string, std::vector<wchar_t> > markov_prefix_map;
00028 
00029 class unit_race
00030 {
00031 public:
00032     enum GENDER { MALE, FEMALE, NUM_GENDERS };
00033 
00034     unit_race();
00035     unit_race(const config& cfg);
00036 
00037     const config& get_cfg() const { return cfg_; };
00038     const std::string& id() const { return id_; };
00039     const t_string& name(GENDER gender=MALE) const { return name_[gender]; };
00040     const t_string& plural_name() const { return plural_name_; };
00041     const t_string& description() const { return description_; };
00042 
00043     std::string generate_name(GENDER gender, rand_rng::simple_rng* rng = 0) const;
00044 
00045     bool uses_global_traits() const;
00046 
00047     const config::const_child_itors &additional_traits() const;
00048     const config::const_child_itors &additional_topics() const;
00049     unsigned int num_traits() const;
00050     const std::string& undead_variation() const { return undead_variation_; };
00051 
00052 private:
00053     const config cfg_;
00054 
00055     std::string id_;
00056     t_string name_[NUM_GENDERS];
00057     t_string plural_name_;
00058     t_string description_;
00059     unsigned int ntraits_;
00060     markov_prefix_map next_[NUM_GENDERS];
00061     int chain_size_;
00062 
00063     config::const_child_itors traits_;
00064     config::const_child_itors topics_;
00065     bool global_traits_;
00066     std::string undead_variation_;
00067 };
00068 
00069 unit_race::GENDER string_gender(const std::string& str,unit_race::GENDER def=unit_race::MALE);
00070 std::string const& gender_string(unit_race::GENDER gender);
00071 
00072 typedef std::map<std::string,unit_race> race_map;
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:08 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs