race.hpp

Go to the documentation of this file.
00001 /* $Id: race.hpp 25481 2008-04-02 22:10:35Z jhinrichs $ */
00002 /*
00003    Copyright (C) 2003 - 2008 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 version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 
00015 #ifndef RACE_HPP_INCLUDED
00016 #define RACE_HPP_INCLUDED
00017 
00018 #include <map>
00019 #include <string>
00020 #include <vector>
00021 
00022 #include "serialization/string_utils.hpp"
00023 #include "config.hpp"
00024 
00025 class simple_rng;
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 std::string& id() const { return id_; };
00038     const t_string& name(GENDER gender=MALE) const { return name_[gender]; };
00039     const t_string& plural_name() const { return plural_name_; };
00040     const t_string& description() const { return description_; };
00041 
00042     std::string generate_name(GENDER gender, simple_rng* rng = 0) const;
00043 
00044     bool uses_global_traits() const;
00045 
00046     const config::child_list& additional_traits() const;
00047     unsigned int num_traits() const;
00048 
00049 private:
00050     std::string id_;
00051     t_string name_[NUM_GENDERS];
00052     t_string plural_name_;
00053     t_string description_;
00054     unsigned int ntraits_;
00055     markov_prefix_map next_[NUM_GENDERS];
00056     int chain_size_;
00057 
00058     const config::child_list* traits_;
00059     bool global_traits_;
00060 };
00061 
00062 unit_race::GENDER string_gender(const std::string& str,unit_race::GENDER def=unit_race::MALE);
00063 std::string const& gender_string(unit_race::GENDER gender);
00064 
00065 typedef std::map<std::string,unit_race> race_map;
00066 
00067 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs