The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
race.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef RACE_HPP_INCLUDED
16 #define RACE_HPP_INCLUDED
17 
18 #include "config.hpp"
19 #include "utils/name_generator.hpp"
20 #include <boost/smart_ptr/shared_ptr.hpp>
21 
22 class unit_race
23 {
24 public:
26  static const std::string s_female;
27  static const std::string s_male;
28 
29 
30  explicit unit_race(const config& cfg);
31 
32  const config& get_cfg() const { return cfg_; }
33  const std::string& id() const { return id_; }
34  const t_string& name(GENDER gender=MALE) const { return name_[gender]; }
35  const t_string& plural_name() const { return plural_name_; }
36  const t_string& description() const { return description_; }
37 
38  std::string generate_name(GENDER gender) const;
39  const name_generator& generator(GENDER gender) const;
40 
41  bool uses_global_traits() const;
42 
45  unsigned int num_traits() const;
46  const std::string& undead_variation() const { return undead_variation_; }
47 
48  /// Dummy race used when a race is not yet known.
49  static const unit_race null_race;
50 
51 private:
52  /// Only used to construct null_race.
53  unit_race();
54 
55  const config cfg_;
56 
61  unsigned int ntraits_;
63 
68 };
69 
72 
73 typedef std::map<std::string,unit_race> race_map;
74 
75 #endif
unit_race::GENDER string_gender(const std::string &str, unit_race::GENDER def=unit_race::MALE)
Definition: race.cpp:161
static const std::string s_male
Standard string id (not translatable) for MALE.
Definition: race.hpp:27
bool uses_global_traits() const
Definition: race.cpp:133
unsigned int ntraits_
Definition: race.hpp:61
const config::const_child_itors & additional_topics() const
Definition: race.cpp:143
const t_string & name(GENDER gender=MALE) const
Definition: race.hpp:34
const std::string & undead_variation() const
Definition: race.hpp:46
boost::shared_ptr< name_generator > name_generator_[NUM_GENDERS]
Definition: race.hpp:62
std::string const & gender_string(unit_race::GENDER gender)
Definition: race.cpp:151
std::string undead_variation_
Definition: race.hpp:67
const std::string & id() const
Definition: race.hpp:33
t_string name_[NUM_GENDERS]
Definition: race.hpp:58
Definitions for the interface to Wesnoth Markup Language (WML).
std::pair< const_child_iterator, const_child_iterator > const_child_itors
Definition: config.hpp:214
const config::const_child_itors & additional_traits() const
Definition: race.cpp:138
static const std::string s_female
Standard string id (not translatable) for FEMALE.
Definition: race.hpp:26
static const unit_race null_race
Dummy race used when a race is not yet known.
Definition: race.hpp:49
const t_string & description() const
Definition: race.hpp:36
t_string description_
Definition: race.hpp:60
const t_string & plural_name() const
Definition: race.hpp:35
config::const_child_itors topics_
Definition: race.hpp:65
std::string id_
Definition: race.hpp:57
const name_generator & generator(GENDER gender) const
Definition: race.cpp:128
const config cfg_
Definition: race.hpp:55
std::string generate_name(GENDER gender) const
Definition: race.cpp:123
t_string plural_name_
Definition: race.hpp:59
unit_race()
Only used to construct null_race.
Definition: race.cpp:48
config::const_child_itors traits_
Definition: race.hpp:64
unsigned int num_traits() const
Definition: race.cpp:148
std::map< std::string, unit_race > race_map
Definition: race.hpp:73
const config & get_cfg() const
Definition: race.hpp:32
bool global_traits_
Definition: race.hpp:66
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503