Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

BonusFeat.h

00001 /*
00002  * BonusFeat.h -- class interface for Bonus Feat feat
00003  * Copyright (C) 2002  Eric Lemings <elemings@users.sourceforge.net>
00004  *
00005  * This software is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This software is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this software; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA
00019  *
00020  * RCS: $Id: BonusFeat.h,v 1.3 2003/03/25 08:13:26 elemings Exp $
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 /* !defined OGS_FEATS_BONUS_FEAT_H */
00172 
00173 #endif /* defined __cplusplus */
00174 

Generated on Sun Apr 20 03:36:14 2003 for Open Gaming System (OGS) by doxygen1.3