Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
feature.hpp
1 //////////////////////////////
2 //
3 // File: swrs/feature.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Feb 6 2013
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __SW_FEATURE_H_
15 #define __SW_FEATURE_H_
16 #include <utility>
17 #include <vector>
18 #include <string>
19 //#include <tr1/unordered_map>
20 //#include <tr1/memory>
21 #include "helper/tr1.hpp"
22 #include "swrs/character.hpp"
23 #include <exception>
24 #include "swrs/ifeatureimpl.hpp"
25 #include "swrs/option.hpp"
26 namespace SWRS
27 {
28 
29  class FeatureImpl;
30  //! pointer to implementation idiom
31  typedef std::tr1::shared_ptr<IFeatureImpl> pFeatureImpl;
32  //! generic class representing common things both for edges and hindrances (and also races)
33  class Feature:public IConstCharacter,public IOption
34  {
35  IConstCharacter * lower_in_chain;
36  protected:
37  //! pointer to implementation (PIMPL idiom)
39  //! feature constructor
41  {
42  lower_in_chain=0;
43  }
44  public:
45  //! first field: do we meet requirements; second: why not?
46  typedef std::pair<bool,std::string> RequirementsCheckResult;
47  //! features are chained so that they can be recursively called to calculate modifiers
49  {
50  lower_in_chain=lic;
51  }
52  //! copy constructor
53  Feature(const Feature & base)
54  {
55  pimpl=base.pimpl;
56  lower_in_chain=base.lower_in_chain;
57  }
58  //! return trait object - lower in chain
59  const Trait * GetTrait(unsigned int id) const
60  {
61  return lower_in_chain->GetTrait(id);
62  }
63  //! return trait - lower in chain
64  const Trait * GetTrait(const std::string & name) const
65  {
66  return lower_in_chain->GetTrait(name);
67  }
68  const std::string & GetName() const
69  {
70  return pimpl->GetName();
71  }
72  const std::string & GetRace() const
73  {
74  if (lower_in_chain)
75  return lower_in_chain->GetRace();
76  else
77  return GetRace();
78  }
79  const std::string & GetFlavorText() const
80  {
81  return pimpl->GetFlavorText();
82  }
83  int GetCharisma()const
84  {
85  return pimpl->GetCharisma(lower_in_chain);
86  }
87  int GetToughness()const
88  {
89  return pimpl->GetToughness(lower_in_chain);
90  }
91  int GetParry()const
92  {
93  return pimpl->GetParry(lower_in_chain);
94  }
95  int GetPace()const
96  {
97  return pimpl->GetPace(lower_in_chain);
98  }
99  int GetPowerPoints()const
100  {
101  return pimpl->GetPowerPoints(lower_in_chain);
102  }
103  int GetPowerAllowance()const
104  {
105  return pimpl->GetPowerAllowance(lower_in_chain);
106  }
107  int GetSkillsPoints() const
108  {
109  return pimpl->GetSkillsPoints(lower_in_chain);
110  }
111  int GetAttributesPoints() const
112  {
113  return pimpl->GetAttributesPoints(lower_in_chain);
114  }
115  int GetEdgesPoints() const
116  {
117  return pimpl->GetEdgesPoints(lower_in_chain);
118  } // for human
119  int GetRequiredSkillsPerAttribute(const std::string& attr_name) const
120  {
121  return pimpl->GetRequiredSkillsPerAttribute(attr_name,lower_in_chain);
122  }
123 
124  int GetTraitLevelModifier(const std::string & trait_name) const
125  {
126  return pimpl->GetTraitLevelModifier(trait_name,lower_in_chain);
127  }
128 
130  {
131  throw std::exception();
132  }
134  {
135  throw std::exception();
136  }
138  {
139  throw std::exception();
140  }
142  {
143  throw std::exception();
144  }
145  int GetMaxWounds()const
146  {
147  throw std::exception();
148  }
149  int GetXP()const
150  {
151  throw std::exception();
152  }
153  const Hindrance * GetHindrance(const std::string & name) const
154  {
155  return 0;
156  }
157  const Edge * GetEdge(const std::string & name) const
158  {
159  return 0;
160  }
161  const Power * GetPower(const std::string & name) const
162  {
163  return 0;
164  }
165  //! \brief check whenever character meets requirements of this particular feature.
166  //! See documentation for RequrementsCheckResult
168  virtual ~Feature(){}
169  };
170 }
171 #endif
172 
173