00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef __cplusplus
00024
00025 # ifndef OGS_FEATS_BONUS_FEAT_H
00026 # define OGS_FEATS_BONUS_FEAT_H
00027
00028 # include <ogs/core/Feat.h>
00029 # include <ogs/feats/Namespace.h>
00030
00031 OGS_BEGIN_FEATS_NAMESPACE
00032
00033 using ogs::core::Feat;
00034
00057 class BonusFeat: public Feat {
00058 public:
00059
00061 enum Restriction {
00062
00064 NONE,
00065
00070 COMBAT_FEAT_ONLY,
00071
00078 MAGIC_FEAT_ONLY,
00079 };
00080
00081 BonusFeat (Restriction restriction = NONE);
00082
00083 Feat::Compatibility getCompatibility () const;
00084 Feat::Group getGroup () const;
00085 Restriction getRestriction () const;
00086 Feat* getFeat () const;
00087 bool setFeat (Feat& feat);
00088
00089 private:
00090 Restriction _restriction;
00091 Feat* _feat;
00092
00093 bool isCombatFeat (const Feat& feat);
00094 bool isMagicFeat (const Feat& feat);
00095 bool checkRestriction (const Feat& feat);
00096 };
00097
00104 BonusFeat::BonusFeat (Restriction restriction):
00105 _restriction (restriction) {
00106 if (_restriction < NONE || _restriction > MAGIC_FEAT_ONLY) {
00107 _restriction = NONE;
00108 }
00109 }
00110
00118 inline Feat::Compatibility
00119 BonusFeat::getCompatibility () const {
00120 return (_feat != NULL? _feat->getCompatibility (): Feat::REPEATABLE);
00121 }
00122
00130 inline Feat::Group
00131 BonusFeat::getGroup () const {
00132 return (_feat != NULL? _feat->getGroup (): Feat::SPECIAL);
00133 }
00134
00140 inline BonusFeat::Restriction
00141 BonusFeat::getRestriction () const {
00142 return (_restriction);
00143 }
00144
00151 inline Feat*
00152 BonusFeat::getFeat () const {
00153 return (_feat);
00154 }
00155
00162 inline bool
00163 BonusFeat::checkRestriction (const Feat& feat) {
00164 return (_restriction == NONE ||
00165 (_restriction == COMBAT_FEAT_ONLY && isCombatFeat (feat)) ||
00166 (_restriction == MAGIC_FEAT_ONLY && isMagicFeat (feat)));
00167 }
00168
00169 OGS_END_FEATS_NAMESPACE
00170
00171 # endif
00172
00173 #endif
00174